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: 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)

Submission status: Runtime Error

Solution code:
N = int(input())
S = input()
cnt = 0
for i in range(1000):
    num = ''
    num += str(i // 100)
    num += str((i // 10) % 10)
    num += str(i % 10)
    j = 0
    for n in range(N):
        if S[n] == num[j]:
            j += 1
        if j == 3:
            break
    if j == 3:
        cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
import numpy as np
val1=input()
s=input()
n=int(val1)

data=np.zeros(1000,dtype=int)

for i in range(0,n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            data[int(s[i]+s[j]+s[k])]+=1
np.count_nonzero(data)

Submission status: Runtime Error

Solution code:
n = int(input())
for i in range(50000):
    x = int(i * 1.08)
    if (n == x):
        print(float(i))
        exit()
print(':(')

Submission status: Runtime Error

Solution code:
import itertools
n = int(input())
s = [i for i in input()]
p = set()
for v in itertools.combinations(s, 3):
  if v[0]+v[1]+v[2] not in p:
    p.add(v[0]+v[1]+v[2])
print(len(p))

Submission status: Runtime Error

Solution code:
import itertools

N = int(input())
S = input()
S_list = []
for i in range(len(S)):
    S_list.append(S[i])

comb_S_list = list(itertools.combinations(S_list,3))

print(len(set(comb_S_list)))

Submission status: Runtime Error

Solution code:
import math
def resolve():
  found = False
  N = int(input())
  for x in range(int(N/1.08), int((N+1)/1.08+1)):
    if N == math.floor(x*1.08):
      print(x)
      found = True
      break
  
  if not found:
    print(":(")

resolve()

Submission status: Runtime Error

Solution code:
def resolve():
  import math
  found = False
  N = int(input())
  for x in range(int(N/1.08), int((N+1)/1.08+1)):
    if N == math.floor(x*1.08):
      print(x)
      found = True
      break
  
  if not found:
    print(":(")
resolve()

Submission status: Runtime Error

Solution code:
l1 = list(map(int,input().split()))
l2 = list(map(int,input().split()))

if l[1] == 1:
  print('1')
else:
  print('0')

Submission status: Runtime Error

Solution code:
import math
N = int(input())
ans = math.ceil(N // (1.08))

while math.floor(ans*1.08) < N:
  ans += 1
  if math.floor(ans*1.08) == N:
    print(ans)
  elif math.floor(ans*1.08) > N:
    print(':(')

Submission status: Runtime Error

Solution code:
import math
N = int(input())
ans = math.ceil(N // (1.08))
while math.floor(ans*1.08) < N:
  ans += 1
  if math.floor(ans*1.08) == N:
    print(ans)
  elif math.floor(ans*1.08) > N:
    print(':(')

Submission status: Runtime Error

Solution code:
import math
def resolve():
    n=int(input())
    ans=(':(')
    for i in range(1,n+1):
        if math.floor(i*1.08)==n:
            ans=i
    print(ans)
resolve()

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
n = int(input())
f = 0
for i in range(1, n+1):
  if int(i*1.08) == n:
    print(i)
    exit()
print(':(')

Submission status: Runtime Error

Solution code:
n = int(input())

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

Submission status: Runtime Error

Solution code:
N = int(input())
S = [int(x) for x in list(input())]
total = []
for x in range(N-2):
  for y in range(x+1,N-1):
    for z in range(y+1,N):
      total.append(S[x]*100+S[y]*10+S[z])
print(len(set(total)))

Submission status: Runtime Error

Solution code:
n=int(input())
A=list(map(int,input().split()))
N=[0]*(10**6)
mod=10**9+7
if len([a for a in A if a==0])==1:
    ans=3
else:
    ans=6

for a in A:
    N[a]+=1
    if a!=0:
        ans*=N[a-1]
        ans%=mod
        N[a-1]-=1
print(ans)

Submission status: Runtime Error

Solution code:
import sys
import math

N = input()

if int(N) <= 100:
    print("0")
    sys.exit()

if int(N) % 100 == 0:
    print("1")
    sys.exit()

tmp = (int(N) - (int(N)//100)*100)

if tmp <= 5:
    print("1")
    sys.exit()

tmp2 = math.ceil(tmp/5)

if int(N) <= tmp2*105:
    print("0")
else:
    print("1")

Submission status: Runtime Error

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


ans =0

for i in range(10):
    if str(i) in s:
        t = s[s.index(str(i))+1:]
        for j in range(10):
            if str(j) in t:
                u = t[t.index(str(j))+1:]
                for k in range(10):
                    if str(k) in u:
                        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
 
ans = 0
for i in range(1, n+1):
  if n in list(range(100 * i, 105 * i + 1))
    ans = 1
print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
S=input()
V=[]
for i in range(10):
    for j in range(10):
        for k in range(10):
            s=""
            a=str(i)
            b=str(j)
            c=str(k)
            s=a+b+c
            V.append(s)
ans=0
for i in range(len(V)):
    v=V[i]
    flag1=False
    flag2=False
    flag3=False
    for j in range(N):
        if not flag1:
            if S[j]==v[0]:
                flag1=True
                continue
        if not flag2:
            if flag1:
                if S[j]==v[1]:
                    flag2=True
                    continue
        if flag2:
            if S[j]==v[2]:
                flag3=True
        if flag3:
            ans+=1
            break
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# Author: cr4zjh0bp
# Created: Sun Mar 29 05:26:08 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
s = ns()

def ok(p):
    k = 0
    for i in range(n):
        if s[i] == p[k]:
            k += 1
        if k == 3:
            return True
    return False

ans = 0
for i in range(1000):
    p = "{:0>3}".format(i)
    if ok(p):
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:

def resolve():

    N=int(input())
    s = str(input())


    l=['%03d'%(p) for p in range(0,10**3)]
    ans=[]
    for i in l:
        if i[0] in s:
            s0=s.index(i[0])
            if i[1] in s[s0+1:]:
                s1=s[s0+1:].index(i[1])
                if i[2] in s[s0+1:][s1+1:]:
                    ans.append(i)



    print(len(set(ans)))


resolve()

Submission status: Runtime Error

Solution code:
N = int(input())
S = str(input())

numbers = []
cnt = 0

for i in range(0, len(S), 1):
    for j in range(i+1, len(S), 1):
        for k in range(j+1, len(S), 1):
            number = (S[i],S[j],S[k])
            numbers.append(number)
print(len(set(numbers)))

Submission status: Runtime Error

Solution code:
N = int(input())
S = str(input())
x = '000'
ans = 0
while int(x) < 1000:
  st = 0
  cnt = 0
  if x[0] in S:
    for i in range(N):
      if x[0] == S[i]:
        st = i+1
        cnt += 1
        break
  if x[1] in S[st:]:
    for j in range(st, N):
      if x[1] == S[j]:
        st = j+1
        cnt += 1
        break
  if x[2] in S[st:]:
    for k in range(st, N):
      if x[2] == S[k]:
        st = k+1
        cnt += 1
        break
                
  if cnt == 3:
    ans += 1
  x = '{:03d}'.format(int(x)+1)
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
s=input()
count=0
for i in range(1000):
    if (i<10):
        num="00"+str(i)
    elif (i<100):
        num="0"+str(i)
    else:
        num=str(i)
    k=0
    flag=num[0]
    for j in range(len(s)):
        if (flag==s[j]):
            if (k<2):
                k=k+1
                flag=num[k]
            elif (k==2):
                count+=1
                #print(num)
                break
print(count)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
print(1-input()[:2]in input())

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a = input().split
b = input().split

if a[0] = b[0]:
  print("0")
else:
  print("1")

Submission status: Runtime Error

Solution code:
_,a _,b=map(int,open(0).read().split());print(1*(a+1==b))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
month = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
m, d = int(input()), int(input())
if month[m] == d:
    print(1)
else:
    print(0)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
S = input()
ans = 0
for i in range(10):
  l = 0
  while(True):
    if(i == int(S[l])):
      for j in range(10):
        m = l + 1
        while(True):
          if(j == int(S[m])):
            for k in range(10):
              for n in range(m+1, N):
                if(k == int(S[n])):
                  ans += 1
                  break
          m += 1
          if(m >= N - 1 or j == int(S[m - 1])):
             break
    l += 1
    if(l >= N - 2 or i == int(S[l - 1])):
      break
print(ans)

Submission status: Runtime Error

Solution code:
m_1,d_1 = int(input(),split())
m_2,d_2 = int(input(),split())
if d_2!=d_1+1:
	print(1)
else:
  print(0)

Submission status: Runtime Error

Solution code:
def LI:
	return [int(s) for s in input().split()]
  

D1 = LI()
D2 = LI()

if print(0) if D2[0] != D1[0] else print(1)

Submission status: Runtime Error

Solution code:
import math
N=int(input())
X=math.ceil(N/1.08)
if math.floor(X*1.08)==N:
    print(X)
else:
    print(':(')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
N=int(input())
X=float(N)/1.08
if X%1==0.0:
    print(int(X))
else:
    Y=math.floor(X)
    if math.floor(Y*1.08)==N or math.floor((Y-1)*1.08)==N:
        print(Y)
    else:
        print(":(")

Submission status: Runtime Error

Solution code:
N = int(input())
l = 100; r = 105
for i in range(5000):
    if l <= N <= r:
        print(1)
        break
    l += 100
    r += 105
print(0)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
m,d=map(int,input()split())
s,t=map(int,input()split())
if t==1:
    print(1)
else:
    print(0)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
m1=int(input())
d1=int(intput())
m2=int(input())
d2=int(intput())
if m1+1==m2:
  print(1)
else:
  print(0)

Submission status: Runtime Error

Solution code:
N = int(input())
count = 0

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

if count == 0:
    print(":(")

Submission status: Runtime Error

Solution code:
li = []
for i in range(2):
  a,b = map(int, input().split())
  li.append(a)
  
if li[1] == li[0]+1:
  return 1
else:
  return 0

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if m1[0] < m2[0]:
    print('1')
else:
    print('0')

Submission status: Runtime Error

Solution code:
M1 = int(input("Enter Month 1 "))
D1 = int(input("Enter Day 1 ")) 
M2 = int(input("Enter Month 2 "))
D2 = int(input("Enter Day 2 ")) 
if M1 and M2 <= 12 and M2-M1 == 1:
    print("1") if D1==30 and D2 == 1 else print("0")
else:    
    print("0")

Submission status: Runtime Error

Solution code:
M1 = int(input("Enter M1 \n"))

D1 = int(input("Enter D1 \n")) 

D2 = int(input("Enter D2 \n")) 
M2 = int(input("Enter M2 \n"))

print("1") if D1 == 30 else print("0")

Submission status: Runtime Error

Solution code:
in1=input().split()
in2=input().split()
if int(in1[0])==int(in2[0]):
  return 0
else:
  return 1

Submission status: Runtime Error

Solution code:
N = input()
S = input()

i = 0
j = 0
k = 0
N = int(N)
count = 0
for a in range(10):
    for i in range(N-2):
        if str(a) == S[i]:
            for b in range(10):
                for j in range(i+1, N-1):
                    if str(b) == S[j]:
                        for c in range(10):
                            for k in range(j+1,N):
                                if str(c) == S[k]:
                                    count += 1
                                    break
                        break
            break
print(count)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

if d2==1:
  print 1
else:
  print 0

Submission status: Runtime Error

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

if d2==1:
  print 1
else:
  print 0

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
for _ in range(M):
    a, b = map(int, input().split())
if M[1]==1:
  print 1
else:
  print 0

Submission status: Runtime Error

Solution code:
a = "11、16"
print "0"

Submission status: Runtime Error

Solution code:
n = int(input())

ans = -1
for x in range(n):
    if int(x*1.08)==n:
        ans = x

if ans != -1:
    print(ans)
else:
    print(':(')

Submission status: Runtime Error

Solution code:
m,d=int(input()),input()
M,D=int(input()),input()

if M - m == 1:
  print('1')
else:
  print('0')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
input=sys.stdin.readline
from itertools import combinations as cmb
n=int(input())
s=set(input())
combiset=set(cmb(s,3))
print(len(combiset))

Submission status: Runtime Error

Solution code:
import sys
input=sys.stdin.readline
from itertools import combinations as cmb
n=int(input())
s=list(input())
sss=[]
for i in s:
    sss.append(i)
combiset=set(cmb(sss,3))
print(len(combiset))

Submission status: Runtime Error

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

n=int(input())
s=input()
dp=[[[False]*1000 for j in range(4)] for i in range(n+1)]

dp[0][0][0]=True

for i in range(n):
    for j in range(4):
        for k in range(1000):
            if dp[i][j][k]==False:continue
            dp[i+1][j][k]=True
            if j<=2:
                dp[i+1][j+1][k*10+int(s[i])]=True
cnt=0
for i in range(1000):
    if dp[n][3][i]==1:cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
# 動的計画法

n=int(input())
s=input()
dp=[[[False for k in range(1000)] for j in range(4)] for i in range(n+1)]

dp[0][0][0]=True

for i in range(n):
    for j in range(4):
        for k in range(1000):
            if dp[i][j][k]==False:continue
            dp[i+1][j][k]=True
            if j<=2:
                dp[i+1][j+1][k*10+int(s[i])]=True
cnt=0
for i in range(1000):
    if dp[n][3][i]==True:cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
n=int(input())
s=input()
dp=[[[False for k in range(1000)] for j in range(4)] for i in range(n+1)]

dp[0][0][0]=True

for i in range(n):
    for j in range(4):
        for k in range(1000):
            if dp[i][j][k]==False:continue
            print(i,j,k)
            dp[i+1][j][k]=True
            print(i+1,j,k,i,j,k)
            if j<=2:
                dp[i+1][j+1][k*10+int(s[i])]=True
                print(i+1,j+1,k*10+int(s[i]),i,j,k)
cnt=0
for i in range(1000):
    if dp[n][3][i]==True:cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
payment = input()
price = float(payment) / 1.08


if (price - int(price)) == 0:
  print(int(price))
else:
  print(':(')

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int, input().split()))

x = 0
y = 0
z = 0
ans = 1
mod = 10 ** 9 + 7

for a in A:
  if a == x:
    if x == y:
      if y == z:
        ans *= 3
      else:
        ans *= 2
    x += 1
  elif a == y:
    if y == z:
      ans *= 2
    y += 1
  else:
    z += 1
ans %= mod
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
 
hats = [0, 0, 0]
count = 1
mod = 1000000007
 
for a in map(int, input().split()):
  count *= hats.count(a)
  count %= mod
  try:
    hats[hats.index(a)] += 1
  except ValueError:
    count = 0
    break
  
print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
 
mod = int(1e+9 + 7)
L = [0, 0, 0]
pi = 1
for i in range(N):
  j = 0
  while L[j] != A[i]:
    j += 1
    if j == 3:
      break
  n = 0
  for k in range(3):
    if L[k] == A[i]:
      n += 1
  if j != 3:
    L[j] += 1
  pi *= n
  pi %= mod
print(pi)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
x = 0
y = 0
z = 0
ans = 1
mod = 1000000007
for i in range(n): #1文字目
  if a[i] == x:
    if x == y:
      if x == z:
        ans *= 3
        ans %= mod
      else:
        ans *= 2
        ans %= mod
    x += 1
  elif a[i] == y:
    if y == z:
      ans *= 2
      ans %= mod
    y += 1
  else:
  	z += 1
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input()) #長さ
a = input().split() #帽子の数
x = 0
y = 0
z = 0
ans = 1
mod = 1000000007
for i in range(n): #1文字目
  if a[i] == str(x):
    if x == y and x == z:
      ans *= 3
      ans %= mod
    elif x == y:
      ans *= 2 
      ans %= mod
    x = x + 1
  elif a[i] == str(y):
    if y == z:
      ans *= 2
      ans %= mod
    y += 1
  else:
    z += 1
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input()) #長さ
a = input().split() #帽子の数
x = 0
y = 0
z = 0
ans = 1
 
for i in range(n): #1文字目
  if a[i] == str(x):
    if x == y and x == z:
      ans *= 3
    elif x == y:
      ans *= 2
    x = x + 1
  elif a[i] == str(y):
    if y == z:
      ans *= 2
    y += 1
  else:
    z += 1
print(ans % 1000000007)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
x = 0
y = 0
z = 0
ans = 1
mod = 10**9+7
for i in range(n): #1文字目
  if a[i] == x:
    x = x + 1
    if x-1 == y:
      if x-1 == z:
        ans = ans * 3
      else:
        ans = ans * 2
  elif a[i] == y:
    y = y + 1
    if y-1 == z:
      ans = ans * 2
  else:
  	z = z + 1
print(ans % mod)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
x = 0
y = 0
z = 0
ans = 1 
for i in range(n): #1文字目
  if a[i] == x:
    x = x + 1
    if x-1 == y:
      if x-1 == z:
        ans = ans * 3
      else:
        ans = ans * 2
  elif a[i] == y:
    y = y + 1
    if y-1 == z:
      ans = ans * 2
  else:
  	z = z + 1
print(ans % 1000000007)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
x = 0
y = 0
z = 0
ans = 1
for i in range(n): #1文字目
  if a[i] == x:
    if x == y == z:
      ans = ans * 3
    elif x == y != z:
      ans = ans * 2
    x = x + 1
  elif a[i] == y:
    if y == z:
      ans = ans * 2
  	y = y + 1
  else:
  	z = z + 1
print(ans % 1000000007)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
x = 0
y = 0
z = 0
ans = 1 
for i in range(n): #1文字目
  if a[i] == x:
    if x == y == z:
      ans = ans * 3
    elif x == y != z:
      ans = ans * 2
    x = x + 1
  elif a[i] == y:
    if y == z:
      ans = ans * 2
    y = y + 1
  else:
  	z = z + 1
print(ans % 1000000007)

Submission status: Runtime Error

Solution code:
n=int(input())
a = n / 1.08
if a-int(a) == 0.00:
      x = int(a)
else:
      x = int(a) + 1
v = int(x * 1.08)
if v == n:
  print(x)
else:
  print(":(")

Submission status: Runtime Error

Solution code:
n=int(input())
a = n / 1.08
if a-int(a) == 0.00:
      x = int(a)
else:
      x = int(a) + 1
v = int(x * 1.08)
if v == n:
  print(x)
else:
  print(":(")

Submission status: Runtime Error

Solution code:
n = int(input())
a = n / 1.08
if a-int(a) == 0.00:
      x = int(a)
else:
      x = int(a) + 1
v = int(x * 1.08)
if v == n:
  print(x)
else:
  print(":(")

Submission status: Runtime Error

Solution code:
n = input()
a = n / 1.08
if float(n%1.08):
      x = int(a)
else:
      x = int(a) + 1
v = int(x * 1.08)
if v == n:
  print(x)
else:
  print(":(")

Submission status: Runtime Error

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

if M1 in [1, 3, 5, 7, 8, 10, 12]:
	if D1 == 31:
		print("1")
	else:
		print("0")
else if M1 == 2:
	if D1 == 28:
		print("1")
	else:
		print("0")
else:
	if D1 == 30:
		print("1")
	else:
		print("0")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
if int((N//1.08)*1.08)==N:
  print(int(N//1.08))
elif int((N//1.08+1)*1.08)==N:
  print(int(N//1.08+1))
else:
  print(':(')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
X = input()
M = {X[0:3]:1}
result = {}

for i in range(3,N):
    i = X[i]
    keys = M.keys()
    for j in tuple(keys):
        if (j, i) in result:
            continue
        M[j[0]+j[1]+i] = 1
        M[j[0]+j[2]+i] = 1
        M[j[1]+j[2]+i] = 1
        result[(j,i)] = True

print (len(M))

Submission status: Runtime Error

Solution code:
#coding:utf-8
n = int(input())
#切り上げ
x = int(-(-n // 1.08))

if x * 1.08 == n:
  print(x)
else:
  print(':(')

Submission status: Runtime Error

Solution code:
import math

n = int(input())
S = input()

ans = 0
flag = [1,1,1]
flag_number = [1,0,0]
li = []

for i in range(10):
    for j in range(10):
        for k in range(10):
            number = [i,j,k]
            for s in range(len(S)):
                if flag[0] and (int(S[s]) == number[0]):
                    flag_number[0] = s
                    flag[0]  = 0
                    flag[1] = 1
                    continue
                if flag[1] and (int(S[s]) == number[1]):
                    flag_number[1] = s
                    flag[1] = 0
                    flag[2] = 1
                    continue
                if  flag[2] and (int(S[s]) == number[2]):
                    flag_number[2] = s
                    flag[2] = 0
                    continue
            if flag_number[2] != 0:
                ans += 1
            flag_number = [0,0,0]
            flag = [1,0,0]

print(ans)

Submission status: Runtime Error

Solution code:
x=int(input())
ans=0
for i in range(1000):
   if i*100<=x<=105*i:
       ans=1
print(ans)

Submission status: Runtime Error

Solution code:
x = int(input())
k = x//100
print(1) if 100*k <= x and x<= 105*k else print(0)

Submission status: Runtime Error

Solution code:
N = int(input())
S = input()
cnt = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            idx = S.find(str(k))
            if idx != -1:
                idx = S.find(str(j),idx+1)
                if idx != -1:
                    idx = S.find(str(i),idx+1)
                    if idx != -1:
                        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
print(1 if int(input().split()[2])==1 else 0)

Submission status: Runtime Error

Solution code:
input1 = int(input())
input2 = input()
inputbox = list(input2)
i=0
count = 0
for i in range(1000):
        c = [int(i/100),int(i/10)%10,i%10]
        f = 0
        for j in range(input1):
            if int(inputbox[j])==c[f]:
                f=f+1
            if f==3:
                break
        if f==3:
            count = count + 1
            
print(count)

Submission status: Runtime Error

Solution code:
input1 = int(input())
input2 = input()
#input1 = len(input2)
kesu = input1 - 1
inputbox = list(input2)
li=[0 for _ in range(1000)]
kazu =""
number = []
i=0
while i < input1-2:
    number.clear()
    number.append(inputbox[i])
    j=0
    while j < input1 - 2 - i:
        number.append(inputbox[j+i+1])
        k=0
        while k < input1 - 2 - i - j:
            number.append(inputbox[k+j+i+2])
            kazu=""
            for n in range(3):
                kazu = kazu+str(number[n])
            kazu1 = int(kazu)
            li[kazu1]=1
            number.pop()
            k=k+1
        j=j+1
        number.pop()
    i=i+1

count = 0
for i in range (1000):
    if li[i] == 1:
        count =count+1

print(count)

Submission status: Runtime Error

Solution code:
t1,t2=map(int,input().split())
a1,a2=map(int,input().split())
b1,b2=map(int,input().split())
sa1=(a1-b1)*t1
sa2=(a2-b2)*t2
if sa1>=0:
    --sa1
    --sa2
if sa1+sa2==0:
    print("infinity")
if sa1+sa2<0:
    print(0)
if sa1+sa2>0:
    ans=((-sa1)//(sa2+sa1))*2+1
    if sa1%(sa1+sa2)==0:
        ans-=1
    print(ans)

Submission status: Runtime Error

Solution code:
for i in range(2):
	n.append([int(x) for x in input().split()])
print(1 if n[0][0]!=n[1][0] else 0)

Submission status: Runtime Error

Solution code:
def main():
    N = int(input())
    S = input()
    lst = list(S)

    a = ['{:03d}'.format(i) for i in range(1000)]
    count = 0
    for i in range(len(a)):
        m,n,o = 0,1,2
        s = list(a[i])
        while m < n < o < len(lst) :
            if s[0] != lst[m]:
                m += 1
                n += 1
                o += 1
            elif s[1] != lst[n]:
                n += 1
                o += 1
            elif s[2] != lst[o]:
                o += 1
            else:
                count += 1
                break

    print(count)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import math

N = int(input())

X = float(N/1.08)
X2 = math.ceil(X)

if N == math.floor(math.ceil(X)*1.08):
 print(X2)

else:
 print(':(')

Submission status: Runtime Error

Solution code:
import math

N = int(input())

X = float(N/1.08)

if N == math.floor(math.ceil(X)*1.08):
 print(math.ceil(X))

else:
 print(':(')

Submission status: Runtime Error

Solution code:
n = int(input())

for i in range(1, n+1):
    if 100*i <= n <= 105*i:
        print(1)
        exit()

print(0)

Submission status: Runtime Error

Solution code:
n = int(input())
s = input()
ans = 0
for i in range(1000):
    c = [i // 100, (i // 10) % 10, i % 10]
    digit = 0
    for j in s:
        if c[digit] == int(j):
            digit+=1
        if digit == 3:
            break
    if digit == 3:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
S = input()
cnt = 0
for i in range(1000):
  hy = i//100
  zyu = (i-hy*100)//10
  ichi = i%10
  cnt_hy = float('inf')
  cnt_zyu = float('inf')
  cnt_ichi = float('inf')
  t = 0
  for j in range(n):
    if int(S[j]) == hy and t == 0:
      cnt_hy = j
      t += 1
    elif int(S[j]) == zyu and t == 1:
      cnt_zyu = j
      t += 1
    elif int(S[j]) == ichi and t == 2:
      cnt_ichi = j
  if cnt_hy < cnt_zyu < cnt_ichi <= n-1:
    cnt += 1
print(cnt)