Problem:


Score : 100 points

Problem Statement

In the Kingdom of AtCoder, people use a language called Taknese, which uses lowercase English letters.

In Taknese, the plural form of a noun is spelled based on the following rules:

If a noun's singular form does not end with s, append s to the end of the singular form.

If a noun's singular form ends with s, append es to the end of the singular form.

You are given the singular form S of a Taknese noun. Output its plural form.

Constraints

S is a string of length 1 between 1000, inclusive.

S contains only lowercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

Print the plural form of the given Taknese word.

Sample Input 1

apple

Sample Output 1

apples

apple ends with e, so its plural form is apples.

Sample Input 2

bus

Sample Output 2

buses

bus ends with s, so its plural form is buses.

Sample Input 3

box

Sample Output 3

boxs



Sample input:
apple


Sample output:
apples

Submission status: Runtime Error

Solution code:
import os
import io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline


n, q = list(map(int, input().split()))
count = (n - 2) ** 2
c = [n] * n
r = [n] * n
mc = n
mr = n
for _ in range(q):
  m,q = list(map(int, input().split()))
  if m == 1:
    pos = r[q-1]
    if q < mc:
        mc = q
        for p in range(pos):
            c[p] = q
    if q not in [1,n]:
      count -= max(0, pos - 2)
  else:
    pos = c[q-1]
    if q < mr:
        mr = q
        for p in range(pos):
            r[p] = q
    if q not in [1,n]:
      count -= max(0, pos-2)
print(count)

Submission status: Runtime Error

Solution code:
p=input()
if p[len(p)-1]=='s':
  p.append('es')
  print(p)
else:
  p.append('s')
  print(p)

Submission status: Runtime Error

Solution code:
n = int(input())
count = 0
for i in range(n):
  d1, d2 = map(int, input().split())
  if count > 2:
    break
  else:
    if d1 == d2:
      count += 1
    else:
      count = 0
if count > 2:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
count = 0
for i in range(n):
  d1, d2 = map(int, input().split())
  if count > 2:
    break
  elif d1 == d2:
    count += 1
  else:
    count == 0
if count > 2:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
count = 0
for i in range(n):
  d1, d2 = map(int, input().split())
  if count == 3:
    break
  elif d1 == d2:
    count += 1
  else:
    count == 0
if count == 3:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
w=input()
a='es' is w[-1]=='s' else 's'
print(w+a)

Submission status: Runtime Error

Solution code:
w=input()
a=w[-1]=='s'?'es':'s'
print(w+a)

Submission status: Runtime Error

Solution code:
S=input()
l=len(S)
s=list(S)
if s[l]=="s":
  print(S+"es")
else:
  print(S+"s")

Submission status: Runtime Error

Solution code:
val = input()
valf=val[-1]
if(valf==s):
    print(val+"es")
else
    print(val+"s")

Submission status: Runtime Error

Solution code:
nk=map(int,input().split())
a=[]
for i in range(k):
  lr=map(int,input().split())
  for i in range(l,r+1):
    a.append(i)
a=list(set(a))
dp=[0]*n
dp[0]=1
for i in range(1,n):
  for j in a:
    if i>=j:
      dp[i]+=dp[i-j]
print(dp[-1])

Submission status: Runtime Error

Solution code:
s = raw_input()
if(s[-1] == 's'):
    s += 'es'
else:
    s += 's'
print(s)

Submission status: Runtime Error

Solution code:
from unittest import TestCase, main
from A import func

class test(TestCase):
  def test_with_valid_params(self):
    test_patterns = [
      ("apple","apples"),
      ("bus","buses"),
      ("box","boxs")
    ]

    for S,result in test_patterns:
      with self.subTest(S=S):
        self.assertEqual(func(S),result)

if __name__ == "__main__":
  main()

Submission status: Runtime Error

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


n = input().split()[:-1]

if n[-1] == "s":
    print(n + "es")
else:
    print(n + "s")

Submission status: Runtime Error

Solution code:
import random

exit = False

count = 0

countNum = 0

randomArray1 = random.randint(1,6)
randomArray2 = random.randint(1,6)

while count < 4:

    randomArray1 = random.randint(1,6)
    randomArray2 = random.randint(1,6)

    print(randomArray1,randomArray2)

    countNum += 1

    if randomArray1 == randomArray2:
        count += 1
        if count 


print(countNum)
print("Yes")

Submission status: Runtime Error

Solution code:
S=input()
s=len(S)
if S[s] == "s":
  print(S+"es")
else:
  print(S+"s")

Submission status: Runtime Error

Solution code:
def change_code(src):
	if src[:1] == s:
    	src=src + "es"
	else:
		src = src + "s"
	return src

Submission status: Runtime Error

Solution code:
f=open('in','r')
input=lambda:f.readline().strip()

s=input()
if s[-1]!='s':print(s+'s')
else:print(s+'es')

Submission status: Runtime Error

Solution code:
input=(S)
if S[-1]!="s":
  	print(S+"s")
elif S[-1]=="s":
  	print(S+"es")

Submission status: Runtime Error

Solution code:
S=input()
if (S[-1:]==s):
  print(S+"es")
else:
  print(S+"s")

Submission status: Runtime Error

Solution code:
words = input()
if words[-1] != s:
  words += "s"
else:
  words += "es"
print(words)

Submission status: Runtime Error

Solution code:
words = input()
if words[-1] != s:
  words += 's'
else:
  words += 'es'
print(words)

Submission status: Runtime Error

Solution code:
string = input()

if string[-1] != 's':
  new_string = string[0:-1] + 's'
if string[-1] = 's':
  new_string = string[0:-1] +'es'
 
print(new_string)

Submission status: Runtime Error

Solution code:
#####segfunc#####
def segfunc(x, y):
    return min(x, y)
#################
 
#####ide_ele#####
ide_ele = 10**9
#################
 
class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])
 
    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1
 
    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele
 
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res


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



ans = (N-2)**2
yoko = [N-2 for _ in range(N-2)]
tate = [N-2 for _ in range(N-2)] 
yoko = SegTree(yoko, segfunc, ide_ele)
tate = SegTree(tate, segfunc, ide_ele)
miny = N-2
minx = N-2
for k in range(Q):
	n, x = map(int, input().split())
	if n == 1:
		y = x -2
		if y < miny:
			ans -= minx
			miny = y
			yoko.update(min(minx, N-3), miny)
		else:
			ans -= tate.query(y, N-1)
	else:
		x = x - 2
		if x < minx:
			ans -= miny
			minx = x
			tate.update(min(miny, N-3), minx)
		else:
			ans -= yoko.query(x, N-1)
print(ans)

Submission status: Runtime Error

Solution code:
from itertools import product
N=int(input())
count=0
lis=[i for i in range(1,N+1)]
x=list(itertools.product(lis,repeat=3))
for i in x:
  if y[0]*y[1]+y[2]==N:
    count+=1

print(count)

Submission status: Runtime Error

Solution code:
s = input()
if s[-1]=='s':
  print(s+'es')
  else:
    print(s+'s')

Submission status: Runtime Error

Solution code:
c=0
for _ in range(int(input())):
    x,y = map(int,input().split())

    if x==y:
        c+=1
    else:
        c=0
    if c==3:
        c=-1
        print('Yes')
        break
if c!=-1:
    print('No')

Submission status: Runtime Error

Solution code:
S = input()
if S[-1] == "s":
  print(S + "es")
  else:
    print(S + "s")

Submission status: Runtime Error

Solution code:
s = input()
if s[-1] != "s":
  print(s+'s')
elif s[-1] == 's'
  print(s[:-1]+'es')

Submission status: Runtime Error

Solution code:
s = input()
if s[-1] != "s":
  print(s+'s')
elif s[-1] == 's' and s[-2] != 'e':
  print(s[:-1]+'es')
else:
    print(s)

Submission status: Runtime Error

Solution code:
if S[-1] == "s":
  print(S + "es")
else:
  print(S + "s")

Submission status: Runtime Error

Solution code:
if S[-1] == s:
  print(S + "es")
else:
  print(S + "s")

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
l = []
mod = 998244353
for i in range(K):
    L,R = map(int,input().split())
    l.append([L,R])
l.sort()

a = [0 for i in range(N+1)]
a[1] = 1
b = [0 for i in range(N+1)]
b[1] = 1
for i in range(2,N+1):
    for j in range(K):
        if l[j][0] < i:
            a[i] += (b[i-l[j][0]]-b[max(0,i-l[j][1]-1)])%mod
        else:
            break
    b[i] = (b[i-1]+a[i])%mod
mod = 998244353
print(a[N]%mod)

Submission status: Runtime Error

Solution code:
S = input()
if S[-1] == 's':
  ans += 'es'
else:
  ans += 's'
print(ans)

Submission status: Runtime Error

Solution code:
s=str(input())
s=list(s)
if s[len(s)-1]=="s":
  print("".join(s)+"es")
else:
  print("".join()+"s")

Submission status: Runtime Error

Solution code:
import collections
n,x,m=map(int,input().split())
if n==1 or x==0:
  print(x)
  exit()
start,end,loopcnt=0,0,0
a={x:0}
wk=x
for i in range(1,m):
  wk=(wk*wk)%m
  if not wk in a:
    a[wk]=i
  else:
    start=a[wk]
    end=i
    break
a=sorted(a.items(),key=lambda x:x[1])
koteiindex=min(n,start)
koteiwa=0
for i in range(koteiindex):
  koteiwa+=a[i][0]
loopcnt=(n-koteiindex)//(end-start)
loopindex=start-1+(n-koteiindex)%(end-start)
loopwa=0
amariwa=0
for i in range(start,end):
  if i<=loopindex:
    amariwa+=a[i][0]
  loopwa+=a[i][0]
ans=koteiwa+loopwa*loopcnt+amariwa
print(ans)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline.rstrip
sys.setrecursionlimit(10**6)
import decimal
from decimal import Decimal
decimal.getcontext().prec = 10

from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
import collections
from collections import deque 

def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)

# ---------------------------------------

s = input()
if s[-1] == "s":
    s += "es"
else:
    s += "s"
print(s)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline.rstrip()
sys.setrecursionlimit(10**6)
import decimal
from decimal import Decimal
decimal.getcontext().prec = 10

from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
import collections
from collections import deque 

def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)

# ---------------------------------------

s = input()
if s[-1] == "s":
    s += "es"
else:
    s += "s"
print(s)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
import decimal
from decimal import Decimal
decimal.getcontext().prec = 10
 
from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
import collections
from collections import deque 
 
def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)
 
# ---------------------------------------
 
n = inp()
cnt = 0
mx = 0
for i in range(n):
    d1, d2 = inpl()
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    mx = max(mx, cnt)
 
if mx >= 3:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
s = input()
l = len(s)
if s[l - 1] == "s":
	s += "es"
else:
 	l.append("s")
print(s)

Submission status: Runtime Error

Solution code:
s = input()
l = len(s)
if s[l - 1] == s:
	l.append(es)
else:
 	l.append(s)
print(s)

Submission status: Runtime Error

Solution code:
s = input()
l = len(s)
if(s[l - 1]) == 's':
	l.append(es)
else:
 	l.append(s)
print(s)

Submission status: Runtime Error

Solution code:
s = input()
l = len(s)
if(s[l - 1]) == s:
	l.append(es)
else:
 	l.append(s)
print(s)

Submission status: Runtime Error

Solution code:
n = input()

if n[len(n - 1)] == 's':
    print(n + 'es')
else:
    print(n + 's')

Submission status: Runtime Error

Solution code:
s=input()
if len(s)<=1:
  print(s)
else:
  if s[-1]='s':
    print(s+'es')
  else:
    print(s+'s')

Submission status: Runtime Error

Solution code:
s=sys.stdin
if s[len(s)-1] =="s":
	print(s + "es")
else:
	print(s + "s")

Submission status: Runtime Error

Solution code:
s = input()
p = ""

if(s.endswith("s")){
  p = s + "es"
}else{
  p = s + "s"
}

print(s)

Submission status: Runtime Error

Solution code:
S = input()
if S[-1] == s:
  S += es
else:
  S += s

Submission status: Runtime Error

Solution code:
print(input().strip()+('es' if s[-1] == 's' else 's'))

Submission status: Runtime Error

Solution code:
print(input()+('es' if s[-1] == 's' else 's'))

Submission status: Runtime Error

Solution code:
N = int(input())

k=0

for s in range(1,N):
  k = (N-1) // s
  t += k 
  
print (t)

Submission status: Runtime Error

Solution code:
N = int(input())
A = 1
B = 1
C = 1
answer = 0
while C < N:
    B = 1
    while B < N:
        A = 1
        while A < N:
            if (A * B) + C == N:
                answer += 1

            A += 1

        B += 1

    C += 1

print(answer)

Submission status: Runtime Error

Solution code:
n = int(input())
import math
ans = 0
for a in range(1, n):
  ans += math.floor((n - 1) / a)
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input().strip())



a = []
c = []
f = 0

for i in range(N):
    array = list(map(int, input().strip().split()))
    a.append(array)

    
for i in range(N):
	if(f == 0 or f == i-1):
		if(a[i][0] == a[i][1]):
			f=i
			c.append(1)
		else:
			f=0


if(len(c) >= 3):
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
#!/usr/local/bin/python3

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

def f(x, m):
    return x**2 % m

check = [False for _ in range(M)]
d = [X]
max_x = 0
for _ in range(1, N+1):
    X = f(X, M)
    if check[X]:
        break
    else:
        check[X] = True
    d.append(X)

idx = d.index(X)
ans = sum(d[:idx])
N -= idx
d = d[idx:]

sumd = sum(d)
ans += N//len(d) * sumd

ans += sum(d[:N%len(d)])

print(ans)

Submission status: Runtime Error

Solution code:
n, x, m = map(int, input().split())
a = x
s = 0
h = []
h.append(a)
i = 0
fl = 0
while i < n:
    s += a
    a = (a*a) % m
    if a == 0:
      break
    i += 1
    if fl == 0 and a in h:
      fl = 1
      po = h.index(a)
      ss = 0
      for j in range(po):
        ss += h[j]
      s2 = s - ss
      f = (n - po) // (i - po)
      s2 *= f
      s = s2 + ss
      i2 = i - po
      i2 *= f
      i = i2 + po
    else:
      h.append(a)
print(s)

Submission status: Runtime Error

Solution code:
line = input()

if line[len(line)] == ("s"):
  line += "es"
else:
  line += "s"
print(line)

Submission status: Runtime Error

Solution code:

from __future__ import division, print_function
# import threading
# threading.stack_size(2**27)
# import sys
# sys.setrecursionlimit(10**7)
import sys
from sys import stdin, stdout
import bisect            #c++ upperbound
import math
import heapq
##import numpy as np
##i_m=9223372036854775807
def modinv(n,p):
    return pow(n,p-2,p)
def cin():
    return map(int,sin().split())
def ain():                           #takes array as input
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())
def msb(n):         #log2 for n <= 10**10
    n|=n>>1
    n|=n>>2
    n|=n>>4
    n|=n>>8
    n|=n>>16
    return n-(n>>1)
def GCD(x, y): 
    x=abs(x)
    y=abs(y)
    if(min(x,y)==0):
        return max(x,y)
    while(y): 
        x, y = y, x % y 
    return x
def pref(a,n):             #preSum array
    pre=[0]*n
    pre[0]=a[0]
    for i in range(1,n):
        pre[i]=a[i]+pre[i-1]
    return pre
##def Divisors(n) : #list of divisors
##    l = []  
##    for i in range(1, int(math.sqrt(n) + 1)) :
##        if (n % i == 0) : 
##            if (n // i == i) : 
##                l.append(i) 
##            else : 
##                l.append(i)
##                l.append(n//i)
##    return l
prime1=[]
def SieveOfEratosthenes(n): #list of primes upto n
    global prime1
    prime1 = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
        if (prime1[p] == True): 
            for i in range(p * p, n+1, p): 
                prime1[i] = False
        p += 1
    f=[]
    for p in range(2, n): 
        if prime1[p]: 
            f.append(p)
    return f
prime=[]
def Sieve(bo):
    global prime
    prime = [1 for i in range(bo)] 
    p = 2
    while (p<bo): 
        if (prime[p] == 1): 
            for i in range(p,bo, p): 
                prime[i] = p
        p += 1
    f=[]
    for p in range(2, n): 
        if prime[p]==1: 
            f.append(p)
    return f
vi=[0]*(200005)
adj=[[] for i in range(200005)]
def dfs(node,ans):
    vi[node]=1
    ans+=[node+1]
    for j in adj[node]:
        if(vi[j]==0):
            dfs(j,ans)
    return ans

# https://github.com/cheran-senthil/PyRival/blob/master/pyrival/misc/bootstrap.py
def bootstrap(f, stack=[]):   #write @bootstrap before recursive func
    def wrappedfunc(*args, **kwargs):
        if stack:
            return f(*args, **kwargs)
        else:
            to = f(*args, **kwargs)
            while True:
                if type(to) is GeneratorType:
                    stack.append(to)
                    to = next(to)
                else:
                    stack.pop()
                    if not stack:
                        break
                    to = stack[-1].send(to)
            return to
 
    return wrappedfunc
def Divisors(n) : #list of divisors
    c=0 
    for i in range(1, int(math.sqrt(n) + 1)) :
        if (n % i == 0) : 
            if (n // i == i) : 
                c+=1
            else :
                c+=2
    return c
"""*******************************************************"""
def main():
    n,x,m=cin();f=0
    if(x==0):
        ans=0
    else:
        nmod=x%m
        store=[nmod];su=nmod
        d=dd(int);d[nmod]=1;x=nmod*nmod
        for i in range(1,n):
            if(x==0):
                f=1
                break
            elif(d[x]==0):
                nmod=x%m
                x=nmod*nmod
                d[nmod]=i+1
                store+=[nmod]
                su+=nmod
            else:
                f=2
                cont=d[x%m]-1
                rem=n-i
                break
        if(f<=1):
            ans=su
        else:
    ##        print(store)
            
            nval=len(store)-cont
            remsum=sum(store[cont:])
            mul=rem//nval
            modu=rem%nval
    ##        print(rem,cont,nval,mul,modu,len(store))
            k=sum(store[cont:(cont+modu)])
            ans=su+mul*remsum+k
    print(ans)
##    dp = np.full(10**5+1, 10**18, dtype=np.int64)
    
######## Python 2 and 3 footer by Pajenegod and c1729
 
# Note because cf runs old PyPy3 version which doesn't have the sped up
# unicode strings, PyPy3 strings will many times be slower than pypy2.
# There is a way to get around this by using binary strings in PyPy3
# but its syntax is different which makes it kind of a mess to use.
 
# So on cf, use PyPy2 for best string performance.

py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange
 
import os, sys
from io import IOBase, BytesIO
 
BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0
 
    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None
 
    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s
 
    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()
 
    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')
 
# Cout implemented in Python
import sys
class ostream:
    def __lshift__(self,a):
        sys.stdout.write(str(a))
        return self
cout = ostream()
endl = '\n'
 
# Read all remaining integers in stdin, type is given by optional argument, this is fast
def readnumbers(zero = 0):
    conv = ord if py2 else lambda x:x
    A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()
    try:
        while True:
            if s[i] >= b'R' [0]:
                numb = 10 * numb + conv(s[i]) - 48
            elif s[i] == b'-' [0]: sign = -1
            elif s[i] != b'\r' [0]:
                A.append(sign*numb)
                numb = zero; sign = 1
            i += 1
    except:pass
    if s and s[-1] >= b'R' [0]:
        A.append(sign*numb)
    return A
 
# threading.Thread(target=main).start()
if __name__== "__main__":
  main()

Submission status: Runtime Error

Solution code:
import math
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
mod = 10**9 + 7

#maincode-------------------------------------------------

n = int(input())
x = [0 for i in range(n)]
y = [0 for i in range(n)]
ans = 'No'

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

for i in range(n-2):
    if (x[i] == y[i])and(x[i+1] == y[i+1])and(x[i+2] == y[i+2]):
        ans = 'Yes'

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
P=998244353
N,K=map(int,input().split())
LR=[]
for _ in range(K):
  l,r=map(int,input().split())
  LR+=range(l,r+1)
LR=list(set(LR))
LR=np.array(LR)
c=[0]*N
c[0]=1
for k in range(N):
  S=list(LR[LR<=k])
  while len(S):
    c[k]+=c[k-S[-1]]%P
    S.pop()
print(c[-1]%P)

Submission status: Runtime Error

Solution code:
import numpy as np
P=998244353
N,K=map(int,input().split())
LR=[]
for _ in range(K):
  l,r=map(int,input().split())
  LR+=range(l,r+1)
LR=list(set(LR))
LR=np.array(LR)
c=[0]*N
c[0]=1
for k in range(N):
  S=LR[LR<=k]
  while len(S):
    c[k]+=c[k-S[-1]]%P
    S=S[:-1]
print(c[-1]%P)

Submission status: Runtime Error

Solution code:
N=int(input())
y=0
for j in range(1,N):
    for k in range(1,N): 
        if (N-k)%j==0:
            y=y+1
print(y)

Submission status: Runtime Error

Solution code:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

n,x,m=map(int,input().split())
s=set()
l=[]
flag=False
cnt=1
ans=0

l.append(x)
for i in range(m):
  if x not in s:
    s.add(x)
    x=(x**2)%m
    l.append(x)
  else:
    break

h=len(l)
cnt=1
num=0
for i in range(h):
  if l[i]==l[h-1]:
    while l[i+cnt]!=l[h-1]:
      cnt+=1
    flag=True
    break
  else:
    num+=1
    ans+=l[i]

n-=num
if num!=0:
  del l[h-1]
  del l[0:num]

if n>=len(l):
  mod=n%len(l)
  ans+=sum(l)*(n//len(l))
  for i in range(1,mod):
    ans+=l[i-1]
  print(ans)
else:
  for i in range(n):
    ans+=l[i]
  print(ans)

Submission status: Runtime Error

Solution code:
import math
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
mod = 10**9 + 7

#maincode-------------------------------------------------

n = int(input())
x = [0 for i in range(n)]
y = [0 for i in range(n)]
ans = 'No'

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

for i in range(n-2):
    if (x[i] == x[i])and(x[i+1] == x[i+1])and(x[i+2] == x[i+2]):
        ans = 'Yes'

print(ans)

Submission status: Runtime Error

Solution code:
n, x, m = map(int, input().split())
a = [x]
if n == 1:
    print(x)
    exit()
for i in range(n-1):
    ad = (a[-1]**2) % m
    if ad in a:
        roop_s = a.index(ad)
        roop_e = len(a)
        break
    else:
        a.append(ad)
    if i == n-2:
        print(sum(a))
        exit()
roop_t = (n-roop_s) // (roop_e - roop_s)
left = n - roop_t*(roop_e - roop_s) - roop_s
ans = sum(a[:roop_s]) + roop_t*sum(a[roop_s : roop_e]) + sum(a[roop_s:roop_s+left])
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input().strip())



a = []
c =0
f = 0

for i in range(N):
    array = list(map(int, input().strip().split()))
    a.append(array)

    
for i in range(N):
	if(f == 0 or f == i-1):
		if(a[i][0] == a[i][1]):
			f=i
			c+=1
		else:
			f=0
			c=0
	else :
		f=0
		c=0

if(c >= 3):
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
N = int(input().strip())



a = []
c =0
f = 0

for i in range(N):
    array = list(map(int, input().strip().split()))
    a.append(array)

    
for i in range(N):
	if(f == 0 or f == i-1):
		if(a[i][0] == a[i][1]):
			f=i
			c+=1
		else:
			f=0
			c=0
	else :
      f=0
      c=0

if(c >= 3):
  print("Yes")
else:
  print("No")