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

dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]

for i in range(1,len(s)+1):
    for j in range(1, len(t)+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

# DPを逆に辿って復元する
ans = ""
i = len(s)
j = len(t)
while( i>0 and j>0):
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans = s[i-1] + ans
        i -= 1
        j -= 1

print(ans)


Fixed submission:
s = input()
t = input()

dp = [[0]*(len(t)+1) for i in range(len(s)+1)]

for i in range(len(s)):
  for j in range(len(t)):
    if s[i] == t[j]:
      dp[i+1][j+1] = dp[i][j]+1
    else:    
      dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j])
           
ans = ""
i = len(s)
j = len(t)
while i > 0 and j > 0 :
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans = s[i-1] +ans
        i -= 1
        j -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()

dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]

for i in range(1,len(s)+1):
    for j in range(1, len(t)+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

# DPを逆に辿って復元する
ans = ""
i = len(s)
j = len(t)
while( i>=0 and j>=0):
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans = s[i-1] + ans
        i -= 1
        j -= 1

print(ans)


Fixed submission:
s = input()
t = input()

dp = [[0]*(len(t)+1) for i in range(len(s)+1)]

for i in range(len(s)):
  for j in range(len(t)):
    if s[i] == t[j]:
      dp[i+1][j+1] = dp[i][j]+1
    else:    
      dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j])
           
ans = ""
i = len(s)
j = len(t)
while i > 0 and j > 0 :
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans = s[i-1] +ans
        i -= 1
        j -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()

dp = [[0]*(len(t)+1) for i in range(len(s)+1)]

for i in range(len(s)):
  for j in range(len(t)):
    if s[i] == t[j]:
      dp[i+1][j+1] = dp[i][j]+1
    else:    
      dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j])
           
ans = ""
i = len(s)
j = len(t)
while i > 0 and j > 0 :
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans = s[i-1] +ans
        i -= 1
        j -= 1
print(ans)


Fixed submission:
s = input()
t = input()

dp = [[0]*(len(t)+1) for i in range(len(s)+1)]

for i in range(len(s)):
  for j in range(len(t)):
    if s[i] == t[j]:
      dp[i+1][j+1] = dp[i][j]+1
    else:    
      dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j])
           
ans = ""
i = len(s)
j = len(t)
while i > 0 and j > 0 :
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans = s[i-1] +ans
        i -= 1
        j -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ab = [tuple(map(int,input().split())) for i in range(m)]
es = [[] for i in range(n)]
for i, (a,b) in enumerate(ab):
    a,b = a-1,b-1
    es[a].append(b)

dp = [-1]*n

def rec(start):
    if dp[start] != -1:
        return dp[start]
    ans = 0
    for next_node in es[start]:
        ans = max(ans, rec(next_node)+1 )
    dp[start] = ans

    return dp[start]

ans = 0
for i in range(n):
    ans = max(ans, rec(i))

print(ans)


Fixed submission:
import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# input処理を高速化する
N, M = [int(_) for _ in input().split()]

# 隣接関係は隣接リストで管理する
lst_edge = [[] for _ in range(N)]

for _ in range(M):
  x, y = map(int, input().split()) 
  # 最初のindexをゼロにする
  lst_edge[x-1].append(y-1)
        
# dp[v] := ノードvを始点とした時の有向パスの長さの最大値
# -1 未訪問で初期化。
dp = [-1] * N

# メモ化再帰
def rec(v):
  # 既に更新済み
  if dp[v] != -1:
    return dp[v]
  ans = 0
  lst_nv = lst_edge[v]
  for nv in lst_nv:
    ans = max(ans, rec(nv) + 1)
  dp[v] = ans
  return dp[v]
    
# 全ての点に対して更新する
ans = 0
for v in range(N):
  ans = max(ans, rec(v))
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(float, input().split()))

dp = [[0]*(n+1) for _ in range(n+1)]
dp[0][0] = 1
# dp[i][j]:i番目以前の商品を見たときに表の枚数がj枚となる確率の和

for i in range(1,n+1):
    for j in range(i+1):
            dp[i][j] = dp[i-1][j]*(1-p[i-1])
            if j>0:
                dp[i][j] += dp[i-1][j-1]*p[i-1]

ans = sum(dp[n][(n+1)//2:])

print(ans)

Fixed submission:
n = int(input())
p = list(map(float, input().split()))

dp = [[0]*(n+1) for _ in range(n+1)]
dp[0][0] = 1
# dp[i][j]:i番目以前の商品を見たときに表の枚数がj枚となる確率の和

for i in range(1,n+1):
    for j in range(i+1):
            dp[i][j] = dp[i-1][j]*(1-p[i-1])
            if j>0:
                dp[i][j] += dp[i-1][j-1]*p[i-1]

ans = sum(dp[n][(n+1)//2:])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
# input処理を高速化する
input = sys.stdin.readline

def main():
    N = int(input())
    lst_p = list(map(float, input().split()))
    # dp[i][j] := 最初の i 枚のコインを投げたときに、表が j 枚となる確率
    # 次のコインが表: dp[i+1][j+1] += dp[i][j]∗p[i]
    # 次のコインが裏: dp[i+1][j] += dp[i][j]∗(1.0−p[i])
    dp = [[0] * (N+1) for i in range(N+1)]
    # 初期条件
    dp[0][0] = 1.0
    for i in range(N):
        for j in range(N):
            dp[i+1][j+1] += dp[i][j] * lst_p[i]
            dp[i+1][j] += dp[i][j] * (1.0 - lst_p[i])
    
    ans = 0
    for i in range((N+1)//2, N+1):
        ans += dp[N][i]
    print(ans)
main()

Fixed submission:
n = int(input())
p = list(map(float, input().split()))

dp = [[0]*(n+1) for _ in range(n+1)]
dp[0][0] = 1
# dp[i][j]:i番目以前の商品を見たときに表の枚数がj枚となる確率の和

for i in range(1,n+1):
    for j in range(i+1):
            dp[i][j] = dp[i-1][j]*(1-p[i-1])
            if j>0:
                dp[i][j] += dp[i-1][j-1]*p[i-1]

ans = sum(dp[n][(n+1)//2:])

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, p = map(int, input().split())

def divisors(n): #sortはしてない
    ret = set()
    m = 1
    while m*m <= n:
        if n%m==0:
            ret.add(m)
            ret.add(n//m)
        m += 1
    return ret

ndivs = list(divisors(p))
ndivs.sort()

ma = int(pow(p,1/n)) #でかい値の時はずれるので，適当に値を足した方がいい

from bisect import bisect_right
index = bisect_right(ndivs, ma)

if index < len(ndivs)-1: index+=1

for i in reversed(range(index)):
    if p%(pow(ndivs[i],n))==0:
        print(ndivs[i])
        exit()


Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, p = map(int, input().split())

from collections import Counter;
def prime_factorize(n):
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m += 1
    if n > 1:
        d[n] += 1
    return d

soinsu = prime_factorize(p)

ans =1
for k,v in soinsu.items():
    if v>=n:
        ans *= k**(v//n)

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, p = map(int, input().split())

def divisors(n): #sortはしてない
    ret = set()
    m = 1
    while m*m <= n:
        if n%m==0:
            ret.add(m)
            ret.add(n//m)
        m += 1
    return ret

ndivs = list(divisors(p))
ndivs.sort()

ma = int(pow(p,1/n)) #でかい値の時はずれるので，適当に値を足した方がいい
ma +=1

from bisect import bisect_right
index = bisect_right(ndivs, ma)

for i in reversed(range(index)):
    if p%(pow(ndivs[i],n))==0:
        print(ndivs[i])
        exit()


Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, p = map(int, input().split())

from collections import Counter;
def prime_factorize(n):
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m += 1
    if n > 1:
        d[n] += 1
    return d

soinsu = prime_factorize(p)

ans =1
for k,v in soinsu.items():
    if v>=n:
        ans *= k**(v//n)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
ss =[1 if s=='B' else 0 for s in input()]

def babble_sort(arr,ans):
    length = len(arr)

    for i in range(length):
        for j in reversed(range(i+1, length)):
            if arr[j-1] > arr[j]:
                arr[j-1], arr[j] = arr[j], arr[j-1]
                ans+=1
    return ans

ans = babble_sort(ss,0)

print(ans)


Fixed submission:
s = input() #sys.stdin.readlineは最後が改行

tmp =0
ans=0
for i in range(len(s)):
    if s[i]=='B':
        tmp+=1
    else:
        ans+=tmp

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, x = map(int, input().split())

border = 2
nborder = 0
eaten = n
cnt = 1
ans = 0
after1 = 1
after3 = 2

while x > eaten:
    if cnt == border:
        if nborder == n-1: break
        eaten += nborder
        nborder += 1
        border = border*2 + 2
        after1 = nborder
    elif (cnt-1) % 4 == 0:
        ans += min(x-eaten,3)
        eaten += 3
    elif (cnt-1) % 4 == 1:
        eaten += after3
        after1 = after3
    elif (cnt-1) % 4 == 2:
        ans += 1
        eaten += 1
    elif (cnt-1) % 4 == 3:
        eaten += after1
        after3 = after1

    cnt += 1


print(ans)


Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

numP_N = [0]*N
numPB_N = [0]*N
numP_N[0] = 3
numPB_N[0] = 5
for i in range(1,N):
    numP_N[i] = numP_N[i-1] * 2 + 1
    numPB_N[i] = numPB_N[i-1] * 2 + 3

def rec(n, x):
    if n == 1:
        ans_1 = [0,0,1,2,3,3]
        return ans_1[x]

    if x == numPB_N[n-1]:
        return numP_N[n-1]

    elif x > numPB_N[n-2] + 2:
        return numP_N[n-2] + 1 + rec(n-1, x-numPB_N[n-2] - 2)

    elif x == numPB_N[n-2] + 2:
        return numP_N[n-2] + 1

    elif x == numPB_N[n-2] + 1:
        return numP_N[n-2]

    elif x < numPB_N[n-2] + 1:
        return rec(n-1, x-1)

print(rec(N,X))
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list(int(input()) for i in range(n))

a.sort()
if n%2==0:
    start = n//2-1
    left = 0
    right = n-1
    ans = abs(a[right]- a[start])
    while start != left:
        ans+=abs(a[left]-a[right])
        right -= 1
        ans+=abs(a[right]-a[left])
        left += 1

    print(ans)

if n%2==1:
    start = n//2
    left = 0
    right = n-1
    
    ans0 = abs(a[right]- a[start])
    while True:
        ans0+=abs(a[left]-a[right])
        right -= 1
        if start == right: break
        ans0+=abs(a[right]-a[left])
        left += 1
        
    ans1 = abs(a[left]- a[start])
    while True:
        ans1+=abs(a[right]-a[left])
        right -= 1
        if start == right: break
        ans1+=abs(a[left]-a[right])
        left += 1

    ans = max(ans0,ans1)
    print(ans)



Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list(int(input()) for i in range(n))

a.sort()
if n%2==0:
    start = n//2-1
    left = 0
    right = n-1
    ans0 = abs(a[right]- a[start])
    while start != left:
        ans0+=abs(a[left]-a[right])
        right -= 1
        ans0+=abs(a[right]-a[left])
        left += 1

    start = n//2
    left = 0
    right = n-1
    ans1 = abs(a[left]- a[start])
    while start != right:
        ans1+=abs(a[right]-a[left])
        left += 1
        ans1+=abs(a[left]-a[right])
        right -= 1

    ans = max(ans0,ans1)
    print(ans)

if n%2==1:
    start = n//2
    left = 0
    right = n-1
    ans0 = abs(a[right]- a[start])
    while True:
        ans0+=abs(a[left]-a[right])
        right -= 1
        if start == right: break
        ans0+=abs(a[right]-a[left])
        left += 1


    left = 0
    right = n-1
    ans1 = abs(a[left]- a[start])
    while True:
        ans1+=abs(a[right]-a[left])
        left += 1
        if start == left: break
        ans1+=abs(a[left]-a[right])
        right -= 1

    ans = max(ans0,ans1)
    print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, m = map(int, input().split())
s = input() #sys.stdin.readlineは最後が改行
t = input() #sys.stdin.readlineは最後が改行

import math

gcdnm = math.gcd(n, m)
L = (n * m) // gcdnm

gcdd = math.gcd(L//n, L//m)
l = (L//n *L//m) // gcdd


if s[0]!=t[0]:
    print(-1)
    exit()

i = 1


while l//(L//n)*i < n and l//(L//m)*i <m:
    if s[l//(L//n)*i] != t[l//(L//m)*i]:
        print(-1)
        exit()
    i+=1

print(L)



Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, m = map(int, input().split())
s = input() #sys.stdin.readlineは最後が改行
t = input() #sys.stdin.readlineは最後が改行

from fractions import gcd

gcdnm = gcd(n, m)
L = (n * m) // gcdnm

gcdd = gcd(L//n, L//m)
l = (L//n *L//m) // gcdd


if s[0]!=t[0]:
    print(-1)
    exit()

i = 1


while l//(L//n)*i < n and l//(L//m)*i <m:
    if s[l//(L//n)*i] != t[l//(L//m)*i]:
        print(-1)
        exit()
    i+=1

print(L)
Buggy python submission (verdict: Runtime Error):
from collections import deque
import sys
sys.setrecursionlimit(10 ** 9)
import numpy as np

h, w = map(int, input().split())
maze = [[-1 for i in range(w)] for j in range(h)]

ans = 0
for i in range(h):
    maze[i] = list( map(int, input().split()))


queue = deque()

ansN = 0
ans = []

for i in range(h):
    for j in range(w):
        if maze[i][j] % 2 != 0:
            if j+1 < w:
                maze[i][j] -= 1
                maze[i][j+1] += 1
                ansN+=1
                ans.append([i, j, i, j+1])


            elif i+1 < h:
                maze[i][j] -= 1
                maze[i+1][j] += 1
                ansN+=1
                ans.append([i, j, i+1, j])

print(ansN)

for i in range(ansN):
    print(*ans[i], sep =' ')


Fixed submission:

from collections import deque
import sys
sys.setrecursionlimit(10 ** 9)

h, w = map(int, input().split())
maze = [[-1 for i in range(w)] for j in range(h)]

ans = 0
for i in range(h):
    maze[i] = list( map(int, input().split()))


queue = deque()

ansN = 0
ans = []

for i in range(h):
    for j in range(w):
        if maze[i][j] % 2 != 0:
            if j+1 < w:
                maze[i][j] -= 1
                maze[i][j+1] += 1
                ansN+=1
                ans.append([i+1, j+1, i+1, j+2])

            elif i+1 < h:
                maze[i][j] -= 1
                maze[i+1][j] += 1
                ansN+=1
                ans.append([i+1, j+1, i+2, j+1])

print(ansN)

for i in range(ansN):
    print(*ans[i], sep =' ')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, m = map(int, input().split())
a = list( map(int, input().split()))
a_modm=[ai%m for ai in a]

from itertools import accumulate
B = [0] + a_modm
B = list(accumulate(B))
ans = 0
for i in range(n):
    for j in range(i,n):
        if (B[j+1]%m-B[i]%m)%m == 0:
            ans+=1

print(ans)


Fixed submission:
from collections import defaultdict
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, m = map(int, input().split())

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

from itertools import accumulate
b = [0] + a
b = list(accumulate(b))

count_mod = defaultdict(int)

for i in range(n+1):
    bi_modm = b[i]%m
    if count_mod[bi_modm] is None: count_mod[bi_modm]=1
    else: count_mod[bi_modm] += 1

ans = 0
for count in count_mod.values():
    ans += count*(count-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, m = map(int, input().split())
a = list( map(int, input().split()))
a_modm=[ai%m for ai in a]

from itertools import accumulate
B = [0] + a_modm
B = list(accumulate(B))
ans = 0
for i in range(0,n):
    for j in range(i,n):
        if (B[j+1]-B[i])%m == 0:
            ans+=1

print(ans)


Fixed submission:
from collections import defaultdict
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, m = map(int, input().split())

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

from itertools import accumulate
b = [0] + a
b = list(accumulate(b))

count_mod = defaultdict(int)

for i in range(n+1):
    bi_modm = b[i]%m
    if count_mod[bi_modm] is None: count_mod[bi_modm]=1
    else: count_mod[bi_modm] += 1

ans = 0
for count in count_mod.values():
    ans += count*(count-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list( map(int, input().split()))
a_modm=[ai%m for ai in a]

from itertools import accumulate
B = [0] + a_modm
B = list(accumulate(B))
ans = 0
for i in range(0,n):
    for j in range(i,n):
        if (B[j+1]-B[i])%m == 0:
            ans+=1

print(ans)


Fixed submission:
from collections import defaultdict
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, m = map(int, input().split())

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

from itertools import accumulate
b = [0] + a
b = list(accumulate(b))

count_mod = defaultdict(int)

for i in range(n+1):
    bi_modm = b[i]%m
    if count_mod[bi_modm] is None: count_mod[bi_modm]=1
    else: count_mod[bi_modm] += 1

ans = 0
for count in count_mod.values():
    ans += count*(count-1)//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

right=0
ans=0

for left in range(n):
    right=left
    xor_sum = 0
    plus_sum = 0
    while right<n and xor_sum >= plus_sum:
        xor_sum ^= a[right]
        plus_sum += a[right]
        if xor_sum == plus_sum: ans+=1
        right+=1

print(ans)


Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

ans=0
right=0
left=0
array_sum = 0
sum_xor = 0
sum_pls = 0

for left in range(n):

    while right<n and sum_pls+a[right] == sum_xor^a[right]:
        sum_pls += a[right]
        sum_xor ^= a[right]
        right+=1

    ans += right-left
    sum_pls -= a[left]
    sum_xor ^= a[left]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
x, y = map(int, input().split())

if x==y:
    print(-1)
    exit()

if y==1:
    print(-1)
    exit()

ans = x
while ans<10**18:
    if x%y!=0:
        print(x)
        exit()
    else:
        ans+=x


Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
x, y = map(int, input().split())

if x%y==0:
    print(-1)
    exit()

ans = x
while ans<=10**18:
    if x%y!=0:
        print(x)
        exit()
    else:
        ans+=x
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))
b = list( map(int, input().split()))

sa = sum(a)
sb = sum(b)

al = sb-sa

if al<0:
    print('No')
    exit()

doub = 0
sing = 0

for i in range(n):
    diff = b[i]-a[i]
    if diff > 0:
        doub += diff//2
        sing += diff%2
    if diff < 0:
        sing += -diff

dnokori = al - doub
snokori = al - sing

if dnokori < 0 or snokori<0:
    print('No')
    exit()

if snokori/dnokori == 2:
    print('Yes')
else:
    print('No')



Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))
b = list( map(int, input().split()))

sa = sum(a)
sb = sum(b)

al = sb-sa

if al<0:
    print('No')
    exit()

doub = 0
sing = 0

for i in range(n):
    diff = b[i]-a[i]
    if diff > 0:
        doub += -(-diff//2)
        sing += diff%2
    if diff < 0:
        sing += -diff

dnokori = al - doub
snokori = al - sing

if dnokori < 0 or snokori<0:
    print('No')
    exit()

if dnokori==0 and snokori==0:
    print('Yes')
    exit()

if dnokori==0:
    print('No')
    exit()

if snokori/dnokori == 2:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))
b = list( map(int, input().split()))

sa = sum(a)
sb = sum(b)

al = sb-sa

if al<0:
    print('No')
    exit()

double = 0
single = 0

for i in range(n):
    diff = b[i]-a[i]
    diff_ = -diff
    if diff > 0:
        double += diff//2
        single += diff%2
    if diff < 0:
        single += diff_

dnokori = al - double
snokori = al - single


if dnokori < 0 or snokori<0:
    print('No')
    exit()

if snokori/dnokori == 2:
    print('Yes')
else:
    print('No')



Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))
b = list( map(int, input().split()))

sa = sum(a)
sb = sum(b)

al = sb-sa

if al<0:
    print('No')
    exit()

doub = 0
sing = 0

for i in range(n):
    diff = b[i]-a[i]
    if diff > 0:
        doub += -(-diff//2)
        sing += diff%2
    if diff < 0:
        sing += -diff

dnokori = al - doub
snokori = al - sing

if dnokori < 0 or snokori<0:
    print('No')
    exit()

if dnokori==0 and snokori==0:
    print('Yes')
    exit()

if dnokori==0:
    print('No')
    exit()

if snokori/dnokori == 2:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
s = input() #sys.stdin.readlineは最後が改行
n=len(s)
ch = 0
ans = 0
left=0
right=n-1
while left!=right:
    if s[left] == s[right]:
        left+=1
        right-=1
    else:
        if s[left] == 'x':
            ans+=1
            left+=1
        elif s[right] =='x':
            ans+=1
            right-=1
        else:
            print(-1)
            exit()
print(ans)



Fixed submission:
s = input() #sys.stdin.readlineは最後が改行
n=len(s)
ch = 0
ans = 0
left=0
right=n-1
while left<right:
    if s[left] == s[right]:
        left+=1
        right-=1
    else:
        if s[left] == 'x':
            ans+=1
            left+=1
        elif s[right] =='x':
            ans+=1
            right-=1
        else:
            print(-1)
            exit()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, k = map(int, input().split())
x = [0]* n
y = [0]* n
for i in range(n):
    x[i], y[i] = map(int, input().split())

xc = list(combinations(x,2))
yc = list(combinations(y,2))
ans = 4*10**18

for yy in yc:
    u = max(yy)
    d = min(yy)
    for xx in xc:
        r = max(xx)
        l = min(xx)
        count = 0
        for i in range(n):
            if l <= x[i] <=r and d <= y[i] <=u: count += 1
        if count >= k:
            ans = min(ans, (u-d)*(r-l))

print(ans)


Fixed submission:
from itertools import combinations
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, k = map(int, input().split())
x = [0]* n
y = [0]* n
for i in range(n):
    x[i], y[i] = map(int, input().split())

xc = list(combinations(x,2))
yc = list(combinations(y,2))
ans = 4*10**18

for yy in yc:
    u = max(yy)
    d = min(yy)
    for xx in xc:
        r = max(xx)
        l = min(xx)
        count = 0
        for i in range(n):
            if l <= x[i] <=r and d <= y[i] <=u: count += 1
        if count >= k:
            ans = min(ans, (u-d)*(r-l))

print(ans)