Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,t = map(int,input().split())

m = 1001

for i in range(N):
    
    c,t = map(int,input().split())
    
    if t <= T:
        m=min(m,c)
        
print("TLE" if m==1001 else m)



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

m = 1001

for i in range(N):
    
    c,t = map(int,input().split())
    
    if t <= T:
        m=min(m,c)
        
print("TLE" if m==1001 else m)
Buggy python submission (verdict: Runtime Error):
x = int(input())
for b in range(1,x):
    for p in range(2,x):
        if b**p<=x:c=max(c,b**p)
        else:break
print(c)

Fixed submission:
x = int(input())
c=1
for b in range(1,x):
    for p in range(2,x):
        if b**p<=x:c=max(c,b**p)
        else:break
print(c)
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
print("Yes" if c>=a and c<=B else "No")

Fixed submission:
a,b,c = map(int,input().split())
print("Yes" if c>=a and c<=b else "No")
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print("GREATER" if a>b else "LESS" if a<b else "EQUAL")

Fixed submission:
a=int(input())
b=int(input())
print("GREATER" if a>b else "LESS" if a<b else "EQUAL")
Buggy python submission (verdict: Runtime Error):
print(math.factorial(int(input()))%(10**9+7))

Fixed submission:
import math
print(math.factorial(int(input()))%(10**9+7))
Buggy python submission (verdict: Runtime Error):
n =int(input())
a=list(map(int,input().split())
counter=0
for i in range(n-1):
	if a[i] >a[i+1]:
    	   counter += a[i] -a[i+1]
print(counter)

Fixed submission:
counter = 0
n = int(input())
a = list(map(int,input().split()))
for i in range(n-1):
  if a[i]>a[i+1]:
    counter += a[i]-a[i+1]
    a[i+1] = a[i]
print(counter)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
A.sort()
check = [0] * 1000001
res = 0
for i in range(N):
    if not check[A[i]] and (i == N-1 or A[i] != A[i+1]):
        res += 1
    for j in range(A[i], 1000001, A[i]):
        check[j] = 1
print(res)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()
check = [0] * 1000001
res = 0
for i in range(N):
    if check[A[i]]:
        continue
    if i == N-1 or A[i] != A[i+1]:
        res += 1
    for j in range(A[i], 1000001, A[i]):
        check[j] = 1
print(res)
Buggy python submission (verdict: Runtime Error):
N = input().split()
X = int(N[0])
Y = int(N[1])

flag = False

if Y % 2 != 0:
    prunt("No")
    exit()

def memo(x, y):
    global flag
    if x == 0:
        if y == 0:
            flag = True
        return flag

    
    memo(x-1, y-2)
    memo(x-1, y-4)

memo(X, Y)

if flag:
    print("Yes")
else:
    print("No")



Fixed submission:
N = input().split()
X = int(N[0])
Y = int(N[1])

flag = False

for i in range(X):
    if flag:
        break

    if (X-i)*2 + i*4 == Y:
        flag = True
    
    if (X-i)*4 + i*2 == Y:
        flag = True

if flag:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
line = input().split()

MAX = 1000000000000000000

ans = 1

for l in line:
    ans = int(l) * ans

if ans <= MAX:
    print(ans)
else:
    print(-1)


Fixed submission:
N = int(input())
line = input().split()

MAX = 1000000000000000000

ans = 1

if not '0' in line:
    for l in line:
        if l == 0:
            ans = 0
            break
        if not ans > MAX:
            ans = int(l) * ans

else:
    ans = 0


if ans <= MAX:
    print(ans)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
N = int(input())

arr = []

for i in range(N):
    arr.append(input())

print(len(set(arr))

Fixed submission:
N = int(input())

arr = []

for i in range(N):
    arr.append(input())

print(len(set(arr)))

Buggy python submission (verdict: Runtime Error):
N = int(input())

arr = []

for i in range(N):
    arr.append(input())

print(len(arr.set()))

Fixed submission:
N = int(input())

arr = []

for i in range(N):
    arr.append(input())

print(len(set(arr)))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

arr = []
counter = 0

for i in range(N):
    string = input()
    if not string in arr:
        counter += 1
        arr.append(string)

print(counter)

Fixed submission:
N = int(input())

arr = []

for i in range(N):
    arr.append(input())

print(len(set(arr)))
Buggy python submission (verdict: Time Limit Exceeded):
arr = input().split(" ")
N = int(arr[0])
K = int(arr[1])

input_arr = input().split(" ")
arr = []


max = 0
tmp = 0
for i in range(N):
    pi = int(input_arr[i])
    ex = (1+pi)/2
    arr.append(ex)
    tmp += ex
    if(i >= K-1):
        if(max <= tmp):
            max = tmp
        tmp -= arr[0]
        arr.pop(0)

print(max)


Fixed submission:
arr = input().split(" ")
N = int(arr[0])
K = int(arr[1])

input_arr = input().split(" ")
arr = []


max = 0
tmp = 0
if(K > 1):
    for i in range(N):
        pi = int(input_arr[i])
        ex = (1+pi)/2
        arr.append(ex)
        tmp += ex
        if(i >= K-1):
            if(max <= tmp):
                max = tmp
            tmp -= arr[i-K+1]
else:
    for i in range(N):
        pi = int(input_arr[i])
        ex = (1+pi)/2
        if(ex > max):
            max = ex
print(max)

Buggy python submission (verdict: Time Limit Exceeded):
arr = input().split(" ")
N = int(arr[0])
K = int(arr[1])

input_arr = input().split(" ")
arr = []


def calc_expected(pi):
    return (1+pi)/2


max = 0
tmp = 0
for i in range(N):
    pi = int(input_arr[i])
    ex = calc_expected(pi)
    arr.append(ex)
    tmp += ex
    if(i >= K-1):
        if(max <= tmp):
            max = tmp
        tmp -= arr[0]
        arr.pop(0)

print(max)


Fixed submission:
arr = input().split(" ")
N = int(arr[0])
K = int(arr[1])

input_arr = input().split(" ")
arr = []


max = 0
tmp = 0
if(K > 1):
    for i in range(N):
        pi = int(input_arr[i])
        ex = (1+pi)/2
        arr.append(ex)
        tmp += ex
        if(i >= K-1):
            if(max <= tmp):
                max = tmp
            tmp -= arr[i-K+1]
else:
    for i in range(N):
        pi = int(input_arr[i])
        ex = (1+pi)/2
        if(ex > max):
            max = ex
print(max)

Buggy python submission (verdict: Time Limit Exceeded):
arr = input().split(" ")
N = int(arr[0])
K = int(arr[1])

input_arr = input().split(" ")
arr = []

def calc_expected(pi):
    out = 0
    for i in range(1, pi+1):
        out += i
    out = out / pi
    return out

max = 0
tmp = 0
for i in range(N):
    pi = int(input_arr[i])
    ex = calc_expected(pi)
    arr.append(ex)
    tmp += ex
    if(i >= K-1):
        if(max <= tmp):
            max = tmp
        tmp -= arr[0]
        arr.pop(0)

print(max)

Fixed submission:
arr = input().split(" ")
N = int(arr[0])
K = int(arr[1])

input_arr = input().split(" ")
arr = []


max = 0
tmp = 0
if(K > 1):
    for i in range(N):
        pi = int(input_arr[i])
        ex = (1+pi)/2
        arr.append(ex)
        tmp += ex
        if(i >= K-1):
            if(max <= tmp):
                max = tmp
            tmp -= arr[i-K+1]
else:
    for i in range(N):
        pi = int(input_arr[i])
        ex = (1+pi)/2
        if(ex > max):
            max = ex
print(max)
Buggy python submission (verdict: Runtime Error):
arr = input().split(" ")
N = int(arr[0])
K = int(arr[1])

HP_arr = input().split(" ")
HP_arr.sort(reverse=True)
HP_arr = [int(i) for i in HP_arr ]

while(True):
    if(K > 0):
        HP_arr.pop(0)
        K -= 1
    else:
        break

print(sum(HP_arr))

Fixed submission:
arr = input().split(" ")
H = int(arr[0])
K = int(arr[1])

HPs = input().split(" ")
HPs = [int(i) for i in HPs ]
HPs.sort(reverse=True)

if(K == 0):
    print(sum(HPs))
else:
    print(sum(HPs[K:]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
M = int(input())

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

Fixed submission:
line = input().split(" ")
N = int(line[0])
M = int(line[1])

if(N == M):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(210000)
def s(x,v,d):
  r=[d,v]
  for u in g[v]:
    if u!=x:
      t=s(v,u,d+1)
      if r[0]<t[0]:r=t
  return r
n,*t=map(int,open(0).read().split())
g=[set()for _ in range(n+1)]
for a,b in zip(t[::2],t[1::2]):
  g[a].add(b)
  g[b].add(a)
print('SFeicrosntd'[s(0,s(0,1,0)[1],0)[0]%3!=1::2])

Fixed submission:
import sys
sys.setrecursionlimit(250000)
def s(x,v,d):
  r=[d,v]
  for u in g[v]:
    if u!=x:
      t=s(v,u,d+1)
      if r[0]<t[0]:r=t
  return r
n,*t=map(int,open(0).read().split())
g=[[]for _ in range(n+1)]
for a,b in zip(t[::2],t[1::2]):
  g[a].append(b)
  g[b].append(a)
print('SFeicrosntd'[s(0,s(0,1,0)[1],0)[0]%3!=1::2])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(200000)
def s(x,v,d):
  r=[d,v]
  for u in g[v]:
    if u!=x:
      t=s(v,u,d+1)
      if r[0]<t[0]:r=t
  return r
n,*t=map(int,open(0).read().split())
g=[set()for _ in range(n+1)]
for a,b in zip(t[::2],t[1::2]):
  g[a].add(b)
  g[b].add(a)
print('SFeicrosntd'[s(0,s(0,1,0)[1],0)[0]%3!=1::2])

Fixed submission:
import sys
sys.setrecursionlimit(250000)
def s(x,v,d):
  r=[d,v]
  for u in g[v]:
    if u!=x:
      t=s(v,u,d+1)
      if r[0]<t[0]:r=t
  return r
n,*t=map(int,open(0).read().split())
g=[[]for _ in range(n+1)]
for a,b in zip(t[::2],t[1::2]):
  g[a].append(b)
  g[b].append(a)
print('SFeicrosntd'[s(0,s(0,1,0)[1],0)[0]%3!=1::2])

Buggy python submission (verdict: Runtime Error):
def s(x,v,d):
  r=[d,v]
  for u in g[v]:
    if u!=x:
      t=s(v,u,d+1)
      if r[0]<t[0]:r=t
  return r
n,*t=map(int,open(0).read().split())
g=[set()for _ in range(n+1)]
for a,b in zip(t[::2],t[1::2]):
  g[a].add(b)
  g[b].add(a)
print('SFeicrosntd'[s(0,s(0,1,0)[1],0)[0]%3!=1::2])

Fixed submission:
import sys
sys.setrecursionlimit(250000)
def s(x,v,d):
  r=[d,v]
  for u in g[v]:
    if u!=x:
      t=s(v,u,d+1)
      if r[0]<t[0]:r=t
  return r
n,*t=map(int,open(0).read().split())
g=[[]for _ in range(n+1)]
for a,b in zip(t[::2],t[1::2]):
  g[a].append(b)
  g[b].append(a)
print('SFeicrosntd'[s(0,s(0,1,0)[1],0)[0]%3!=1::2])
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
a.sort()
Alice = 0
Bob = 0
for i in range(n):
  if i%2 == 0:
    Alice += A[i]
  else:
    Bob += A[i]
ans = Alice - Bob
print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
Alice = 0
Bob = 0
for i in range(N):
  if i%2 == 0:
    Alice += A[i]
  else:
    Bob += A[i]
ans = Alice - Bob
print(ans)
Buggy python submission (verdict: Runtime Error):
t1=raw_input()
t2=raw_input()
if t1[0]==t2[2] and t1[1]==t2[1] and t1[2]==t2[0]:
 return "YES"
else
 return "NO"

Fixed submission:
t1=raw_input()
t2=raw_input()
if t1[0]==t2[2] and t1[1]==t2[1] and t1[2]==t2[0]:
 print "YES"
else:
 print "NO"

Buggy python submission (verdict: Runtime Error):
t1=raw_input().split(' ')
t2=raw_input().split(' ')
if t1[0]==t2[2] and t1[1]==t2[1] and t1[2]==t2[0]:
 return "YES"
else
 return "NO"


Fixed submission:
t1=raw_input()
t2=raw_input()
if t1[0]==t2[2] and t1[1]==t2[1] and t1[2]==t2[0]:
 print "YES"
else:
 print "NO"
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
H, W, M = map(int, input().split())

h_list = [0 for _ in range(H + 1)]
w_list = [0 for _ in range(W + 1)]
m_list = [[0 for _ in range(W + 1)] for _ in range(H + 1)]
for i in range(M):
    h, w = map(int, input().split())
    h_list[h] += 1
    w_list[w] += 1
    m_list[h][w] = 1

max_h_list = []
max_h = -1
for i in range(H + 1):
    if max_h == h_list[i]:
        max_h_list.append(i)
    elif max_h < h_list[i]:
        max_h = h_list[i]
        max_h_list = [i]

max_w_list = []
max_w = -1
for i in range(W + 1):
    if max_w == w_list[i]:
        max_w_list.append(i)
    elif max_w < w_list[i]:
        max_w = w_list[i]
        max_w_list = [i]

adjust_dupl = 1
for i in range(len(max_h_list)):
    for j in range(len(max_w_list)):
        if m_list[max_h_list[i]][max_w_list[j]] == 0:
            adjust_dupl = 0
            break
    if adjust_dupl == 0:
        break
print(max_h + max_w - adjust_dupl)

Fixed submission:
# -*- coding: utf-8 -*-
H, W, M = map(int, input().split())

h_list = [0 for _ in range(H + 1)]
w_list = [0 for _ in range(W + 1)]
m_dic = {}
for i in range(M):
    h, w = map(int, input().split())
    h_list[h] += 1
    w_list[w] += 1
    m_dic["{}_{}".format(h, w)] = 1

max_h_list = []
max_h = -1
for i in range(H + 1):
    if max_h == h_list[i]:
        max_h_list.append(i)
    elif max_h < h_list[i]:
        max_h = h_list[i]
        max_h_list = [i]

max_w_list = []
max_w = -1
for i in range(W + 1):
    if max_w == w_list[i]:
        max_w_list.append(i)
    elif max_w < w_list[i]:
        max_w = w_list[i]
        max_w_list = [i]

adjust_dupl = 1
for i in range(len(max_h_list)):
    for j in range(len(max_w_list)):
        if "{}_{}".format(max_h_list[i], max_w_list[j]) not in m_dic:
            adjust_dupl = 0
            break
    if adjust_dupl == 0:
        break
print(max_h + max_w - adjust_dupl)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
K = int(input())

def factorize(target_number):
    factor_list = []
    while target_number % 2 == 0:
        factor_list.append(2)
        target_number //= 2
    factor = 3
    while factor * factor <= target_number:
        while target_number % factor == 0:
            target_number //= factor
            factor_list.append(factor)
        factor += 2
    if target_number > 1:
        factor_list.append(target_number)
    return factor_list

fact_list = factorize(K)
if fact_list.count(2) > 0 or fact_list.count(5) > 0:
    print(-1)
else:
    num = 7
    for i in range(10 ** 6):
        if num % K == 0:
            print(i + 1)
            break
        num = num * 10 + 7
    

Fixed submission:
# C TLE
# -*- coding: utf-8 -*-
K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    num = 7
    for i in range(10 ** 6):
        mod_num = num % K
        if mod_num == 0:
            print(i + 1)
            break
        num = mod_num * 10 + 7
Buggy python submission (verdict: Runtime Error):
a=list(map(int,input().split()))
q=int(input())
dic={}
for i in range(len(a)):
  dic.setdefault(a[i],1)
  dic[a[i]]+=1
answer=sum(a)
for i in range(q):
    b,c=map(int,input().split())
    dic.setdefault(b,0)
    dic.setdefault(c,0)
    dic[c]+=dic[b]
    answer=answer+dic[b]*c-dic[b]*b
    dic[b] = 0
    print(answer)

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())
A_list = list(map(int, input().split()))
Q = int(input())

count_list = [0 for i in range(10 ** 5 + 1)]
for i in range(len(A_list)):
    count_list[A_list[i]] += 1

ans = sum(A_list)
for i in range(Q):
    B, C = map(int, input().split())
    ans = ans - count_list[B] * B + count_list[B] * C
    print(ans)
    count_list[C] += count_list[B]
    count_list[B] = 0

Buggy python submission (verdict: Runtime Error):
a=list(map(int,input().split()))
q=int(input())
dic={}
for i in range(len(a)):
  dic.setdefault(a[i],1)
  dic[a[i]]+=1
answer=sum(a)
for i in range(q):
    b,c=map(int,input().split())
    dic.setdefault(b,0)
    dic.setdefault(c,0)
    dic[c]+=dic[b]
    answer=answer+dic[b]*c-dic[b]*b
    dic[b] = 0
    print(answer)

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())
A_list = list(map(int, input().split()))
Q = int(input())

count_list = [0 for i in range(10 ** 5 + 1)]
for i in range(len(A_list)):
    count_list[A_list[i]] += 1

ans = sum(A_list)
for i in range(Q):
    B, C = map(int, input().split())
    ans = ans - count_list[B] * B + count_list[B] * C
    print(ans)
    count_list[C] += count_list[B]
    count_list[B] = 0
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
N = int(input())
A_list = list(map(int, input().split()))
ans = 1
for i in range(N):
    ans *= A_list[i]

print(-1 if ans > 10 ** 18 else ans)

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())
A_list = list(map(int, input().split()))

if A_list.count(0) > 0:
    print(0)
else:
    ans = 1
    for i in range(N):
        ans *= A_list[i]
        if ans > 10 ** 18:
            print(-1)
            break
    else:
        print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import collections
# factrize
def factorize(target_number):
    factor_list = []
    while target_number % 2 == 0:
        factor_list.append(2)
        n //= 2
    factor = 3
    while factor * factor <= target_number:
        while target_number % factor == 0:
            target_number //= factor
            factor_list.append(factor)
        factor += 2
    if target_number > 1:
        factor_list.append(target_number)
    return factor_list

N = int(input())

fact_list = factorize(N)

fact_counter_dict = collections.Counter(fact_list)
ans = 0
for fact, freq in fact_counter_dict.items():
    freq_copy = freq
    for i in range(1, freq + 1):
        freq_copy -= i
        if freq_copy < 0:
            break
        ans += 1
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
import collections
# factrize
def factorize(target_number):
    factor = 2
    factor_list = []
    while factor * factor <= target_number:
        while target_number % factor == 0:
            target_number //= factor
            factor_list.append(factor)
        factor = factor + 1
    if target_number > 1:
        factor_list.append(target_number)
    return factor_list

N = int(input())

fact_list = factorize(N)

fact_counter_dict = collections.Counter(fact_list)
ans = 0
for fact, freq in fact_counter_dict.items():
    freq_copy = freq
    for i in range(1, freq + 1):
        freq_copy -= i
        if freq_copy < 0:
            break
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
X = int(input())

ans = ""
for i in range(70):
    for j in range(-70, i, 1):
        if i ** 5 - j ** 5 == X:
            ans = "{} {}".format(i, j)
            break
    if ans != "":
        break

if ans != "":
    print(ans)
else:
    print(aaa)

Fixed submission:
# -*- coding: utf-8 -*-
X = int(input())

ans = ""
for i in range(10 ** 4):
    for j in range(-70, i, 1):
        if i ** 5 - j ** 5 == X:
            ans = "{} {}".format(i, j)
            break
    if ans != "":
        break

if ans != "":
    print(ans)
else:
    print(aaa)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import numpy as np
K = int(input())
 
ans = 0
for i in range(1, K + 1):
    for j in range(1, K + 1):
        gcd_ij = np.gcd(i, j)
        for k in range(1, K + 1):
            ans += np.gcd(gcd_ij, k)

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
K = int(input())

# lcm & gcd not math library
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

from functools import reduce
def gcd_multi(num_list):
    return reduce(gcd, num_list)

ans = 0
for i in range(1, K + 1):
    for j in range(i, K + 1):
        for k in range(j, K + 1):
            if i == j and j == k:
                dup_num = 1
            elif i == j or j == k:
                dup_num = 3
            else:
                dup_num = 6
            ans += gcd_multi([i, j, k]) * dup_num

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
K = int(input())

# lcm & gcd not math library
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
ans = 0
for i in range(1, K + 1):
    for j in range(1, K + 1):
        for k in range(1, K + 1):
            ans += gcd(gcd(i, j), k)

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
K = int(input())

# lcm & gcd not math library
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

from functools import reduce
def gcd_multi(num_list):
    return reduce(gcd, num_list)

ans = 0
for i in range(1, K + 1):
    for j in range(i, K + 1):
        for k in range(j, K + 1):
            if i == j and j == k:
                dup_num = 1
            elif i == j or j == k:
                dup_num = 3
            else:
                dup_num = 6
            ans += gcd_multi([i, j, k]) * dup_num

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# D
# -*- coding: utf-8 -*-
N, X, Y = map(int, input().split())
X -= 1
Y -= 1

ans_list = [[-1 for _ in range(N)] for _ in range(N)]
for i in range(N - 1):
    for j in range(i + 1, N):
#         ans_list[i][j] = min(abs(j - i), abs(X - i) + 1 + abs(j - Y))
        ans_list[i][j] = min(abs(j - i), abs(X - i) + 1 + abs(j - Y))

for i in range(1, N):
    ans = 0
    for j in range(N):
        ans += ans_list[j].count(i)
    print(ans)

Fixed submission:
# D
# -*- coding: utf-8 -*-
N, X, Y = map(int, input().split())
X -= 1
Y -= 1

ans_list = [0 for _ in range(N)]
for i in range(N - 1):
    for j in range(i + 1, N):
        ans_list[min(abs(j - i), abs(X - i) + 1 + abs(j - Y))] += 1

for i in range(1, N):
    print(ans_list[i])
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
H, W = map(int, input().split())
if H > 1 and W > 1:
    print((H * W) // 2 + (H * W) % 2)
else
    print(1)

Fixed submission:
# -*- coding: utf-8 -*-
H, W = map(int, input().split())
if H > 1 and W > 1:
    print((H * W) // 2 + (H * W) % 2)
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
print('Yes' if !input().replace('hi','') else 'No')

Fixed submission:
# -*- coding: utf-8 -*-
S = str(input())

print("Yes" if len(S.replace("hi", "")) == 0 else "No")
Buggy python submission (verdict: Runtime Error):
resolve()
def resolve():
    S = str(input())
    Q = int(input())

    rev_flag = 1
    head_str = ""
    tail_str = ""
    for _ in range(Q):
        query = input() # contains spaces
        if query[0] == "1":
            rev_flag *= -1
        else:
            h_or_t_flag = 1 if query[2] == "1" else -1
            h_or_t_flag *= rev_flag

            if h_or_t_flag == 1:
                head_str += query[4]
            else:
                tail_str += query[4]

    ans = head_str[::-1] + S + tail_str
    print(ans if rev_flag == 1 else ans[::-1])


Fixed submission:
# -*- coding: utf-8 -*-
S = str(input())
Q = int(input())

rev_flag = 1
head_str = ""
tail_str = ""
for _ in range(Q):
    query = list(map(str, input().split()))
    if query[0] == "1":
        rev_flag *= -1
    else:
        h_or_t_flag = 1 if query[1] == "1" else -1
        h_or_t_flag *= rev_flag
        
        if h_or_t_flag == 1:
            head_str = query[2] + head_str
        else:
            tail_str += query[2]

ans = head_str + S + tail_str
print(ans if rev_flag == 1 else ans[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
N, a, b = map(int, input().split())

def get_combi_mod(n, k, MOD):
    if n < k:
        return 0
    if n-k < k:
        k = n-k
    comb = 1
    for x in range(n-k+1, n+1):
        comb = (comb * x) % MOD
    d = 1
    for x in range(1, k+1):
        d = (d * x) % MOD
    comb *= pow(d, MOD-2, MOD)
    return comb % MOD

ans = 1
mod_case = 1 if N % 1000 != 0 else 0
div_num = 10 ** 9 + 7
for i in range(N // 1000 + mod_case):
    ans = (ans * (2 ** 1000)) % div_num

print((2 ** N - 1 - get_combi_mod(N, a, div_num) - get_combi_mod(N, b, div_num)) % (10 ** 9 + 7))

Fixed submission:
# -*- coding: utf-8 -*-
N, a, b = map(int, input().split())

def get_combi_mod(n, k, MOD):
    if n < k:
        return 0
    if n-k < k:
        k = n-k
    comb = 1
    for x in range(n-k+1, n+1):
        comb = (comb * x) % MOD
    d = 1
    for x in range(1, k+1):
        d = (d * x) % MOD
    comb *= pow(d, MOD-2, MOD)
    return comb % MOD

ans = 1
div_num = 10 ** 9 + 7
two_thou = (2 ** 1000) % div_num
for i in range(N // 1000):
    ans = (ans * two_thou) % div_num

ans = (ans * (2 ** (N % 1000))) % div_num
print((ans - 1 - get_combi_mod(N, a, div_num) - get_combi_mod(N, b, div_num)) % (10 ** 9 + 7))