Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = input().split()
a_int = [int(n) for n in a]
ans = 1
for num in a_int:
    if ans > 10**18:
        print(-1)
        exit()
    else:
        ans *= num
print(ans)

Fixed submission:
a = input().split()
b = int(a[0])
c = float(a[1])
c = round(c*100)

ans = b*c // 100
print(int(ans))

Buggy python submission (verdict: Runtime Error):
from math import floor
a, b = input().split()
a = int(a)
b = float(b)
print(int(floor(a*b))

Fixed submission:
a = input().split()
b = int(a[0])
c = float(a[1])
c = round(c*100)

ans = b*c // 100
print(int(ans))
Buggy python submission (verdict: Runtime Error):
from math import cos, sqrt, pi
a, b, h, m = map(int, input().split())
#時針の角度
ang_a = pi * h / 6 + pi * m / 360
#分針の角度
ang_b = pi * m / 30
#角度差
ang = abs(ang_a-ang_b)
#余弦定理
c = sqrt(a**2 + b**2 - 2*a*b*cos(ang))
print(c)

Fixed submission:
k = int(input())
s = str(input())
if k < len(s):
    ans = s[0:k]+'...'
    print(ans)
else:
    print(s)
Buggy python submission (verdict: Runtime Error):
s = str(input())
if s == 'ABC':
  print('ARC)
else:
  print('ABC')

Fixed submission:
s = str(input())
if s == 'ABC':
  print('ARC')
else:
  print('ABC')
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
h = list(map(int, input().split()))
delete_list =[]
pairs = []
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] > h[b-1]:
        delete_list.append(b)
    if h[a-1] == h[b-1]:
        delete_list.append(a, b)
    else:
        delete_list.append(a)

delete_list = set(delete_list)
print(n - len(delete_list))

Fixed submission:
n, m = map(int, input().split())
h = list(map(int, input().split()))
delete_list =[]
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] > h[b-1]:
        delete_list.append(b)
    if h[a-1] == h[b-1]:
        delete_list.append(a)
        delete_list.append(b)
    if h[a-1] < h[b-1] :
        delete_list.append(a)

delete_list = set(delete_list)
print(n - len(delete_list))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
anss = [0] * n
for _ in a:
    anss[a-1] += 1
for ans in anss:
    print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
anss = [0] * n
for _ in a:
    anss[_-1] += 1
for ans in anss:
    print(ans)

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

for i in range(n-1):
    print(a.count(i+1))
print(0)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
anss = [0] * n
for _ in a:
    anss[_-1] += 1
for ans in anss:
    print(ans)
Buggy python submission (verdict: Runtime Error):
N, R = map(int, input().split())
if N >= 10:
  I == R
  print(I)
else:
  I = R+100*(10-N)
  print(I)

Fixed submission:
N, R = map(int, input().split())
if N >= 10:
  I = R
  print(I)
else:
  I = R+100*(10-N)
  print(I)
Buggy python submission (verdict: Runtime Error):
A, B = map(int.input().split())
if (0<=A<=9) and (0<=B<=9):
  print(A*B)
else:
  print(-1)

Fixed submission:
A, B = map(int,input().split())
if (0<=A<=9) and (0<=B<=9):
  print(A*B)
else:
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
data = int(stdin.readline().rstrip())

list = []
for x in range(1,10**2):
    for y in range(1, 10**2):
        for z in range(1, 10**2):
            list.append(x**2+y**2+z**2+x*y+y*z+z*x)

for i in range(1,data+1):
    print(list.count(i))

Fixed submission:
from sys import stdin
data = int(stdin.readline().rstrip())

list = [0]*10000
for x in range(1,10**2):
    for y in range(1, 10**2):
        for z in range(1, 10**2):
            a = x**2+y**2+z**2+x*y+y*z+z*x
            if a <= 10**4:
                list[a-1] += 1

for i in range(1,data+1):
    print(list[i-1])
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
data = stdin.readline().rstrip()

a = int(data)

def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n
    #
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff
def divisor_num(n):
    a = 1
    for _, x in factorization(n):
        a *= x + 1
    return a

ans = 0
for i in range(1,a+1):
    ans += i*divisor_num(i)
print(ans)

Fixed submission:
from sys import stdin
data = stdin.readline().rstrip()

a = int(data)

ans = 0
for i in range(1,a+1):
    tmp = a//i
    ans += int(i * tmp * (tmp +1) / 2)
print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
n = int(stdin.readline().rstrip())

a = []
while n // 26 >= 1:
    if n%26 == 0:
        a.insert(0, 26)
        n = (n - 26) // 26
    else:
        a.insert(0, n%26)
        n = (n - n%26) // 26
if n >= 0:
    a.insert(0, n)

i = 1
while i <= len(a):
    t = a[i-1]
    if t == 1:
        a[i-1] = "a"
    elif t == 2:
        a[i-1] = "b"
    elif t == 3:
        a[i-1] = "c"
    elif t == 4:
        a[i-1] = "d"
    elif t == 5:
        a[i-1] = "e"
    elif t == 6:
        a[i-1] = "f"
    elif t == 7:
        a[i-1] = "g"
    elif t == 8:
        a[i-1] = "h"
    elif t == 9:
        a[i-1] = "i"
    elif t == 10:
        a[i-1] = "j"
    elif t == 11:
        a[i-1] = "k"
    elif t == 12:
        a[i-1] = "l"
    elif t == 13:
        a[i-1] = "m"
    elif t == 14:
        a[i-1] = "n"
    elif t == 15:
        a[i-1] = "o"
    elif t == 16:
        a[i-1] = "p"
    elif t == 17:
        a[i-1] = "q"
    elif t == 18:
        a[i-1] = "r"
    elif t == 19:
        a[i-1] = "s"
    elif t == 20:
        a[i-1] = "t"
    elif t == 21:
        a[i-1] = "u"
    elif t == 22:
        a[i-1] = "v"
    elif t == 23:
        a[i-1] = "w"
    elif t == 24:
        a[i-1] = "x"
    elif t == 25:
        a[i-1] = "y"
    elif t == 26:
        a[i-1] = "z"
    i += 1


print(''.join(a))

Fixed submission:
from sys import stdin
n = int(stdin.readline().rstrip())

a = []
while n // 26 >= 1:
    if n%26 == 0:
        a.insert(0, 26)
        n = (n - 26) // 26
    else:
        a.insert(0, n%26)
        n = (n - n%26) // 26
if n > 0:
    a.insert(0, n)

i = 1
while i <= len(a):
    t = a[i-1]
    if t == 1:
        a[i-1] = "a"
    elif t == 2:
        a[i-1] = "b"
    elif t == 3:
        a[i-1] = "c"
    elif t == 4:
        a[i-1] = "d"
    elif t == 5:
        a[i-1] = "e"
    elif t == 6:
        a[i-1] = "f"
    elif t == 7:
        a[i-1] = "g"
    elif t == 8:
        a[i-1] = "h"
    elif t == 9:
        a[i-1] = "i"
    elif t == 10:
        a[i-1] = "j"
    elif t == 11:
        a[i-1] = "k"
    elif t == 12:
        a[i-1] = "l"
    elif t == 13:
        a[i-1] = "m"
    elif t == 14:
        a[i-1] = "n"
    elif t == 15:
        a[i-1] = "o"
    elif t == 16:
        a[i-1] = "p"
    elif t == 17:
        a[i-1] = "q"
    elif t == 18:
        a[i-1] = "r"
    elif t == 19:
        a[i-1] = "s"
    elif t == 20:
        a[i-1] = "t"
    elif t == 21:
        a[i-1] = "u"
    elif t == 22:
        a[i-1] = "v"
    elif t == 23:
        a[i-1] = "w"
    elif t == 24:
        a[i-1] = "x"
    elif t == 25:
        a[i-1] = "y"
    elif t == 26:
        a[i-1] = "z"
    i += 1

print(''.join(a))
Buggy python submission (verdict: Runtime Error):
"""
input.txt

2
1 2
3
1 100
2 100
100 1000

"""

from sys import stdin
data = stdin.readlines()

n = int(data[0])
a = [int(s) for s in data[1].split()]
q = int(data[2])

i = 1
l = []
while i <= q:
    l.append(int(data[i+2].split()[0]))
    l.append(int(data[i+2].split()[1]))
    i += 1

dic = {}
for s in range(1,10**5):
    tmp = {s: a.count(s)}
    dic.update(tmp)

s = sum(a)
i = 1
while i <= q:
    s = s + (l[2*i-1]-l[2*i-2]) * dic[l[2*i-2]]
    print(s)
    dic[l[2*i-1]] += dic[l[2*i-2]]
    dic[l[2*i-2]] = 0
    i += 1


Fixed submission:
import collections
from sys import stdin
data = stdin.readlines()

n = int(data[0].split()[0])
a = [int(s) for s in data[1].split()]
q = int(data[2].split()[0])

sum = sum(a)

l = []
for i in range(q):
    l.append(int(data[i+3].split()[0]))
    l.append(int(data[i+3].split()[1]))

d = collections.Counter(a)

for i in range(q):
    sum += (l[2*i+1]-l[2*i]) * d[l[2*i]]
    d[l[2*i+1]] += d[l[2*i]]
    d[l[2*i]] = 0
    print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
data = stdin.readlines()

n = int(data[0])
a = [int(s) for s in data[1].split()]
q = int(data[2])

i = 1
l = []
while i <= q:
    l.append(int(data[i+2].split()[0]))
    l.append(int(data[i+2].split()[1]))
    i += 1

i = 0
while i <= q-1:
    m = 0
    while m <= n-1:
        if a[m] ==  l[2*i]:
            a[m] = l[2*i+1]
        m += 1
    print(sum(a))
    i += 1

Fixed submission:
import collections
from sys import stdin
data = stdin.readlines()

n = int(data[0].split()[0])
a = [int(s) for s in data[1].split()]
q = int(data[2].split()[0])

sum = sum(a)

l = []
for i in range(q):
    l.append(int(data[i+3].split()[0]))
    l.append(int(data[i+3].split()[1]))

d = collections.Counter(a)

for i in range(q):
    sum += (l[2*i+1]-l[2*i]) * d[l[2*i]]
    d[l[2*i+1]] += d[l[2*i]]
    d[l[2*i]] = 0
    print(sum)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
data = stdin.readlines()

n = int(data[0].split()[0])
a = [int(s) for s in data[1].split()]
a = sorted(a)

max = a[-1]

l = [0]*(max+1)

for i in a:
    l[i] += 1
    if l[i] == 1:
        for j in range(i*2,max+1,i):
            l[j] = 2
print(l.count(1))

Fixed submission:
from sys import stdin
data = stdin.readline().rstrip()


b = [int(s) for s in data.split()]
print(b.index(0)+1)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
data = stdin.readlines()

x = int(data[0].split()[0])
a = [int(s) for s in data[1].split()]
a = sorted(a, reverse = True)

counter = 0
for i in range(len(a)):
    for j in range(len(a)):
        if i != j and a[i] % a[j] == 0:
            break
    else:
        counter += 1
print(counter)

Fixed submission:
from sys import stdin
data = stdin.readlines()

n = int(data[0].split()[0])
a = [int(s) for s in data[1].split()]
a = sorted(a)

max = a[-1]

l = [0]*(max+1)

for i in a:
    l[i] += 1
    if l[i] == 1:
        for j in range(i*2,max+1,i):
            l[j] = 2
print(l.count(1))
Buggy python submission (verdict: Runtime Error):
from sys import stdin
data = stdin.readlines()

a = int(data[0])
b = [int(s) for s in data[1].split()]

i = 0
ans = 1
while i <= a-1:
    ans = ans * b[i]
    i += 1
if ans > 10 ** 18:
    ans = -1

print(ans)

Fixed submission:
from sys import stdin
data = stdin.readline().rstrip()

a = int(data.split()[0])
b = int(data.split()[1])

print(a * b)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
data = stdin.readlines()

a = int(data[0])
b = [int(s) for s in data[1].split()]

ans = 1
for i in range(0,a):
    ans = ans * b[i]
if ans > 10 ** 18:
    ans = -1

print(ans)

Fixed submission:
from sys import stdin
data = stdin.readlines()

a = int(data[0])
b = [int(s) for s in data[1].split()]

if 0 in b:
    print(0)
else:
    ans = 1
    for i in range(0,a):
        ans = ans * b[i]
        if ans > 10**18:
            print(-1)
            break
        else:
            continue
    else:
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
data = stdin.readlines()

a = int(data[0])
b = [int(s) for s in data[1].split()]

i = 0
ans = 1
while i <= a-1:
    ans = ans * b[i]
    i += 1
if ans > 10 ** 18:
    ans = -1

print(ans)

Fixed submission:
from sys import stdin
data = stdin.readlines()

a = int(data[0])
b = [int(s) for s in data[1].split()]

if 0 in b:
    print(0)
else:
    ans = 1
    for i in range(0,a):
        ans = ans * b[i]
        if ans > 10**18:
            print(-1)
            break
        else:
            continue
    else:
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
data = stdin.readlines()

n = int(data[0].split()[0])

l = []
for i in range(n):
    if not data[i+1].split()[0] in l:
        l.append(data[i+1].split()[0])
print(len(l))

Fixed submission:
from sys import stdin
data = stdin.readlines()

n = int(data[0].split()[0])

l = []
for i in range(n):
    l.append(data[i+1].split()[0])
print(len(set(l)))
Buggy python submission (verdict: Time Limit Exceeded):
def main():    
    t =  int(input())
    n = 1
    a = list(map(int,input().strip().split()))[:t]
    for i in range(t):
        n*=a[i]
    if n>1e18:
        print(-1)
    else:
        print(n)
        
if __name__ == '__main__':
    main()

Fixed submission:
def main():    
    t =  int(input())
    n = 1
    a = list(map(int,input().strip().split()))[:t]
    for i in range(t):
        if a[i]==0:
            return 0
    for i in range(t):
        n*=a[i]
        if n>1e18:
            return -1
    if n>1e18:
        return -1
    else:
        return n
        
if __name__ == '__main__':
    print(main())
Buggy python submission (verdict: Runtime Error):
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
for i in range(1,N):
  A[i]+=A[i-1]
for i in range(1,M):
  B[i]+=B[i-1]

j,best=0,0
for j in range(M):
  if B[j] > K: break
  else:best=j+1
j＝0
for i in range(N):
  if A[i] > K: break
  while j < M:
    if A[i]+B[j] > K: break
    else: j+=1
  best=max(best,i+1+j)
print(best)





Fixed submission:
N,M,K=map(int,input().split())
A=[0]+list(map(int,input().split()))
B=[0]+list(map(int,input().split()))
for i in range(1,N+1):
  A[i]+=A[i-1]
for i in range(1,M+1):
  B[i]+=B[i-1]

best=0
j=M
for i in range(0,N+1):
  while j>0:
    if A[i]+B[j]<=K:
      break
    else: j-=1
  if A[i]+B[j]<=K:
    best=max(best,i+j)
  pass
print(best)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
def calcXor(nums):
  x=0
  for n in nums:
    x=x^n
  return x

N=int(input())
A=list(map(int,input().split()))
ans=deque()
for i in range(N):
  #print(A[0:i])
  x=calcXor(A[0:i])
  #print(A[i+1:N])
  y=calcXor(A[i+1:N])
  ans.append(x^y)
print(" ".join(map(str,ans)))



Fixed submission:
from collections import deque
def calcXor(nums):
  x=0
  for n in nums:
    x=x^n
  return x

N=int(input())
A=list(map(int,input().split()))
A_xor=calcXor(A)

ans=deque()
for a in A:
  ans.append(A_xor^a) 

#for i in range(N):  
  #print(A[0:i])
  #x=calcXor(A[0:i])
  #print(A[i+1:N])
  #y=calcXor(A[i+1:N])
  #ans.append(x^y)
print(" ".join(map(str,ans)))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
ans=1
for a in A:
  ans*=a
if ans > 10**18:
  ans=-1
print(ans)

Fixed submission:
def main():
  N=int(input())
  A=list(map(int,input().split()))
  A.sort(reverse=True)
  ans=1
  if A[-1]!=0:
    for a in A:
      ans*=a
      if ans > 10**18:
        ans=-1
        break
  else:ans=0
  print(ans)
if __name__ == '__main__':
  main()
Buggy python submission (verdict: Runtime Error):
def function(arg1, arg2):
    N,K = map(int, arg1.split())
    teleportes = list(map(int, arg2.split()))
    checked = [0] * len(teleportes) # 訪れた街にチェック

    i = 0
    c = 1
    while True :
        nextTerminal = teleportes[i] - 1
        if checked[i] == 0:
            checked[i] = c # 何番目に訪れたか
            i = nextTerminal
            c += 1
        else:
            loops = c - checked[i] # 以前訪れてから何回旅したか
            
            break
    
    if K <= i:
        goal = teleportes[K]
    else:
        k = 0
        nextTerminal = 0
        while k in range((K-i)%loops + i):
            nextTerminal = teleportes[nextTerminal] - 1
            goal = nextTerminal + 1
            k+=1
    return str(goal)

if __name__ == '__main__':
    print(function(input(),input()))


Fixed submission:
def function():
    _N,K = map(int, input().split())
    teleportes = list(map(int, input().split()))

    # ループを見つける
    i,count = 0,0
    visited = [-1] * len(teleportes) # 訪れた街にチェック
    while True :
        if visited[i] == -1: # 最初に訪れた
            visited[i] = count # 何番目に訪れたかを記録
            i = teleportes[i] - 1
            count += 1
        else:
            loops = count - visited[i] # 以前訪れてから何回旅したか
            break
    
    if K <= visited[i]:
        i = 0
    else:
        K -= visited[i]
        K %= loops
    for _k in range(K):
        i = teleportes[i] - 1
    print(i+1)

if __name__ == '__main__':
    function()
Buggy python submission (verdict: Runtime Error):
S,W=map(int,input().split())
if S <= W:
  print('unsafe')
else
  print('safe')

Fixed submission:
S,W=map(int,input().split())
if S <= W:
  print('unsafe')
else:
  print('safe')

Buggy python submission (verdict: Runtime Error):
S,W=map(int,input.split())
if S <= W:
  print('unsafe')
else
  print('safe')

Fixed submission:
S,W=map(int,input().split())
if S <= W:
  print('unsafe')
else:
  print('safe')
Buggy python submission (verdict: Time Limit Exceeded):
def function(S):
    S_num = int(S)
    digit = len(S)
    multiple = 2019
    
    # make mod 2019 for each digit
    # 12114 -> 100
    # 2114 -> 2109
    # 114 -> 114
    digitAmari = []
    num = S_num
    while digit >= 0:
        digitAmari.append(num % multiple)
        num = num % pow(10, digit-1)
        digit -= 1
    
    # find same mod.
    # 余りが等しい場合、その区間は2019で割り切れるはず。
    kukans = []
    for i in range(0, len(digitAmari)):
        for j in range(i+1, len(digitAmari)):
            if digitAmari[i] == digitAmari[j]:
                kukans.append([i,j])
    return str(len(kukans))

if __name__ == '__main__':
    print(function(input()))


Fixed submission:
def function(S):
    S = S[::-1]
    mods = [0]*2019 # mod 2019の余り0~2018の数
    mods[0] += 1 # 自身が割れる場合
    # MEMO : int(c) * 10^n % 2019 をまともに計算するとTLE
    # １つ前の桁のmodを利用する
    num = 0
    digit = 1
    for c in S:
        num = (int(c) * digit + num) % 2019
        digit = (digit * 10) % 2019
        mods[num] += 1
    
    result = 0
    for m in mods:
        result +=  m * (m-1) // 2

    return str(result)

if __name__ == '__main__':
    print(function(input()))
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
  amari = a % b
  if amari == 0:
    return b
  else:
    return gcd(b, amari)

K=int(input())
ans=0
for a in range(1,K+1):
  for b in range(1,K+1):
    ab=gcd(a,b)
    for c in range(1,K+1):
      ans += gcd(ab,c)
print(ans)

Fixed submission:
def gcd(a,b):
  amari = a % b
  if amari == 0:
    return b
  else:
    return gcd(b, amari)

K=int(input())
ans=0
for a in range(1,K+1):
  for b in range(1,K+1):
    ab=gcd(a,b)
    if ab == 1:
      ans += K
    else:
      for c in range(1,K+1):
        ans += gcd(ab,c)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
  amari = a % b
  if amari == 0:
    return b
  else:
    return gcd(b, amari)

K=int(input())
ans=0
for a in range(1,K+1):
  for b in range(1,K+1):
    ab=gcd(a,b)
    for c in range(1,K+1):
      ans += gcd(ab,c)
print(ans)

Fixed submission:
def gcd(a,b):
  amari = a % b
  if amari == 0:
    return b
  else:
    return gcd(b, amari)

K=int(input())
ans=0
for a in range(1,K+1):
  for b in range(1,K+1):
    ab=gcd(a,b)
    if ab == 1:
      ans += K
    else:
      for c in range(1,K+1):
        ans += gcd(ab,c)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
ans = 0
for i in range(0,N):
  for j in range(i+1,N):
    if S[i] != S[j]:
      for k in range(j+1,N):
        if S[i] != S[k] and S[j] != S[k]:
          if j-i != k-j:
            #print(i,j,k)
            ans += 1
print(ans)

Fixed submission:
N=int(input())
S=input()
ans = 0
for i in range(0,N):
  for j in range(i+1,N):
    if S[i] != S[j]:
      k = j+j-i
      if k < N:
        if S[i] != S[k] and S[j] != S[k]:
          #print(i,j,k)
          ans += 1
ans = (S.count('R') * S.count('G') * S.count('B')) - ans
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def isLunLun(num):
  pre = num%10
  while num != 0:
    num, mod = divmod(num, 10)
    if abs(mod-pre) > 1:
      return False
    pre = mod
  return True

K=int(input())
k=0
num = 1
latestLunLun = 0
while k != K:
  if isLunLun(num):
    k+=1
    latestLunLun = num
  num+=1
print(latestLunLun)

Fixed submission:

def makeLunLun(num):
  lunlunNums = []
  m = num % 10 -1
  z = m + 1
  p = m + 2
  if m >= 0:
    lunlunNums.append(num * 10 + m)
  lunlunNums.append(num * 10 + z)
  if p <= 9:
    lunlunNums.append(num * 10 + p)
  return lunlunNums

K=int(input())

queue = [1,2,3,4,5,6,7,8,9]
i=0
while K > len(queue):
  lunluns = makeLunLun(queue[i])
  queue += lunluns
  i += 1
print(queue[K-1])
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
div,mod=divmod(h*w)
print(div+mod)

Fixed submission:
h,w=map(int,input().split())
if h == 1 or w == 1:
  print(1)
else:
  div,mod=divmod(h*w,2)
  print(div+mod)
Buggy python submission (verdict: Time Limit Exceeded):
X=int(input())
ps=[2]
x=2
while ps[-1]<X:
  f=True
  for p in ps:
    if x%p==0:
      f=False
      break
  if f:ps.append(x)
  x+=1
print(ps[-1])


Fixed submission:
def is_prime(p):
  if p>1:
    for i in range(2,p):
      if p%i==0:return True
  return False

X=int(input())
p=X
while is_prime(p) != False:p+=1
print(p)

Buggy python submission (verdict: Runtime Error):
X=int(input())
ps=[]
x=2
while x=<X:
  f=True
  for p in ps:
    if x%p==0:
      f=False
      break
  if f:ps.append(x)
  x+=1
print(x)

Fixed submission:
def is_prime(p):
  if p>1:
    for i in range(2,p):
      if p%i==0:return True
  return False

X=int(input())
p=X
while is_prime(p) != False:p+=1
print(p)
Buggy python submission (verdict: Time Limit Exceeded):
_N=input()
A=list(map(int,input().split()))
B=[i for i in range(1,len(A)+1)]
reverse_ans=[]
while len(A)!=0:
  max_a,max_i=0,0
  for i in range(0,len(A)):
    if max_a < A[i]:
      max_a = A[i]
      max_i = i
  A.pop(max_i)
  reverse_ans.append(B.pop(max_i))
reverse_ans.reverse()
print(' '.join(map(str,reverse_ans)))



Fixed submission:
_N=input()
A=list(map(int,input().split()))
B=[0]*len(A)
for i in range(0,len(A)):
  B[A[i]-1]=i+1
print(' '.join(map(str,B)))
Buggy python submission (verdict: Runtime Error):
n=int(input())
p=list(map(int,input()))
ans=0
for i in range(1,n-1):
  pre=p[i-1]
  cur=p[i]
  nex=p[i+1]
  if (pre<cur and cur<nex) or(pre>cur and cur>nex):
    ans+=1
print(ans)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
  pre=p[i-1]
  cur=p[i]
  nex=p[i+1]
  if (pre<cur and cur<nex) or(pre>cur and cur>nex):
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
def main():
  n=int(input())
  dp=[[0,0,0]]
  for i in range(1,n+1):
    a,b,c=map(int,input().split())
    dp.append([
      dp[i-1][0]+max(b,c),
      dp[i-1][1]+max(a,c),
      dp[i-1][2]+max(a,b)
    ]
  print(max(dp[n]))

Fixed submission:
N=int(input())
h=list(map(int,input().split()))
DP=[0]*N
DP[0]=0
DP[1]=abs(h[1]-h[0])+DP[0]
i=2
while i<N:
  DP[i]=min(abs(h[i]-h[i-1])+DP[i-1],abs(h[i]-h[i-2])+DP[i-2])
  i+=1
print(DP[-1])
Buggy python submission (verdict: Runtime Error):
def main():
  n=int(input())
  dp=[[0,0,0]]
  for i in range(1,n+1):
    a,b,c=map(int,input().split())
    dp.append([
      dp[i-1][0]+max(b,c),
      dp[i-1][1]+max(a,c),
      dp[i-1][2]+max(a,b)
    ]
  print(max(dp[n]))


Fixed submission:
def main():
  n=int(input())
  dp=[[0,0,0]]
  for i in range(1,n+1):
    a,b,c=map(int,input().split())
    dp.append([max(dp[i-1][1],dp[i-1][2])+a,max(dp[i-1][0],dp[i-1][2])+b,max(dp[i-1][0],dp[i-1][1])+c])
    #print(dp)
  print(max(dp[n]))
if __name__=='__main__':
  main()