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

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

if k==0:
    print s
    exit(0)
if len(s) % (k+1) == 0:
    p = len(s) / (k+1)
    print max(int(s[i:i+p]) for i in xrange(0,len(s),p))
    exit(0)

l = len(s) / (k+1)
r = (len(s)+k) / (k+1)
left = 10**(l-1)
right = 10**r
while 1:
    mid = (left + right) / 2
    cnt = 0
    now = ""
    mid_c = str(mid)
    cp = idx = 0
    for c in s:
        now += c
        if not cp and idx < len(mid_c) and c != mid_c[idx]:
            cp = 1 if c > mid_c[idx] else -1
        idx += 1
        if (idx == len(mid_c) and cp == 1) or idx > len(mid_c):
            cnt += 1
            idx = 1; cp = 0
            if int(c) > mid:
                cnt = 100003
                break
            now = c
            if c != mid_c[0]:
                cp = 1 if c > mid_c[0] else -1
    if cnt > k:
        if left == mid:
            break
        left = mid
    else:
        if right == mid:
            break
        right = mid
print left+1

Buggy submission (verdict: Runtime Error):
k = input()
s = raw_input()
if len(s) > 100:
    exit(1)

left = 0; right = int(s)
while 1:
    mid = (left + right) / 2
    cnt = 0
    now = 0
    for c in s:
        now = 10*now + int(c)
        if now > mid:
            cnt += 1
            now = int(c)
            if now > mid:
                cnt = 100003
                break
    if cnt > k:
        if left == mid:
            break
        left = mid
    else:
        if right == mid:
            break
        right = mid
print left+1
Problem p03937 (python)

Fixed submission:
h, w = map(int, raw_input().split())
A = [list(raw_input()) for i in xrange(h)]

x = y = 0
A[0][0] = '.'
while 1:
    if y+1 < h and A[y+1][x] == '#':
        A[y+1][x] = '.'
        y += 1
    elif x+1 < w and A[y][x+1] == '#':
        A[y][x+1] = '.'
        x += 1
    else: break
if y == h-1 and x == w-1 and all(all(f is '.' for f in e) for e in A):
    print "Possible"
else:
    print "Impossible"

Buggy submission (verdict: Runtime Error):
n, e, t = map(int, raw_input().split())
X = map(int, raw_input().split())

if n > 2001:
    exit(1)
ans = 0
bef = 0
bef_i = 0

d = [[0 for i in xrange(n)] for j in xrange(n)]
for i in xrange(n):
    el = d[i]
    xi = X[i]
    for j in xrange(i, n):
        el[j] = max(2*(X[j] - xi), t) + X[j] - xi
for i in xrange(n):
    for j in xrange(i):
        d[0][i] = min(d[0][j]+d[j+1][i]+(X[j+1]-X[j]), d[0][i])
print d[0][n-1]+ e - X[-1] + X[0]
Problem p03949 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):
    A, B = map(int, input().split())
    G[A-1].append(B-1)
    G[B-1].append(A-1)
M = {}
K = int(input())
for i in range(K):
    V, P = map(int, input().split())
    M[V-1] = P
memo = [0]*N
def dfs(v, p, x, y):
    if v in M:
        x = y = M[v]
    x0 = x; y0 = y
    for w in G[v]:
        if p == w:
            continue
        s, t = dfs(w, v, x-1, y+1)
        x0 = max(x0, s-1); y0 = min(y0, t+1)
    memo[v] = x0, y0
    return x0, y0
def dfs1(v, p, x, y, c):
    if v in M:
        x = y = M[v]
        if c != (M[v] % 2):
            return 0
    x0, y0 = memo[v]
    x = max(x, x0); y = min(y, y0)
    for w in G[v]:
        if p == w:
            continue
        if not dfs1(w, v, x-1, y+1, c^1):
            return 0
    memo[v] = x, y
    return 1

INF = 10**18
f = list(M.keys())[0]
dfs(f, -1, -INF, INF)
ok = dfs1(f, -1, -INF, INF, M[f]%2)
for i in range(N):
    x, y = memo[i]
    if not x <= y:
        ok = 0
if ok:
    print('Yes')
    print(*map(lambda x: x[1], memo), sep='\n')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):
    A, B = map(int, input().split())
    G[A-1].append(B-1)
    G[B-1].append(A-1)
M = {}
K = int(input())
for i in range(K):
    V, P = map(int, input().split())
    M[V-1] = P
memo = [0]*N
def dfs(v, p, x, y):
    if v in M:
        x = y = M[v]
    x0 = x; y0 = y
    for w in G[v]:
        if p == w:
            continue
        s, t = dfs(w, v, x-1, y+1)
        x0 = max(x0, s-1)
        y0 = min(y0, t+1)
    for w in G[v]:
        if p == w:
            continue
        dfs(w, v, x0-1, y0+1)
    memo[v] = x0, y0
    return x0, y0
INF = 10**18
dfs(list(M.keys())[0], -1, -INF, INF)
ok = 1
for i in range(N):
    x, y = memo[i]
    if not x <= y:
        ok = 0
if ok:
    print('Yes')
    print(*map(lambda x: x[1], memo), sep='\n')
else:
    print('No')
Problem p03997 (python)

Fixed submission:
print(input()+input())*input()/2

Buggy submission (verdict: Runtime Error):
S={c:list(input())for c in"abc"}
s="a"
while S[s]:s=S[s].pop(0)
print(s.upper())
Problem p04014 (python)

Fixed submission:
# seishin.py
from math import sqrt
n, s = map(int, open(0).read().split())

# s = n
if s == n:
    print(n+1)
    exit(0)

def f(b, n):
    res = 0
    while n:
        res += n % b
        n //= b
    return res

# 2 <= b <= sqrt(n)
for b in range(2, int(sqrt(n))+1):
    if f(b, n) == s:
        print(b)
        exit(0)

# sqrt(n) <= b <= n
for p in range(int(sqrt(n)), 0, -1):
    if (n - s) % p > 0:
        continue
    b = (n - s) // p + 1
    if b*b <= n:
        continue
    if f(b, n) == s:
        print(b)
        exit(0)
print(-1)

Buggy submission (verdict: Runtime Error):
# seishin.py
from math import sqrt
n, s = map(int, open(0).read().split())

# s = n
if s == n:
    print(n+1)
    exit(0)

def f(b, n):
    res = 0
    while n:
        res += n % b
        n //= b
    return res

# 2 <= b <= sqrt(n)
for b in range(2, int(sqrt(n))+1):
    if f(b, n) == s:
        print(b)
        exit(0)

# sqrt(n) <= b <= n
for p in range(int(sqrt(n)), 0, -1):
    if (n - s) % p > 0:
        continue
    b = (n - s) // p + 1
    if f(b, n) == s:
        print(b)
        exit(0)
print(-1)
Problem p04017 (python)

Fixed submission:
# seishin.py
N = int(input())
*X, = map(int, input().split())
L = int(input())

K = 20

D = [[N]*(K+1) for i in range(N)]
j = N-1
for i in range(N-1, -1, -1):
    while j > 0 and X[j] - X[i] > L:
        j -= 1
    D[i][0] = j
for k in range(K):
    for i in range(N):
        if D[i][k] != N:
            D[i][k+1] = D[D[i][k]][k]
def solve(a, b):
    if not a < b:
        a, b = b, a
    res = 1
    for k in range(K, -1, -1):
        if D[a][k] < b:
            a = D[a][k]
            res += 2**k
    return res
Q = int(input())
ans = []
for i in range(Q):
    a, b = map(int, input().split())
    ans.append(solve(a-1, b-1))
print(*ans, sep='\n')

Buggy submission (verdict: Runtime Error):
# seishin.py
N = int(input())
*X, = map(int, input().split())
L = int(input())

K = N.bit_length()

D = [[-1] for i in range(N)]
j = N-1
for i in range(N-1, -1, -1):
    while j > 0 and X[j] - X[i] > L:
        j -= 1
    D[i][0] = j
v = 2
for k in range(K):
    for i in range(N-v):
        if i + v < N and len(D[D[i][k]]) == k+1:
            D[i].append(D[D[i][k]][k])
    v <<= 1
def solve(a, b):
    if not a < b:
        a, b = b, a
    res = 1
    v = 2**K
    for k in range(K, -1, -1):
        if a + v < N-1 and D[a][k] < b:
            a = D[a][k]
            res += v
        v >>= 1
    return res
Q = int(input())
ans = []
for i in range(Q):
    a, b = map(int, input().split())
    ans.append(solve(a-1, b-1))
print(*ans, sep='\n')
Problem p02946 (python)

Fixed submission:
K,X = map(int,input().split())
L1 = list(range(X-K+1,X+K))
L1_str = [str(n) for n in L1]
L2 = ' '.join(L1_str)
print(L2)

Buggy submission (verdict: Runtime Error):
K,X = map(int,input().split())
L1 = list(range(X-K+1,X+K-1))
L2 =' '.join(L1)
print(L2)
Problem p02952 (python)

Fixed submission:
N = int(input())
sum = 0
for i in range(1,N+1):
  if len(str(i)) % 2 == 1:
    sum += 1
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range[1,N+1]:
  if len(str(i)) % 2 == 1:
    sum += 1
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range[1,N+1]:
  if len(i) % 2 == 1:
    sum += 1
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range[1,N+1]:
  if len(i) // 2:
    i += 1
  else:
    sum += 1
    i += 1
print(sum)
Problem p02957 (python)

Fixed submission:
A,B = map(int,input().split()) 
if (A+B) % 2 == 0:
  print(int((A+B)/2))
else:
  print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split()) 
if (A % 2) == (B % 2):
  print(abs((A+B)/2))
else:
  print(IMPOSSIBLE)
Problem p02969 (python)

Fixed submission:
r = int(input())
print(3*r**2)

Buggy submission (verdict: Runtime Error):
r = int(input())
print(3r**2)
Problem p02988 (python)

Fixed submission:
n=int(input())
p = list(map(int, input().split()))
sum = 0
for i in range(1,n-1):
  if p[i+1]>p[i]>p[i-1] or p[i-1]>p[i]>p[i+1]:
    sum +=1
print(sum)

Buggy submission (verdict: Runtime Error):
n=int(input())
p = list(map(int, input().split()))
sum = 0
for i in range(1,n):
  if p[i+1]>p[i]>p[i-1] or p[i-1]>p[i]>p[i+1]:
    sum +=1
print(sum)
Problem p04029 (python)

Fixed submission:
N = int(input())
sum = 0
for i in range(0,N+1):
  sum+=i
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range(0,N+1):
  sum + i = sum
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range(0,N):
  sum + i = sum
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i  in N:
  sum + i = sum
print(sum)
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

def dfs(graph, node, dist):
    if graph[node-1][2] == 1:
        return
    else:
        graph[node-1][2] = 1
        graph[node-1][3] += dist
        if graph[node-1][3] % 2 == 0:
            graph[node-1][4] = 1
        else:
            pass
        ll = graph[node-1][0]
        for i in range(len(ll)):
            dfs(graph, ll[i], graph[node-1][3] + graph[node-1][1][i]);

def main():
    n = int(input())
    edge = []
    for i in range(n-1): edge.append(list(map(int,input().split())))

# graph[[node, node, ...], [dist, dist, ...], [reached or not], 
#       [dist from root], [color]]
    graph = [[[],[],0,0,0] for i in range(n)]
    for i in range(n-1):
        node1 = edge[i][0]
        node2 = edge[i][1]
        weight = edge[i][2]
        graph[node1-1][0].append(node2)
        graph[node2-1][0].append(node1)
        graph[node1-1][1].append(weight)
        graph[node2-1][1].append(weight)
    
    dfs(graph, 1, 0)
    for i in range(n):
        print(graph[i][4])

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def dfs(graph, node, dist):
    if graph[node-1][2] == 1:
        return
    else:
        graph[node-1][2] = 1
        graph[node-1][3] += dist
        if graph[node-1][3] % 2 == 0:
            graph[node-1][4] = 1
        else:
            pass
        ll = graph[node-1][0]
        for i in range(len(ll)):
            dfs(graph, ll[i], graph[node-1][3] + graph[node-1][1][i]);

def main():
    n = int(input())
    edge = []
    for i in range(n-1): edge.append(list(map(int,input().split())))

# graph[[node, node, ...], [dist, dist, ...], [reached or not], 
#       [dist from root], [color]]
    graph = [[[],[],0,0,0] for i in range(n)]
    for i in range(n-1):
        node1 = edge[i][0]
        node2 = edge[i][1]
        weight = edge[i][2]
        graph[node1-1][0].append(node2)
        graph[node2-1][0].append(node1)
        graph[node1-1][1].append(weight)
        graph[node2-1][1].append(weight)
    
    dfs(graph, 1, 0)
    for i in range(n):
        print(graph[i][4])

if __name__ == "__main__":
    main()
Problem p03050 (python)

Fixed submission:
n = int(input())
if n == 1:
  print(0)
  quit()
else:
  res = n-1 if n%(n-1) == int(n/(n-1)) else 0
i = 2
while i*i <= n:
  if n%i == 0:
    if n%(i-1) == int(n/(i-1)):
      res += i-1
    if i*i != n:
      if n%(int(n/i)-1) == int(n/(int(n/i)-1)):
        res += int(n/i) - 1
  else:
    pass
  i += 1
print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
res = n-1 if n%(n-1) == int(n/(n-1)) else 0
i = 2
while i*i <= n:
  if n%i == 0:
    if n%(i-1) == int(n/(i-1)):
      res += i-1
    if i*i != n:
      if n%(int(n/i)-1) == int(n/(int(n/i)-1)):
        res += int(n/i) - 1
  else:
    pass
  i += 1
print(res)
Problem p03071 (python)

Fixed submission:
a,b = list(map(int,input().split()))
s = 0
if a >= b:
    s += a
    a -= 1
else:
    s += b
    b -= 1
s += max(a,b)
print(s)

Buggy submission (verdict: Runtime Error):
n,k = list(map(int, input().split()))
s = input()
if s[n-1] == '1':
	s += '0'
else:
	s += '1'
c = []

j = 0
for i in range(1, n+1):
	if s[i-1] == s[i]:
		j += 1
	else:
		c.append([s[i-1], j+1])
		j = 0

for i in range(1, len(c)):
	c[i][1] += c[i-1][1]

if 2*k >= 2*len(c):
	print(c[-1][1])
	quit()
else:
	p = 0
	res = 0
	if s[0][0] == '0':
		res = c[1][1] if k == 1 else c[2*k+1][1]
		p += 1
	else:
		res = c[2][1] if k == 1 else c[2*k][1]
		p += 2

	while p+2*k < len(c):
		res = max(res, c[p+2*k][1] - c[p-1][1])
		p += 2

	print(res)
	quit()

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))
ans = 1
for i in range(1,n):
    flag = 1
    for j in range(i):
        if h[j] > h[i]:
            flag = 0
            break
        else:
            pass
    if flag:
        ans += 1
print(ans)
Problem p03128 (python)

Fixed submission:
if __name__ == "__main__":
  l = [0,2,5,5,4,5,6,3,7,6]
  n,m = list(map(int,input().split()))
  a = list(map(int,input().split()))
  res = ''
  INF = 10**4
  
  dp = [[0,0] for i in range(n+1)]
  for i in range(n):
    for j in range(m):
      if dp[i][1] + l[a[j]] != i + l[a[j]] or i + l[a[j]] > n:
        pass
      else:
        dp[i + l[a[j]]][0] = max(dp[i][0] + 1, dp[i + l[a[j]]][0])
        dp[i + l[a[j]]][1] = dp[i][1] + l[a[j]]
  for i in range(1,n): dp[i][0] = -INF if dp[i][0] == 0 else dp[i][0]
  
  a.sort(reverse = True)
  i = n
  while i > 0:
    for j in range(m):
      if i >= l[a[j]] and dp[i - l[a[j]]][0] + 1 == dp[i][0]:
        res += str(a[j])
        i -= l[a[j]]
        break
      else:
        pass
  print(res)

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
  l = [0,2,5,5,4,5,6,3,7,6]
  n,m = list(map(int,input().split()))
  a = list(map(int,input().split()))
  res = ''
  INF = 10**4
  
  dp = [[0,0] for i in range(n+1)]
  for i in range(n):
    for j in range(m):
      if dp[i][1] + l[a[j]] != i + l[a[j]] or i + l[a[j]] > n:
        pass
      else:
        dp[i + l[a[j]]][0] = max(dp[i][0] + 1, dp[i + l[a[j]]][0])
        dp[i + l[a[j]]][1] = dp[i][1] + l[a[j]]
  for i in range(1,n): 
    if dp[i][0] == 0:
      dp[i][0] = -INF
    else:
      pass
  
  a.sort(reverse = True)
  i = n
  while i > 0:
    for j in range(m):
      if dp[i - l[a[j]]][0] + 1 == dp[i][0]:
        res += str(a[j])
        i -= l[a[j]]
        break
      else:
        pass
  print(res)

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
  l = [0,2,5,5,4,5,6,3,7,6]
  n,m = list(map(int,input().split()))
  a = list(map(int,input().split()))
  res = ''
  INF = 10**4
  
  dp = [[0,0] for i in range(n+1)]
  for i in range(n):
    for j in range(m):
      if dp[i][1] + l[a[j]] != i + l[a[j]] or i + l[a[j]] > n:
        pass
      else:
        dp[i + l[a[j]]][0] = max(dp[i][0] + 1, dp[i + l[a[j]]][0])
        dp[i + l[a[j]]][1] = dp[i][1] + l[a[j]]
  for i in range(1,n): dp[i][0] = -INF if dp[i][0] == 0 else dp[i][0]
  
  a.sort(reverse = True)
  i = n
  for k in range(dp[n][0], 0, -1):
    for j in range(m):
      if dp[i - l[a[j]]][0] + 1 == dp[i][0]:
        res += str(a[j])
        i -= l[a[j]]
        break
      else:
        pass
  print(res)
Problem p03145 (python)

Fixed submission:
l=list(map(int,input().split()))
l.sort()
print(int(0.5*l[0]*l[1]))

Buggy submission (verdict: Runtime Error):
    l=list(map(int,input().split()))
    l.sort()
    print(int(0.5*l[0]*l[1]))
Problem p03206 (python)

Fixed submission:
D = int(input())
print('Christmas' + ' Eve'*(25-D))

Buggy submission (verdict: Runtime Error):
N = int(input())
h = list(map(int, input().split()))
h.append(0)
count=0
while 1:
  flag=0
  for i in range(N):
    if h[i]>0:
      h[i] -= 1
      flag = 1
      if h[i+1]==0:
        count+=1
      else:
        pass
  if flag==0:
    break
print(count)
Problem p03324 (python)

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

if not N==100:
    print(N*pow(100, D))
else:
    print(101*pow(100, D))

Buggy submission (verdict: Runtime Error):
if not N==100:
    print(N*pow(100, D))
else:
    print(101*pow(100, D))

Buggy submission (verdict: Runtime Error):
if N==100:
    print((N+1)*pow(100, D))
else:
    print(N*pow(100, D))
Problem p03331 (python)

Fixed submission:
import math
N=int(input())
i=2
digitSum=pow(10,5)
A=int(2)
while i<=int(N/2)+1:
    A=i
    B=N-A
    A_digitsum=0
    while A>=10:
        A_digitsum += A%10
        A = A//10
    if A<10:
        A_digitsum+=A
    B_digitsum=0
    while B>=10:
        B_digitsum += B%10
        B = B//10
    if B<10:
        B_digitsum+= B
    if digitSum > A_digitsum+B_digitsum:
        digitSum = A_digitsum+B_digitsum
    i+=1
print(digitSum)

Buggy submission (verdict: Runtime Error):
import math
N=int(input())
i=2
digitSum=pow(10,5)
while A<math.sqrt(N):
    A=i
    B=N-A
    A_digitsum=0
    while A>10:
        A_digitsum += N%10
        A = A//10
    while B>10:
        B_digitsum += N%10
        B = B//10
    if digitSum > A_digitsum+B_digitsum:
        digitSum = A_digitsum+B_digitsum
print(digitSum)
Problem p03359 (python)

Fixed submission:
a,b=list(map(int, input().split()))
if a<=b:
    print(a)
else:
    print(a-1)

Buggy submission (verdict: Runtime Error):
a,b=list(map(int, input().aplit()))
if a<=b:
    print(a)
else:
    print(a-1)
Problem p03415 (python)

Fixed submission:
grid=[]
for i in range(3):
    grid.append(input())
S=''
for i in range(3):
    S=S+grid[i][i]
print(S)

Buggy submission (verdict: Runtime Error):
grid=[]
for i in range(3):
    grid.append(list(map(int,input().split())))
S=''
for i in range(3):
    S=S+grid[i][i]
print(S)
Problem p03424 (python)

Fixed submission:
N=int(input())
S=list(map(str,input().split()))
bucket=[0*i for i in range(4)]
for i in range(N):
    if S[i]=='P':
        bucket[0]+=1
    elif S[i]=='W':
        bucket[1]+=1
    elif S[i]=='G':
        bucket[2]+=1
    else:
        bucket[3]+=1
if 4 - bucket.count(0)==3:
    print('Three')
else:
    print('Four')

Buggy submission (verdict: Runtime Error):
N=int(input())
S=list(map(int,input().split()))
bucket=[]
for i in range(N):
    if S[i]=='P':
        bucket[0]+=1
    elif S[i]=='W':
        bucket[1]+=1
    elif S[i]=='G':
        bucket[2]+=1
    else:
        bucket[3]+=1
if 4 - bucket.count(0)==3:
    print('Three')
else:
    print('Four')
Problem p03434 (python)

Fixed submission:
N = int(input())
numbers = list(map(int, input().split()))
Alice_point = 0
Bob_point = 0

numbers.sort(reverse=True)

while True:
    try:
        Alice_point += numbers[0]
        Bob_point += numbers[1]
        numbers.remove(numbers[0])
        numbers.remove(numbers[0])
    except IndexError:
        break

print(Alice_point - Bob_point)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

#N枚のカードがあり、i枚目のカードにはaiという数が書かれています。
#AliceとBobはこれらのカードを使ってゲームを行います。ゲームでは2人が交互に1枚ずつカードを取っていきます。Aliceが先にカードを取ります。
#2人が全てのカードを取った時ゲームは終了し、取ったカードの数の合計がその人の得点になります。2人とも自分の得点を最大化するように最適戦略を取った時、AliceはBobより何点多く獲得できるかを求めてください。

#1<=N<=100, 1<=ai<=100, 入力は整数
#数値例 N=3, a=(2,7,4), Answer: 5

N = int(input())
numbers = list(map(int, input().split()))
Alice_point = 0
Bob_point = 0

numbers.sort()
print(numbers)

while True:
    Alice_point += numbers[0]
    try:
        Bob_point += numbers[1]
        numbers.remove(numbers[0])
        numbers.remove(numbers[0])
    except IndexError:
        break

print(Alice_point - Bob_point)
Problem p03435 (python)

Fixed submission:
gridNumber = []
numbers = []
for i in range(3):
    gridNumber.append(list(map(int, input().split())))

a1=0
b1=gridNumber[0][0] - a1
b2=gridNumber[0][1] - a1
b3=gridNumber[0][2] - a1

a2=gridNumber[1][0] - b1
a3=gridNumber[2][0] - b1

numbers.append([a1+b1, a1+b2, a1+b3])
numbers.append([a2+b1, a2+b2, a2+b3])
numbers.append([a3+b1, a3+b2, a3+b3])

for i in range(3):
    for j in range(3):
        if not(numbers[i][j] == gridNumber[i][j]):
            print("No")
            quit()
        else:
            pass

print("Yes")

Buggy submission (verdict: Runtime Error):
gridNumber = []
numbers = []
for i in range(3):
    gridNumber.append(list(map(int, input().split())))

a1=0
b1=gridNumber[0][0] - a1
b2=gridNumber[1][0] - a1
b3=gridNumber[2][0] - a1

a2=gridNumber[2][0] - b1
a3=gridNumber[3][0] - b1

numbers.append([a1+b1, a1+b2, a1+b3])
numbers.append([a2+b1, a2+b2, a2+b3])
numbers.append([a3+b1, a3+b2, a3+b3])

for i in range(3):
    for j in range(3):
        if not(numbers[i][j] == gridNumber[i][j]):
            print("No")
            quit()
        else:
            pass

print("Yes")
Problem p03447 (python)

Fixed submission:
X=int(input())
A=int(input())
B=int(input())
X=X-A
while X>=B:
    X=X-B
print(X)

Buggy submission (verdict: Runtime Error):
N=int(input())
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
B1=[0*i for i in range(N)]
B2=[0*i for i in range(N)]

B1[0]=A1[0]
B2[0]=A2[0]
for i in range(0,N-1):
    B1[i+1]=B1[i]+A1[i+1]
    B2[i+1]=B2[i]+A2[i+1]
maximum=B1[0]+B2[N-1]
for i in range(1,N):
    point=B1[i]+(B2[N-1]-B2[i-1])
    maximum=max(maximum,point)
print(maximum)
Problem p03449 (python)

Fixed submission:
N=int(input())
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
B1=[0*i for i in range(N)]
B2=[0*i for i in range(N)]

B1[0]=A1[0]
B2[0]=A2[0]
for i in range(0,N-1):
    B1[i+1]=B1[i]+A1[i+1]
    B2[i+1]=B2[i]+A2[i+1]
maximum=B1[0]+B2[N-1]
for i in range(1,N):
    point=B1[i]+(B2[N-1]-B2[i-1])
    maximum=max(maximum,point)
print(maximum)

Buggy submission (verdict: Runtime Error):
N=int(input())
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
B1=[0*i for i in range(N)]
B2=[0*i for i in range(N)]

B1[0]=A1[0]
B2=[0]=A2[0]
for i in range(0,N-1):
    B1[i+1]=B1[i]+A1[i+1]
    B2[i+1]=B2[i]+A2[i+1]
maximum=B1[0]+B2[N-1]
for i in range(1,N):
    point=B1[i]+(B2[N-1]-B2[i-1])
    maximum=max(maximum,point)
print(maximum)

Buggy submission (verdict: Runtime Error):
N=int(input())
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
B1=[0*i for i in range(N)]
B2=[0*i for i in range(N)]

B1[0]=A1[0]
B2=[0]=A2[0]
for i in range(0,N-1):
    B1[i+1]=B1[i]+A1[i+1]
    B2[i+1]=B2[i]+A2[i+1]
maximum=B1[0]+B2[N-1]
for i in range(1,N):
    point=B1[i]+(B2[N-1]-B2[i-1])
    maximum=max(maximum,point)
print(maximum)
Problem p03457 (python)

Fixed submission:
N=int(input())
Destinations=[[0,0,0]]
for i in range(N):
    Destinations.append(list(map(int, input().split())))

for i in range(N):
    x_distance = Destinations[i+1][1] - Destinations[i][1]
    y_distance = Destinations[i+1][2] - Destinations[i][2]
    if x_distance < 0:
        x_distance = -x_distance
    if y_distance < 0:
        y_distance = -y_distance
    move_distance = x_distance+y_distance

    move_time = Destinations[i+1][0] - Destinations[i][0]

    if move_distance == 0:
        print("No")
        break

    if move_distance > move_time*1:
        print("No")
        break
    elif move_distance%2 == move_time%2:
        pass
    else:
        print("No")
        break

    if i == N-1:
        print("Yes")

Buggy submission (verdict: Runtime Error):

N=int(input())
Destinations=[[0,0,0]]
for i in range(N):
    Destinations.append(list(map(int, input().split())))

for i in range(N-1):
    x_distance = Destinations[i+1][1] - Destinations[i][1]
    y_distance = Destinations[i+1][2] - Destination[i][2]
    if x_distance < 0:
        x_distance = -x_distance
    if y_distance < 0:
        y_distance = -y_distance
    move_distance = x_distance+y_distance

    move_time = Destinations[i+1][0] Destinations[i][0]

    if move_distance == 0:
        print("No")

    if move_distance > move_time*1:
        print("No")
    elif move_distance%2 == move_time%2:
        print("Yes")
    else:
        print("No")