Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

for i in range(1,3500+1):
    for j in range(1,3500+1):
        h = i
        n = j
        
        low = 1
        high = 3500
        
        if N*n+N*h-4*h*n == 0:
            continue
        if N*h*n % (N*n+N*h-4*h*n) == 0:
            w = -N*h*n // (N*n+N*h-4*h*n)
            if w > 0:
                print(h,n,w)
                exit()
        


Fixed submission:
N = int(input())

for i in range(1,3500+1):
    for j in range(1,3500+1):
        h = i
        n = j
        
        low = 1
        high = 3500
        
        if N*n+N*h-4*h*n == 0:
            continue
        if N*h*n % (N*n+N*h-4*h*n) == 0:
            w = -N*h*n // (N*n+N*h-4*h*n)
            if w > 0:
                print(h,n,w)
                exit()

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

for i in range(1,3500+1):
    for j in range(1,3500+1):
        h = i
        n = j
        
        low = 1
        high = 3500
        
        while low+1 < high:
            mid = (low + high) //2
            
            if 4*h*n*mid >= N*(n*mid+h*n+mid*h):
                high = mid
            else:
                low = mid
                
        if 4*h*n*high == N*(n*high+h*n+high*h):
            print(h,n,high)
            exit()
        


Fixed submission:
N = int(input())

for i in range(1,3500+1):
    for j in range(1,3500+1):
        h = i
        n = j
        
        low = 1
        high = 3500
        
        if N*n+N*h-4*h*n == 0:
            continue
        if N*h*n % (N*n+N*h-4*h*n) == 0:
            w = -N*h*n // (N*n+N*h-4*h*n)
            if w > 0:
                print(h,n,w)
                exit()
Buggy python submission (verdict: Runtime Error):
x,a,b = map(int.input().split())
if abs(x-a) > abs(x-b):
    print('B')
else:
    print('A')

Fixed submission:
x,a,b = map(int,input().split())
if abs(x-a) > abs(x-b):
    print('B')
else:
    print('A')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]

a.sort(reverse= True)

cnt = 0
top = []

for i in range(n):
    if len(top) == 2:
        break    
    for j in range(4):
        if a[i] == a[i+1+j]:
            if len(top) == 2:
                break
            if j == 1:
                top.append(a[i])
            elif j == 3:
                top.append(a[i])

if len(top) != 2:
    print(0)
    exit()

print(int(top[0]*top[1]))

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

a.sort(reverse= True)

cnt = 0
top = []

for i in range(n-1):
    #print(i)
    if len(top) == 2:
        break    
    if a[i] == a[i+1]:
        if len(top) == 2:
            break
        if cnt%2 == 0:
            top.append(a[i])
        cnt += 1
    else:
        cnt = 0

if len(top) < 2:
    print(0)
    exit()

print(int(top[0]*top[1]))
Buggy python submission (verdict: Runtime Error):
import fractions

n = int(input())
a = [int(input()) for i in range(n)]

ans = a[0] * a[1] // fractions.gcd(a[0],a[1])

for i in range(1,n-1):
    ans = ans * a[i+1] // fractions.gcd(ans,a[i+1])
    
print(ans)

Fixed submission:
import fractions

n = int(input())
a = [int(input()) for i in range(n)]

if len(a) == 1:
    print(a[0])
    exit()

ans = a[0] * a[1] // fractions.gcd(a[0],a[1])

for i in range(1,n-1):
    ans = ans * a[i+1] // fractions.gcd(ans,a[i+1])
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import queue
import sys
sys.setrecursionlimit(10**7)
n = int(input())

abc = [[] for i in range(n+1)]

for i in range(n-1):
    a,b,c = map(int,input().split())
    abc[a].append([b,c])
    abc[b].append([a,c])

Q,k = map(int,input().split())
xy = [[int(i) for i in input().split()] for j in range(Q)]

q = queue.Queue()

q.put(k)

path = [-1]*(n+1)
path[k] = 0

def dfs(p):
    for i in range(len(abc[p])):
        num = abc[p][i][0]
        if path[num] != -1:
            continue
        else:
            path[num] = path[p] + abc[p][i][1]
            dfs(num)

dfs(k)

for i in range(Q):
    print(path[xy[i][0]]+path[xy[i][1]])

Fixed submission:
import queue
n = int(input())

abc = [[] for i in range(n+1)]

for i in range(n-1):
    a,b,c = map(int,input().split())
    abc[a].append([b,c])
    abc[b].append([a,c])

Q,k = map(int,input().split())
xy = [[int(i) for i in input().split()] for j in range(Q)]

q = queue.Queue()

q.put(k)

path = [-1]*(n+1)
path[k] = 0

while not q.empty():
    tmp = q.get()
    for i in range(len(abc[tmp])):
        #print(abc[tmp])
        #exit()
        num = abc[tmp][i][0]
        if path[num] != -1:
            continue
        else:
            path[num] = path[tmp] + abc[tmp][i][1]
            q.put(num)
            
for i in range(Q):
    print(path[xy[i][0]]+path[xy[i][1]])
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n,m = map(int,input().split())

g = [[ ] for i in range(n+1)]

for i in range(m):
    a,b = map(int,input().split())
    if a == 1 or a == n or b == 1 or b == n:
        bisect.insort(g[a],b)
        bisect.insort(g[b],a)

    #print(bisect.bisect_left(g[a],b))
    #g[a][] = b
    #g[a].append(b)
    #g[b].append(a)

if len(g[n]) == 0:
    print('IMPOSSIBLE')
    exit()

for i in g[n]:
    if g[i][0] == 1:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

Fixed submission:
import bisect
n,m = map(int,input().split())

g = [[ ] for i in range(n+1)]

for i in range(m):
    a,b = map(int,input().split())
    if a == 1 or a == n or b == 1 or b == n:
        g[a].append(b)
        g[b].append(a)

    #print(bisect.bisect_left(g[a],b))
    #g[a][] = b
    #g[a].append(b)
    #g[b].append(a)

#g[4].sort()

#print(g[4])

if len(g[n]) == 0:
    print('IMPOSSIBLE')
    exit()

for i in g[n]:
    g[i].sort()
    if g[i][0] == 1:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n,m = map(int,input().split())

g = [[ ] for i in range(n+1)]

for i in range(m):
    a,b = map(int,input().split())
    bisect.insort(g[a],b)
    bisect.insort(g[b],a)
    #print(bisect.bisect_left(g[a],b))
    #g[a][] = b
    #g[a].append(b)
    #g[b].append(a)

if len(g[n]) == 0:
    print('IMPOSSIBLE')
    exit()

for i in g[n]:
    if g[i][0] == 1:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

Fixed submission:
import bisect
n,m = map(int,input().split())

g = [[ ] for i in range(n+1)]

for i in range(m):
    a,b = map(int,input().split())
    if a == 1 or a == n or b == 1 or b == n:
        g[a].append(b)
        g[b].append(a)

    #print(bisect.bisect_left(g[a],b))
    #g[a][] = b
    #g[a].append(b)
    #g[b].append(a)

#g[4].sort()

#print(g[4])

if len(g[n]) == 0:
    print('IMPOSSIBLE')
    exit()

for i in g[n]:
    g[i].sort()
    if g[i][0] == 1:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n,m = map(int,input().split())

g = [[ ] for i in range(n+1)]

for i in range(m):
    a,b = map(int,input().split())
    bisect.insort(g[a],b)
    bisect.insort(g[b],a)
    #print(bisect.bisect_left(g[a],b))
    #g[a][] = b
    #g[a].append(b)
    #g[b].append(a)

if len(g[n]) == 0:
    print('IMPOSSIBLE')
    exit()

for i in g[n]:
    if g[i][0] == 1:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

Fixed submission:
import bisect
n,m = map(int,input().split())

g = [[ ] for i in range(n+1)]

for i in range(m):
    a,b = map(int,input().split())
    if a == 1 or a == n or b == 1 or b == n:
        g[a].append(b)
        g[b].append(a)

    #print(bisect.bisect_left(g[a],b))
    #g[a][] = b
    #g[a].append(b)
    #g[b].append(a)

#g[4].sort()

#print(g[4])

if len(g[n]) == 0:
    print('IMPOSSIBLE')
    exit()

for i in g[n]:
    g[i].sort()
    if g[i][0] == 1:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
import fractions
n,k = map(int,input().split())
ai = [int(i) for i in input().split()]

g = fractions.gcd(ai[0],ai[1])

for i in range(1,n-1):
    #print(i)
    g = fractions.gcd(g,ai[i+1])

if k % g == 0 and max(ai) >= k:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Fixed submission:
import fractions
n,k = map(int,input().split())
ai = [int(i) for i in input().split()]

if n == 1:
    if k == ai[0]:
        print('POSSIBLE')
        exit()
    else:
        print('IMPOSSIBLE')
        exit()

g = fractions.gcd(ai[0],ai[1])

for i in range(1,n-1):
    #print(i)
    g = fractions.gcd(g,ai[i+1])

if k % g == 0 and max(ai) >= k:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Buggy python submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())
ai = [int(i) for i in input().split()]

g = math.gcd(ai[0],ai[1])

for i in range(1,n-1):
    #print(i)
    g = math.gcd(g,ai[i+1])

if k % g == 0 and max(ai) >= k:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Fixed submission:
import fractions
n,k = map(int,input().split())
ai = [int(i) for i in input().split()]

if n == 1:
    if k == ai[0]:
        print('POSSIBLE')
        exit()
    else:
        print('IMPOSSIBLE')
        exit()

g = fractions.gcd(ai[0],ai[1])

for i in range(1,n-1):
    #print(i)
    g = fractions.gcd(g,ai[i+1])

if k % g == 0 and max(ai) >= k:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]

b = []
b.append(a[0])

for i in range(n-1):
    b.append(a[i+1])
    b = b[::-1]
    
print(*b)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

b = []

for i in range((n+1)//2):
    #print(i)
    b.append(a[n-1-2*i])

even = False

if n % 2 == 0:
    even = False
else:
    even = True

if even == True:
    for i in range(n//2):
        b.append(a[1+2*i])
else:
    for i in range(n//2):
        b.append(a[2*i])
    

print(*b)

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

b = []
b.append(a[0])

for i in range(n-1):
    b.append(a[i+1])
    b = b[::-1]
    
print(*b)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

b = []

for i in range((n+1)//2):
    #print(i)
    b.append(a[n-1-2*i])

even = False

if n % 2 == 0:
    even = False
else:
    even = True

if even == True:
    for i in range(n//2):
        b.append(a[1+2*i])
else:
    for i in range(n//2):
        b.append(a[2*i])
    

print(*b)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
ab = [[int(i) for i in input().split()] for j in range(m)]

im_b = [0]*(n)

for i in range(n):
    im_b[ab[i][0]-1] += 1
    im_b[ab[i][1]-1] -= 1

if im_b[0] % 2 == 1:
    print('NO')
    exit()

#im_a = [0]*(n)
#im_a[0] = im_b[0]

for i in range(n-1):
    #print(i)
    if im_b[i] % 2 == 1:
        print('NO')
        exit()

print('YES')

Fixed submission:
n,m = map(int,input().split())
ab = [[int(i) for i in input().split()] for j in range(m)]

im_b = [0]*(n)

for i in range(m):
    im_b[ab[i][0]-1] += 1
    im_b[ab[i][1]-1] -= 1

if im_b[0] % 2 == 1:
    print('NO')
    exit()

#im_a = [0]*(n)
#im_a[0] = im_b[0]

for i in range(n-1):
    #print(i)
    if im_b[i] % 2 == 1:
        print('NO')
        exit()

print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    ans = 1
    for i in range(N):
        ans = ans * (i+1)
    print(ans%(10**9+7))
    
main()

Fixed submission:
def main():
    N = int(input())
    ans = 1
    for i in range(N):
        ans = (ans * (i+1)) % (10**9+7)
    print(ans)
    
main()
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int,input())

print(max(a*b,c*d))

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

print(max(a*b,c*d))
Buggy python submission (verdict: Runtime Error):
n = int(input())

mod = 10**9+7

sosu = [1] * 100

for j in range(2,n+1):
    tmp = j
    while tmp > 1:
        for i in range(2,n+1):
            if tmp % i == 0:
                sosu[i] += 1
                tmp = tmp // i
        
#print(sosu)
sosu.sort(reverse=True)

ans = 1

for i in range(len(sosu)):
    if sosu[i] > 0:
        ans = ans*sosu[i] % mod
        
print(ans)

Fixed submission:
n = int(input())

mod = 10**9+7

sosu = [1] * 1001

for j in range(2,n+1):
    tmp = j
    i = 2
    while tmp > 1:
        if tmp % i == 0:
            sosu[i] += 1
            tmp = tmp // i
        else:
            i += 1
        
#print(sosu)
sosu.sort(reverse=True)

ans = 1

for i in range(len(sosu)):
    if sosu[i] > 1:
        ans = ans*sosu[i] % mod
        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# cook your dish here
def dijkstra_back(s,t,n,w,cost):
    #sからtへの最短経路の経路復元
    prev = [s] * n #最短経路の直前の頂点
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        for i in range(n):
            if (not used[i]) and (v == -1):
               v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
               break
        used[v] = True
        
        for i in range(n):
            if d[i] > d[v] + cost[v][i]: 
                d[i] = d[v] + cost[v][i]
                prev[i] = v
        
    path = [t]
    while prev[t] != s:
        path.append(prev[t])
        prev[t] = prev[prev[t]]
    path.append(s)
    path = path[::-1]
    return path

################################
n,w = map(int,input().split()) #n:頂点数　w:辺の数

cost = [[float("inf") for i in range(n)] for i in range(n)] 
#cost[u][v] : 辺uvのコスト(存在しないときはinf この場合は10**10)
for i in range(w):
    x,y,z = map(int,input().split())
    cost[x-1][y-1] = z
    cost[y-1][x-1] = z

check = [[0 for i in range(n)] for j in range(n)]

for i in range(n):
    for j in range(i+1,n):
        tmp = dijkstra_back(i,j,n,w,cost)
        #print(tmp)
        for k in range(len(tmp)-1):
            #print(tmp[k],tmp[k+1])
            check[min(tmp[k],tmp[k+1])][max(tmp[k],tmp[k+1])] = 1

#print(check)

#exit()

print(w - sum(map(sum, check)))

#print(dijkstra_back(0,1,n,w,cost))

Fixed submission:
# cook your dish here
def dijkstra_back(s,t,n,w,cost):
    #sからtへの最短経路の経路復元
    prev = [s] * n #最短経路の直前の頂点
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        for i in range(n):
            if (not used[i]) and (v == -1):
               v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
               break
        used[v] = True
        
        for i in range(n):
            if d[i] > d[v] + cost[v][i]: 
                d[i] = d[v] + cost[v][i]
                prev[i] = v
        
    path = [t]
    while prev[t] != s:
        path.append(prev[t])
        prev[t] = prev[prev[t]]
    path.append(s)
    path = path[::-1]
    return path

################################
n,w = map(int,input().split()) #n:頂点数　w:辺の数

cost = [[float("inf") for i in range(n)] for i in range(n)] 
#cost[u][v] : 辺uvのコスト(存在しないときはinf この場合は10**10)
for i in range(w):
    x,y,z = map(int,input().split())
    cost[x-1][y-1] = z
    cost[y-1][x-1] = z

check = [[0 for i in range(n)] for j in range(n)]

for i in range(n):
    for j in range(i+1,n):
        tmp = dijkstra_back(i,j,n,w,cost)
        #print(tmp)
        for k in range(len(tmp)-1):
            #print(tmp[k],tmp[k+1])
            check[min(tmp[k],tmp[k+1])][max(tmp[k],tmp[k+1])] = 1

#print(check)

#exit()

print(w - sum(map(sum, check)))

#print(dijkstra_back(0,1,n,w,cost))
Buggy python submission (verdict: Runtime Error):
a,b,c = input().split()

if b == "+":
    print(a+c)
else:
    print(a-c)

Fixed submission:
a,b,c = input().split()

a = int(a)
c = int(c)

if b == "+":
    print(int(a)+c)
else:
    print(a-c)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())

len_s = len(s)
moji = [0]*(len_s)

for i in range(len_s):
    num = 26-(ord(s[i])-ord('a'))
    if num <= k:
        moji[i] = 'a'
        k -= num
    else:
        moji[i] = s[i]
        
if k != 0:
    #print(k)
    moji[len_s-1] = chr(ord(moji[len_s-1])+k)
        
print(*moji,sep='')

Fixed submission:
s = input()
k = int(input())

len_s = len(s)
moji = [0]*(len_s)

for i in range(len_s):
    num = 26-(ord(s[i])-ord('a'))
    if num <= k and num != 26:
        moji[i] = 'a'
        k -= num
    else:
        moji[i] = s[i]

     
if k != 0:
    #print(k)
    moji[len_s-1] = chr(ord(moji[len_s-1])+k%26)
        
print(*moji,sep='')
Buggy python submission (verdict: Time Limit Exceeded):
n,a = map(int,input().split())
x = [int(i) for i in input().split()]

sum_x = sum(x)

dp = [[[0 for i in range(n+1)]for j in range(sum_x+1)]for k in range(n+1)]

dp[0][0][0] = 1

for i in range(n):
    for j in range(n):
        for k in range(sum_x+1):
            dp[i+1][k][j] += dp[i][k][j]
            if k + x[i] > sum_x:
                continue
            dp[i+1][k+x[i]][j+1] += dp[i][k][j]
            
ans = 0

for i in range(n):
    if a*(i+1) > sum_x:
        break
    ans += dp[n][a*(i+1)][i+1]

print(ans)

Fixed submission:
n,a = map(int,input().split())
x = [int(i) for i in input().split()]

sum_x = sum(x)

dp = [[[0 for i in range(n+1)]for j in range(sum_x+1)]for k in range(n+1)]

dp[0][0][0] = 1

for i in range(n):
    for j in range(n):
        for k in range(sum_x+1):
            dp[i+1][k][j] += dp[i][k][j]
            if k + x[i] > sum_x:
                continue
            dp[i+1][k+x[i]][j+1] += dp[i][k][j]
            
ans = 0

for i in range(n):
    if a*(i+1) > sum_x:
        break
    ans += dp[n][a*(i+1)][i+1]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,a = map(int,input().split())
x = [int(i) for i in input().split()]

s = x

ans = 0

#print(s[0],s[1],s[2])

for i in range(2**(len(s))):
    tmp = i
    #print(tmp,tmp,tmp)
    temp = 0
    cnt = 0
    for j in range(len(s)):
        #print(ans)
        #temp += int(s[j])
        #print(temp)
        if tmp % 2 == 0:
            #temp = temp * 10
            #print(0)
            b = 1
            #if j == len(s)-2:
                #ans += temp + int(s[j+1])
        else:
            #ans += s[i]
            temp += x[j]
            cnt += 1
            #ans += temp
            #temp = 0
        if j == len(s)-1:
            #ans += temp + int(s[j+1])
            if cnt == 0:
                continue
            #print(temp,cnt,a)
            if temp / cnt == a:
                #print(temp,cnt)
                ans += 1
        tmp = tmp // 2
    
print(ans)

Fixed submission:
n,a = map(int,input().split())
x = [int(i) for i in input().split()]

sum_x = sum(x)

dp = [[[0 for i in range(n+1)]for j in range(sum_x+1)]for k in range(n+1)]

dp[0][0][0] = 1

for i in range(n):
    for j in range(n):
        for k in range(sum_x+1):
            dp[i+1][k][j] += dp[i][k][j]
            if k + x[i] > sum_x:
                continue
            dp[i+1][k+x[i]][j+1] += dp[i][k][j]
            
ans = 0

for i in range(n):
    if a*(i+1) > sum_x:
        break
    ans += dp[n][a*(i+1)][i+1]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int (input ())
A = [int (x) for x in input().split()]
X = 0
for i in range (N-1):
  for j in range (N-i-1):
    X += A[i]*A[j+i+1]
    if X > 10**9+7:
      X = X%(10**9+7)
print (X)

Fixed submission:
N = int (input ())
A = [int (x) for x in input().split()]
S = sum (A)
X = 0
for i in range (N-1):
  X += A[i]*(S-A[i])
  S -= A[i]
  if X > 10**9+7:
    X = X%(10**9+7)
print (X)

Buggy python submission (verdict: Time Limit Exceeded):
N = int (input ())
A = [int (x) for x in input().split()]
X = 0
for i in range (N-1):
  for j in range (N-i-1):
    X += A[i]*A[j+i+1]
    X = X%(10**9+7)
print (X)

Fixed submission:
N = int (input ())
A = [int (x) for x in input().split()]
S = sum (A)
X = 0
for i in range (N-1):
  X += A[i]*(S-A[i])
  S -= A[i]
  if X > 10**9+7:
    X = X%(10**9+7)
print (X)

Buggy python submission (verdict: Time Limit Exceeded):
N = int (input ())
A = [int (x) for x in input().split()]
X = 0
for i in range (N-1):
  for j in range (N-i-1):
    X += A[i]*A[j+i+1]
print (X%(10**9+7))

Fixed submission:
N = int (input ())
A = [int (x) for x in input().split()]
S = sum (A)
X = 0
for i in range (N-1):
  X += A[i]*(S-A[i])
  S -= A[i]
  if X > 10**9+7:
    X = X%(10**9+7)
print (X)
Buggy python submission (verdict: Time Limit Exceeded):
X,K,D = map(int, input().split())
x = 0
if X == 0:
  if K%2 == 0:
    print (0)
  else:
    print (abs(D))
  x =1
elif X < 0:
  if abs(X) >= K*D:
    print (abs(X+K*D))
    x = 1
  if x == 0:
    for i in range (K):
      X += D
      if X >= 0:
        if (K-i-1)%2 == 0:
          print (abs(X))
        else:
          print (abs(X-D))
        x = 1
        break
else:
  if X >= K*D:
    print (X-K*D)
    x = 1
  if x == 0:
    for i in range (K):
      X -= D
      if X < 0:
        if (K-i)%2 == 0:
          print (abs(X+D))
        else:
          print (abs(X))
        x = 1
        break

Fixed submission:
X,K,D = map(int, input().split())
x = 0
if X == 0:
  if K%2 == 0:
    print (0)
  else:
    print (abs(D))
  x =1
elif X < 0:
  if abs(X) >= K*D:
    print (abs(X+K*D))
  else:
    K = K-(-1*X//D)
    X = X+(-1*X//D)*D
    if K%2 == 0:
      print (abs(X))
    else:
      print (abs(X+D))
else:
  if X >= K*D:
    print (X-K*D)
  else:
    K = K-(X//D)
    X = X-(X//D)*D
    if K%2 == 0:
      print (abs(X))
    else:
      print (abs(X-D))
Buggy python submission (verdict: Time Limit Exceeded):
N = int (input ())
z = 1
while True:
  if N < (2+z)**2-(1+z+z):
    break
  else:
    z += 1
z -= 1
n = 1
while n < N+1:
  p = 0
  for X in range (z):
    for Y in range (z):
      for Z in range (z):
        if n == (X+Y+Z+3)**2-((X+1)*(Y+1)+(Y+1)*(Z+1)+(Z+1)*(X+1)):
          if X >= 0 and Y >= 0 and Z >= 0:
            p += 1
  print (p)
  n += 1

Fixed submission:
N = int ( input())
ans = [0]*N
for x in range (1,101):
  for y in range (1,101):
    for z in range (1,101):
      m = (x+y+z)**2-(x*y+y*z+z*x)
      if m <= N:
        ans[m-1] += 1
for i in ans:
  print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N = int (input ())
z = 1
while True:
  if N < (2+z)**2-(1+z+z):
    break
  else:
    z += 1
z -= 1
n = 1
while n < N+1:
  p = 0
  for X in range (z+1):
    for Y in range (z+1):
      for Z in range (z+1):
        if n == (X+Y+Z)**2-(X*Y+Y*Z+Z*X):
          if X > 0 and Y > 0 and Z > 0:
            p += 1
  print (p)
  n += 1

Fixed submission:
N = int ( input())
ans = [0]*N
for x in range (1,101):
  for y in range (1,101):
    for z in range (1,101):
      m = (x+y+z)**2-(x*y+y*z+z*x)
      if m <= N:
        ans[m-1] += 1
for i in ans:
  print(i)
Buggy python submission (verdict: Runtime Error):
S,T = input (),split ()
A,B = map (int, input (),split ())
U = input ()
if U == S:
  print (A-1,B)
else:
  print (A,B-1)

Fixed submission:
S,T = input ().split ()
A,B = map (int, input ().split ())
U = input ()
if U == S:
  print (A-1,B)
else:
  print (A,B-1)

Buggy python submission (verdict: Runtime Error):
S,T = input (),split ()
A,B = map (int, input ().split ())
U = input ()
if U == S:
  print (A-1,B)
else:
  print (A,B-1)

Fixed submission:
S,T = input ().split ()
A,B = map (int, input ().split ())
U = input ()
if U == S:
  print (A-1,B)
else:
  print (A,B-1)
Buggy python submission (verdict: Runtime Error):
A,B = mao (int, input ().split ())
if B%A == 0:
  print (A+B)
else:
  print (B-A)

Fixed submission:
A,B = map (int, input ().split ())
if B%A == 0:
  print (A+B)
else:
  print (B-A)
Buggy python submission (verdict: Time Limit Exceeded):
s = int (input ())
l = []
a = 0
l.append (s)
while True:
  a += 1
  if s%2 == 0:
    s = round(s/2)
  else:
    s = s*3+1
  if l.count (s) != 0:
    print (a+1)
    break
  

Fixed submission:
s = int (input ())
l = []
a = 0
l.append (s)
for i in range (1000000):
  a += 1
  if s%2 == 0:
    s = round(s/2)
  else:
    s = s*3+1
  if l.count (s) != 0:
    print (a+1)
    break
  else:
    l.append (s)
Buggy python submission (verdict: Runtime Error):
a,b = int (input ())
if a+b == 15:
  print ('+')
elif a*b == 15:
  print ('*')
else:
  print ('x')

Fixed submission:
a,b = map (int, input ().split ())
if a+b == 15:
  print ('+')
elif a*b == 15:
  print ('*')
else:
  print ('x')