Problem:


Score: 100 points

Problem Statement

In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019.

Integers M_1, D_1, M_2, and D_2 will be given as input.

It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1.

Determine whether the date 2019-M_1-D_1 is the last day of a month.

Constraints

Both 2019-M_1-D_1 and 2019-M_2-D_2 are valid dates in the Gregorian calendar.

The date 2019-M_2-D_2 follows 2019-M_1-D_1.

Input

Input is given from Standard Input in the following format:

M_1 D_1
M_2 D_2

Output

If the date 2019-M_1-D_1 is the last day of a month, print 1; otherwise, print 0.

Sample Input 1

11 16
11 17

Sample Output 1

0

November 16 is not the last day of a month.

Sample Input 2

11 30
12 1

Sample Output 2

1

November 30 is the last day of November.



Sample input:
11 16
11 17


Sample output:
0

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# rstrip().decode('utf-8')
# INF=float("inf")
#MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
#import numpy as np
# import operator
#import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
# from fractions import gcd
#from collections import deque
#from collections import defaultdict
# from collections import Counter
#from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())


def main():
	a,b=map(int,input().split())
	c,d=map(int,input().split())
	
	ans=0
	if a<c:
		ans=1
	print(ans)
	
	
	
if __name__ == "__main__":
		main()

Submission status: Accepted

Solution code:
M1,D1=map(int, input().split())
M2,D2=map(int, input().split())

if M1!=M2:
    print(1)
else:
    print(0)

Submission status: Accepted

Solution code:
m1,d1= map(int, input().split())
m2,d2= map(int, input().split())

if m1!=m2 and d2==1:
    print(1)
else:
    print(0)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [M1, D1] = string_to_int(inputs[0])
    [M2, D2] = string_to_int(inputs[1])
    if M1 != M2:
        return 1
    return 0


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(2))
    print(ret)

Submission status: Accepted

Solution code:
m1,p1 = map(int,input().split())
m2,p2 = map(int,input().split())
if m1 != m2:
    print(1)
else:
    print(0)

Submission status: Accepted

Solution code:
l=list(map(int,input().split()))
l2=list(map(int,input().split()))
if l[0]+1==l2[0]:
  print(1)
else:
  print(0)

Submission status: Accepted

Solution code:
m1,d1 = map(int,input().split())
m2,d2 = map(int,input().split())

if (m1 == m2):
    print(0)
else:
    print(1)

Submission status: Accepted

Solution code:
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())

print(1 if d2 == 1 else 0)

Submission status: Accepted

Solution code:
M1,D1 = map(int,input().split())
M2,D2 = map(int,input().split())

if M1!=M2:
	print(1)
else:
	print(0)

Submission status: Accepted

Solution code:
a, b = input().split()
c, d = input().split()
if a != c:
  print(1)
else:
  print(0)

Submission status: Accepted

Solution code:
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

M, D = IL()
MM, DD = IL()
if M == MM:
  print(0)
else:
  print(1)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
a,b=map(int,input().split())
if n==a:
    print(0)
else:
    print(1)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    m1,_=MI()
    m2,_=MI()
    if m1==m2:print(0)
    else:print(1)
main()

Submission status: Accepted

Solution code:
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if M1 != M2:
    print(1)
else:
    print(0)

Submission status: Accepted

Solution code:
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

print(1 if M1 != M2 else 0)

Submission status: Accepted

Solution code:
M1,D1=map(int,input().split())
M2,D2=map(int,input().split())
print((M1!=M2)*1)

Submission status: Accepted

Solution code:
import sys
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())

if m1 == m2:
    print("0")
else:
    print("1")

Submission status: Accepted

Solution code:
M1, D1=map(int, input().split())
M2, D2=map(int, input().split())

if M1!=M2:
  print(1)
else:
  print(0)

Submission status: Accepted

Solution code:
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())
if m2 == m1 + 1:
    print(1)
else:
    print(0)

Submission status: Accepted

Solution code:
m1,d1 = map(int, input().split())
m2,d2 = map(int, input().split())
print(int(m1!=m2))

Submission status: Accepted

Solution code:
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
if a1 == a2:
    print(0)
else:
    print(1)

Submission status: Accepted

Solution code:
M1, D1 = map(int,input().split())
M2, D2 = map(int,input().split())

print(int(M1 != M2))

Submission status: Accepted

Solution code:
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())
if M2 != M1 and D2 == 1:
    print(1)
else:
    print(0)

Submission status: Accepted

Solution code:
a, _ = raw_input().split()
b, _ = raw_input().split()
if a == b:
    print 0
else:
    print 1

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
x = list(map(int, input().split()))
y = list(map(int, input().split()))
if x[0] != y[0]: print(1)
else: print(0)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline


M1,D1=map(int,input().split())
M2,D2=map(int,input().split())

if D2<D1:
    print(1)
else:
    print(0)

Submission status: Accepted

Solution code:
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())

if m1==m2:
    print(0)
else:
    print(1)

Submission status: Accepted

Solution code:
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import decimal

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

M1, D1 = map(int, raw_input().split())
M2, D1 = map(int, raw_input().split())

print int(M1 != M2)

Submission status: Accepted

Solution code:
inf = float("inf")

a, b = map(int, input().split())
c, d = map(int, input().split())
if d == 1:
    print(1)
else:
    print(0)

Submission status: Accepted

Solution code:
def main():
    M1, D1 = (int(i) for i in input().split())
    M2, D2 = (int(i) for i in input().split())
    if M1 != M2:
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    m1,d1=map(int,input().split())
    m2,d2=map(int,input().split())
    if m1!=m2:
        print(1)
    else:
        print(0)
main()

Submission status: Accepted

Solution code:
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())
if D2 == 1:
    print(1)
else:
    print(0)

Submission status: Accepted

Solution code:
M, D = map(int, input().split())
m2 , m3 = map(int, input().split())
if M!=m2:
  print(1)
else:
  print(0)

Submission status: Accepted

Solution code:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

M1,D1 = many_int()
M2,D2 = many_int()

if M1 != M2:
    print(1)
else:
    print(0)

Submission status: Accepted

Solution code:
def main():
    m,d=map(int,input().split())
    n,e=map(int,input().split())
    
    print(0 if m==n else 1)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    M1, D1 = MI()
    M2, D2 = MI()

    if M1 != M2:
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
# l = list(map(int, input().split()))
if a1 == a2:
    print(0)
else:
    print(1)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
c, d = map(int, input().split())
print(int(c!=a))

Submission status: Accepted

Solution code:

M1,D1 = map(int,input().split())
M2,D2 = map(int,input().split())

if (M1==M2):
    print(0)
else:
    print(1)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
c,d = map(int,input().split())
if a != c:
  print('1')
else:
  print('0')

Submission status: Accepted

Solution code:
m1, d1 = [int(_) for _ in input().split()]
m2, d2 = [int(_) for _ in input().split()]

if m1 != m2:
    print(1)
else:
    print(0)

Submission status: Accepted

Solution code:
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if(D2 == 1):
    print(1)
else:
    print(0)

Submission status: Accepted

Solution code:
a,_ = map(int,input().split())
b,_ = map(int,input().split())
print(1 if a != b else 0)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(M: "List[int]", D: "List[int]"):
    if M[0] != M[1]:
        print(1)
    else:
        print(0)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    M = [int()] * (2)  # type: "List[int]"
    D = [int()] * (2)  # type: "List[int]"
    for i in range(2):
        M[i] = int(next(tokens))
        D[i] = int(next(tokens))
    solve(M, D)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    a,b=inpm()
    c,d=inpm()
    if a==c:
        print(0)
    else:
        print(1)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    m1,d1=map(int,input().split())
    m2,d2=map(int,input().split())
    print(0 if(d2-d1==1) else 1)
resolve()

Submission status: Accepted

Solution code:
m1, d1 = map(int,input().split())
m2, d2 = map(int,input().split())
if m1 == m2:
  print(0)
else:
  print(1)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  M1,D1=LI()
  M2,D2=LI()

  if D2==1:
    return 1
  return 0

# main()
print(main())

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
c,d=map(int,input().split())
if c!=a:
    print(1)
else:
    print(0)

Submission status: Accepted

Solution code:
X, Y = map(int, input().split())
A, B = map(int, input().split())
if X != A:
    print(1)
else:
    print(0)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())

c,d = map(int,input().split())

if a == c:
    print ("0")
else:
    print (1)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)
M1, D1 = map(int,input().split())
M2, D2 = map(int,input().split())

print(0 if M1==M2 else 1)

Submission status: Accepted

Solution code:
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())

if m1 == m2:
    print('0')
else:
    print('1')

Submission status: Accepted

Solution code:
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())
if M1 != M2:
  print('1')
else:
  print('0')

Submission status: Accepted

Solution code:
m, d = map(int, input().split())
m2, d2 = map(int, input().split())
if m != m2:
    print(1)
else:
    print(0)

Submission status: Accepted

Solution code:
a, b = map(int,input().split())
c,d = map(int,input().split())

if d < b:
    print(1)
else:
    print(0)

Submission status: Accepted

Solution code:
M1,D1=map(int,input().split())
M2,D2=map(int,input().split())
print('1' if M1<M2 else '0')

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
m, d = map(int, input().split())
print(1 if d == 1 else 0)

Submission status: Accepted

Solution code:
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if M1 != M2 :
    print(1)
else :
    print(0)

Submission status: Accepted

Solution code:
a,b = map(int, input().split())
c,d = map(int, input().split())
if a!= c:
  print(1)
else:
  print(0)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
c, d = map(int, input().split())

if a == c:
  print(0)
else:
  print(1)

Submission status: Accepted

Solution code:
m1,d1=map(int,input().split())
m2,d2=map(int,input().split())
if d2==1:print("1")
else:print(0)

Submission status: Accepted

Solution code:
m, _ = [int(i) for i in input().split()]
n, _ = [int(i) for i in input().split()]
print(int(m!=n))

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    a,b = MI()
    c,d = MI()
    if a!=c:
        print(1)
    else:
        print(0)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
c,d = map(int,input().split())
if d == 1:
    print(1)
else:
    print(0)

Submission status: Accepted

Solution code:

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

M1,D1 = inpl()
M2,D2 = inpl()

if M1 == M2:
    print(0)
else:
    print(1)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    m,d = LI()
    a,b = LI()
    if a != m:
        print(1)
    else:
        print(0)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
# Input Values
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

# Check if D2 equals 1 or not
if D2 == 1:
	print(1)
else:
	print(0)

Submission status: Accepted

Solution code:
# Input Values
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

# Check if M1 is not equal to M2
if M1 != M2:
	print(1)
else:
	print(0)

Submission status: Accepted

Solution code:
# Input Values
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

# The case when the last day of the month is "31st"
if M1 == 1 or M1 == 3 or M1 == 5 or M1 == 7 or M1 == 8 or M1 == 10 or M1 == 12:
	print(1 if D1 == 31 else 0)

# The case when the last day of the month is "30th"
if M1 == 4 or M1 == 6 or M1 == 9 or M1 == 11:
	print(1 if D1 == 30 else 0)

# The case when the last day of the month is "28th"
if M1 == 2:
	print(1 if D1 == 28 else 0)

Submission status: Runtime Error

Solution code:
N = int(input())
S = input()
res = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            tnp = [i,j,k]
            flag = 0
            for s in S:
                if int(s) == tnp[flag]:
                    flag += 1
                if flag == 3:
                    res += 1
                    break
print(res)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
c,d=map(int,input().split())
print([0,1][a==b+1]

Submission status: Runtime Error

Solution code:
import math
N = int(input())
S = math.ceil(N / 1.08)
if S * 1.08 != N:
  print(":(")
else:
  print(S)

Submission status: Runtime Error

Solution code:
MD = [map(int, input().split()) for _ in range(N)]
M, D = [list(i) for i in zip(*MD)]

if D[1] == 1:
    print(1)
else:
    print(0)

Submission status: Runtime Error

Solution code:
N=int(input())

for i in range(N+1):
    if int(i*1.08)==N:
        print(i)
        break

if all(int(i*1.08)!=N for i in range(N))==True:
    print(":(")

Submission status: Runtime Error

Solution code:
import itertools
n = int(input())
s = list(input())
a = ['0','1','2','3','4','5','6','7','8','9']
cnt=0
for i in list(itertools.product(a, repeat=3)):
  d =0
  e =0
  while d < n:
    if s[d] == i[e]:
      e+=1
    d+=1
    if e==3:
      cnt+=1
      break
print(cnt)

Submission status: Runtime Error

Solution code:
import math
N=int(input())
x=math.floor(N/1.08)
X=math.floor((N+1)/1.08)
if x < X:
  print(x)
else:
  print(":(")

Submission status: Runtime Error

Solution code:
import math
N=int(input())
x=math.floor(N/1.08)
X=math.floor((N+1)/1.08)
if  x < X:
  print(x)
else:
  print(":(")

Submission status: Runtime Error

Solution code:
n = int(input())
a = n // 100
b = n % 100
check = a >= 20 or b / 5 <= a
print("1" if check else "0")

Submission status: Runtime Error

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline
 
N=int(input())
A=list(map(int,input().split()))
color1 = -1
color2 = -1
color3 = -1
 
m = 10**9+7
patern = 1
 
for a in A:
    if color1 == a-1 and color2 == a-1 and color3 == a-1:
        patern = (patern * 3)%m
        color1 = a
 
    elif (color1 != a-1 and color2 == a-1 and color3 == a-1):
        patern = (patern * 2)%m
        color2 = a
 
    elif (color1 == a-1 and color2 == a-1 and color3 != a-1):
        patern = (patern * 2)%m
        color1 = a
    elif (color1 == a-1 and color2 != a-1 and color3 != a-1):
        color1 = a
 
    elif (color1 != a-1 and color2 == a-1 and color3 != a-1):
        color2 = a
 
    elif (color1 != a-1 and color2 != a-1 and color3 == a-1):
        color3 = a
 
    elif (color1 != a-1 and color2 != a-1 and color3 != a-1):
        patern = 0
        break
print(patern)

Submission status: Runtime Error

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline
 
N=int(input())
A=list(map(int,input().split()))
color1 = -1
color2 = -1
color3 = -1
 
m = 10**9+7
patern = 1
 
for a in A:
    if color1 == a-1 and color2 == a-1 and color3 == a-1:
        patern = patern * 3
        color1 = a
 
    elif (color1 != a-1 and color2 == a-1 and color3 == a-1):
        patern = patern * 2
        color2 = a
 
    elif (color1 == a-1 and color2 == a-1 and color3 != a-1):
        patern = patern * 2
        color1 = a
    elif (color1 == a-1 and color2 != a-1 and color3 != a-1):
        color1 = a
 
    elif (color1 != a-1 and color2 == a-1 and color3 != a-1):
        color2 = a
 
    elif (color1 != a-1 and color2 != a-1 and color3 == a-1):
        color3 = a
 
    elif (color1 == a-1 and color2 != a-1 and color3 == a-1):
        patern = patern * 2
        color1 = a
 
    elif (color1 != a-1 and color2 != a-1 and color3 != a-1):
        print(0)
        exit()
        
print(patern % m)

Submission status: Runtime Error

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline
 
N=int(input())
A=list(map(int,input().split()))
color1 = -1
color2 = -1
color3 = -1
 
m = 10**9+7
patern = 1
 
for a in A:
    if color1 == a-1 and color2 == a-1 and color3 == a-1:
        patern = patern * 3
        color1 = a
 
    elif (color1 != a-1 and color2 == a-1 and color3 == a-1):
        patern = patern * 2
        color2 = a
 
    elif (color1 == a-1 and color2 == a-1 and color3 != a-1):
        patern = patern * 2
        color1 = a
    elif (color1 == a-1 and color2 != a-1 and color3 != a-1):
        color1 = a
 
    elif (color1 != a-1 and color2 == a-1 and color3 != a-1):
        color2 = a
 
    elif (color1 != a-1 and color2 != a-1 and color3 == a-1):
        color3 = a
 
    elif (color1 == a-1 and color2 != a-1 and color3 == a-1):
        patern = patern * 2
        color1 = a
 
    elif (color1 != a-1 and color2 != a-1 and color3 != a-1):
        patern = 0
        break
print(patern % m)

Submission status: Runtime Error

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))
color1 = -1
color2 = -1
color3 = -1

m = 10**9+7
patern = 1

for a in A:
    if color1 == a-1 and color2 == a-1 and color3 == a-1:
        patern = patern * 3
        color1 = a

    elif (color1 != a-1 and color2 == a-1 and color3 == a-1):
        patern = patern * 2
        color2 = a

    elif (color1 == a-1 and color2 == a-1 and color3 != a-1):
        patern = patern * 2
        color1 = a
    elif (color1 == a-1 and color2 != a-1 and color3 != a-1):
        color1 = a

    elif (color1 != a-1 and color2 == a-1 and color3 != a-1):
        color2 = a

    elif (color1 != a-1 and color2 != a-1 and color3 == a-1):
        color3 = a

    elif (color1 == a-1 and color2 != a-1 and color3 == a-1):
        patern = patern * 2
        color1 = a

    elif (color1 != a-1 and color2 != a-1 and color3 != a-1):
        #(これはありえない)
        continue
print(patern % m)

Submission status: Runtime Error

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))
color1 = -1
color2 = -1
color3 = -1

m = 10**9+7
patern = 1

for a in A:
    if color1 == a-1 and color2 == a-1 and color3 == a-1:
        patern = patern * 3
        color1 = a

    elif (color1 != a-1 and color2 == a-1 and color3 == a-1):
        patern = patern * 2
        color2 = a

    elif (color1 == a-1 and color2 == a-1 and color3 != a-1):
        patern = patern * 2
        color1 = a
    elif (color1 == a-1 and color2 != a-1 and color3 != a-1):
        color1 = a

    elif (color1 != a-1 and color2 == a-1 and color3 != a-1):
        color2 = a

    elif (color1 != a-1 and color2 != a-1 and color3 == a-1):
        color3 = a

    elif (color1 == a-1 and color2 != a-1 and color3 == a-1):
        patern = patern * 2
        color1 = a

    elif (color1 != a-1 and color2 != a-1 and color3 != a-1):
        #(これはありえない)
    
print(patern % m)

Submission status: Runtime Error

Solution code:
md1=map(int,input().split())
md2=map(int,input().split())

print(1 if md1[0]!=md2[0] else 0)

Submission status: Runtime Error

Solution code:
#B - Tax Rate 
import math
N = int(input())

result = ':('
for i in range(1,50000):
    if math.floor(i * 1.08) == N:#小数点以下切り捨て
        result = i
print(result)

Submission status: Runtime Error

Solution code:
n = int(input())
s = input()
ans = 0

for i in range(0,1000):
    num = str(i)
    if i < 10:
        num = "00"+num
    elif i <100:
        num = "0" + num
    f = 0
    for j in range(n):
        if s[j] == num[f]:
            f += 1
        if f == 3:
            break
    if f==3:
        ans +=1
print(ans)

Submission status: Runtime Error

Solution code:
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]


n = int(input())
s = input()
ans = set()

for i in range(0,1000):
    num = str(i)
    if i < 10:
        num = "00"+num
    elif i <100:
        num = "0" + num
    for j in range(n):
        if s[j] == num[0]:
            for k in range(j+1,n):
                if s[k] == num[1]:
                    for l in range(k+1,n):
                        if s[l] == num[2]:
                            ans.add(i)
print(len(ans))

Submission status: Runtime Error

Solution code:
import math
N = int(input())
A = N/1.08 
B = (N+1)/1.08 

if math.ceil(N/1.08) < math.ceil((N+1)/1.08 ):
  print(math.ceil(N/1.08))
else:
  print(':(')

Submission status: Runtime Error

Solution code:
n=int(input())

x=int(n/1.08)

if int(x*1.08)==n:
    print(x)
elif int((x+1)*1.08)==n:
    print(x+1)
else:
    print(':(')

Submission status: Runtime Error

Solution code:
x = int(input())
n = x // 100

if x <= 105 * n:
  print(1)
else:
  print(0)

Submission status: Runtime Error

Solution code:
a=int(input())
for i in range(1,500001):
    if int(i*1.08)==a:
        print(i)
        break
else:
      print(':(')

Submission status: Runtime Error

Solution code:
import math
n=int(input())
for i in range(1,n+1):
  if math.floor(i*1.08)==n:
    print(i)
    break
  else:
    continue
else:
  print(":(")

Submission status: Runtime Error

Solution code:
n = int(input())

from decimal import Decimal

import sys

for i in range(60000):
    if int(Decimal(i) * Decimal('1.08')) == n:
        print(i)
        sys.exit()

print(':(')

Submission status: Runtime Error

Solution code:
N=int(input())
S=input()
re_list=[]
ele = list(map(str, S))
v_list=[]
vi_list=[]
flag = 0
count = 0
for i in range(1000):
    if i < 10:
        v_list.append("00"+str(i))
    elif i < 100:
        v_list.append("0" + str(i))
    else:
        v_list.append(str(i))

for i in range(1000):
    for j in range(N):
        if ele[j] == v_list[i][0] and flag == 0:
            flag = 1
            continue
        if ele[j] == v_list[i][1] and flag == 1:
            flag = 2
            continue
        if ele[j] == v_list[i][2] and flag == 2:
            count += 1
            break
    flag = 0
print(count)

Submission status: Runtime Error

Solution code:
m1,d1 = map(int,input().split())
m2,d2 = map(int,input().split())

if mi == m2:
    print(0)
else:
    print(1)

Submission status: Runtime Error

Solution code:
n = int(input())
s = input()
cou = 0
for i in range(1000):
  i = "{0:03d}".format(i)
  a,b,c = i[0],i[1],i[2]
  for j in range(n):
    if s[j]==a and bit==0:
      for k in range(j+1,n):
        if s[k]==b :
          for m in range(k+1,n):
            if s[m]==c :
              cou += 1
            
print(cou)

Submission status: Runtime Error

Solution code:
n = input()
ln = input()

n=int(n)
sec_set = set()

for i in range(10):
    first = ln.find(str(i))
    if first == -1:
        continue
    for j in range(10):
        second = ln[(first+1):].find(str(j))
        if second == -1:
            continue
        for k in range(10):
            third = ln[(first + second+2):].find(str(k))
            if third == -1:
                continue
            else:
                sec_set.add(str(i)+str(j)+str(k))
print(len(sec_set))

Submission status: Runtime Error

Solution code:
n = input()
ln = input()
sec_num = ""
n=int(n)
sec_set = set()
for i in range(10):
    first = ln.find(str(i))
    if first == -1:
        continue
    for j in range(10):
        second = ln[(first+1):].find(str(j))
        if second == -1:
            continue
        for k in range(10):
            third = ln[(first + second+2):].find(str(k))
            if third == -1:
                continue
            else:
                sec_set.add(str(i)+str(j)+str(k))
print(len(sec_set))

Submission status: Runtime Error

Solution code:
n = int(input())
s = input()

count = 0
for i in range(1000):
  pin = "00" + str(i)
  pin = pin[-3:]
  
  idx = 0
  for j in range(n):
    if s[j] == pin[idx]:
      idx += 1
      
    if idx == 3:
      count += 1
      break
      
print(count)

Submission status: Runtime Error

Solution code:
from itertools import product

N = int(input())
S = input()
S = [int(s) for s in S]


res = 0
for q in product(range(10), repeat=3):
    i = 0
    for s in S:
        if s==q[i]:
            if i==2:
                res += 1
                break
            else:
                i+=1
print (res)