Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, m = map(int, input().split())

    islands_to_1 = []
    islands_to_n = []
    for _ in range(m):
        boat = list(map(int, input().split()))
        if 1 in boat:
            islands_to_1.append(max(boat))

        if n in boat:
            islands_to_n.append(min(boat))

    for island_to_1 in islands_to_1:
        if island_to_1 in islands_to_n:
            print("POSSIBLE")
            return

    print("IMPOSSIBLE")
    return


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    n, m = map(int, input().split())

    islands_to_1 = [0 for _ in range(n+1)]
    islands_to_n = []
    for _ in range(m):
        boat = list(map(int, input().split()))
        if 1 in boat:
            islands_to_1[boat[1]] = 1

        if n in boat:
            islands_to_n.append(min(boat))

    for island_to_n in islands_to_n:
        if islands_to_1[island_to_n] == 1:
            print("POSSIBLE")
            return

    print("IMPOSSIBLE")
    return


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, m = map(int, input().split())

    boats = []
    islands = []
    for _ in range(m):
        boat = list(map(int, input().split()))
        if 1 in boat:
            islands.append(max(boat))

        boats.append(boat)

    for boat in boats:
        if boat[0] in islands:
            if boat[1] == n:
                print("POSSIBLE")
                return

        elif boat[1] in islands:
            if boat[0] == n:
                print("POSSIBLE")
                return

    print("IMPOSSIBLE")
    return


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    n, m = map(int, input().split())

    islands_to_1 = [0 for _ in range(n+1)]
    islands_to_n = []
    for _ in range(m):
        boat = list(map(int, input().split()))
        if 1 in boat:
            islands_to_1[boat[1]] = 1

        if n in boat:
            islands_to_n.append(min(boat))

    for island_to_n in islands_to_n:
        if islands_to_1[island_to_n] == 1:
            print("POSSIBLE")
            return

    print("IMPOSSIBLE")
    return


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))

cum_sum = [sum(A[:i+1]) for i in range(len(A))]
b = cum_sum[-1]

ans = float("inf")

for a in cum_sum[:-1]:
    ans = min(ans, abs(2 * a - b))

print(ans)


Fixed submission:
n = int(input())
A = list(map(int, input().split()))
b = sum(A)

ans = float("inf")
cum_sum = 0

for a in A[:-1]:
    cum_sum += a
    ans = min(ans, abs(2 * cum_sum - b))

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
count= [0 for _ in range(9)]
for i in range(n):
    if a[i] // 400 >= 8:
        count[8] += 1
    elif count[a[i] // 400] == 0:
        count[a[i] // 400] += 1

if count[8] == sum(count):
    print(1, sum(count))
else:
    print(sum(count)-count[8], sum(count))


Fixed submission:
n = int(input())
A = list(map(int, input().split()))
count = [0 for _ in range(9)]
for i in range(n):
    if A[i] // 400 >= 8:
        count[8] += 1
    elif count[A[i] // 400] == 0:
        count[A[i] // 400] += 1

if count[8] == sum(count):
    print(1, sum(count))
else:
    print(sum(count)-count[8], sum(count))
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if a<=8:
    if b<=8:
        print('Yay!')
    else:
        print(': (')
else:
    print(': (')


Fixed submission:
a,b=map(int,input().split())
if a<=8 and b<=8:
    print('Yay!')
else:
    print(':(' )

Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if a<=8 and b<=8:
    print('Yay!')
else:
    print(': (')

Fixed submission:
a,b=map(int,input().split())
if a<=8 and b<=8:
    print('Yay!')
else:
    print(':(' )

Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if a<=8 and b<=b:
    print('Yay!')
else:
    print(': (')

Fixed submission:
a,b=map(int,input().split())
if a<=8 and b<=8:
    print('Yay!')
else:
    print(':(' )
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
lst=[]
for i in range(n-1):
    lst.append(list(map(int,input().split())))
def neccesary_time(m):
    t=0
    for i in range(m,n-1):
        s=lst[i][1]
        if t<=s:
            t=s+lst[i][0]
        else:
            while s<t:
                s+=lst[i][2]
            t=s+lst[i][0]
    return t
for i in range(n-1):
    print(neccesary_time(i))
print(0)

Fixed submission:
from math import ceil
n=int(input())
lst=[]
for i in range(n-1):
    lst.append(list(map(int,input().split())))
def neccesary_time(m):
    t=0
    for i in range(m,n-1):
        s=lst[i][1]
        if t<=s:
            t=s+lst[i][0]
        else:
            t=s+lst[i][2]*ceil((t-s)/lst[i][2])+lst[i][0]
    return t
for i in range(n-1):
    print(neccesary_time(i))
print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
list=[]
for i in range(n):
    a,b=map(int,input().split())
    for j in range(b):
        list.append(a)
list.sort()
print(list[k-1])

Fixed submission:
n,k=map(int,input().split())
list=[]
for i in range(n):
    a,b=map(int,input().split())
    list.append([a,b])
list.sort()
sum=0
for x in list:
    sum+=x[1]
    if sum >=k:
        print(x[0])
        break

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
list=[]
for i in range(n):
    a,b=map(int,input().split())
    list.append(str(a)*b)
list.sort
print(list[k])

Fixed submission:
n,k=map(int,input().split())
list=[]
for i in range(n):
    a,b=map(int,input().split())
    list.append([a,b])
list.sort()
sum=0
for x in list:
    sum+=x[1]
    if sum >=k:
        print(x[0])
        break
Buggy python submission (verdict: Runtime Error):
import sys
2. 
3.stdin = sys.stdin
4.na = lambda: list(map(int, stdin.readline().split()))
5. 
6.k,s = na()
7.ans = 0
8.for x in range(k+1):
9.    for y in range(k+1):
10.        z = s - (x+y)
11.        if z >= 0 and z <= k:
12.            ans += 1
13.print(ans)


Fixed submission:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

def main():
    sx,sy,tx,ty = na()
    ret = ""
    for i in range(tx-sx):
        ret += "R"
    for i in range(ty-sy):
        ret += "U"
    for i in range(tx-sx):
        ret += "L"
    for i in range(ty-sy):
        ret += "D"
    ret += "L"
    for i in range(ty-sy+1):
        ret += "U"
    for i in range(tx-sx+1):
        ret += "R"
    ret += "D"
    ret += "R"
    for i in range(ty-sy+1): ret += "D"
    for i in range(tx-sx+1): ret += "L"
    ret += "U"
    print(ret)
    pass


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def base_N(N,n,n_N):#N進数に変換
    if n==0:
        return int(n_N[::-1])
    else:
        n_N+=str(n%N)
        n=n//N
        return base_N(N,n,n_N)
"""
def base_N_10(N,n):#N進数を10進数に変換
    n_10=0
    for i in range(len(str(n))):
        n_10+=int(str(n)[i])*N**(len(str(n))-i-1)
    return n_10
"""


n,k=map(int,input().split())
dislike=list(map(int,input().split()))

usable=[i for i in range(10)]
for number in dislike:
    usable.remove(number)

N=len(usable)
M=0
bit=''
num_s=''    
num_i=0



while 1:
    M+=1
    bit=str(base_N(N,M,''))
    for i in range(len(bit)):
        num_s+=str(usable[int(bit[i])])
    num_i=int(num_s)
    if num_i>=n:
        print(num_i)
        exit()
    else:
        num_s=''
        bit=''
        num_i=0

Fixed submission:
n,k=map(int,input().split())
dislike=list(map(int,input().split()))


while 1:
    for i in range(len(str(n))):
        if int(str(n)[i]) in dislike:
            break
        if i==len(str(n))-1:
            print(n)
            exit()
    n+=1

Buggy python submission (verdict: Runtime Error):
def base_N(N,n,n_N):#N進数に変換
    if n==0:
        return int(n_N[::-1])
    else:
        n_N+=str(n%N)
        n=n//N
        return base_N(N,n,n_N)
"""
def base_N_10(N,n):#N進数を10進数に変換
    n_10=0
    for i in range(len(str(n))):
        n_10+=int(str(n)[i])*N**(len(str(n))-i-1)
    return n_10
"""


n,k=map(int,input().split())
dislike=list(map(int,input().split()))

usable=[i for i in range(10)]
for number in dislike:
    usable.remove(number)

N=len(usable)
M=0
bit=''
num_s=''    
num_i=0



while 1:
    M+=1
    bit=str(base_N(N,M,''))
    for i in range(len(bit)):
        num_s+=str(usable[int(bit[i])])
    num_i=int(num_s)
    if num_i>=n:
        print(num_i)
        exit()
    else:
        num_s=''
        bit=0
        num_i=0

Fixed submission:
n,k=map(int,input().split())
dislike=list(map(int,input().split()))


while 1:
    for i in range(len(str(n))):
        if int(str(n)[i]) in dislike:
            break
        if i==len(str(n))-1:
            print(n)
            exit()
    n+=1

Buggy python submission (verdict: Runtime Error):
def base_N(N,n,n_N):#N進数に変換
    if n==0:
        return int(n_N[::-1])
    else:
        n_N+=str(n%N)
        n=n//N
        return base_N(N,n,n_N)

def base_N_10(N,n):#N進数を10進数に変換
    n_10=0
    for i in range(len(str(n))):
        n_10+=int(str(n)[i])*N**(len(str(n))-i-1)
    return n_10



n,k=map(int,input().split())
dislike=list(map(int,input().split()))

usable=[i for i in range(10)]
for number in dislike:
    usable.remove(number)

N=len(usable)
M=0
bit=0
num_s=''    
num_i=0



while 1:
    M+=1
    bit=str(base_N(N,M,''))
    for i in range(len(bit)):
        num_s+=str(usable[int(bit[i])])
    num_i=int(num_s)
    if num_i>=n:
        print(num_i)
        exit()
    else:
        num_s=''
        bit=0
        num_i=0

Fixed submission:
n,k=map(int,input().split())
dislike=list(map(int,input().split()))


while 1:
    for i in range(len(str(n))):
        if int(str(n)[i]) in dislike:
            break
        if i==len(str(n))-1:
            print(n)
            exit()
    n+=1
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input())
print(abs((N2-)*(M-2)))

Fixed submission:
N, M = map(int, input().split())
print(abs(N-2)*abs(M-2))
Buggy python submission (verdict: Runtime Error):
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;

long long int N, K;
long long int a, b;


int main(){
    cin >> N >> K;
    vector<pair<long long int, long long int> > pairs(N);

    for(int i = 0; i < N; i++){
        cin >> a >> b;
        pairs[i] = make_pair(a, b);
    }
    sort(pairs.begin(), pairs.end());

    for(int i = 0; i < N; i++){
        K -= pairs[i].second;
        if(K <= 0){
            cout << (pairs[i].first);
            return 0;
        }
    }
    return 0;
}

Fixed submission:
AB = []
N, K = map(int, input().split())

for _ in range(N):
    a, b = map(int, input().split())
    AB.append((a, b))

AB.sort()
for ab in AB:
    K -= ab[1]
    if K <= 0:
        print(ab[0])
        exit()
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())

def F(a, b):
    a = len(str(a))
    b = len(str(b))
    if a > b:
        return a
    elif a < b:
        return b
    else:
        return b

elements = []

for i in range(1, math.floor(math.sqrt(N+1))):
    if N % i == 0: elements.append(i)

a = elements[-1]
b = N // a
print(F(a,b))

Fixed submission:
import math

N = int(input())

def F(a, b):
    a = len(str(a))
    b = len(str(b))
    if a > b:
        return a
    elif a < b:
        return b
    else:
        return b

elements = []

for i in range(1, math.ceil(math.sqrt(N+1))):
    if N % i == 0: elements.append(i)

a = elements[-1]
b = N // a
print(F(a,b))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

def F(a, b):
    a = len(str(a))
    b = len(str(b))
    if a > b:
        return a
    elif a < b:
        return b
    else:
        return b

elements = []

for i in range(1, N+1):
    if N % i == 0: elements.append(i)

a = elements[len(elements)//2]
b = N // a
print(F(a,b))

Fixed submission:
import math

N = int(input())

def F(a, b):
    a = len(str(a))
    b = len(str(b))
    if a > b:
        return a
    elif a < b:
        return b
    else:
        return b

elements = []

for i in range(1, math.ceil(math.sqrt(N+1))):
    if N % i == 0: elements.append(i)

a = elements[-1]
b = N // a
print(F(a,b))
Buggy python submission (verdict: Runtime Error):
N = int(input())
T, A = np.array(input().split(), dtype="int")[:2]
H = [int(i) for i in input().split()]
    
min_dif = 10000
place = 0
for i in range(N):
  temp = T - H[i] *0.006
  dif = abs(A-temp)
        
  #誤差の最小値(→候補地も更新)
  if min_dif >= dif:
    min_dif = dif
    place = i+1
    
print(place)

Fixed submission:
import numpy as np

def palace():
    
    N = int(input())
    T, A = np.array(input().split(), dtype="int")[:2]
    H = [int(i) for i in input().split()]
    
    min_dif = 10000
    place = 0
    for i in range(N):
        temp = T - H[i] *0.006
        dif = abs(A-temp)
        
        #誤差の最小値(→候補地も更新)
        if min_dif >= dif:
            min_dif = dif
            place = i+1
    
    print(place)
    
    
palace()
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
length = 0
maxLength = 0
for i in range(len(s)):
    if s[i] != "A":
        continue
    for j in range(i+1, len(s)):
        if s[j] != "Z":
            continue
        length = abs(j+1 - i)
        if maxLength < length:
            maxLength = length
print(maxLength)


Fixed submission:
s = input()
print(s.rfind('Z') + 1 - s.find('A'))
Buggy python submission (verdict: Runtime Error):
N,x = input().split()
A = input().split()
a = []
for i in range(int(N)):
  a.append(int(A[i]))
  
a.sort()
a.append(1)
X = int(x)
 
idx = 0
while X>=0:
  X = X-a[idx]
  idx+=1

print(idx-1)

Fixed submission:
N,x = input().split()
A = input().split()
a = []
for i in range(int(N)):
  a.append(int(A[i]))
  
a.sort()
X = int(x)
 
idx = 0
while X>0 and idx<int(N):
  X = X-a[idx]
  idx+=1

if X==0:
  idx+=1
  
print(idx-1)

Buggy python submission (verdict: Runtime Error):
N,x = input().split()
A = input().split()
a = []
for i in range(N):
  a.append(int(A[1]))

a.sort()
a.reverse()
X = int(x)

idx = 0
while X>0:
  X = X-a[idx]
  idx+=1
  
print(idx)

Fixed submission:
N,x = input().split()
A = input().split()
a = []
for i in range(int(N)):
  a.append(int(A[i]))
  
a.sort()
X = int(x)
 
idx = 0
while X>0 and idx<int(N):
  X = X-a[idx]
  idx+=1

if X==0:
  idx+=1
  
print(idx-1)
Buggy python submission (verdict: Runtime Error):
int main() {
  int N;
  int K;
  int a[55];
  cin >> N >> K;
  
  for(int i=0; i<N; ++i) {
    cin >> a[i];
  }
  sort(a,a+N,greater<int>());
  int ans=0;
  for(int i=0; i<=K; ++i) {
    ans += a[i];
  }
  cout << ans << endl;
}

Fixed submission:
N,K = map(int,input().split())
L = list(map(int,input().split()))
L.sort(reverse = True)
print(sum(L[0:K]))
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
c = 0

for x in range(k + 1):
  for y in range(k + 1):
    for z in range(k + 1):
      if x + y + z == s:
        c += 1
print(c)


Fixed submission:
k, s = map(int, input().split())
c = 0

for x in range(k + 1):
  for y in range(k + 1):
    if 0 <= s - (x + y) <= k:
      c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
s = input()

s[:4] = '2018'
print(s)

Fixed submission:
s = input()
modify = '2018'+ s[4:]

print(modify)
Buggy python submission (verdict: Runtime Error):
import numpy as np
 
s_list = [int(i) for i in list(input())]
ans = np.count_nonzero(s_list>0)
 
print(ans)

Fixed submission:
s = input()
counter = 0

for i in range(len(s)):
  if s[i]=='1':
    counter += 1

print(counter)
Buggy python submission (verdict: Runtime Error):
N = int(input())
num_list = [int(i) for i in input().split(' ')]

even_counter = 0
for n in range(N):
  if num_list[n]%2 != 0:
    print('0')
    break
  else:
    even_counter += 1
  
  if even_counter == N:
    min_counter = float('inf')
    for i in range(N):
      num =  num_list[i]
      counter = 0
      while num%2 == 0:
        counter += 1
      	num //= 2
      if counter <= min_counter:
        min_counter = counter
      
    print(counter)


Fixed submission:
N = int(input())
num_list = [int(i) for i in input().split(' ')]

even_counter = 0
for n in range(N):
  if num_list[n]%2 != 0:
    print('0')
    break
  else:
    even_counter += 1
  
  if even_counter == N:
    min_counter = float('inf')
    for i in range(N):
          num =  num_list[i]
          counter = 0
          while num%2 == 0:
            counter += 1
            num //= 2
          if counter <= min_counter:
            min_counter = counter
      
    print(min_counter)

Buggy python submission (verdict: Runtime Error):
N = int(input())
num_list = [int(i) for i in input().split(' ')]

even_counter = 0
for n in range(N):
  if num_list[n]%2 != 0:
    print('0')
    break
  else:
    even_counter += 1
  
  if even_counter == N:
    min_counter = float('inf')
    for i in range(N):
      num =  num_list[i]
      counter = 0
      while num%2 == 0:
        counter += 1
      	num //= 2
      if counter <= min_counter:
        min_counter = counter
      
    print(counter)


Fixed submission:
N = int(input())
num_list = [int(i) for i in input().split(' ')]

even_counter = 0
for n in range(N):
  if num_list[n]%2 != 0:
    print('0')
    break
  else:
    even_counter += 1
  
  if even_counter == N:
    min_counter = float('inf')
    for i in range(N):
          num =  num_list[i]
          counter = 0
          while num%2 == 0:
            counter += 1
            num //= 2
          if counter <= min_counter:
            min_counter = counter
      
    print(min_counter)
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
ls = sorted([int(i) for i in input().split(' ')], reverse=True)

l_sum = 0
for k in range(K):
    l = ls[k]
    l_sum += l

print(l_sum)

Fixed submission:
data = [int(i) for i in input().split(' ')]
K = data[1]
ls = sorted([int(i) for i in input().split(' ')], reverse=True)

l_sum = 0
for k in range(K):
    l = ls[k]
    l_sum += l

print(l_sum)

Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
ls = sorted([int(i) for i in input().split(' ')], reverse=True)

l_sum = 0
for k in range(K):
    l = ls[k]
    l_sum += l

print(l_sum)

Fixed submission:
data = [int(i) for i in input().split(' ')]
K = data[1]
ls = sorted([int(i) for i in input().split(' ')], reverse=True)

l_sum = 0
for k in range(K):
    l = ls[k]
    l_sum += l

print(l_sum)
Buggy python submission (verdict: Runtime Error):
r,g,b = map(int, input().spilit())
ans = r*100+10*g+b

if ans%4==0:
  print('YES')
else:
  print('NO')

Fixed submission:
r,g,b = map(int, input().split())
ans = 100*r+10*g+b

if ans%4==0:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
info = [int(i) for i in input().split(' ')]
K = info[0]
S = info[1]

count = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            ans = x+y+z
            if ans == S:
                count += 1
                
print(count)

Fixed submission:
info = [int(i) for i in input().split(' ')]
K = info[0]
S = info[1]

count = 0
for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if (0<=z)&(z<=K):
          count += 1
                
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
T,A = map(int, input().split())
H = list(map(int, input().split()))

min_val = 10000

for i in range(len(H)):
    tmp = T - H[i] * 0.006
    sub = abs(tmp - A)
    if min_val > sub:
        ans = i
        min_val = sub2


print(ans+1)


Fixed submission:
N = int(input())
T,A = map(int, input().split())
H = list(map(int, input().split()))

min_val = 10000

for i in range(len(H)):
    tmp = T - H[i] * 0.006
    sub = abs(tmp - A)
    if min_val > sub:
        ans = i
        min_val = sub


print(ans+1)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())

flag = False

for i in range(ceil(N/7)+1):
    for j in range(ceil(N/4)+1):
        if flag == True:
            continue
        #print(N - i * 7 - j * 4 )
        if N - i * 7 - j * 4 == 0:
            flag = True

if flag == True:
    print('Yes')
else:
    print('No')


Fixed submission:
import math
N = int(input())

flag = False

for i in range(100):
    for j in range(100):
        if flag == True:
            continue
        #print(N - i * 7 - j * 4 )
        if N - i * 7 - j * 4 == 0:
            flag = True

if flag == True:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
for i in range(100):
    for j in range(100):
        if flag == True:
            continue
        print(N - i * 7 - j * 4 )
        if N - i * 7 - j * 4 == 0:
            flag = True

if flag == True:
    print('Yes')
else:
    print('No')


Fixed submission:
import math
N = int(input())

flag = False

for i in range(100):
    for j in range(100):
        if flag == True:
            continue
        #print(N - i * 7 - j * 4 )
        if N - i * 7 - j * 4 == 0:
            flag = True

if flag == True:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):

N,X = (map(int, input().split()))
m = [0] * N
for i in range(N):
    m[i] = int(input())

for i in range(N):
    X = X - m[i]

min_value = min(m)
ind = m.index(min_value)
count = N

while X - m[ind]=> 0:
    X = X - m[ind]
    count += 1

print(count)


Fixed submission:

N,X = (map(int, input().split()))
m = [0] * N
for i in range(N):
    m[i] = int(input())

for i in range(N):
    X = X - m[i]

min_value = min(m)
ind = m.index(min_value)
count = N

while X - m[ind] >= 0:
    X = X - m[ind]
    count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
, b = map(int,input().split())
c = a* b

if  c%2 == 0:
    print('Even')
else:
    print('Odd')


Fixed submission:
a, b = map(int,input().split())
c = a* b

if  c%2 == 0:
    print('Even')
else:
    print('Odd')
Buggy python submission (verdict: Runtime Error):
N,Y = map(int, input().split())


a = -1
b = -1
c = -1

flag = 0

for i in range(N + 1):
    if flag == 1:
        break
    if  Y - 10000 * i  == 0 & i == N:
        a = i
        b = 0
        c = 0
        flag = 1

    #if Y - 10000 * i - 5000 * (N - i) <= 0:
    for j  in range(N-i,N+1):
        if Y - 10000 * i - 5000 * j  - 1000 * (N - i -j)<= 0:
            for k in range(N-i-j,N + 1):
                if Y - 10000 * i - 5000 * j - 1000 * k == 0:
                    a = i
                    b = j
                    c   = k
                    flag = 1
                    break


print(str(a) +' '+ str(b) +' '+ str(c))


Fixed submission:
S = input()

S=S.replace('2017','2018')

print(S)