Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
print(n * (n-1)//2)

Fixed submission:
S = input()
T = input()
cnt = 0
for i in range(len(S)):
  if S[i] == T[i]:
    cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
H = list(map(int, input().split()))
ans = 0
for i in range(n):
  if ans >= n-i-1:
    break
  tmp = 0
  for j in range(i, n-1):
    if H[j] >= H[j+1]:
      tmp += 1
    else:
      break
    ans = max(ans, tmp)
print(ans)

Fixed submission:
n = int(input())
H = list(map(int, input().split()))
TMP = []
ans = 0
for i in range(n-1):
  if H[i] >= H[i+1]:
    TMP.append(1)
  else:
    TMP.append(-1)
tmp = 0
for i in range(n-1):
  if TMP[i] == 1:
    tmp += 1
  else:
    ans = max(ans, tmp)
    tmp = 0
ans = max(ans, tmp)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
H = list(map(int, input().split()))
ans = 0
for i in range(n):
  tmp = 0
  for j in range(i, n-1):
    if H[j] >= H[j+1]:
      tmp += 1
    else:
      break
    ans = max(ans, tmp)
print(ans)

Fixed submission:
n = int(input())
H = list(map(int, input().split()))
TMP = []
ans = 0
for i in range(n-1):
  if H[i] >= H[i+1]:
    TMP.append(1)
  else:
    TMP.append(-1)
tmp = 0
for i in range(n-1):
  if TMP[i] == 1:
    tmp += 1
  else:
    ans = max(ans, tmp)
    tmp = 0
ans = max(ans, tmp)
print(ans)
Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())

stack = [[] for _ in range(n+1)]
stack[0].append(1)
for i in range(n-1):
  a,b = map(int, input().split())
  stack[a].append(b)

ans = [0] * n
pool = {}
def dfs(cur, num):
	ans[cur-1] += num
	if len(stack[cur]) <= 0:
		return
	for c in stack[cur]:
		dfs(c, num)

for i in range(q):
  p, x = map(int, input().split())
  pool[p] = pool.get(p, 0) + x
for k, v in pool.items():
  dfs(k, v)
print(*ans)

Fixed submission:
a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print('red')

Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(n-1)]
PX = [list(map(int, input().split())) for _ in range(q)]

stack = [[] for _ in range(n+1)]
stack[0].append(1)
for i in range(n-1):
	stack[AB[i][0]].append(AB[i][1])

ans = [0] * n
pool = {}
def dfs(cur, num):
	ans[cur-1] += num
	if len(stack[cur]) <= 0:
		return
	for c in stack[cur]:
		dfs(c, num)

for px in PX:
	pool[px[0]] = pool.get(px[0], 0) + px[1]
for k, v in pool.items():
  	dfs(k, v)
print(*ans)

Fixed submission:
a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print('red')
Buggy python submission (verdict: Runtime Error):
n = int(input())
V = sorted(list(map(int, input().split())))
print(ans)
for i in range(1, n):
  ans = (V[i] + ans)/2

print(ans)

Fixed submission:
n = int(input())
V = sorted(list(map(int, input().split())))
ans = V[0]
for i in range(1, n):
  ans = (V[i] + ans)/2

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
alrdy = []
 
def is_anagrams(word1, word2):
    def get_counter(s):
        return Counter(s.upper().replace(' ', ''))
 
    return get_counter(word1) == get_counter(word2)

dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]
cnt = 0
while len(s) > 1:
  remove_list = []
  for i in range(len(s)-1):
    remove_list.append(i)
    for j in range(i+1, len(s)):
      if is_anagrams(s[i], s[j]):
        cnt += 1
        remove_list.append(j)
  s = dellist(s, remove_list)
print(cnt)

Fixed submission:
n = int(input())
s = [input() for _ in range(n)]
existed = {}
cnt = 0
for i in range(n):
  sorted_s = ''.join(sorted(s[i]))
  if sorted_s in existed:
    cnt += existed[sorted_s]
    existed[sorted_s] += 1
  else:
    existed[sorted_s] = 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
alrdy = []
 
def is_anagrams(word1, word2):
    def get_counter(s):
        return Counter(s.upper().replace(' ', ''))
 
    return get_counter(word1) == get_counter(word2)

cnt = 0
for i in range(n-1):
  for j in range(i+1, n):
    if is_anagrams(s[i], s[j]):
      cnt += 1
      continue
print(cnt)

Fixed submission:
n = int(input())
s = [input() for _ in range(n)]
existed = {}
cnt = 0
for i in range(n):
  sorted_s = ''.join(sorted(s[i]))
  if sorted_s in existed:
    cnt += existed[sorted_s]
    existed[sorted_s] += 1
  else:
    existed[sorted_s] = 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
alrdy = []
 
def is_anagrams(word1, word2):
    def get_counter(s):
        return Counter(s.upper().replace(' ', ''))
 
    return get_counter(word1) == get_counter(word2)

cnt = 0
for i in range(n):
  for j in range(n):
    if i == j:
      continue
    if is_anagrams(s[i], s[j]):
      cnt += 1
print(cnt//2)

Fixed submission:
n = int(input())
s = [input() for _ in range(n)]
existed = {}
cnt = 0
for i in range(n):
  sorted_s = ''.join(sorted(s[i]))
  if sorted_s in existed:
    cnt += existed[sorted_s]
    existed[sorted_s] += 1
  else:
    existed[sorted_s] = 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
import heapq
n, m = map(int, input().split())
jobs = [[] for _ in range(n)]

for i in range(n):
  a, b = map(int, input().split())
  if a > m:
    continue
  jobs[m-a].append(b)

que = []#候補入れ
ans = 0
for i in range(m-1, -1, -1):
  for wage in jobs[i]:
    heapq.heappush(que, wage*-1)
  if len(que):
    ans += heapq.heappop(que)*-1
    
print(ans)

  

Fixed submission:
import heapq
n, m = map(int, input().split())
jobs = [[] for _ in range(m)]

for i in range(n):
  a, b = map(int, input().split())
  if a > m:
    continue
  jobs[m-a].append(b)

que = []#候補入れ
ans = 0
for i in range(m-1, -1, -1):
  for wage in jobs[i]:
    heapq.heappush(que, wage*-1)
  if len(que):
    ans += heapq.heappop(que)*-1
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
a = [int(input()) for i in range(n)]
pre_max = max(a)

for i in range(n):
  if pre_max != a[i]:
    print(pre_max)
  else:
    copy_a = copy.copy(a)
    copy_a.pop(i)
    print(max(copy_a))
  

Fixed submission:
import copy
n = int(input())
a = [int(input()) for i in range(n)]
sorted_a = sorted(a, reverse=True)
n1 = sorted_a[0]
n2 = sorted_a[1]
if(n1 == n2):
  for i in range(n):
    print(n1)
else:
  for i in range(n):
    if a[i] == n1:
      print(n2)
    else:
      print(n1)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
a = [int(input()) for i in range(n)]
pre_max = max(a)

for i in range(n):
  copy_a = copy.copy(a)
  tmp = copy_a.pop(i)
  if pre_max != tmp:
    print(pre_max)
  else:
    this_max = max(copy_a)
    print(this_max)
    pre_max = this_max
  
  

Fixed submission:
import copy
n = int(input())
a = [int(input()) for i in range(n)]
sorted_a = sorted(a, reverse=True)
n1 = sorted_a[0]
n2 = sorted_a[1]
if(n1 == n2):
  for i in range(n):
    print(n1)
else:
  for i in range(n):
    if a[i] == n1:
      print(n2)
    else:
      print(n1)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
a = [int(input()) for i in range(n)]

for i in range(n):
  copy_a = copy.copy(a)
  tmp = copy_a.pop(i)
  print(max(copy_a))

Fixed submission:
import copy
n = int(input())
a = [int(input()) for i in range(n)]
sorted_a = sorted(a, reverse=True)
n1 = sorted_a[0]
n2 = sorted_a[1]
if(n1 == n2):
  for i in range(n):
    print(n1)
else:
  for i in range(n):
    if a[i] == n1:
      print(n2)
    else:
      print(n1)
Buggy python submission (verdict: Time Limit Exceeded):
#nn
L, R = map(int, input().split())
mod = 2019

if R - L >= mod:
  print(0)
else:
  s = []
  for i in range(L, R):
    for j in range(i+1, R+1):
      s.append((i*j) % mod)
    s.sort()
  print(s[0])

Fixed submission:
#nn
L, R = map(int, input().split())
mod = 2019

if R - L >= mod:
  print(0)
else:
  s = []
  for i in range(L, R):
    for j in range(i+1, R+1):
      s.append((i*j) % mod)
  s.sort()
  print(s[0])
Buggy python submission (verdict: Runtime Error):
from operator import mul
from functools import reduce
n,k = map(int,input().split())
mod = 10**9+7

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

for l in range(1,k+1):
  a = cmb(k-1,l-1)
  b = cmb(n-k+1,l)
  print(a*b%mod)

Fixed submission:
from operator import mul
from functools import reduce
n,k = map(int,input().split())
mod = 10**9+7

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

for l in range(1,k+1):
  if n-k+1 < l:
    print(0)
    continue
  a = cmb(k-1,l-1)
  b = cmb(n-k+1,l)
  print(a*b%mod)
Buggy python submission (verdict: Runtime Error):
from collections import deque
N, X = map(int, input().split())
L = list(map(int, input().split()))
d = [0]
current = 0
for i in range(N):
    current = current + L[i]
    d.append(current)

index = 0
flg = True
while flg:
    if d[index] <= X:
        index += 1
    else:
        flg = False

print(index)


Fixed submission:
from collections import deque

N, X = map(int, input().split())
L = list(map(int, input().split()))
d = deque([0])
current = 0
for i in range(N):
    current = current + L[i]
    d.append(current)

lessX = [i for i in d if i <= X]
print(len(lessX))

Buggy python submission (verdict: Runtime Error):
from collections import deque
N, X = map(int, input().split())
L = list(map(int, input().split()))
d = deque([0])
current = 0
for i in range(N):
    current = current + L[i]
    d.append(current)

count = 0
while d.popleft() <= X:
    count += 1

print(count)


Fixed submission:
from collections import deque

N, X = map(int, input().split())
L = list(map(int, input().split()))
d = deque([0])
current = 0
for i in range(N):
    current = current + L[i]
    d.append(current)

lessX = [i for i in d if i <= X]
print(len(lessX))
Buggy python submission (verdict: Runtime Error):
#nn
N,M=map(int,input().split())
a = [int(input()) for _ in range(M)]
dp = [0]*(N+1)
j = 0
dp[0] = 1
mod = 10**9+7
for i in range(1, N+1):
    if j < M and i == a[j]:
        j += 1
    elif i == 1:
        dp[i] = 1
    else:
        dp[i] = (dp[i-1]+dp[i-2]) % mod
print(dp[N])

Fixed submission:
times = list(map(int, input().strip().split()))

times.sort()
print(times[0] + times[1])
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for i in range(M)]
dp = [0]*(N+1)
div = 10**9 + 7
#dp[x] = dp[x-1] + dp[x-2]になる
dp[0] = 1
dp[1] = 1 if a[0] != 1 else 0

for x in range(2, N+1):
  if (x-1 in a and x-2 in a) or (x in a):
    dp[x] = 0
  elif x-1 in a:
    dp[x] = dp[x-2]
  elif x-2 in a:
    dp[x] = dp[x-1]
  else:
    dp[x] = dp[x-1]+dp[x-2]
  dp[x] = dp[x] % div
print(dp[-1]%div)


Fixed submission:
N,M=map(int,input().split())
a = [int(input()) for _ in range(M)]
dp = [0]*(N+1)
j = 0
dp[0] = 1
mod = 10**9+7
for i in range(1, N+1):
    if j < M and i == a[j]:
        j += 1
    elif i == 1:
        dp[i] = 1
    else:
        dp[i] = (dp[i-1]+dp[i-2]) % mod
print(dp[N])

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for i in range(M)]
dp = [0]*(N+1)
div = 10**9 + 7
#dp[x] = dp[x-1] + dp[x-2]になる
dp[0] = 1
dp[1] = 1 if a[0] != 1 else 0

for x in range(2, N+1):
  if (x-1 in a and x-2 in a) or (x in a):
    dp[x] = 0
  elif x-1 in a:
    dp[x] = dp[x-2]
  elif x-2 in a:
    dp[x] = dp[x-1]
  else:
    dp[x] = dp[x-1]+dp[x-2]

print(dp[-1]%div)


Fixed submission:
N,M=map(int,input().split())
a = [int(input()) for _ in range(M)]
dp = [0]*(N+1)
j = 0
dp[0] = 1
mod = 10**9+7
for i in range(1, N+1):
    if j < M and i == a[j]:
        j += 1
    elif i == 1:
        dp[i] = 1
    else:
        dp[i] = (dp[i-1]+dp[i-2]) % mod
print(dp[N])
Buggy python submission (verdict: Runtime Error):
3 2 9

Fixed submission:
import math
A, B, T = map(int, input().split())
total = 0
time = math.floor(T + 0.5)
total = B * (math.floor(time / A))
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd 
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
  if i == 0:
    tmp = a[1]
  else:
    tmp = a[0]
  for j in range(n):
    if j == i:
      continue
    else:
      tmp = gcd(tmp, a[j])
  ans = max(ans, tmp)
print(ans)

Fixed submission:
#nn
from fractions import gcd 
n = int(input())
a = list(map(int, input().split()))
ans = 1
left = [0]
right = [0]

for i in range(n):
  left.append(gcd(left[-1], a[i]))
  right.append(gcd(right[-1], a[-(i+1)]))
right.reverse()

for i in range(n):
  ans = max(ans, gcd(left[i], right[i+1]))
print(ans)

Buggy python submission (verdict: Runtime Error):
import copy as cp
N = int(input())
a = list(map(int, input().split()))

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def gcd_all(a_list):
    if len(a_list)<1:
      return
    gcd_num = gcd(a_list[0],a_list[1])
    for i in range(2, len(a_list)):
        gcd_num = gcd(gcd_num, a[i])
    return gcd_num

max_gcd = 0
for i in range(N):
    a_cp = cp.copy(a)
    del a_cp[i]
    max_gcd = max(max_gcd, gcd_all(a_cp))
print(max_gcd)

Fixed submission:
#nn
from fractions import gcd 
n = int(input())
a = list(map(int, input().split()))
ans = 1
left = [0]
right = [0]

for i in range(n):
  left.append(gcd(left[-1], a[i]))
  right.append(gcd(right[-1], a[-(i+1)]))
right.reverse()

for i in range(n):
  ans = max(ans, gcd(left[i], right[i+1]))
print(ans)

Buggy python submission (verdict: Runtime Error):
import copy as cp
N = int(input())
a = list(map(int, input().split()))

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def gcd_all(a_list):
    gcd_num = gcd(a_list[0],a_list[1])
    for i in range(2, len(a_list)):
        gcd_num = gcd(gcd_num, a[i])
    return gcd_num

max_gcd = 0
for i in range(N):
    a_cp = cp.copy(a)
    del a_cp[i]
    max_gcd = max(max_gcd, gcd_all(a_cp))
print(max_gcd)

Fixed submission:
#nn
from fractions import gcd 
n = int(input())
a = list(map(int, input().split()))
ans = 1
left = [0]
right = [0]

for i in range(n):
  left.append(gcd(left[-1], a[i]))
  right.append(gcd(right[-1], a[-(i+1)]))
right.reverse()

for i in range(n):
  ans = max(ans, gcd(left[i], right[i+1]))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
ans = []
for i in range(q):
  l,r = map(int, input().split())
  flg = False
  cnt = 0
  for j in range(l-1,r):
    if flg and s[j] == 'C':
      cnt += 1
      flg = False
    elif s[j] == 'A':
      flg = True
    else:
      flg = False
  ans.append(cnt)
for i in range(len(ans)):
  print(ans[i])

Fixed submission:
n, q = map(int, input().split())
s = input()
tmp = [0]
cnt = 0
for i in range(n-1):
  if s[i] == 'A' and s[i+1] == 'C':
    cnt += 1
  tmp.append(cnt)

for i in range(q):
  l, r = map(int, input().split())
  print(tmp[r-1]-tmp[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
V = list(map(int, input().split()))
A = V[::2]
B = V[1::2]
set_A = set(A)
set_B = set(B)
max_a = 0
max_b = 0

for a in set_A:
  cnt_a = A.count(a)
  max_a = max(max_a, cnt_a)
for b in set_B:
  cnt_b = B.count(b)
  max_b = max(max_b, cnt_b)
ans = (len(A) - max_a) + (len(B) - max_b)
if ans == 0 and A[0] == B[0]:
  ans = n // 2
print(ans)

Fixed submission:
n = int(input())
V = list(map(int, input().split()))
A = {}
B = {}
for i in range(n):
  if i % 2 == 0:#A
    A[V[i]] = A.get(V[i], 0) + 1
  else:#B
    B[V[i]] = B.get(V[i], 0) + 1

A = sorted(A.items(), key=lambda x:x[1], reverse=True)
B = sorted(B.items(), key=lambda x:x[1], reverse=True)
a1, b1 = A[0][1], B[0][1]
am, bm = A[0][0], B[0][0]
ans = n - a1 - b1
if ans == 0 and V[0]==V[1]:
  ans = n//2
elif am == bm and n > 4:
  a2,b2 = A[1][1], B[1][1]
  ans = min(n - a2 - b1, n - a1 - b2) 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
V = list(map(int, input().split()))
A = V[::2]
B = V[1::2]
set_A = set(A)
set_B = set(B)
max_a = 0
max_b = 0

for a in set_A:
  cnt_a = A.count(a)
  max_a = max(max_a, cnt_a)
for b in set_B:
  cnt_b = B.count(b)
  max_b = max(max_b, cnt_b)
ans = (len(A) - max_a) + (len(B) - max_b)
if ans == 0 and A[0] == B[0]:
  ans = n // 2
print(ans)

Fixed submission:
n = int(input())
V = list(map(int, input().split()))
A = {}
B = {}
for i in range(n):
  if i % 2 == 0:#A
    A[V[i]] = A.get(V[i], 0) + 1
  else:#B
    B[V[i]] = B.get(V[i], 0) + 1

A = sorted(A.items(), key=lambda x:x[1], reverse=True)
B = sorted(B.items(), key=lambda x:x[1], reverse=True)
a1, b1 = A[0][1], B[0][1]
am, bm = A[0][0], B[0][0]
ans = n - a1 - b1
if ans == 0 and V[0]==V[1]:
  ans = n//2
elif am == bm and n > 4:
  a2,b2 = A[1][1], B[1][1]
  ans = min(n - a2 - b1, n - a1 - b2) 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
d = []  # l,r詰める
sum = []

for i in range(n):
    left = 0
    right = 0
    for j in range(n):
        if j == i:
            continue
        elif j < i and s[j] == 'W':
            left += 1
        elif j > i and s[j] == 'E':
            right += 1
            
    d.append([left, right])
    sum.append(left+right)

print(min(sum))    


Fixed submission:
n = int(input())
s = input()
d = []

num_first = 0
for i in range(1, n):
    if s[i] == 'E':
        num_first += 1

d.append(num_first)

for i in range(1, n):
    tmp = 0
    if s[i-1] == 'W':
        tmp += 1
    if s[i] == 'E':
        tmp -= 1
    d.append(d[i-1] + tmp)

print(min(d))
Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
x = list(map(int, input().split()))

middle = int(n/2) - 1
for i in range(n):
  copy_list = copy.copy(x)
  elm = copy_list.pop(i)
  print(sorted(copy_list).pop(middle))


Fixed submission:
import copy
n = int(input())
x = list(map(int, input().split()))
sort_x = sorted(copy.copy(x))

middle = int(n/2) - 1
next_middle = middle + 1

for i in range(n):
  if x[i] <= sort_x[middle]:
    print(sort_x[next_middle])
  elif x[i] >= sort_x[next_middle]:
    print(sort_x[middle])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
cnt = 0

for i in range(n):
  for j in range(n):
    b1 = b[j]
    c1 = c[i]
    if c1 <= b1:
      break
    for k in range(n):
      a1 = a[k]
      if b1 <= a1:
        break
      else:
        cnt += 1

print(cnt)

Fixed submission:
import bisect
n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0

for b in B:
  num_a = bisect.bisect_left(A, b)
  num_c = n - bisect.bisect_right(C, b)
  ans += num_a * num_c
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
line1 = input().split()
n = int(line1[0])
k = int(line1[1])
a = [int(ai) for ai in input().split()]

route = [0]
for j in range(k):
  now = a[route[j]] - 1
  if now in route:
    break
  else:
    route.append(now)

l_start = route.index(now)
print(route[l_start + ((k - l_start) % (len(route) - l_start))] + 1)

Fixed submission:
line1 = input().split()
n = int(line1[0])
k = int(line1[1])
a = [int(ai) for ai in input().split()]

route = [0]
use = {0}
for j in range(k):
  now = a[route[j]] - 1
  if now in use:
    break
  else:
    route.append(now)
    use.add(now)

l_start = route.index(now)
print(route[l_start + ((k - l_start) % (len(route) - l_start))] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

k = []

for i in range(n):
  s = input()
  if not s in k:
    k.append(s)

print(len(k))

Fixed submission:
n = int(input())

k = []

for i in range(n):
  k.append(input())

print(len(set(k)))
Buggy python submission (verdict: Runtime Error):
import math
r = int(input))
print(math.pi * 2 * r)

Fixed submission:
import math
r = int(input())
print(math.pi * 2 * r)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# coding: utf-8
import math
# def debug(arg):
#     if __debug__:
#         pass
#     else:
#         import sys
#         print(arg, file=sys.stderr)

def main():
    A, B, H, M = map(int, input().split())

    vh = ((H * 60 + M) / (12 * 60))
    vm = (M / 60)

    theta = (vh - vm) * math.tau
    d = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta))

    print(d)

if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python3
# coding: utf-8
def main():
    K = int(input())
    S = input()
    if len(S) <= K:
        print(S)
    else:
        print(S[:K] + '...')

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def debug(arg):
    if __debug__:
        pass
    else:
        import sys
        print(arg, file=sys.stderr)



k = (int(x) for x in input().split())

n = 3
c = {} 
t = 0
for x in range(k, 0, -1):
    c[x] = (k // x) ** n
    c[x] = c[x] - sum(c[x * y] for y in range(2, k // x + 1))
    s = c[x] * x
    t += s
    # t = t % 1000000007

print(t)

Fixed submission:
import itertools
import math

n = int(input())
c1 = range(1, n + 1)
c2 = itertools.combinations(range(1, n + 1), 2)
c3 = itertools.combinations(range(1, n + 1), 3)

t1 = sum(list(c1))
t2 = sum(list(map(lambda x: math.gcd(x[0], x[1]), c2))) * 6
t3 = sum(list(map(lambda x: math.gcd(x[0], math.gcd(x[1], x[2])), c3))) * 6

print(sum([t1, t2, t3]))

Buggy python submission (verdict: Runtime Error):
def debug(arg):
    if __debug__:
        pass
    else:
        import sys
        print(arg, file=sys.stderr)



k = (int(x) for x in input().split())

c = {} 
t = 0
for x in range(k, 0, -1):
    c[x] = (k // x) ** n
    c[x] = c[x] - sum(c[x * y] for y in range(2, k // x + 1))
    s = c[x] * x
    t += s
    # t = t % 1000000007

print(t)

Fixed submission:
import itertools
import math

n = int(input())
c1 = range(1, n + 1)
c2 = itertools.combinations(range(1, n + 1), 2)
c3 = itertools.combinations(range(1, n + 1), 3)

t1 = sum(list(c1))
t2 = sum(list(map(lambda x: math.gcd(x[0], x[1]), c2))) * 6
t3 = sum(list(map(lambda x: math.gcd(x[0], math.gcd(x[1], x[2])), c3))) * 6

print(sum([t1, t2, t3]))

Buggy python submission (verdict: Runtime Error):
def debug(arg):
    if __debug__:
        pass
    else:
        import sys
        print(arg, file=sys.stderr)



n, k = (int(x) for x in input().split())

c = {} 
t = 0
for x in range(k, 0, -1):
    c[x] = (k // x) ** n
    c[x] = c[x] - sum(c[x * y] for y in range(2, k // x + 1))
    s = c[x] * x
    t += s
    t = t % 1000000007

print(t)

Fixed submission:
import itertools
import math

n = int(input())
c1 = range(1, n + 1)
c2 = itertools.combinations(range(1, n + 1), 2)
c3 = itertools.combinations(range(1, n + 1), 3)

t1 = sum(list(c1))
t2 = sum(list(map(lambda x: math.gcd(x[0], x[1]), c2))) * 6
t3 = sum(list(map(lambda x: math.gcd(x[0], math.gcd(x[1], x[2])), c3))) * 6

print(sum([t1, t2, t3]))

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
n = int(input())
c = itertools.product(range(1, n + 1), repeat=3)
t = 0
for l in c:
    s = math.gcd(l[0], math.gcd(l[1], l[2]))
    t += s
print(t)


Fixed submission:
import itertools
import math

n = int(input())
c1 = range(1, n + 1)
c2 = itertools.combinations(range(1, n + 1), 2)
c3 = itertools.combinations(range(1, n + 1), 3)

t1 = sum(list(c1))
t2 = sum(list(map(lambda x: math.gcd(x[0], x[1]), c2))) * 6
t3 = sum(list(map(lambda x: math.gcd(x[0], math.gcd(x[1], x[2])), c3))) * 6

print(sum([t1, t2, t3]))