Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())

H = [0] * N
for i in range(N):
    H[i] = int(input())

H.sort()

d = max(H)
for i in range(N-K+1):
    d = min(max(H[i:i+K]) - min(H[i:i+K]), d)
print(d)

Fixed submission:
N, K = map(int, input().split())

H = [0] * N
for i in range(N):
    H[i] = int(input())
H.sort()

d = H[K-1] - H[0]
for i in range(1, N-K+1):
    d = min(H[i+K-1] - H[i], d)
print(d)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

x = {}
y = [None] * M
for i in range(M):
    P, Y = map(int, input().split())
    if P in x:
        x[P] += [Y]
    else:
        x[P] = [Y]
    y[i] = (P, Y)

for i in range(N):
    x[i+1].sort()

for i in range(M):
    P, Y = y[i]
    print('{}{}'.format(str(P).zfill(6), str(x[P].index(Y) + 1).zfill(6)))


Fixed submission:
N, M = map(int, input().split())

x = [[] for _ in range(N)]
a = [None] * M
for i in range(M):
    P, Y = map(int, input().split())
    x[P-1].append(Y)
    a[i] = (P, Y)

y = {}
for i in range(N):
    x[i].sort()
    for j, Y in enumerate(x[i]):
        y[(i+1, Y)] = j + 1
for i in range(M):
    print('{}{}'.format(str(a[i][0]).zfill(6), str(y[a[i]]).zfill(6)))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

x = {i+1: [] for i in range(N)}
y = [None] * M
for i in range(M):
    P, Y = map(int, input().split())
    x[P].append(Y)
    y[i] = (P, Y)

for i in range(N):
    x[i+1].sort()

for i in range(M):
    P, Y = y[i]
    print('{}{}'.format(str(P).zfill(6), str(x[P].index(Y) + 1).zfill(6)))


Fixed submission:
N, M = map(int, input().split())

x = [[] for _ in range(N)]
a = [None] * M
for i in range(M):
    P, Y = map(int, input().split())
    x[P-1].append(Y)
    a[i] = (P, Y)

y = {}
for i in range(N):
    x[i].sort()
    for j, Y in enumerate(x[i]):
        y[(i+1, Y)] = j + 1
for i in range(M):
    print('{}{}'.format(str(a[i][0]).zfill(6), str(y[a[i]]).zfill(6)))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))

d = sorted(A.count(a) for a in set(A))

if len(d) > K:
    print(sum(d[:len(d) - K]))
else:
    print(0)

Fixed submission:
from collections import Counter

N, K = map(int, input().split())
A = list(map(int, input().split()))
d = Counter(A).most_common()

if len(d) > K:
    print(sum(v for k, v in d[-(len(d) - K):]))
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))

d = sorted([A.count(a) for a in set(A)])

if len(d) > K:
    print(sum(d[:len(d) - K]))
else:
    print(0)

Fixed submission:
from collections import Counter

N, K = map(int, input().split())
A = list(map(int, input().split()))
d = Counter(A).most_common()

if len(d) > K:
    print(sum(v for k, v in d[-(len(d) - K):]))
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = sorted(list(map(int, input().split())))

s = 0
while a:
    x = [a[0]] + a[-2:]
    s += x[1]
    a = a[1:-2]
print(s)

Fixed submission:
N = int(input())
a = sorted(list(map(int, input().split())))

print(sum(a[-2 * (i+1)] for i in range(N)))
Buggy python submission (verdict: Time Limit Exceeded):
N, C, K = map(int, input().split())

T = []
for _ in range(N):
    T.append(int(input()))
T.sort()

buss = []
x, *T = T
bus = [x]
while T:
    while T:
        t, *T = T
        if t <= x + K and len(bus) < C:
            bus.append(t)
        else:
            x = t
            buss.append(bus)
            bus = [x]
            break
buss.append(bus)
print(len(buss))

Fixed submission:
N, C, K = map(int, input().split())

T = sorted([int(input()) for _ in range(N)])

x = T[0]
p = 1
b = 1
for i in range(1, N):
    if T[i] <= x + K and p < C:
        p += 1
    else:
        x = T[i]
        b += 1
        p = 1
print(b)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

cnt = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i + j + k == S:
                cnt += 1
print(cnt)

Fixed submission:
K, S = map(int, input().split())

cnt = 0
for i in range(K+1):
    for j in range(K+1):
        if 0 <= S - i - j <= K:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):


ar = input()

k = int(input())

l = len(ar)


DP = [[[-1] * 2 for j in range(5)] for i in range(102)]


def dp(i, j, fl):
    if i == l:
        if j == k:
            return 1
        else:
            return 0

    if DP[i][j][fl] != -1:
        return DP[i][j][fl]

    res = 0

   # print(i,j,fl)
    if fl:
        for p in range(10):

            res += dp(i+1, j + (p != 0) , fl == 1)
    else:
        ko = ord(ar[i]) - ord('0')
        for p in range(ko + 1):

            res += dp(i + 1, j + (p != 0), p < ko)
    DP[i][j][fl] = res
    return res

print(dp(0, 0, 0))


Fixed submission:


ar = input()

k = int(input())

l = len(ar)


DP = [[[-1] * 2 for j in range(103)] for i in range(102)]


def dp(i, j, fl):
    if i == l:
        if j == k:
            return 1
        else:
            return 0

    if DP[i][j][fl] != -1:
        return DP[i][j][fl]

    res = 0

   # print(i,j,fl)
    if fl:
        for p in range(10):

            res += dp(i+1, j + (p != 0) , fl == 1)
    else:
        ko = ord(ar[i]) - ord('0')
        for p in range(ko + 1):

            res += dp(i + 1, j + (p != 0), p < ko)
    DP[i][j][fl] = res
    return res

print(dp(0, 0, 0))
Buggy python submission (verdict: Time Limit Exceeded):
a, b, n = map(int, input().split(' '))
c = 0
d = 0
for x in range(n+1):
	c = int(a*x/b) - a*int(x/b)
	if c > d:
		d = c
print(d)

Fixed submission:
a, b, n = map(int, input().split(' '))
r = min(b-1, n)
c = int(a*r/b) - a*int(r/b)
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
import math

def combi(nam,r):
  return math.factorial(nam)//(math.factorial(nam-r)*math.factorial(r))
  
n=int(input())
a=list(map(int,input().split()))

for i in range(n):
  b=a[:i]+a[i+1:]
  c=collections.Counter(b)
  d=0
  for j in c.values():
    if j>1:
      d+=combi(j,2)
  print(d)

Fixed submission:
from collections import Counter
n=int(input())
A=list(map(int,input().split()))
cnt=Counter(A)
tot=0
dif={}
for k,v in cnt.items():
  tot += v*(v-1)//2
  dif[k]=v-1
ans=[tot-dif[a] for a in A]
print('\n'.join(map(str,ans)))
Buggy python submission (verdict: Time Limit Exceeded):
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=[list(map(int,input().split())) for i in range(M)]
d = 0
e = 10**10

for i in range(A):
	for j in range(B):
		d = a[i]+b[j]
		if d<e:
			e=d

for i in range(M):
	d=a[c[i][0]-1]+b[c[i][1]-1]-c[i][2]
	if d<e:
		e=d

print(e)

Fixed submission:
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=[list(map(int,input().split())) for i in range(M)]
d = 0
e = 0
aa=sorted(a)
bb=sorted(b)

e=aa[0]+bb[0]

for i in range(M):
	d=a[c[i][0]-1]+b[c[i][1]-1]-c[i][2]
	if d<e:
		e=d

print(e)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=list(map(int,input().split()))
a=0

for i in range(1,n):
	if p[i] <= min(p[:i]):
		a+=1
	else:
		pass
print(a+1)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
a=0
b=10**10
for i in range(n):
	if p[i] <= b:
		a+=1
		b=p[i]
	else:
		pass
print(a)
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
ans=0
if (b-a)%2 == 0:
	ans = (b-a)//2
else:
	ans = min(n-a, b-1, (b-a-1)//2
print(ans)

Fixed submission:
n,a,b=map(int,input().split())
ans=0
if (b-a)%2 == 0:
	ans = (b-a)//2
else:
	if (b-1) < (n-a):
		ans = min(n-a, b-1, a+(b-a-1)//2)
	else:
		ans = min(n-a, b-1, n-b+1+(b-a-1)//2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))

b=0
c=10**10
for i in range(1,n):
  b=abs(sum(a[:i])-sum(a[i:]))
  if b<c:
    c=b
print(c)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
tot=sum(a)
b=0
c=10**10
d=0
for i in range(n):
  b+=a[i]
  d=abs(tot/2 - b)
  if d<c:
    c=d
print(int(2*c))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n,k,q=map(int,input().split())
a=np.ones(n)*k
for i in range(q):
	b=int(input())
	a=a-1
	a[b-1]+=1
	
for j in range(n):
	if a[j]>0:
		print('Yes')
	else:
		print('No')

Fixed submission:
import numpy as np

n,k,q=map(int,input().split())
a=np.ones(n)*k - q
for i in range(q):
	b=int(input())
	a[b-1]+=1
b=a>0

for j in range(n):
	if b[j]:
		print('Yes')
	else:
		print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=0
for i in range(n):
  a+=i
print(a)

Fixed submission:
n=int(input())
a=(n-1)*n//2
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(input()) for i in range(n)]

for i in range(n):
	b=a.pop(0)
	print(max(a))
	a.append(b)


Fixed submission:
n=int(input())
a=[int(input()) for i in range(n)]
b=sorted(a,reverse=True)
for i in range(n):
	if b[0]!=a[i]:
		print(b[0])
	else:
		print(b[1])
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=list(range(1,n+1))
for i in range(m):
	b=list(map(int,input().split()))
	c=list(range(b[0],b[1]+1))
	a=list(set(c) & set(a))
print(len(list(a)))

Fixed submission:
n,m=map(int,input().split())
a=list(range(1,n+1))
l=0
l1=0
r=0
r1=10**10

for i in range(m):
	l,r=map(int,input().split())
	if l>l1:
		l1=l
	if r<r1:
		r1=r
b=list(range(l1,r1+1))
a=list(set(b) & set(a))
print(len(list(a)))
Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())
a=0
f=True
while f:
  for i in range(1,len(s)):
    if s[i]=='W' and s[i-1]=='B':
      a+=1
      s[i]='B'
      s[i-1]='W'
      break
  else:
    f=False
    
print(a)

Fixed submission:
s=list(input())
cnt=s.count('W')
a=[i for i,x in enumerate(s) if x=='W']
ans=0
for i in range(cnt):
  ans+=a[i]-i
print(ans)
Buggy python submission (verdict: Runtime Error):
S=list(input())
K=int(input())
a=b=0

for s in S:
	if s=='1':
		a+=1
	else:
		b=s
		break
if a>=K:
	print(i)
else:
	print(b)

Fixed submission:
S=list(input())
K=int(input())
a=b=0

for s in S:
	if s=='1':
		a+=1
	else:
		b=s
		break
if a>=K:
	print(1)
else:
	print(b)
Buggy python submission (verdict: Runtime Error):
s,t=input().split()
a=0
f=False

for i in range(len(s)):
	a=s[-1]
	s=s[:-1]
	s=a+s
	
	if s==t:
		f=True
		break
		
if f:
	print('Yes')
else:
	print('No')

Fixed submission:
s=input()
t=input()
a=0
f=False

for i in range(len(s)):
	a=s[-1]
	s=s[:-1]
	s=a+s
	
	if s==t:
		f=True
		break
		
if f:
	print('Yes')
else:
	print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(input()) for _ in range(n)]
b=list(set(a))
ans=0
for i in b:
  if a.count(i)%2:
    ans+=1
print(ans)

Fixed submission:
import collections
n=int(input())
a=[int(input()) for _ in range(n)]
b=collections.Counter(a)
ans=0
for i in b.keys():
  if b[i]%2:
    ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(input()) for _ in range(n)]
b=list(set(a))
ans=0
for i in b:
  if a.count(i)%2:
    ans+=1
print(ans)

Fixed submission:
import collections
n=int(input())
a=[int(input()) for _ in range(n)]
b=collections.Counter(a)
ans=0
for i in b.keys():
  if b[i]%2:
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=[0]*9
for i in range(n):
  if a[i]<400:
    b[0]+=1
  elif a[i]<800:
    b[1]+=1
  elif a[i]<1200:
    b[2]+=1
  elif a[i]<1600:
    b[3]+=1
  elif a[i]<2000:
    b[4]+=1
  elif a[i]<2400:
    b[5]+=1
  elif a[i]<2800:
    b[6]+=1
  elif a[i]<3200:
    b[7]+=1
  else:
    b[8]+=1
    
min=8-b[:8].count(0)
max=min+b[8]

if min=0:
  min=1
print(min,max)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]*9
for i in range(n):
  if a[i]<400:
    b[0]+=1
  elif a[i]<800:
    b[1]+=1
  elif a[i]<1200:
    b[2]+=1
  elif a[i]<1600:
    b[3]+=1
  elif a[i]<2000:
    b[4]+=1
  elif a[i]<2400:
    b[5]+=1
  elif a[i]<2800:
    b[6]+=1
  elif a[i]<3200:
    b[7]+=1
  else:
    b[8]+=1
    
min=8-b[:8].count(0)
max=min+b[8]

if min==0:
  min=1
print(min,max)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)

ans = 0
ans += A[0]
for i in range(1, N - 1):
    ans += A[tmp]
    if i % 2 == 0:
        tmp += 1
print(ans)

Fixed submission:
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = LI()

A.sort(reverse=1)
ans = 0
ans += A[0]

tmp = 1
for i in range(1, N - 1):
    ans += A[tmp]
    if i % 2 == 0:
        tmp += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
a = LI()

anss = []
for i in range(N):
    ans = 0
    for j in range(N):
        if i != j:
            ans ^= a[j]

    anss.append(ans)

anss = map(str, anss)
print(" ".join(anss))


Fixed submission:
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
a = LI()

anss = []
ans_base = 0
for i in range(N):
    ans_base ^= a[i]

for i in range(N):
    anss.append(ans_base ^ a[i])


anss = map(str, anss)
print(" ".join(anss))
Buggy python submission (verdict: Runtime Error):
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
 
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000
 
d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))
 

"""
3
1 1 2
のパターンが例外だった
"""

N = int(input())
A = LI()
A.sort()

table = [0 for i in range(2 * 10 ** 5 + 1)]
cnt = 0
for a in A:
    if table[a] != 0:
        pass
    else:
        cnt += 1
        for i in range(2 * 10 ** 5):
            if a * i > 2 * 10 ** 5:
                break
            table[a * i] = 1

A_dic = collections.Counter(A)
for key in A_dic.keys():
    if A_dic[key] > 1:
        cnt -= 1
    
print(cnt)


Fixed submission:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
 
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000
 
d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))
 

"""
3
1 1 2
のパターンが例外だった
"""

N = int(input())
A = LI()
A.sort()

table = [0 for i in range(10 ** 6 + 1)]
cnt = 0

cc = collections.Counter(A)
duplicate = []
for key in cc.keys():
    if cc[key] > 1:
        duplicate.append(key)

for a in A:
    if table[a] != 0:
        pass
    else:
        if a not in duplicate:
            cnt += 1
        for i in range(1, 10 ** 6 + 1):
            if a * i > 10 ** 6:
                break
            table[a * i] = 1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
 
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000
 
d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))
 
N = int(input())
A = LI()
A.sort()
 
cc = collections.Counter(A)
# print(cc)
chosen = []
cnt = 0
for key in cc.keys():
    if cc[key] > 1:
        chosen.append(key)
        continue
    if len(chosen) == 0:
        cnt += 1
        chosen.append(key)
    else:
        for c in chosen:
            if key % c == 0:
                break
        else:
            chosen.append(key)
            cnt += 1
 
print(cnt)

Fixed submission:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
 
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000
 
d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))
 

"""
3
1 1 2
のパターンが例外だった
"""

N = int(input())
A = LI()
A.sort()

table = [0 for i in range(10 ** 6 + 1)]
cnt = 0

cc = collections.Counter(A)
duplicate = []
for key in cc.keys():
    if cc[key] > 1:
        duplicate.append(key)

for a in A:
    if table[a] != 0:
        pass
    else:
        if a not in duplicate:
            cnt += 1
        for i in range(1, 10 ** 6 + 1):
            if a * i > 10 ** 6:
                break
            table[a * i] = 1

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())

def factorint(N):
    """
    Nを作っている素数を辞書で返す．
    input 100
    output Counter({2: 2, 5: 2})
    """
    table = []
    tmp = 2
    while(N > 1):
        for i in range(tmp,N+1):
            if N%i == 0:
                while N%i == 0:
                    N = N//i
                    table.append(i)
                tmp = i+1
                break
    table_ = collections.Counter(table)
    return table_

factors = factorint(N)
ans = 0

for key in factors.keys():
    f_c = factors[key]
    tmp = 1
    while f_c >= tmp:
        ans += 1
        f_c -= tmp
        tmp += 1

print(ans)

Fixed submission:
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())

def factorint(N):
    """
    Nを作っている素数を辞書で返す．
    input 100
    output Counter({2: 2, 5: 2})
    """
    table = []
    tmp = 2
    while(N > 1):
        for i in range(tmp,N+1):
            if N%i == 0:
                while N%i == 0:
                    N = N//i
                    table.append(i)
                tmp = i+1
                break
    table_ = collections.Counter(table)
    return table_

def primes(n): #試し割り法で各素因数とその指数を求める
    cnt=collections.defaultdict(int)
    for i in range(2,int(n**0.5)+1):
        if n%i==0:
            while n%i==0:
                cnt[i]+=1
                n//=i
    if n!=1:
        cnt[n]+=1
    return cnt

# factors = factorint(N)
factors = primes(N)
ans = 0

for key in factors.keys():
    f_c = factors[key]
    tmp = 1
    while f_c >= tmp:
        ans += 1
        f_c -= tmp
        tmp += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる
import sympy
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

A, B, H, M = LI()
sympy.pi.evalf(30)
pi = sympy.pi

h_p = [A * math.cos(2 * pi * (H * 60 + M) / 720), A * math.sin(2 * pi * (H * 60 + M) / 720)]
m_p = [B * math.cos(2 * pi * M / 60), B * math.sin(2 * pi * M / 60)]

# print(h_p, m_p)
length = ((h_p[0] - m_p[0])**2 + (h_p[1] - m_p[1])**2)**0.5
print(length) 


Fixed submission:
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

A, B, H, M = LI()

pi = math.pi
h_p = [A * math.cos(2 * pi * (H * 60 + M) / 720), A * math.sin(2 * pi * (H * 60 + M) / 720)]
m_p = [B * math.cos(2 * pi * M / 60), B * math.sin(2 * pi * M / 60)]

# print(h_p, m_p)
length = ((h_p[0] - m_p[0])**2 + (h_p[1] - m_p[1])**2)**0.5
print(length)
Buggy python submission (verdict: Time Limit Exceeded):
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = LI()

ans = 0
for i in range(N):
    h_i = A[i]
    for j in range(h_i + i, N):
        if h_i + A[j] == j - i:
            ans += 1
print(ans)

Fixed submission:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())

A = LI()

A_ii = copy.deepcopy(A)
for i in range(N):
    A_ii[i] += i
dic_A_ii = collections.Counter(A_ii)

A_jj = copy.deepcopy(A)

for j in range(N):
    A_jj[j] = -1 * A_jj[j] + j

ans = 0
dic_A_jj = collections.Counter(A_jj)
# print(dic_A_ii)
# print(dic_A_jj)

for ii_key in dic_A_ii.keys():
    ans += dic_A_jj[ii_key] * dic_A_ii[ii_key]

print(ans)
Buggy python submission (verdict: Runtime Error):
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

A, B, N = LI()
ans = math.floor(A * N / B)
if N > B:
    ans = max(ans, math.floot(A * (B - 1) / B))
print(ans)





Fixed submission:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

A, B, N = LI()
if N < B:
    ans = math.floor(A * N / B)
elif N >= B:
    ans = math.floor(A * (B - 1) / B)
print(ans)