Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02991 (python)

Fixed submission:


import sys
from collections import deque, defaultdict
import copy
import bisect
#sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import combinations, permutations

import sys
def input():
	return sys.stdin.readline().strip()


N, M = list(map(int, input().split()))

graph = [[] for _ in range(3*N)]

for i in range(M):
	u, v = list(map(int, input().split()))
	u -= 1
	v -= 1
	graph[u%(3*N)].append((v + N)%(3*N))
	graph[(u + N) % (3 * N)].append((v+2*N)%(3*N))
	graph[(u + 2*N) % (3 * N)].append(v % (3 * N))
S, T = list(map(int, input().split()))
S -= 1
T -= 1

dist = [1000000000000000000 for _ in range(3*N)]
que = deque([])
que.append(S)
dist[S] = 0
while len(que) > 0:
	node = que.popleft()
	for edge in graph[node]:
		if dist[edge] > dist[node] + 1:
			dist[edge] = dist[node] + 1
			que.append(edge)

if dist[T] < 100000000000000:
	print(dist[T]//3)
else:
	print(-1)

Buggy submission (verdict: Runtime Error):
NM=list(map(int,input().split()))
N=NM[0]
M=NM[1]
graph=[[] for j in range(N)]
 
for i in range(M):
  edge=list(map(int,input().split()))
  graph[edge[0]-1].append(edge[1]-1)
  
ST=list(map(int,input().split()))
S=ST[0]-1
T=ST[1]-1
 
 
 
first=[]
second=[]
third=[]
able=set([S])
 
step=0
 
while True:
  first=[]
  second=[]
  third=[]
  judge = 0
  for i in range(len(able)):
    for j in range(len(graph[able[i]])):
      if not (graph[able[i]][j] in first):
        first.append(graph[able[i]][j])
  for i in range(len(first)):
    for j in range(len(graph[first[i]])):
      if not (graph[first[i]][j] in second):
        second.append(graph[first[i]][j])
  for i in range(len(second)):
    for j in range(len(graph[second[i]])):
      if not (graph[second[i]][j] in third):
        third.append(graph[second[i]][j])
  able=able&set(third)
  if judge == 0:
    print(-1)
    break
  step+=1
  if T in able:
    print(step)
    break
Problem p03029 (python)

Fixed submission:
A, P = list(map(int,input().split()))

print((A*3 + P)//2)

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque, defaultdict
import copy
import bisect
#input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

N, Q = map(int, input().split())
 
STX = [list(map(int, input().split())) for _ in range(N)]
# xの昇順に工事の区間をsort
STX = sorted(STX, key=lambda x: x[2])
 
D = [int(input()) for _ in range(Q)]
ans = [-1] * Q
index = [-1] * Q
for s, t, x in STX:
    left = bisect.bisect_left(D, s - x - 0.5)
    right = bisect.bisect_left(D, t - x - 0.5)
    now = left
    while now < right:
        if index[now] == -1:  # まだansが更新されていない場合
            ans[now] = x
            index[now] = right
            now += 1
        else:
            now = index[now]
            
 
for a in ans:
    print(a)

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque, defaultdict
import copy
import bisect
#input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)


N, Q = list(map(int, input().split()))
STX=[]
D=[]
for i in range(N):
    S, T, X = list(map(int, input().split()))
    bisect.insort(STX, (X, S, T))
for i in range(Q):
    D.append(int(input()))

skip = [-1 for i in range(Q)]

dist = [10000000000000 for i in range(Q)]

for (X, S, T) in STX:
    s = S - X
    t = T - X - 1
    a = bisect.bisect_left(D, s)
    b = bisect.bisect_right(D, t)
    #print(D)
    j = a
    while j < b:
        if skip[j] == -1:
            skip[j] = b
            dist[j] = X
            j+=1
        else:
            j=skip[j]



for i in range(Q):
    if dist[i] > 100000000000:
        print(-1)
    else:
        print(dist[i])
Problem p03030 (python)

Fixed submission:
import sys
from collections import deque, defaultdict
import copy
import bisect
#input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)


N = int(input())
res = []
for i in range(N):
    S, P = list(input().split())
    bisect.insort(res, (S, -int(P), i + 1))
for i in range(len(res)):
    print(res[i][2])

Buggy submission (verdict: Runtime Error):

N = int(input())
res = []
for i in range(N):
    S, P = list(input().split())
    bisect.insort(res, (S, -int(P), i + 1))
for i in range(len(res)):
    print(res[i][2])
Problem p03035 (python)

Fixed submission:
A, B = list(map(int, input().split()))

if A >=13:
	print(B)
elif A>=6:
	print(int(B/2))
else:
	print(0)

Buggy submission (verdict: Runtime Error):
A, B = list(map(int, input().split()))

if A >=13:
	print(B)
elif A>=6:
	print(1nt(B/2))
else:
	print(0)
Problem p03085 (python)

Fixed submission:
import sys

b = input()
if b == 'A':
	print('T')
elif b == 'T':
	print('A')
elif b == 'G':
	print('C')
elif b == 'C':
	print('G')

Buggy submission (verdict: Runtime Error):
input=sys.stdin.readline

b = input()
if b == 'A':
	print('T')
elif b == 'T':
	print('A')
elif b == 'G':
	print('C')
elif b == 'C':
	print('G')
Problem p03087 (python)

Fixed submission:
import sys
def input():
	return sys.stdin.readline().strip()

N, Q = list(map(int, input().split()))
S = input()

i = 0
num = 0
num_acc2 = [0]*N
for i in range(N - 1):
	if S[i:i + 2] == "AC":
		num += 1
	num_acc2[i + 1] = num

for i in range(Q):
	l, r = list(map(int, input().split()))
	print(num_acc2[r - 1] - num_acc2[l - 1])

Buggy submission (verdict: Runtime Error):
def input():
	return sys.stdin.readline().strip()

N, Q = list(map(int, input().split()))
S = input()

i = 0
num = 0
num_acc2 = [0]*N
for i in range(N - 1):
	if S[i:i + 2] == "AC":
		num += 1
	num_acc2[i + 1] = num

for i in range(Q):
	l, r = list(map(int, input().split()))
	print(num_acc2[r - 1] - num_acc2[l - 1])
Problem p03158 (python)

Fixed submission:

import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions

import sys
def input():
	return sys.stdin.readline().strip()

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

sum_list = [0]
even_odd_sum = [0, 0]
for i in range(N):
	sum_list.append(sum_list[-1] + A[i])
	even_odd_sum.append(even_odd_sum[-2] + A[i])

for q in range(Q):
	x = int(input())
	if x >= A[-1]:
		print(even_odd_sum[-1])
	else:
		loc_min = bisect.bisect_left(A, x)
		loc_min = max(loc_min, N // 2)
		loc_max = (loc_min + N) // 2

		t = (loc_min + loc_max) // 2


		#print(x, loc_min, loc_max, t, 2*t - N - 1)
		while (loc_min <= loc_max):

			if 2*t - N - 1 >= 0 and A[t - 1] - x >= x - A[2*t - N - 1]:
				loc_max = t - 1
			elif 2*t - N >= 0 and A[t] - x < x - A[2*t - N]:
				loc_min = t + 1
			elif 2*t - N < 0 and A[t] - x < x - A[0]:
				loc_min = t + 1
			else:
				break

			t = (loc_min + loc_max) // 2
		ans = sum_list[-1] - sum_list[t] + even_odd_sum[2*t - N - 1 + 2]
		print(ans)

Buggy submission (verdict: Runtime Error):

import sys
def input():
	return sys.stdin.readline().strip()

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

sum_list = [0]
even_odd_sum = [0, 0]
for i in range(N):
	sum_list.append(sum_list[-1] + A[i])
	even_odd_sum.append(even_odd_sum[-2] + A[i])

for q in range(Q):
	x = int(input())
	if x >= A[-1]:
		print(even_odd_sum[-1])
	else:
		loc_min = bisect.bisect_right(A, x)
		loc_min = max(loc_min, N // 2)
		loc_max = (loc_min + N) // 2

		t = (loc_min + loc_max) // 2

		while (loc_min <= loc_max):

			if 2*t - N - 1 >= 0 and A[t - 1] - x >= x - A[2*t - N - 1]:
				loc_max = t - 1

			elif A[t] - x < x - A[2*t - N]:
				loc_min = t + 1
			else:
				break
			#print(loc_min, loc_max, t)
			t = (loc_min + loc_max) // 2
		ans = sum_list[-1] - sum_list[t] + even_odd_sum[2*t - N - 1 + 2]
		print(ans)
Problem p03214 (python)

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

ave=sum(a)/N

mini=1000
argmin=-1
for i in range(N):
  if abs(ave-a[i])<mini:
    mini=abs(ave-a[i])
    argmin=i
    
print(argmin)

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

num=0
a_sum=[0]
for i in range(N):
  num+=a[i]
  a_sum.append(num)
  

a_mat=[[0 for i in range(N)] for j in range(N)]
non_zero=[]
for i in range(N):
  for j in range(i,N):
    a_mat[i][j] = a_sum[j+1]-a_sum[i]
    non_zero.append([i,j])

a_mat2=copy.deepcopy(a_mat)

maxbit=1
while True:
  if a_sum[N]<2**maxbit and a_sum[N]>=2**(maxbit-1): 
    break
  else:
    maxbit+=1
maxnum=0
num_rest=int(N*(N+1)/2)
num_rest_now=int(N*(N+1)/2)
for bit in range(maxbit):
  non_zero2=[]
  for i, j in non_zero:
    if a_mat[i][j]&(2**(maxbit-bit-1)) == 0 and a_mat[i][j]!=0:
      num_rest_now-=1
      a_mat2[i][j]=0
    else:
      non_zero2.append([i,j])
  #print(non_zero)
  #print(a_mat)
  #print(num_rest_now)
  
  if num_rest_now >= K:
    maxnum+=2**(maxbit-bit-1)
    a_mat=copy.deepcopy(a_mat2)
    num_rest=num_rest_now
    non_zero=copy.deepcopy(non_zero2)
  else:
    a_mat2=copy.deepcopy(a_mat)
    num_rest_now=num_rest
    
  
  
print(maxnum)
Problem p03470 (python)

Fixed submission:

import sys
from collections import deque, defaultdict
import copy
import bisect
#sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import combinations, permutations

import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())
ans = 0
d = defaultdict(int)
for i in range(N):
	di = int(input())
	if d[di] == 0:
		ans += 1
		d[di] += 1
print(ans)

Buggy submission (verdict: Runtime Error):

import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())
ans = 0
d = defaultdict(int)
for i in range(N):
	di = int(input())
	if d[di] == 0:
		ans += 1
		d[di] += 1
print(ans)
Problem p03633 (python)

Fixed submission:
import fractions

import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())
T = []
for i in range(N):
	T.append(int(input()))

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

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque, defaultdict
import copy
import bisect
#sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations


import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())
T = []
for i in range(N):
	T.append(int(input()))

ans = T[0]
for i in range(N - 1):
	ans = (ans * T[i + 1])//math.gcd(ans, T[i + 1])
print(ans)
Problem p03799 (python)

Fixed submission:
import sys
def input():
	return sys.stdin.readline().strip()

N, M = list(map(int, input().split()))

if 2*N >= M:
	print(M // 2)
else:
	x = M - 2*N
	print(N + x//4)

Buggy submission (verdict: Runtime Error):

import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions

import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())
a = list(map(int, input().split()))

top_list = [0]


for i in range(1, N):

	if a[i] > a[top_list[-1]]:
		top_list.append(i)

num_list = [0]*N
com = []
for i in range(len(top_list)):
	bisect.insort(com, a[top_list[i]])


for i in range(N - 1, top_list[-1], -1):
	bisect.insort(com, a[i])

stock = 0
#print(com, top_list, num_list)
for top in range(len(top_list) - 2, -1, -1):
	for i in range(top_list[top + 1] - 1, top_list[top], -1):
		#bisect.insort(com, a[i])
		com.append(a[i])
	com.sort()
	judge = 0
	total = stock*(a[top_list[top + 1]] - a[top_list[top]])
	#print(total, (a[top_list[top + 1]] - a[top_list[top]])*stock,  top)
	while judge == 0:
		x = com.pop()
		if x > a[top_list[top]]:
			total += x - a[top_list[top]]
			stock += 1
		else:
			bisect.insort(com, x)
			judge = 1
	num_list[top_list[top + 1]] = total
	#print(com, top_list, num_list, stock)


num_list[top_list[0]] = sum(a) - sum(num_list)
for i in range(N):
	print(num_list[i])
Problem p02953 (python)

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    
    n = int(input())
    arr = list(map(int, input().split()))
    
    ok = 1
    for i in reversed(range(n - 1)):
        if arr[i] > arr[i + 1]:
            arr[i] -= 1
        if arr[i] > arr[i + 1]:
            ok = 0
    
    if ok:
        print("Yes")
    else:
        print("No")
    
    return 0

main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.readline
    
    n = int(input().split())
    arr = list(map(int, input().split()))
    
    ok = 1
    for i in reversed(range(n - 1)):
        if arr[i] > arr[i + 1]:
            arr[i] -= 1
        if arr[i] > arr[i + 1]:
            ok = 0
    
    if ok:
        print("Yes")
    else:
        print("No")
    
    return 0

main()
Problem p02982 (python)

Fixed submission:
n, d = map(int, input().split())
points = [[]] * n
for i in range(n):
  points[i] = list(map(int, input().split()))
 
def helper(a, b):
  s = 0
  for i in range(d):
    s += (a[i] - b[i]) ** 2
  a = int(0.5 + (s ** 0.5))
  if a * a == s:
    return 1
  return 0
 
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        ans += helper(points[i], points[j])
print(ans)

Buggy submission (verdict: Runtime Error):
n, d = map(int, input().split())
points = [[]] * n
for i in range(n):
  points[i] = list(map(int, input().split()))

def helper(a, b):
  s = 0
  for i in range(n):
    s += (a[i] - b[i]) ** 2
  a = int(0.5 + (s ** 0.5))
  if a * a == s:
    return 1
  return 0

ans = 0
for i in range(n):
	for j in range(i + 1, n):
		ans += helper(points[i], points[j])
print(ans)
Problem p02993 (python)

Fixed submission:
a = input()
ok = 1
for i in range(1, 4):
    if a[i] == a[i - 1]:
        ok = 0
if ok:
    print("Good")
else:
    print("Bad")

Buggy submission (verdict: Runtime Error):
a = input()
ok = 1
for i in range(1, 4):
	if a[i] == a[i - 1]:
      ok = 0
if ok:
  print("Good")
else:
	print("Bad")
Problem p02994 (python)

Fixed submission:
n, l = map(int, input().split())
s = 0
for i in range(1, n + 1):
    s += l + i - 1
 
x = 1 - l
if x <= n and x >= 1:
    print(s)
else:
    a = l
    b = l + n - 1
    if abs(a) < abs(b):
        print(s - a)
    else:
        print(s - b)

Buggy submission (verdict: Runtime Error):
n, l = map(int, input().split())
s = 0
for i in range(1, n + 1):
    s += l + i - 1

x = 1 - l
if x <= n and x >= i:
    print(s)
else:
    a = L
    b = L + n - 1
    if abs(a) < abs(b):
        print(s - a)
    else:
        print(s - b)

Buggy submission (verdict: Runtime Error):
n, l = map(int, input().split())
s = 0
for i in range(1, n + 1):
  	s += l + i - 1

x = 1 - l
if x <= n and x >= i:
	print(s)
else:
    a = L
    b = L + n - 1
    if abs(a) < abs(b):
      print(s - a)
    else:
      print(s - b)
Problem p03071 (python)

Fixed submission:
def main():
    a, b = map(int, input().split())
    ans = 0
    if a > b:
        ans += a
        a -= 1
    else:
        ans += b
        b -= 1
    print(ans + max(a, b))
    return 0
main()

Buggy submission (verdict: Runtime Error):
def main():
    n, k = map(int, input().split())
    s = input()
    
    arr = []
    if s[0] == '0':
        arr.append(0)
    cnt = 1
    i = 1
    while i != n:
        if s[i] != s[i - 1]:
            arr.append(cnt)
            cnt = 1
        else:
            cnt += 1
        i += 1
    arr.append(cnt)
    if s[-1] == '0':
        arr.append(0)
    
    ans = 0
    curr = arr[0]
    j = 1
    if len(arr) - 1 <= 2 * k:
        print(n)
        return 0
    for i in range(1, len(arr), 2):
        curr += arr[i] + arr[i + 1]
        if i - j == 2 * k:
            curr -= arr[j] + arr[j - 1]
            j += 2
        ans = max(ans, curr)
    print(ans)
    return 0
main()
Problem p03074 (python)

Fixed submission:
def main():
    ans = 0
    n, k = map(int, input().split())
    s = input()
    arr = []
    if s[0] == '0':
        arr.append(0)
    cnt = 1
    i = 1
    while i != n:
        if s[i] != s[i - 1]:
            arr.append(cnt)
            cnt = 1
        else:
            cnt += 1
        i += 1
    arr.append(cnt)
    if s[-1] == '0':
        arr.append(0)
    ans = 0
    curr = arr[0]
    j = 1
    if len(arr) - 1 <= 2 * k:
        print(n)
        return 0
    for i in range(1, len(arr), 2):
        curr += arr[i] + arr[i + 1]
        if i - j == 2 * k:
            curr -= arr[j] + arr[j - 1]
            j += 2
        ans = max(ans, curr)
    print(ans)
    return 0
main()

Buggy submission (verdict: Runtime Error):
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    
    vector<int> arr;
    if (s[0] == '0') arr.push_back(0);
    int cnt = 1;
    for (int i = 1; i != n; ++i)
    {
        if (s[i] != s[i - 1])
        {
            arr.push_back(cnt);
            cnt = 1;
        }
        else ++cnt;
    }
    arr.push_back(cnt);
    if (s[n - 1] == '0') arr.push_back(0);
    
    int ans = 0;
    int curr = arr[0];
    int j = 1;
    for (int i = 1; i != arr.size(); i += 2)
    {
        curr += arr[i] + arr[i + 1];
        if (i - j == k << 1)
        {
            curr -= arr[j] + arr[j - 1];
            j += 2;
        }
        ans = max(ans, curr);
    }
    cout << ans << endl;
    return 0;
}
Problem p03161 (python)

Fixed submission:
def main():
  import sys
  input = sys.stdin.readline
  n, k = map(int, input().split())
  arr = list(map(int, input().split()))
  dp = [1000000000] * n
  dp[0] = 0
  for i in range(1, n):
    for j in range(max(0, i - k), i):
      dp[i] = min(dp[i], dp[j] + abs(arr[i] - arr[j]))
  print(dp[-1])
main()

Buggy submission (verdict: Runtime Error):


oo = 1000000000 + 5

def main():
    n, k = map(int, input().split())
    a = [int(x) for x in input().split()]
    
    dp = [oo for _ in range(n)]
    dp[0] = 0
    for i in range(n):
        for j in range(i + 1, i + k + 1):
            if j < n:
                dp[j] = min(dp[j], dp[i] + fabs(a[i] - a[j]))
                
    print(int(dp[n - 1]))

main()

Buggy submission (verdict: Runtime Error):
def main():
  import sys
  input = sys.stdin.readline
  n, k = map(int, input().split())
  arr = list(map(int, input().split()))
  dp = [1000000000] * n
  dp[0] = 0
  for i in range(1, n):
    for j in range(max(0, i - k), i):
    dp[i] = min(dp[i], dp[j] + abs(arr[i] - arr[j]))
  print(dp[-1])
main()
Problem p03303 (python)

Fixed submission:
S = input()
w = int(input())
l = len(S)
ret = ""
if l % w:
  for i in range(1 + l // w):
    ret += S[i * w]
else:
  for i in range(l // w):
    ret += S[i * w]
print(ret)

Buggy submission (verdict: Runtime Error):
S = input()
w = int(input())
l = len(S)
ret = ""
if S % w:
  for i in range(1 + S // w):
    ret += S[i * w]
else:
  for i in range(S // w):
    ret += S[i * w]
print(ret)
Problem p03308 (python)

Fixed submission:
def main():
	N = int(input())
	seq = list(map(int, input().split()))
	maks = 0
	for i in range(0, N):
		for j in range(i, N):
			maks = max(abs(seq[j] - seq[i]), maks)
	print(maks)
	return 0
main()

Buggy submission (verdict: Runtime Error):
def main():
	N = int(input())
	seq = list(map(int, input().split()))
	maks = 0
	for i in range(1, N):
		maks = max(seq[i] - seq[i - 1])
	print(maks)
	return 0
main()
Problem p03316 (python)

Fixed submission:
def main():
    def dig_sum(x):
        return sum(list(map(int, [i for i in str(x)])))
    N = int(input())
    if (N / dig_sum(N)) % 1 == 0:
        print("Yes")
    else:
        print("No")
    return 0
main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    if (N / (N % 9)) % 1 == 0:
        print("Yes")
    else:
        print("No")
    return 0
main()
Problem p03738 (python)

Fixed submission:
def resolve():
    a = int(input())
    b = int(input())

    ans = str()

    if a > b:
        ans = "GREATER"
    elif a < b:
        ans = "LESS"
    else:
        ans = "EQUAL"

    print(ans)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    a, b = map(int, input().split())

    ans = str()

    if a > b:
        ans = "GREATER"
    elif a < b:
        ans = "LESS"
    else:
        ans = "EQUAL"

    print(ans)
resolve()
Problem p03889 (python)

Fixed submission:
s = raw_input().rstrip()
t = s
s = s[::-1]
s = s.replace("b", "t")
s = s.replace("p", "s")
s = s.replace("d", "b")
s = s.replace("q", "p")
s = s.replace("t", "d")
s = s.replace("s", "q")
print ((s == t) * "Yes") or "No"

Buggy submission (verdict: Runtime Error):
s = raw_input().rstrip()
t = s
s = s[::-1]
s = s.replace("b", "d")
s = s.replace("p", "q")
s = s.replace("d", "b")
s = s.replace("q", "p")
print s == t * "YES" or "NO"
Problem p03891 (python)

Fixed submission:
a = int(raw_input())
b = int(raw_input())
c = int(raw_input())

s = 3*c

print a,b,s-a-b
print s-(c+s-(s-a-b+s-a-c)),c,s-(s-a-b+s-a-c)
print a+b-c,s-b-c,s-a-c

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, raw_input().split())

s = 3*c

print a,b,s-a-b
print s-(c+s-(s-a-b+s-a-c)),c,s-(s-a-b+s-a-c)
print a+b-c,s-b-c,s-a-c

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, raw_input())

s = 3*c

print a,b,s-a-b
print s-(c+s-(s-a-b+s-a-c)),c,s-(s-a-b+s-a-c)
print a+b-c,s-b-c,s-a-c
Problem p03892 (python)

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

x = abs(c-a)
y = abs(d-b)

if x == 0 or y == 0:
	print 0
	import sys
	sys.exit(0)

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

e = gcd(x,y)
x /= e
y /= e

print (x+y-1) * e

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int, raw_input().split())

x = abs(c-a)
y = abs(d-b)

if x == 0 or y == 0:
	print 0
	return

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

e = gcd(x,y)
x /= e
y /= e

print (x+y-1) * e
Problem p02882 (python)

Fixed submission:
import math
a,b,x = map(int,input().split())
if b*a**2 == x:
    print("0")
elif x >= (b*a**2)/2:
    print(90-math.degrees(math.atan(a**3/(2*(b*a**2-x)))))
else:
    print(90-math.degrees(math.atan(2*x/(a*b**2))))

Buggy submission (verdict: Runtime Error):
import math
a,b,x = map(int,input().split())
if x >= (b*a**2)/2:
    print(90-math.degrees(math.atan(a**3/(2*(b*a**2-x)))))
else:
    print(90-math.degrees(math.atan(2*x/(a*b**2))))
Problem p02995 (python)

Fixed submission:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

a,b,c,d = map(int,input().split())
lcm = int(c*d/gcd(c,d))

total = b-a+1
totalc = b//c-(a-1)//c
totald = b//d-(a-1)//d
totalcd = b//lcm-(a-1)//lcm
print(total - (totalc + totald - totalcd))

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
lcm = int(c*d/math.gcd(c,d))

print((b-a+1) - ((b//c-(a-1)//c) + (b//d-(a-1)//d) - (b//lcm-(a-1)//lcm)))
Problem p03043 (python)

Fixed submission:
import math
n,k = map(int,input().split())
twos = [1]
i = 0
while 2*twos[i] <= 10**5:
    twos.append(twos[i]*2)
    i += 1
twos.append(twos[-1]*2)

ans = 0
for i in range(1,n+1):
    temp = 0
    while twos[temp] * i <= k-1:
        temp += 1
    ans += 1/n * 1/twos[temp]
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())
twos = [1]
i = 0
while 2*twos[i] <= 10**5:
    twos.append(twos[i]*2)
    i += 1

ans = 0
for i in range(1,n+1):
    temp = 0
    while twos[temp] * i <= k-1:
        temp += 1
    ans += 1/n * 1/twos[temp]
print(ans)
Problem p03087 (python)

Fixed submission:
n,q = map(int,input().split())
s = list(input())
cum = [0 for i in range(n+1)]
i = 0
while i < n:
    if i < n-1 and s[i] == "A" and s[i+1] == "C":
        cum[i+1] = cum[i]
        cum[i+2] = 1+cum[i+1]
        i += 2
    else:
        cum[i+1] = cum[i]
        i += 1

for i in range(q):
    l,r = map(int,input().split())
    print(cum[r]-cum[l])

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = list(input())
cum = [0 for i in range(n+1)]
i = 0
while i < n:
    if s[i] == "A" and s[i+1] == "C":
        cum[i+1] = cum[i]
        cum[i+2] = 1+cum[i+1]
        i += 2
    else:
        cum[i+1] = cum[i]
        i += 1

for i in range(q):
    l,r = map(int,input().split())
    print(cum[r]-cum[l])
Problem p03210 (python)

Fixed submission:
x  = int(input())
if x == 3 or x == 5 or x == 7:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
x  = int(input())
if x == 3 or x == 5 or x == 7:
    print('YES')
else:
    print('NO')