TnT/CodeNet4Repair huggingface dataset:
Problem:
Write a program which reads a sequence and prints it in the reverse order.

Incorrect submission (verdict: Wrong Answer):
n = list(map(int,input().split()))
for i in range(len(n)):
         print(n[len(n)-i-1])

Fixed, accepted submission:
n =int(input())
a = list(map(int,input().split()))
a.reverse()
for i in range(n):
    if i!=n-1:
        print(a[i],end=" ")
    else:
        print(a[i])
Problem:
There are N integers, A_1, A_2, ..., A_N, written on a blackboard.  We will repeat the following operation N-1 times so that we have only one integer on the blackboard.    * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y.  Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
a.sort()
mi,ma=a[0],a[-1]
for i in a[1:-1]:
  if i<0:print(ma,i);ma-=i
  else:print(mi,i);mi-=i
print(ma,mi)

Fixed, accepted submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
mi,ma=a[0],a[-1]
for i in a[1:-1]:
  if i<0:ma-=i
  else:mi-=i
print(ma-mi)
mi,ma=a[0],a[-1]
for i in a[1:-1]:
  if i<0:print(ma,i);ma-=i
  else:print(mi,i);mi-=i
print(ma,mi)
Problem:
We have N pieces of ropes, numbered 1 through N. The length of piece i is a_i.  At first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly:    * Choose a (connected) rope with a total length of at least L, then untie one of its knots.  Is it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.

Incorrect submission (verdict: Wrong Answer):
n,l=map(int,input().split())
A=list(map(int,input().split()))
for i in range(n-1):
    if A[i]+A[i+1]>=l:
        print('Possible')
        break
else:
    print('Impossible')

Fixed, accepted submission:
n,l=map(int,input().split())
A=list(map(int,input().split()))
for i in range(n-1):
    if A[i]+A[i+1]>=l:
        print('Possible')
        t=i+1
        break
else:
    print('Impossible')
    exit()
for i in range(1,t):
    print(i)
for i in range(n-1,t,-1):
    print(i)
print(t)
Problem:
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total?  Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.

Incorrect submission (verdict: Wrong Answer):
a, b, c, x = map(int,[input() for i in range(4)])
ans = 0
for i in range(0, a):
    for j in range(0, b):
        for k in range(0, c):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)


Fixed, accepted submission:
a, b, c, x = map(int,[input() for i in range(4)])
ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)
Problem:
As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below:    * A consists of integers between X and Y (inclusive).   * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.  Find the maximum possible length of the sequence.

Incorrect submission (verdict: Wrong Answer):
import math


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

print(int(math.log2(Y / X)))


Fixed, accepted submission:
X, Y = map(int, input().split())

cnt = 1
k = X
while k * 2 <= Y:
    cnt += 1
    k *= 2

print(cnt)
Problem:
This contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters.  Mr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way.  You are given a string s consisting of uppercase English letters. Determine whether the string `CF` can be obtained from the string s by deleting some characters.

Incorrect submission (verdict: Wrong Answer):
import sys
s=input()
for i in range(len(s)):
    if s[i]=="C":
        for j in range(i+1,len(s)):
            if s[j]=="F":
                print("YES")
                sys.exit()
            if j==len(s)-1:
                print("NO")
                sys.exit()

Fixed, accepted submission:
import sys
s=input()
for i in range(len(s)):
    if i==len(s)-1:
        print("No")
        sys.exit()
    if s[i]=="C":
        for j in range(i+1,len(s)):
            if s[j]=="F":
                print("Yes")
                sys.exit()
            if j==len(s)-1:
                print("No")
                sys.exit()
Problem:
E869120 found a chest which is likely to contain treasure.   However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.   He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`.  One more thing he found is a sheet of paper with the following facts written on it:    * Condition 1: The string S contains a string T as a contiguous substring.   * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.  Print the string S.   If such a string does not exist, print `UNRESTORABLE`.

Incorrect submission (verdict: Wrong Answer):
S = input()
T = input()

l = len(T)

ind = 51
for i in range(len(S)-l+1):
    flag = 0
    for j in range(l):
        if S[i+j]!='?' and S[i+j]!=T[j]:
            flag = 1
    if flag==0:
        ind = i

if ind == 51:
    print('UNRESTORABLE')
    exit()

print(S[:i].replace('?','a')+T+S[i+j:].replace('?','a'))

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

l = len(T)

ind = 51
for i in range(len(S)-l+1):
    flag = 0
    for j in range(l):
        if S[i+j]!='?' and S[i+j]!=T[j]:
            flag = 1
    if flag==0:
        ind = i

if ind == 51:
    print('UNRESTORABLE')
    exit()

print(S[:ind].replace('?','a')+T+S[ind+l:].replace('?','a'))
Problem:
大きな数を表そうとすると、文字数も多くなるし、位取りがわからなくなってしまうので、なかなか面倒です。大きな数をわかりやすく表すために、人々は数の単位を使ってきました。江戸時代に書かれた「塵劫記」という本の中では、数の単位が次のように書かれています。      たとえば、２の１００乗のようなとても大きな数は、１２６穣７６５０(じょ)６００２垓２８２２京９４０１兆４９６７億３２０万５３７６と表せます。それでは、正の整数 m と n が与えられたとき、m の n 乗を塵劫記の単位を使って上のように表すプログラムを作成してください。

Incorrect submission (verdict: Wrong Answer):

# Python3 2018.6.26 bal4u

unit = ("", "Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko", "Kan", \
"Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts")

while True:
	m, n = map(int, input().split())
	if m == 0: break
	s = str(m ** n)[::-1]
	ans, j = [], 0
	for i in range(0, len(s), 4):
		t = s[i:i+4][::-1]
		if t != "0000":
			ans += [unit[j], t]
		j += 1
	print(*ans[::-1], sep='')


Fixed, accepted submission:

# Python3 2018.6.26 bal4u

unit = ("", "Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko", "Kan", \
"Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts")

while True:
	m, n = map(int, input().split())
	if m == 0: break
	s = str(m ** n)[::-1]
	ans = []
	for i in range(0, len(s), 4):
		t = str(int(s[i:i+4][::-1]))
		if t != "0": ans += [unit[i>>2], t]
	print(*ans[::-1], sep='')
Problem:
There are N positive integers written on a blackboard: A_1, ..., A_N.  Snuke can perform the following operation when all integers on the blackboard are even:    * Replace each integer X on the blackboard by X divided by 2.  Find the maximum possible number of operations that Snuke can perform.

Incorrect submission (verdict: Wrong Answer):
ans = 0
N = input()
A = list(map(int, input().split()))
for i in A :
  p = 0
  if i % 2 != 0 :
    print(0)
    break
  else :
    while i % 2 != 0 :
      i //= 2
      p += 1
    if ans < p :
      ans = p
print(ans)
     
    

Fixed, accepted submission:
import sys


def main():

    N = int(sys.stdin.readline().rstrip())
    A = list(map(int, sys.stdin.readline().rstrip().split()))
    
    cnt = 0
    exist_odd = False
    while True:
        for i in range(N):
            if A[i] % 2 != 0:
                exist_odd = True
                
        if exist_odd == True:
            break
            
        for i in range(N):
            A[i] /= 2
        cnt += 1
        
    print(cnt)
        
        
            
    
    
if __name__ == '__main__':
    main()
Problem:
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes:    * Hit his pocket, which magically increases the number of biscuits by one.   * Exchange A biscuits to 1 yen.   * Exchange 1 yen to B biscuits.  Find the maximum possible number of biscuits in Snuke's pocket after K operations.

Incorrect submission (verdict: Wrong Answer):
K, A, B = map(int, input().split())

if not B - A <= 2:
    if not (A == K or A == K + 1):
        if (K - A) // 2 == 0:
            print(B + (B - A) * ((K - A - 1) // 2) + 1)
        else:
            print(B + (B - A) * ((K - A - 1) // 2))
    else:
        print(K + 1)

else:
    print(K + 1)


Fixed, accepted submission:
K, A, B = map(int, input().split())

if (B - A) <= 2:
  print(K + 1)
else:
  res = K-A+1
  print(A+(B-A)*(res//2)+res%2)
Problem:
Your task is to perform a simple table calculation.  Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.

Incorrect submission (verdict: Wrong Answer):
r,c = map(int, input().split())
for i in range(r):
    a = list(map(int, input().split()))
    sum = 0
    for j in range(c):
        sum += a[j]
    a.append(sum)
    for k in range(c+1):
        print(a[k], end = "")
        if k != c:
            print(" ")
    print()

        


Fixed, accepted submission:
r,c = map(int, input().split())
matrix = []
for i in range(r):
    a = list(map(int, input().split()))
    sum = 0
    for j in range(c):
        sum += a[j]
    a.append(sum)
    matrix.append(a)
    for k in range(c+1):
        print(a[k], end = "")
        if k != c:
            print(" ", end = "")
    print()
for l in range(c+1):
    sum2 = 0
    for m in range(r):
        sum2 += matrix[m][l]
    print(sum2, end = "")
    if l != c:
        print(" ", end = "")
print()
Problem:
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?

Incorrect submission (verdict: Wrong Answer):
M = int(input())
print(24-M)

Fixed, accepted submission:
M = int(input())
print(48-M)
Problem:
Two students of AtCoder Kindergarten are fighting over candy packs.  There are three candy packs, each of which contains a, b, and c candies, respectively.  Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.  Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.

Incorrect submission (verdict: Wrong Answer):
# -*- coding: utf-8 -*-


a, b, c = map(int, input().split())

if a+b == c or a == b+c:
  print('Yes')
else:
  print('No')

Fixed, accepted submission:
# -*- coding: utf-8 -*-


a, b, c = map(int, input().split())

if a == (b+c):
  print('Yes')
elif (a+b) == c:
  print('Yes')
elif (a+c) == b:
  print('Yes')
else:
  print('No')
Problem:
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.

Incorrect submission (verdict: Wrong Answer):
N = int(input())

t0, x0, y0 = map(int, input().split())
if t0 < x0 + y0 or t0 % 2 != (x0 + y0) % 2:
    print("No")
    exit()

for i in range(1, N):
    t1, x1, y1 = map(int, input().split())
    dist_t, dist_x, dist_y = abs(t1-t0), abs(x1-x0), abs(y1-y0)
    print("dist_t: {}, dist_x: {}, dist_y: {}".format(dist_t, dist_x, dist_y))
    if dist_t < dist_x + dist_y or dist_t % 2 != (dist_x + dist_y) % 2:
        print("No")
        exit()
    t0, x0, y0 = t1, x1, y1
print("Yes")


Fixed, accepted submission:
N = int(input())

t0, x0, y0 = map(int, input().split())
if t0 < x0 + y0 or t0 % 2 != (x0 + y0) % 2:
    print("No")
    exit()

for i in range(1, N):
    t1, x1, y1 = map(int, input().split())
    dist_t, dist_x, dist_y = abs(t1-t0), abs(x1-x0), abs(y1-y0)
    # print("dist_t: {}, dist_x: {}, dist_y: {}".format(dist_t, dist_x, dist_y))
    if dist_t < dist_x + dist_y or dist_t % 2 != (dist_x + dist_y) % 2:
        print("No")
        exit()
    t0, x0, y0 = t1, x1, y1
print("Yes")
Problem:
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.  The problem has N test cases.  For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.  See the Output section for the output format.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
n = [input() for i in range(N)]
count_AC = 0
count_WA = 0
count_TLE = 0
count_RE = 0
for i in n:
    if i == 'AC':
        count_AC += 1
    elif i == 'WA':
        count_WA += 1
    elif i == 'TLE':
        count_WA += 1
    elif i == 'RE':
        count_WA += 1
print('AC x {0}\nWA x {1}\nTLE x {2}\nRE x {3}'.format(count_AC, count_WA, count_TLE, count_RE))

Fixed, accepted submission:
N = int(input())
n = [input() for i in range(N)]
count_AC = 0
count_WA = 0
count_TLE = 0
count_RE = 0
for i in n:
    if i == 'AC':
        count_AC += 1
    elif i == 'WA':
        count_WA += 1
    elif i == 'TLE':
        count_TLE += 1
    elif i == 'RE':
        count_RE += 1
print('AC x {0}\nWA x {1}\nTLE x {2}\nRE x {3}'.format(count_AC, count_WA, count_TLE, count_RE))
Problem:
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.  The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)  Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?

Incorrect submission (verdict: Wrong Answer):
X=int(input())
A=int(100)
B=int(0)
while A<=X:
  A=A*101//100
  B=B+1
print(B)

Fixed, accepted submission:
X=int(input())
A=int(100)
B=int(0)
while A<X:
  A=A*101//100
  B=B+1
print(B)
Problem:
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.  The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)  Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?

Incorrect submission (verdict: Wrong Answer):
import math

X = int(input())

deposit = 100
y_later = 0

while deposit < X:
    y_later += 1
    deposit = math.floor(deposit) * 1.01
    
    print(deposit)

print(y_later)

Fixed, accepted submission:
X = int(input())

deposit = 100
y_later = 0

while deposit < X:
    y_later += 1
    deposit += deposit // 100

print(y_later)
Problem:
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:    * 1 \leq x,y,z   * x^2 + y^2 + z^2 + xy + yz + zx = n  Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).

Incorrect submission (verdict: Wrong Answer):
n = int(input())
a = [0 for _ in range(n+1)]
for i in range(1,n+1):
  if i*i>n:
    break
  for j in range(1,n+1):
    if i*i + j*j +i*j > n:
      break
    for k in range(1,n+1):
      tmp = i*i + j*j + k*k + i*j + j*k + k*i
      if tmp==n:
        a[tmp]+=1
      else:
        break
for i in range(1,n+1):
  print(a[i])

Fixed, accepted submission:
n = int(input())
a = [0 for _ in range(n+1)]
for i in range(1,n+1):
  if i*i>n:
    break
  for j in range(1,n+1):
    if i*i + j*j +i*j > n:
      break
    for k in range(1,n+1):
      tmp = i*i + j*j + k*k + i*j + j*k + k*i
      if tmp<=n:
        a[tmp]+=1
      else:
        break
for i in range(1,n+1):
  print(a[i])
Problem:
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second.  He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.

Incorrect submission (verdict: Wrong Answer):
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())

if a==b:
  print("Yes")
else:
  if w>v:
    print("No")
  else:
    if (v-w)*t<abs(b-a):
      print("No")
    else:
      print("Yes")

Fixed, accepted submission:
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())

if a==b:
  print("YES")
else:
  if w>v:
    print("NO")
  else:
    if (v-w)*t<abs(b-a):
      print("NO")
    else:
      print("YES")
Problem:
Snuke built an online judge to hold a programming contest.  When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S.)  Determine whether the judge can return the string `AC` as the verdict to a program.

Incorrect submission (verdict: Wrong Answer):
s=input()

if s in 'AC':
    print('Yes')

else:
    print('No')

Fixed, accepted submission:
s=input()

if 'AC' in s:
    print('Yes')

else:
    print('No')
Problem:
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?

Incorrect submission (verdict: Wrong Answer):
print(24 - int(input()) + 12)

Fixed, accepted submission:
print(24 - int(input()) + 24)
Problem:
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives.  You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative.  For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins.  If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?

Incorrect submission (verdict: Wrong Answer):
N = int(input())
money = 0
for i in range(N):
    x, u = list(input().split(' '))
    if(u == 'JPY'):
        rate = 1.0
    else:
        rate = 380000.0
    money += int(float(x) * rate)
print(money)

Fixed, accepted submission:
N = int(input())
money = 0
for i in range(N):
    x, u = list(input().split(' '))
    if(u == 'JPY'):
        rate = 1.0
        x = int(x)
    else:
        rate = 380000.0
        x = float(x)
    money += x * rate
print(money)
Problem:
Print all the integers that satisfies the following in ascending order:    * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.

Incorrect submission (verdict: Wrong Answer):
A,B,K=map(int, input().split())
if B-A<2*K:
  for i in range(A,B+1):
    print(i)
else:
  for i in range(K):
    print(A+i)
  for i in range(K):
    print(B-K+i)

Fixed, accepted submission:
A,B,K=map(int, input().split())
if B-A+1-2*K<1:
  for i in range(A,B+1):
    print(i)
else:
  for i in range(K):
    print(A+i)
  for i in range(K):
    print(B-K+i+1)
Problem:
AtCoDeer has three cards, one red, one green and one blue.   An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.   We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.   Is this integer a multiple of 4?

Incorrect submission (verdict: Wrong Answer):
a,b,c=list(map(int,input().split()))
d=100*a+10*b+c
print("Yes" if d%4==0 else "No")

Fixed, accepted submission:
a,b,c=list(map(int,input().split()))
d=100*a+10*b+c
print("YES" if d%4==0 else "NO")
Problem:
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not.  You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.

Incorrect submission (verdict: Wrong Answer):
S=input()

for i in range(len(S),0,-1):
    if S[:i]==S[i:]:
        break

Fixed, accepted submission:
S=input()

for i in range(len(S)-1,0,-1):
    if i%2:
        continue
    else:
        t=i//2
        if S[:t]==S[t:i]:
            print(i)
            break
Problem:
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i.  Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.

Incorrect submission (verdict: Wrong Answer):
num = int(input())
a = num // 100
b = num // 10 - (a * 10)
c = num - (a * 100) - (b * 10)
print(num)
print(a, b, c)

Fixed, accepted submission:
num = int(input())
a = num // 100
b = num // 10 - (a * 10)
c = num - (a * 100) - (b * 10)
print(a + b + c)
Problem:
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.

Incorrect submission (verdict: Wrong Answer):
import sys

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

    if(M1==2 and D1!=28):
        print('0')
        sys.exit()

    if(M1==4 or M1==6 or M1==9 or M1==11 and D1==30):
        print('0')
        sys.exit()

    if(M1==1 or M1==3 or M1==5 or M1==7 or M1==8 or M1==10 or M1==12 and D1!=31):
        print('0')
        sys.exit()

    print('1')

main()


Fixed, accepted submission:
import sys

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

    if(M1==2 and D1==28):
        if(M2==M1+1 and D2==1):
            print('1')
            sys.exit()

    if(M1==4 or M1==6 or M1==9 or M1==11 and D1==30):
        if(M2==M1+1 and D2==1):
            print('1')
            sys.exit()

    if(M1==1 or M1==3 or M1==5 or M1==7 or M1==8 or M1==10 or M1==12 and D1==31):
        if(M2==M1+1 and D2==1) or (M1==12 and M2==1 and D2==1):
            print('1')
            sys.exit()

    print('0')

main()