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

sum = 0
for i in range(N):
    sum += b[a[i]]
    if((i < N-1) and (a[i+1] == (a[i] + 1))):
        sum += c[a[i]]

print(sum)


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

sum = 0
for i in range(n):
    sum += b[a[i]-1]
    if((i < n-1) and (a[i] < n) and (a[i+1] == a[i] + 1)):
        sum += c[a[i]-1]

print(sum)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input())
print(max(a+b, a-b, a*b))

Fixed submission:
a, b = map(int, input().split())
print(max(a+b, a-b, a*b))
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))

def dp(n):
    if n == 0:
        return 0
    if n == 1:
        return abs(h[1] - h[0])
    return min(dp(n-1) + abs(h[n] - h[n-1]), dp(n-2) + abs(h[n] - h[n-2]))

print(dp(n-1))

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

dp = [float('inf')] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, N):
    dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1], abs(h[i] - h[i-2]) + dp[i-2])

print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
childs = [[] for _ in range(N)]
for i in range(M):
    p, c = map(int, input().split())
    childs[p-1].append(c)

stack = list(range(1, N+1))
# dp[n]: nに到達する最長のパス
dp = [0] * N
while stack:
    n = stack.pop()
    for nc in childs[n-1]:
        if dp[nc-1] < dp[n-1] + 1:
            stack.append(nc)
            dp[nc-1] = dp[n-1] + 1

print(max(dp))


Fixed submission:
import sys
sys.setrecursionlimit(100000)

N, M = map(int, input().split())
childs = [[] for _ in range(N)]
for i in range(M):
    p, c = map(int, input().split())
    childs[p-1].append(c-1)

depth = [-1] * N
def dfs(n):
    if depth[n] != -1:
        return depth[n]
    if childs[n]:
        depth[n] = max((dfs(nc) for nc in childs[n])) + 1
    else:
        depth[n] = 0
    return depth[n]

print(max((dfs(n) for n in range(N))))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
edges = [[0, 0] for _ in range(M)]
for i in range(M):
    edges[i][0], edges[i][1] = map(int, input().split())

stack = list(range(1, N+1))
# dp[n]: nに到達する最長のパス
dp = [0] * N
while stack:
    n = stack.pop()
    childs = [edge[1] for edge in edges if edge[0] == n]
    for nc in childs:
        if dp[nc-1] < dp[n-1] + 1:
            stack.append(nc)
            dp[nc-1] = dp[n-1] + 1

print(max(dp))


Fixed submission:
import sys
sys.setrecursionlimit(100000)

N, M = map(int, input().split())
childs = [[] for _ in range(N)]
for i in range(M):
    p, c = map(int, input().split())
    childs[p-1].append(c-1)

depth = [-1] * N
def dfs(n):
    if depth[n] != -1:
        return depth[n]
    if childs[n]:
        depth[n] = max((dfs(nc) for nc in childs[n])) + 1
    else:
        depth[n] = 0
    return depth[n]

print(max((dfs(n) for n in range(N))))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
edges = [[0, 0] for _ in range(M)]
for i in range(M):
    edges[i][0], edges[i][1] = map(int, input().split())

stack = list(range(1, N+1))
# dp[n]: nに到達する最長のパス
dp = [0] * N
while stack:
    n = stack.pop()
    childs = [edge[1] for edge in edges if edge[0] == n]
    for nc in childs:
        stack.append(nc)
        if dp[nc-1] < dp[n-1] + 1:
            dp[nc-1] = dp[n-1] + 1

print(max(dp))


Fixed submission:
import sys
sys.setrecursionlimit(100000)

N, M = map(int, input().split())
childs = [[] for _ in range(N)]
for i in range(M):
    p, c = map(int, input().split())
    childs[p-1].append(c-1)

depth = [-1] * N
def dfs(n):
    if depth[n] != -1:
        return depth[n]
    if childs[n]:
        depth[n] = max((dfs(nc) for nc in childs[n])) + 1
    else:
        depth[n] = 0
    return depth[n]

print(max((dfs(n) for n in range(N))))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a, b = input().split()
pirnt("{}{}".format(b,a))


Fixed submission:
# -*- coding: utf-8 -*-
a, b = input().split()
print("{}{}".format(b,a))

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a, b = input().split()
pirnt("{}{}".format(b,a))


Fixed submission:
# -*- coding: utf-8 -*-
a, b = input().split()
print("{}{}".format(b,a))
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, D = map(int, input().split())
cnt = 0
for i in range(A, B+1):
    if i%C != 0 and i%D != 0:
        cnt += 1

print(cnt)

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

def lcm(a,b):
    return (a*b) // gcd(a,b)

A, B, C, D = map(int, input().split())

a1 = -(-A // C)
a2 = -(-A // D)
a3 = -(-A // lcm(C,D))

b1 = B // C
b2 = B // D
b3 = B // (lcm(C,D))

ans = (B-A+1) - ((b1-a1+1) + (b2-a2+1) - (b3-a3+1))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
i = int(input())

count = 0;

for j  in range(i+1):
    lst = []
    while j > 0:
        lst.append(j%10)
        j //= 10 # 必須
    lst.reverse()
    
    flag3 = 3 in lst
    flag5 = 5 in lst
    flag7 = 7 in lst
    
    flag0 = 0 in lst
    flag1 = 1 in lst
    flag2 = 2 in lst
    flag4 = 4 in lst
    flag6 = 6 in lst
    flag8 = 8 in lst
    flag9 = 9 in lst

    if not flag0 and not flag1 and not flag2 and not flag4 and not flag6 and not flag8 and not flag9 :
        if flag3 and flag5 and flag7 :
            count = count + 1
            
print(count)

Fixed submission:
N = int(input())
ans = 0

def f(target):
    for i in '753':
        targetJoin = str(target) + str(i)
        
        if int(targetJoin) > N:
            continue

        if  '7' in targetJoin and '5' in targetJoin and '3' in targetJoin :
            
            flag = True
            if '0' in targetJoin:
                flag = False
            if '1' in targetJoin:
                flag = False
            if '2' in targetJoin:
                flag = False
            if '4' in targetJoin:
                flag = False
            if '6' in targetJoin:
                flag = False
            if '8' in targetJoin:
                flag = False
            if '9' in targetJoin:
                flag = False
            
            if flag :
                global ans
                ans+=1
                
        f(targetJoin)
        
f(3)
f(5)
f(7)
print(ans)
Buggy python submission (verdict: Runtime Error):
from sympy import nextprime
print(nextprime(int(input())-1))


Fixed submission:
def prime(n):
    for i in range(2, n):
        if n%i == 0: break
    else: return True
    return False

n = int(input())
while not prime(n): n += 1
else: print(n)
Buggy python submission (verdict: Runtime Error):
s,t = input.split()
print(t,s,sep='')

Fixed submission:
s,t = input().split()
print(t, s, sep='')
Buggy python submission (verdict: Runtime Error):
n,k = (int(w) for w in input().split()[:2])
r,s,p = (int(w) for w in input().split()[:3])
t = input()

h = {'r': 'p', 's': 'r', 'p': 's'}
score = {'r': r, 's': s 'p': p}

x = sum(score[h[t[i]]] for i in range(k))

x += sum(score[h[c]] for c,cp in zip(t[k:], t) if c!=cp)

print(x)


Fixed submission:
n,k = (int(w) for w in input().split()[:2])
r,s,p = (int(w) for w in input().split()[:3])
t = input()

h = {'r': 'p', 's': 'r', 'p': 's'}
score = {'r': r, 's': s, 'p': p, 'e': 0}

z = [h[c] for c in t]
for i in range(k, n):
    if z[i]==z[i-k]: z[i] = 'e'

x = sum(score[v] for v in z)

print(x)
Buggy python submission (verdict: Runtime Error):
S, T = input()
print(S + T)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
S,T = read().decode('utf-8').split()
 
answer = T + S
print(answer)

Buggy python submission (verdict: Runtime Error):
S, T = input()
txt = S + T
print(txt)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
S,T = read().decode('utf-8').split()
 
answer = T + S
print(answer)

Buggy python submission (verdict: Runtime Error):
S = input().split()
T = input().split()
print(S + T)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
S,T = read().decode('utf-8').split()
 
answer = T + S
print(answer)

Buggy python submission (verdict: Runtime Error):
S = input().split()
T = input().split()
txt = S + T
print(txt)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
S,T = read().decode('utf-8').split()
 
answer = T + S
print(answer)

Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
print(S + T)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
S,T = read().decode('utf-8').split()
 
answer = T + S
print(answer)

Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
txt = S + T
print(txt)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
S,T = read().decode('utf-8').split()
 
answer = T + S
print(answer)

Buggy python submission (verdict: Runtime Error):
S = input("文字列Sを入力")
T = input("文字列Tを入力")
txt = S + T
print(txt)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
S,T = read().decode('utf-8').split()
 
answer = T + S
print(answer)

Buggy python submission (verdict: Runtime Error):
moji_s=input("文字列Sを入力:")
moji_t=input("文字列Tを入力:")
print(moji_s + moji_t)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
S,T = read().decode('utf-8').split()
 
answer = T + S
print(answer)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
#A,Bは1,2,3のいずれか
#AとBは異なる
print(6-a-b)

    
  
  	

Fixed submission:
a = int(input())
b = int(input())
print(6-a-b)
Buggy python submission (verdict: Runtime Error):
print("".join(reverse(input("").split(" "))))

Fixed submission:
print("".join(reversed(input("").split(" "))))
Buggy python submission (verdict: Runtime Error):
def nextprime(x):
    if pow(2, x-1, x) != 1:
        return nextprime(x+1)
    for i in range(2, i*i):
        if x % i == 0:
            return nextprime(x+1)
    return x


x = int(input())

if x == 2:
    print("2")
else:
    print(nextprime(x))


Fixed submission:
def nextprime(x):
    if pow(2, x-1, x) != 1:
        return nextprime(x+1)
    for i in range(2, x):
        if x % i == 0:
            return nextprime(x+1)
    return x


x = int(input())

if x == 2:
    print("2")
else:
    print(nextprime(x))
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
n, m = map(int, input().split())
jobs = [[int(x) for x in input().split()] for _ in range(n)]
jobs = sorted(jobs, key=lambda x:x[0], reverse=True)
ans = 0
q = []

for i in range(m+1):
    tmp = reversed(jobs[:])
    for job in tmp:
        if job[0] <= i:
            heapq.heappush(q, -jobs.pop()[1])
        else:
            break
    if q:
        ans += -heapq.heappop(q)
print(ans)


Fixed submission:
import heapq
n, m = map(int, input().split())
jobs = [[int(x) for x in input().split()] for _ in range(n)]
jobs = sorted(jobs, key=lambda x:x[0], reverse=True)
r_jobs = list(reversed(jobs[:]))
ans = 0
q = []
cnt = 0
l = len(jobs)
for i in range(m+1):
    while cnt < l:
        if r_jobs[cnt][0] == i:
            heapq.heappush(q, -jobs.pop()[1])
            cnt += 1
        else:
            break

    if q:
        ans += -heapq.heappop(q)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
n, m = map(int, input().split())
jobs = [[int(x) for x in input().split()] for _ in range(n)]
jobs = sorted(jobs, key=lambda x:x[0], reverse=True)
ans = 0
q = []
l = len(jobs)
for i in range(m+1):
    tmp = jobs[:]
    for j in range(1, l+1):
        job = tmp[-j]
        if job[0] <= i:
            heapq.heappush(q, -jobs.pop()[1])
            l -= 1
        else:
            break
    if len(q) > 0:
        ans += -heapq.heappop(q)
print(ans)


Fixed submission:
import heapq
n, m = map(int, input().split())
jobs = [[int(x) for x in input().split()] for _ in range(n)]
jobs = sorted(jobs, key=lambda x:x[0], reverse=True)
r_jobs = list(reversed(jobs[:]))
ans = 0
q = []
cnt = 0
l = len(jobs)
for i in range(m+1):
    while cnt < l:
        if r_jobs[cnt][0] == i:
            heapq.heappush(q, -jobs.pop()[1])
            cnt += 1
        else:
            break

    if q:
        ans += -heapq.heappop(q)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
n, m = map(int, input().split())
jobs = [[int(x) for x in input().split()] for _ in range(n)]
jobs = sorted(jobs, key=lambda x:x[0], reverse=True)
ans = 0
q = []

for i in range(m+1):
    tmp = reversed(jobs[:])
    for job in tmp:
        if job[0] <= i:
            heapq.heappush(q, -jobs.pop()[1])
        else:
            break
    if len(q) > 0:
        ans += -heapq.heappop(q)
print(ans)


Fixed submission:
import heapq
n, m = map(int, input().split())
jobs = [[int(x) for x in input().split()] for _ in range(n)]
jobs = sorted(jobs, key=lambda x:x[0], reverse=True)
r_jobs = list(reversed(jobs[:]))
ans = 0
q = []
cnt = 0
l = len(jobs)
for i in range(m+1):
    while cnt < l:
        if r_jobs[cnt][0] == i:
            heapq.heappush(q, -jobs.pop()[1])
            cnt += 1
        else:
            break

    if q:
        ans += -heapq.heappop(q)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
a = list(map(int, input().split()))
A = []
for i in range(n):
    c = [0] * n
    if i != n-1:
        c[i], c[i+1] = 0.5, 0.5
    else:
        c[0], c[n-1] = 0.5, 0.5
    A.append(c)

A = np.array(A)
b = np.array(a)
ans = list(np.linalg.solve(A, b))
ans = map(int, ans)
ans = map(str, ans)
print(" ".join(ans))


Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
s = sum(a)
ans = [0] * n
even_a = 0
for i in a[1::2]:
    even_a += i
ans[0] = s - 2 * even_a
for i in range(1, n):
    ans[i] = 2 * a[i-1] - ans[i-1]
print(" ".join(map(str, ans)))

Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = list(map(int, input().split()))
A = []
for i in range(n):
    c = [0] * n
    if i != n-1:
        c[i], c[i+1] = 0.5, 0.5
    else:
        c[0], c[n-1] = 0.5, 0.5
    A.append(c)

A = np.array(A)
b = np.array(a)
ans = list(np.linalg.solve(A, b))
ans = map(int, ans)
ans = map(str, ans)
print(" ".join(ans))


Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
s = sum(a)
ans = [0] * n
even_a = 0
for i in a[1::2]:
    even_a += i
ans[0] = s - 2 * even_a
for i in range(1, n):
    ans[i] = 2 * a[i-1] - ans[i-1]
print(" ".join(map(str, ans)))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
a = list(map(int, input().split()))
A = []
for i in range(n):
    c = [0] * n
    if i != n-1:
        c[i], c[i+1] = 1/2, 1/2
    else:
        c[0], c[n-1] = 1/2, 1/2
    A.append(c)

A = np.array(A)
b = np.array(a)
ans = list(np.linalg.solve(A, b))
ans = map(int, ans)
ans = map(str, ans)
print(" ".join(ans))

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
s = sum(a)
ans = [0] * n
even_a = 0
for i in a[1::2]:
    even_a += i
ans[0] = s - 2 * even_a
for i in range(1, n):
    ans[i] = 2 * a[i-1] - ans[i-1]
print(" ".join(map(str, ans)))
Buggy python submission (verdict: Runtime Error):
n, m = (int(x) for x in input().split())
a = [0] * m
for i in range(m):
    a[i] = int(input())

dp = [0] * (n + 1)
mod = 1000000007
dp[0] = 1
j = 0
for i in range(1, n+1):
    if i == a[j]:
        dp[i] = 0
        if j != m - 1:
            j += 1
    elif i >= 2:
        dp[i] = (dp[i-1] + dp[i-2]) % mod
    else:
        dp[i] = dp[i-1] % mod

print(dp[n])

Fixed submission:
n, m = (int(x) for x in input().split())
a = [0] * m
for i in range(m):
    a[i] = int(input())
dp = [0] * (n + 1)
mod = 1000000007
dp[0] = 1
j = 0

if m > 0:
    for i in range(1, n + 1):
        if i == a[j]:
            dp[i] = 0
            if j != m - 1:
                j += 1
        elif i >= 2:
            dp[i] = (dp[i - 1] + dp[i - 2]) % mod
        else:
            dp[i] = dp[i - 1] % mod
else:
    for i in range(1, n + 1):
        if i >= 2:
            dp[i] = (dp[i - 1] + dp[i - 2]) % mod
        else:
            dp[i] = dp[i - 1] % mod
print(dp[n])
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = list(input())
cusum = [0] * n
c = 0
lr = [[int(x) for x in input().split()] for _ in range(q)]
for j in range(q):
    for i in range(n-1):
        cusum[i] = c
        if s[i:i+2] == ["A", "C"]:
            c += 1
            cusum[i+1] = c
    cusum[n-1] = c
    l, r = lr[j]
    print(cusum[r-1] - cusum[l-1])
    cusum = [0] * n
    c = 0


Fixed submission:
n, q = map(int, input().split())
s = list(input())
cusum = [0] * n
c = 0
lr = [[int(x) for x in input().split()] for _ in range(q)]
for i in range(n-1):
    cusum[i] = c
    if s[i:i+2] == ["A", "C"]:
        c += 1
        cusum[i+1] = c
cusum[n-1] = c

for j in range(q):
    l, r = lr[j]
    print(cusum[r-1] - cusum[l-1])
Buggy python submission (verdict: Runtime Error):
a, b, c, d = input()
o = "+-"
for i in range(2 ** 3):
    s = a + o[i & 1] + b + o[i & 2] + c + o[i & 4] + d
    if eval(s) == 7:
        print(s + "=7")
        break

Fixed submission:
a = [int(x) for x in list(input())]
op = 3
ops = [0] * op
for i in range(2 ** op):
    result = a[0]
    bry = list(format(i, "0{}b".format(op)))
    for index, value in enumerate(bry):
        if value == "1":
            result += a[index + 1]
            ops[index] = "+"
        else:
            result -= a[index + 1]
            ops[index] = "-"
    if result == 7:
        ans = str(a[0])
        for j in range(3):
            ans += "{}{}".format(ops[j], a[j+1])
        ans += "=7"
        print(ans)
        break
Buggy python submission (verdict: Runtime Error):

num = input()
num_array = [i for i in num]

splits = len(num) - 1
n = 2 ** splits

sum = 0

for i in range(n):
    bin = format(i, "0{}b".format(splits))
    bin_array = [i for i in bin]
    tmp_num = str(num_array[0])
    for index, value in enumerate(bin_array):
        if value == "0":
            tmp_num += num_array[index+1]
        else:
            sum += int(tmp_num)
            tmp_num = num_array[index+1]
    sum += int(tmp_num)

print(sum)

Fixed submission:

num = input()
num_array = [i for i in num]

splits = len(num) - 1
n = 2 ** splits

sum = 0

if splits > 0:
    for i in range(n):
        bin = format(i, "0{}b".format(splits))
        bin_array = [i for i in bin]
        tmp_num = str(num_array[0])
        for index, value in enumerate(bin_array):
            if value == "0":
                tmp_num += num_array[index+1]
            else:
                sum += int(tmp_num)
                tmp_num = num_array[index+1]
        sum += int(tmp_num)
else:
    sum = num

print(sum)
Buggy python submission (verdict: Runtime Error):
s=input("")
t=input("")
print(str(s)+str(t))


Fixed submission:
S,T=map(str,input().split(" "))
print(T+S)
Buggy python submission (verdict: Runtime Error):
#import numpy as np
#import csv
import sys
#import time

def main():
  argv = sys.argv
  print(argv[2]+argv[1])


if __name__  == "__main__":
  try:
    main() #main
  #error IO Error
  except IOError as error:
    print("No file.")

Fixed submission:
import sys

def main():
  ri=raw_input().split()
  if len(ri) > 0:
    print(str(ri[1]+ri[0]))


if __name__  == "__main__":
  try:
    main() #main
  #error IO Error
  except IOError as error:
    print("No file.")

Buggy python submission (verdict: Runtime Error):
if __name__=="__main__":
    s,t=input.split()
    print(t+s)

Fixed submission:
if __name__=="__main__":
    s,t=input().split()
    print(t+s)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
b=[]
c=[]
for i in range(n):
    s=input().split()
    A,B=int(s[0]),int(s[1])
    a.append(A)
    b.append(B)
    c.append(A+B)
print(n,a,b,c,d)
c.sort(reverse=True)
s1=0
s2=0
for i in range(n):
    s1+=a[i]
    if i%2:
        s2+=c[i]
print(s1-s2)

Fixed submission:
n=int(input())
a=[]
b=[]
c=[]
for i in range(n):
    s=input().split()
    A,B=int(s[0]),int(s[1])
    a.append(A)
    b.append(B)
    c.append(A+B)
c.sort(reverse=True)
s1=0
s2=0
for i in range(n):
    s1+=a[i]
    if i%2:
        s2+=c[i]
print(s1-s2)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
b=[]
c=[]
d=[]
for i in range(n):
    A,B=int(input().split()[0]),int(input().split()[1])
    a.append(A)
    b.append(B)
    c.append(A+B)
    d.append(i)
d.sort(key=lambda x:c[x],reverse='True')
s1=0
s2=0
for i in range(n):
    s1+=a[i]
    if i%2==0:
        s2+=c[d[i]]
print(s1-s2)

Fixed submission:
n=int(input())
a=[]
b=[]
c=[]
for i in range(n):
    s=input().split()
    A,B=int(s[0]),int(s[1])
    a.append(A)
    b.append(B)
    c.append(A+B)
c.sort(reverse=True)
s1=0
s2=0
for i in range(n):
    s1+=a[i]
    if i%2:
        s2+=c[i]
print(s1-s2)
Buggy python submission (verdict: Runtime Error):
s,t = input().split()
return t + s

Fixed submission:
s, t = input().split()
print(t + s)

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

prims = list()

prims.append(2)

base = int(input())

def _is_prim(n):
  global prims
  for p in prims:
    if n == p:
      return True
    elif n % p == 0:
      return False
  
  return True

# 入力値の平方根までの素数を作る
base_rt = int(math.sqrt(base))
for n in range(rt):
  if n < 2:
    continue
  elif n % 2 == 0:
    continue
  elif _is_prim(n):
    prims.append(n)

# 作った素数値で。。。
while not _is_prim(base):
  base += 1

print(base)   

Fixed submission:
stdin = input().split()
print(stdin[1] + stdin[0])
Buggy python submission (verdict: Time Limit Exceeded):
stdin = input().split()
a = int(stdin[0]) # 高橋君のクッキー
b = int(stdin[1]) # 青木君のクッキー
K = int(stdin[2]) # 繰り返し回数

for turn in range(K):
  if a > 0: # 高橋君のクッキーがあった
    a -= 1
  elif b > 0: # 青木君のがあった
    b -= 1


print('{} {}'.format(a, b))

Fixed submission:
stdin = input().split()
a = int(stdin[0]) # 高橋君のクッキー
b = int(stdin[1]) # 青木君のクッキー
k = int(stdin[2]) # 繰り返し回数

if a > k:
  a -= k
else:
  k -= a
  a = 0
  
  if k > b:
    b = 0
  else:
    b -= k
  
print('{} {}'.format(a, b))
Buggy python submission (verdict: Time Limit Exceeded):
prims = list()

prims.append(2)

base = int(input())

def _is_prim(n):
  global prims
  for p in prims:
    if n == p:
      return True
    elif n % p == 0:
      return False
  
  return True

# 入力値までの素数を作る
for n in range(base):
  if n < 2:
    continue
  elif n % 2 == 0:
    continue
  elif _is_prim(n):
    prims.append(n)

# 作った素数値で。。。
while not _is_prim(base):
  base += 1

print(base)    


Fixed submission:
import math

prims = list()

prims.append(2)

base = int(input())

def _is_prim(n):
  global prims
  for p in prims:
    if n == p:
      return True
    elif n % p == 0:
      return False
  
  return True

# 入力値の平方根までの素数を作る
rt = int(math.sqrt(base))
for n in range(rt):
  if n < 2:
    continue
  elif n % 2 == 0:
    continue
  elif _is_prim(n):
    prims.append(n)

# 作った素数値で。。。
while not _is_prim(base):
  base += 1

print(base)