Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
def input(itr=iter(sys.stdin.readlines())):  # pylint: disable= redefined-builtin
    return next(itr).rstrip('\n\r')
###############################################################################

from networkx.utils.union_find import UnionFind

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

uf = UnionFind()
responses = []
for _ in range(Q):
    uq, u, v = map(int, input().split())
    if uq == 0:
        uf.union(u, v)
    else:
        responses.append(1 if uf[u] == uf[v] else 0)

print(*responses, sep='\n')


Fixed submission:
import sys
def input(itr=iter(sys.stdin.readlines())):  # pylint: disable= redefined-builtin
    return next(itr).rstrip('\n\r')
###############################################################################

from networkx.utils.union_find import UnionFind

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

uf = UnionFind()
responses = []
for _ in range(Q):
    uq, u, v = map(int, input().split())
    if uq == 0:
        uf.union(u, v)
    else:
        responses.append(1 if uf[u] == uf[v] else 0)

print(*responses, sep='\n')
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

def diff(a, b):
    return sum(aa != bb for aa, bb in zip(a, b))

answer = min( diff(S[i: i+len(T)], T) for i in range(len(S)-len(T)) )
print(answer)


Fixed submission:
S = input()
T = input()

def diff(a, b):
    return sum(aa != bb for aa, bb in zip(a, b))

answer = min( diff(S[i: i+len(T)], T) for i in range(len(S)-len(T)+1) )
print(answer)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
print(sum(s != t for s, t in zip(S, T)))

Fixed submission:
a = int(input())
print(a + a**2 + a**3)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
print(sum(s != t for s, t in zip(S, T))

Fixed submission:
S = input()
T = input()
print(sum(s != t for s, t in zip(S, T)))
Buggy python submission (verdict: Runtime Error):
import sys
def input(itr=iter(sys.stdin.readlines())):  # pylint: disable= redefined-builtin
    return next(itr).rstrip('\n\r')
###############################################################################

import collections
import math as m
from fractions import Fraction

MOD = 1000000007

N = int(input())
Sardine = collections.namedtuple("Sardine", "A B")
sardines = [Sardine(*map(int, input().split())) for _ in range(N)]

def slope(sardine):
    if sardine.A == sardine.B == 0:
        return None
    elif sardine.B == 0:
        return m.inf
    else:
        return Fraction(sardine.A, sardine.B)

def perpendicular(slope):
    if slope == 0:
        return m.inf
    elif slope == m.inf:
        return 0
    else:
        return -1 / slope

groups = collections.Counter(slope(s) for s in sardines)
if groups[None]:
    zeroes = groups[None]
    del groups[None]
else:
    zeroes = 0

ways = 1
while groups:
    slope, count = groups.popitem()
    perp_slope = perpendicular(slope)
    perp_count = groups[perp_slope]

    ways *= (pow(2, count, MOD) + pow(2, perp_count, MOD) - 1) % MOD
    ways %= MOD

    del groups[perp_slope]

output = (ways-1 + zeroes) % MOD
print(output)


Fixed submission:
counters = {
    'hon': {2, 4, 5, 7, 9},
    'pon': {0, 1, 6, 8},
    'bon': {3},
}

N = input()
for k, v in counters.items():
    if int(str(N)[-1]) in v:
        print(k)
        break
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
count = 0
for i in range(1,n):
    for j in range(1,n):
        if i*j <= n-1:
            count += 1
        else:
            continue
print(count)


Fixed submission:
import math
n = int(input())
count = 0
for i in range(1,n):
    for j in range(i,n):
        if i*j <= n-1:
            if i != j:
                count += 2
            else:
                count += 1
        else:
            break
print(count)
Buggy python submission (verdict: Runtime Error):
x,k,d = [int(x) for x in input().split()]
t = abs(int(x/d))
if x < 0:
    d = -d
if t >= k:
    print(x-d*k)
elif t == 0:
    if k % 2 == 0:
        print(abs(x))
    else:
        print(min(abs(x-d),abs(x+d)))
elif t < k:
    if abs(x-d*t) < abs(x-d*t-d):
        if (t-k)%2==0:
            print(abs(x-d*t))
        else:
            print(min(abs(x-d*t+d),abs(x-d*t-d)))
    elif abs(x-d*t) = abs(x-d*t-d):
        print(abs(x-d*t))
    else:
        if (t-k-1)%2==0:
            print(abs(x-d*t-d))
        else:
            print(min(abs(x-d*t),abs(x-d*t-2*d)))


Fixed submission:
x,k,d = [int(x) for x in input().split()]
t = abs(int(x/d))
if x < 0:
    d = -d
if t >= k:
    print(abs(x-d*k))
elif t == 0:
    if k % 2 == 0:
        print(abs(x))
    else:
        print(min(abs(x-d),abs(x+d)))
elif t < k:
    if abs(x-d*t) < abs(x-d*t-d):
        if (k-t)%2==0:
            print(abs(x-d*t))
        else:
            print(min(abs(x-d*t+d),abs(x-d*t-d)))
    elif abs(x-d*t) == abs(x-d*t-d):
        print(abs(x-d*t))
    else:
        if (k-t-1)%2==0:
            print(abs(x-d*t-d))
        else:
            print(min(abs(x-d*t),abs(x-d*t-2*d)))

Buggy python submission (verdict: Runtime Error):
x,k,d = [int(x) for x in input().split()]
t = abs(int(x/d))
if x < 0:
    d = -d
if t >= k:
    print(x-d*k)
elif t == 0:
    if k % 2 == 0:
        print(abs(x))
    else:
        print(min(abs(x-d),abs(x+d)))
elif t < k:
    if abs(x-d*t) < abs(x-d*t-d):
        if (t-k)%2==0:
            print(abs(x-d*t))
        else:
            print(min(abs(x-d*t+d),abs(x-d*t-d)))
    elif  abs(x-d*t) = abs(x-d*t-d):
        print(abs(x-d*t))
    else:
        if (t-k-1)%2==0:
            print(abs(x-d*t-d))
        else:
            print(min(abs(x-d*t),abs(x-d*t-2*d)))


Fixed submission:
x,k,d = [int(x) for x in input().split()]
t = abs(int(x/d))
if x < 0:
    d = -d
if t >= k:
    print(abs(x-d*k))
elif t == 0:
    if k % 2 == 0:
        print(abs(x))
    else:
        print(min(abs(x-d),abs(x+d)))
elif t < k:
    if abs(x-d*t) < abs(x-d*t-d):
        if (k-t)%2==0:
            print(abs(x-d*t))
        else:
            print(min(abs(x-d*t+d),abs(x-d*t-d)))
    elif abs(x-d*t) == abs(x-d*t-d):
        print(abs(x-d*t))
    else:
        if (k-t-1)%2==0:
            print(abs(x-d*t-d))
        else:
            print(min(abs(x-d*t),abs(x-d*t-2*d)))
Buggy python submission (verdict: Time Limit Exceeded):
N,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
score = 1
tmp = 0
for i in range(K):
    score *= A[i]
for j in range(N-K):
    tmp = score
    score = score * A[j+K] / A[j]
    if score > tmp:
        print("Yes")
    else:
        print("No")


Fixed submission:
N,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
for j in range(N-K):
    if A[j+K] > A[j]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
N,M = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]
X = sorted(X)
dis = [0 for x in range(M-1)]
for i in range(M-1):
    dis[i] = X[i+1] - X[i]
dis.sort()
dis.reverse()
for i in range(N-1):
    dis[i] = 0
print(sum(dis))


Fixed submission:
import sys
N,M = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]
if N >= M:
    print(0)
    sys.exit()
X = sorted(X)
dis = [0 for x in range(M-1)]
for i in range(M-1):
    dis[i] = X[i+1] - X[i]
dis.sort()
dis.reverse()
for i in range(N-1):
    dis[i] = 0
print(sum(dis))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
S = input()
T = input()
tmp = {}
for i in range(len(S)):
    if S.count(S[i]) > 1:
        if S[i] not in tmp:
            tmp[S[i]] = T[i]
        elif tmp[S[i]] == T[i]:
            pass
        else:
            print("No")
            sys.exit()
tmp = {}
for i in range(len(T)):
    if T.count(T[i]) > 1:
        if T[i] not in tmp:
            tmp[T[i]] = S[i]
        elif tmp[T[i]] == S[i]:
            pass
        else:
            print("No")
            sys.exit()
print("Yes")


Fixed submission:
import sys
S = input()
T = input()
tmp1 = [set() for i in range(26)]
tmp2 = [set() for i in range(26)]
alpha2num = lambda c: ord(c) - ord('a')
for i in range(len(S)):
    tmp1[alpha2num(S[i])].add(T[i])
    tmp2[alpha2num(T[i])].add(S[i])
for i in range(26):
    if len(tmp1[i]) > 1 or len(tmp2[i]) > 1:
        print("No")
        sys.exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):

input = sys.stdin.readline

S = input()
T = input()

result = float('inf')
for i in range(len(S) - len(T) + 1):
    t = 0
    for j in range(len(T)):
        if S[i + j] != T[j]:
            t += 1
    result = min(result, t)
print(result)


Fixed submission:
S = input()
T = input()

result = float('inf')
for i in range(len(S) - len(T) + 1):
    t = 0
    for j in range(len(T)):
        if S[i + j] != T[j]:
            t += 1
    result = min(result, t)
print(result)
Buggy python submission (verdict: Runtime Error):
from collections import deque
import sys, copy,itertools
input = sys.stdin.readline

n, k = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = [-10**12] * n
#print(ans)

q = k // n
mod = k % n

POINT = [[-10**12 for i in range(n)] for j in range(k)]
PLACE = [[0 for i in range(n)] for j in range(k)]
for i in range(n):
  POINT[0][i] = C[P[i]-1]  
  PLACE[0][i] = P[i]-1 #P[i]は1スタートなのでずれる

tempmax= max(POINT[0])

z = min(k,n)

for j in range(1,z): #日付
  for i in range(n):
    PLACE[j][i]=P[PLACE[j-1][i]]-1
    POINT[j][i]=POINT[j-1][i] + C[PLACE[j][i]]
    tempmax = max(tempmax,POINT[j][i])

tt = -10**-12
if k <= n:
  answer = tempmax
else:
  for i in range(n):
    ans[i] = q * POINT[n][i]
    for j in range(mod):
      tt = max(tt, POINT[j][i])
    ans[i] += tt
print(max[answer])

Fixed submission:
from collections import deque
import sys, copy,itertools
input = sys.stdin.readline

n, k = map(int,input().split())
#P = list(map(int,input().split()))
P = list(map(lambda x : int(x) - 1, input().split())) #ひとつづつずらす
C = list(map(int,input().split()))
SCORE = [0]*(n+1)

max_score = -10**12
for i in range(n):
  x = i
  TEMPMAX = [-10**9] * (n+1)
  for j in range(1, n+1):
    SCORE[j] = SCORE[j-1] + C[P[x]]
    TEMPMAX[j]= max(TEMPMAX[j-1], SCORE[j])
    x = P[x]
    if x == i:
      break
  if j >= k:
    max_score = max(max_score,TEMPMAX[k])
  elif SCORE[j] < 0:
    max_score = max(max_score, TEMPMAX[j])
  else:
    m = k//j
    a = SCORE[j] *(m-1) + TEMPMAX[j]
    b = SCORE[j] *m + TEMPMAX[k % j]
    max_score = max(max_score, a, b)
print(max_score)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import sys, copy,itertools
input = sys.stdin.readline

n, k = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))

POINT = [[-10**12 for i in range(n)] for j in range(k)]
PLACE = [[0 for i in range(n)] for j in range(k)]
for i in range(n):
  POINT[0][i] = C[P[i]-1]  
  PLACE[0][i] = P[i]-1 #P[i]は1スタートなのでずれる
  #A[0][i] = C[P[i]]
#print(PLACE)
#print(POINT)

tempmax= max(POINT[0])

for j in range(1,k): #日付
  for i in range(n):
    PLACE[j][i]=P[PLACE[j-1][i]]-1
    POINT[j][i]=POINT[j-1][i] + C[PLACE[j][i]]
    tempmax = max(tempmax,POINT[j][i])

#print(PLACE)
#print(POINT)
print(tempmax)

Fixed submission:
from collections import deque
import sys, copy,itertools
input = sys.stdin.readline

n, k = map(int,input().split())
#P = list(map(int,input().split()))
P = list(map(lambda x : int(x) - 1, input().split())) #ひとつづつずらす
C = list(map(int,input().split()))
SCORE = [0]*(n+1)

max_score = -10**12
for i in range(n):
  x = i
  TEMPMAX = [-10**9] * (n+1)
  for j in range(1, n+1):
    SCORE[j] = SCORE[j-1] + C[P[x]]
    TEMPMAX[j]= max(TEMPMAX[j-1], SCORE[j])
    x = P[x]
    if x == i:
      break
  if j >= k:
    max_score = max(max_score,TEMPMAX[k])
  elif SCORE[j] < 0:
    max_score = max(max_score, TEMPMAX[j])
  else:
    m = k//j
    a = SCORE[j] *(m-1) + TEMPMAX[j]
    b = SCORE[j] *m + TEMPMAX[k % j]
    max_score = max(max_score, a, b)
print(max_score)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import sys
input = sys.stdin.readline

k = int(input())
n = 7
ans = -1

for i in range(10**6): #注意
  if n % k  == 0:
    ans = i+1
    break
  else:
    n =  n*10 + 7
    
print(ans)

Fixed submission:
from collections import deque
import sys
input = sys.stdin.readline
 
k = int(input())
n = 7
ans = -1
 
for i in range(10**6): #注意
  if n % k  == 0:
    ans = i+1
    break
  else:
    n =  (n % k) *10 + 7
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math

N = int(input())
S = input()
PW = []

for i in range(N-2):
    A = S[i]
    for j in range(i+1, N-1):
        B = S[j]
        for k in range(j+1, N):
            C = S[k]
            T = A + B + C
            if T in PW:
                continue
            else:
                PW.append(T)


ans = len(PW)

print(ans)

Fixed submission:
import sys
import math

N = int(input())
S = input()
ans = 0

for i in range(10):
    a = S.find(str(i))
    if a == -1:
        continue
    for j in range(10):
        b = S.find(str(j), a+1)
        if b == -1:
            continue
        for k in range(10):
            if S.find(str(k), b+1) != -1:
                ans += 1


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math

N = int(input())
S = input()
PW = []

for i in range(N-2):
    A = S[i]
    for j in range(i+1, N-1):
        B = S[j]
        for k in range(j+1, N):
            C = S[k]
            T = A + B + C
            if T in PW:
                continue
            else:
                PW.append(T)


ans = len(PW)

print(ans)

Fixed submission:
import sys
import math

N = int(input())
S = input()
ans = 0

for i in range(10):
    a = S.find(str(i))
    if a == -1:
        continue
    for j in range(10):
        b = S.find(str(j), a+1)
        if b == -1:
            continue
        for k in range(10):
            if S.find(str(k), b+1) != -1:
                ans += 1


print(ans)
Buggy python submission (verdict: Runtime Error):
import sys    #インタプリタや実行環境に関する情報を扱うためのライブラリ
import os     #フォルダやファイルを操作
import math

N=input()
count=0

for i in range(N):
    if i==0:
        continue
    if i<10:
        count +=1
    elif i<1000:
        count +=1
    elif i<100000:
        count+=1

print(count)
input()



Fixed submission:
import sys    #インタプリタや実行環境に関する情報を扱うためのライブラリ
import os     #フォルダやファイルを操作
import math

N=int(input())
count=0

for i in range(N+1):
    if i==0:
        continue
    if i<10:
        count +=1
    if i<100:
        continue
    elif i<1000:
        count +=1
    elif i<10000:
        continue
    elif i<100000:
        count+=1

print(count)
Buggy python submission (verdict: Runtime Error):
from collections import deque
import sys
input = sys.stdin.readline

h,w = map(int,input().split())
MAP = [list(input().rstrip()) for i in range(h)]  #rstripで最後の/nを省ける
sharp = 0
for i in range(h):
  sharp += MAP[i].count("#")
#print(sharp)

#必要なもの MAP(list), MOVE(list), STACK(deque)
MAP[0][0]=1
MOVE = [[1,0],[-1,0],[0,1],[0,-1]]
STACK = deque([(0,0)])
while STACK:
  y, x = STACK.popleft()
  for dy,dx in MOVE:
    ny = y + dy
    nx = x + dx
    if not(0 <= ny < h) or not(0 <= nx < w) or MAP[ny][nx]!='.':
      continue
    else:
      STACK.append((ny,nx))
      MAP[ny][nx] = MAP[y][x] + 1

ans = h*w -MAP[h-1][w-1]-sharp
#print(MAP)
print(ans)

Fixed submission:
from collections import deque
import sys
input = sys.stdin.readline

h,w = map(int,input().split())
MAP = [list(input().rstrip()) for i in range(h)]  #rstripで最後の/nを省ける
sharp = 0
for i in range(h):
  sharp += MAP[i].count("#")
#print(sharp)

#必要なもの MAP(list), MOVE(list), STACK(deque)
MAP[0][0]=1
MOVE = [[1,0],[-1,0],[0,1],[0,-1]]
STACK = deque([(0,0)])
while STACK:
  y, x = STACK.popleft()
  for dy,dx in MOVE:
    ny = y + dy
    nx = x + dx
    if not(0 <= ny < h) or not(0 <= nx < w) or MAP[ny][nx]!='.':
      continue
    else:
      STACK.append((ny,nx))
      MAP[ny][nx] = MAP[y][x] + 1


if type(MAP[h-1][w-1]) == int:
  ans = h*w -MAP[h-1][w-1]-sharp
else:
  ans = -1
    
print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import deque
import sys
input = sys.stdin.readline

h,w = map(int,input().split())
MAP = [list(input().rstrip()) for i in range(h)]  #rstripで最後の/nを省ける
sharp = 0
for i in range(h):
  sharp += MAP[i].count("#")
#print(sharp)

#必要なもの MAP(list), MOVE(list), STACK(deque)
MAP[0][0]=1
MOVE = [[1,0],[-1,0],[0,1],[0,-1]]
STACK = deque([(0,0)])
while STACK:
  y, x = STACK.popleft()
  for dy,dx in MOVE:
    ny = y + dy
    nx = x + dx
    if not(0 <= ny < h) or not(0 <= nx < w) or MAP[ny][nx]!='.':
      continue
    else:
      STACK.append((ny,nx))
      MAP[ny][nx] = MAP[y][x] + 1

ans = h*w -MAP[h-1][w-1]-sharp
#print(MAP)
print(ans)

Fixed submission:
from collections import deque
import sys
input = sys.stdin.readline

h,w = map(int,input().split())
MAP = [list(input().rstrip()) for i in range(h)]  #rstripで最後の/nを省ける
sharp = 0
for i in range(h):
  sharp += MAP[i].count("#")
#print(sharp)

#必要なもの MAP(list), MOVE(list), STACK(deque)
MAP[0][0]=1
MOVE = [[1,0],[-1,0],[0,1],[0,-1]]
STACK = deque([(0,0)])
while STACK:
  y, x = STACK.popleft()
  for dy,dx in MOVE:
    ny = y + dy
    nx = x + dx
    if not(0 <= ny < h) or not(0 <= nx < w) or MAP[ny][nx]!='.':
      continue
    else:
      STACK.append((ny,nx))
      MAP[ny][nx] = MAP[y][x] + 1


if type(MAP[h-1][w-1]) == int:
  ans = h*w -MAP[h-1][w-1]-sharp
else:
  ans = -1
    
print(ans)
Buggy python submission (verdict: Runtime Error):
def main():
	N = int(input())
	z = []
	for i in range(N):
		d1, d2 = [int(d) for d in input().split(" ")]
		if d1 == d2:
			z.append(1)
		else:
			z.append(0)
	zc = []
	now = 2
	c = 0
	for i in range(len(z)):
		if i == 0:
			now = z[i]
			c += 1
		elif now == z[i]:
			c += 1
		elif now == 1 and z[i] == 0:
			zc.append(c)
			c = 1
			now = z[i]
		elif now == 0 and z[i] == 1:
			c = 1
			now = z[i]
	else:
		if now == 1:
			zc.append(c)

	print("Yes") if max(zc) >= 3 else print("No")

main()

Fixed submission:
def main():
	N = int(input())
	z = []
	for i in range(N):
		d1, d2 = [int(d) for d in input().split(" ")]
		if d1 == d2:
			z.append(1)
		else:
			z.append(0)
	zc = []
	now = 2
	c = 0
	for i in range(len(z)):
		if i == 0:
			now = z[i]
			c += 1
		elif now == z[i]:
			c += 1
		elif now == 1 and z[i] == 0:
			zc.append(c)
			c = 1
			now = z[i]
		elif now == 0 and z[i] == 1:
			c = 1
			now = z[i]
	else:
		if now == 1:
			zc.append(c)

	print("Yes") if len(zc) > 0 and max(zc) >= 3 else print("No")

main()
Buggy python submission (verdict: Runtime Error):
def main():
	N, X, M = [int(a) for a in input().split(" ")]
	used_r = [0] * (M - 1)
	r = [-1, X]
	used_r[X] = 1
	loop_start_elm = -1
	loop_start_n_2 = -1
	for i in range(M):
		A = r[-1]
		B = (A * A) % M
		if used_r[B] == 0:
			r.append(B)
			used_r[B] = 1
		else:
			loop_start_elm = B
			loop_start_n_2 = i + 2
			break
	loop_start_n = r.index(B)

	s1 = sum(r[:loop_start_n]) + 1
	s2 = sum(r[loop_start_n:loop_start_n_2])
	loop_len = loop_start_n_2 - loop_start_n
	loop_n = int((N - loop_start_n + 1) / loop_len)
	rest_n = (N - loop_start_n + 1) % loop_len
	s3 = sum(r[loop_start_n:(loop_start_n + rest_n)])
	print(s1 + s2 * loop_n + s3)

main()



Fixed submission:
def main():
	N, X, M = [int(a) for a in input().split(" ")]
	used_r = [0] * M
	r = [-1, X]
	used_r[X] = 1
	loop_start_elm = -1
	loop_start_n_2 = -1
	for i in range(M):
		A = r[-1]
		B = (A * A) % M
		if used_r[B] == 0:
			r.append(B)
			used_r[B] = 1
		else:
			loop_start_elm = B
			loop_start_n_2 = i + 2
			break
	loop_start_n = r.index(B)

	s1 = sum(r[:loop_start_n]) + 1
	s2 = sum(r[loop_start_n:loop_start_n_2])
	loop_len = loop_start_n_2 - loop_start_n
	loop_n = int((N - loop_start_n + 1) / loop_len)
	rest_n = (N - loop_start_n + 1) % loop_len
	s3 = sum(r[loop_start_n:(loop_start_n + rest_n)])
	print(s1 + s2 * loop_n + s3)

main()
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

def main():
	N = int(input())
	A = [int(a) for a in input().split(" ")]
	p = 1000000007
	ans = 0
	for c in itertools.combinations(A, 2):
		ans += (c[0] * c[1]) % p
		ans = ans % p
	print(ans)

main()

Fixed submission:
def main():
	N = int(input())
	A = [int(a) for a in input().split(" ")]
	p = 1000000007
	S = 0
	Asq = 0
	for i in range(len(A)):
		x = A[i]
		S += x % (2 * p)
		Asq += (x * x) % (2 * p)
	t = ((S * S) % (2 * p) - Asq) % (2 * p)
	print(int(t / 2))

main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
c0, c1, c2, c3 = [0 for i in range(4)]
for j in range(n):
  judge = input()
  c0 += 1 if judge == "AC" else c1 += 1 if judge == "WA" else c2 += 1 if judge == "TLE" else c3 += 1

print("AC x " + str(c0))
print("WA x " + str(c1))
print("TLE x " + str(c2))
print("RE x " + str(c3))

Fixed submission:
n = int(input())
c0, c1, c2, c3 = [0 for i in range(4)]
for j in range(n):
  judge = input()
  if judge == "AC":
    c0 += 1
  elif judge == "WA":
    c1 += 1
  elif judge == "TLE":
    c2 += 1
  else:
  	c3 += 1

print("AC x " + str(c0))
print("WA x " + str(c1))
print("TLE x " + str(c2))
print("RE x " + str(c3))
Buggy python submission (verdict: Time Limit Exceeded):
def getIntList(strList):
  return list(map(lambda x: int(x), strList))

N, M, K = getIntList(input().split(" "))
A = getIntList(input().split(" "))
B = getIntList(input().split(" "))

ta = 0
tb = 0
TA = [0]
TB = [0]

for i in range(len(A)):
  ta += A[i]
  if ta <= K:
    TA.append(ta)
  else:
    break
for j in range(len(B)):
  tb += B[j]
  if tb <= K:
    TB.append(tb)
  else:
    break

cnt = []

for i in range(len(TA)):
  for j in range(len(TB)):
#    print(" ".join([str(TA[i]), str(TB[-j-1]), str(K)]))
    if TA[i] + TB[-j-1] <= K:
      cnt.append(i - j + len(TB) - 1)
#      print(" ".join([str(i), str(j), str(len(TB)), "-1"]))
      break

print(max(cnt))
      

Fixed submission:
def getIntList(strList):
  return list(map(lambda x: int(x), strList))

N, M, K = getIntList(input().split(" "))
A = getIntList(input().split(" "))
B = getIntList(input().split(" "))

ta = 0
tb = 0
TA = [0]
TB = [0]

for i in range(len(A)):
  ta += A[i]
  if ta <= K:
    TA.append(ta)
  else:
    break
for j in range(len(B)):
  tb += B[j]
  if tb <= K:
    TB.append(tb)
  else:
    break

Cij = [0]

j = len(TB) - 1
for i in range(len(TA)):
  while TA[i] + TB[j] > K:
    j += -1
  else:
    if j >= 0:
      Cij.append(i + j)
  if j == -1:
    break


print(max(Cij))

Buggy python submission (verdict: Time Limit Exceeded):
def getIntList(strList):
  return list(map(lambda x: int(x), strList))

N, M, K = getIntList(input().split(" "))
A = getIntList(input().split(" "))
B = getIntList(input().split(" "))

TA = 0
T = [0]
cnt = [] # idx = n of B books

for i in range(len(A)):
  TA += A[i]
  if TA <= K:
    T.append(TA)
  else:
    break

cnt.append(len(T) - 1)

for j in range(len(B)):
  T = list(filter(lambda t: t<= K, list(map(lambda t: t + B[j], T))))
  cnt.append(len(T) - 1)
  if len(T) <= 0:
    break

for k in range(len(cnt)):
  cnt[k] += k

print(max(cnt))

Fixed submission:
def getIntList(strList):
  return list(map(lambda x: int(x), strList))

N, M, K = getIntList(input().split(" "))
A = getIntList(input().split(" "))
B = getIntList(input().split(" "))

ta = 0
tb = 0
TA = [0]
TB = [0]

for i in range(len(A)):
  ta += A[i]
  if ta <= K:
    TA.append(ta)
  else:
    break
for j in range(len(B)):
  tb += B[j]
  if tb <= K:
    TB.append(tb)
  else:
    break

Cij = [0]

j = len(TB) - 1
for i in range(len(TA)):
  while TA[i] + TB[j] > K:
    j += -1
  else:
    if j >= 0:
      Cij.append(i + j)
  if j == -1:
    break


print(max(Cij))