jiahuimbzuai/CoQuIR huggingface dataset:
//  [python]
import heapq
import copy
import numpy as np

N=int(input())
A=[]
for n in range(N):
    A.append( int(input()) )
A_ = copy.deepcopy(A)
A_ = np.array(A_)
A_ *= -1
A_ = list(A_)
heapq.heapify( A_ )
max_val = heapq.heappop(A_)*(-1)
second_max_val = heapq.heappop(A_)*(-1)

is_max = []
for n in range(N):
    if A[n]==max_val:
        is_max.append(True)
    else:
        is_max.append(False)
max_val_num = np.sum( np.array(is_max) )

for n in range(N):
    if max_val_num > 1:
        print(max_val)
    else:
        if is_max[n]:
            print(second_max_val)
        else:
            print(max_val)
//  [python]
import numpy as np

now_max = -1
prev_max = 100000000
left_max = -1
right_max = -1
right_max_index = 0

N = int(input())
A_list = [int(input()) for _ in range(N)]
np_A_list = np.array(A_list)
for i, A in enumerate(A_list):
    # 右端
    if i == len(A_list) - 1:
        print(left_max)
        break
    if right_max_index == i:
        slc = np_A_list[i + 1:]
        right_max = slc.max()
        right_max_index = len(np_A_list) - 1 - slc[::-1].argmax()

    if left_max > right_max:
        now_max = left_max
        print(left_max)
    else:
        now_max = right_max
        print(right_max)
    
    if prev_max < now_max:
        left_max = right_max = now_max
        right_max_index = 10000000
    
    prev_max = now_max
    if left_max < A:
        left_max = A
//  [java]
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> val = new ArrayList<>();
        for(int i= 0;i<N;i++){
            int A = scanner.nextInt();
            val.add(A);
        }
        Map<Integer,Integer> maxLeft = new HashMap<>();
        Map<Integer,Integer> maxRight = new HashMap<>();
        maxLeft.put(0,0);
        maxLeft.put(1,val.get(0));
        for(int i=2; i<N; i++){
            int ml = Math.max(maxLeft.get(i-1), val.get(i-1));
            maxLeft.put(i, ml);
        }
        maxRight.put(N-1, 0);
        maxRight.put(N-2, val.get(N-1));
        for(int i=N-3; i>=0; i--){
            int mr = Math.max(maxRight.get(i+1), val.get(i+1));
            maxRight.put(i, mr);
        }
        // System.out.println(maxLeft);
        // System.out.println(maxRight);

        for(int i=0; i<N; i++){
            System.out.println(Math.max(maxLeft.get(i), maxRight.get(i)));
        }
    }
}
//  [java]
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;

    public static void main(String[] args) {
        int N = nint();
        int[] A = nints(N);
        int[] sorted = Arrays.copyOf(A, N);
        Arrays.sort(sorted);
        int m = sorted[N-1];
        int n = sorted[N-2];
        for (int a: A) {
            so.println(a == m ? n : m);
        }
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}
//  [cpp]
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template <typename T>
T maximum(vector<T> A,int idx){
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    return A[idx];
}


int main(){
    int N,A_max,A_sec;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    A_max = maximum(A,0);
    A_sec = maximum(A,1);
    rep(i,N){
        if (A[i] == A_max){
            cout << A_sec << endl;
        } else {
            cout << A_max << endl;
        }
    }
}
//  [cpp]
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef vector<int>     Vi;
typedef vector<ll>      Vl;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD1    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define psb push_back
#define epb emplace_back
#define psf push_front
#define mkp make_pair
#define fst first
#define scd second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(bit, n)  for(int bit = 0; (bit) < (1 << (n)); ++(bit))
#define ifbit(bit, i)   if((bit) & (1 << (i)))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    // std::cin.tie(nullptr);
    // std::cout.tie(nullptr);
    // std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    int max_a = 0;
    Vi a(n);
    rep(i, n){
        cin >> a[i];
        chmax(max_a, a[i]);
    }

    Vi d; d = a;
    sort(all(d));
    int cnt = 0;
    rep(i, n){
        if(d[i] == max_a){
            ++cnt;
            d[i] = 0;
        }
    }

    sort(all(d));

    if(cnt == 1){
        rep(i, n){
            if(a[i] != max_a)
                cout << max_a << endl;
            else cout << d[n-1] << endl;
        }
    }

    else if(cnt >= 2){
        rep(i, n){
            cout << max_a << endl;
        }
    }

return 0;
}
//  [cpp]
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef vector<int>     Vi;
typedef vector<ll>      Vl;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD1    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define psb push_back
#define epb emplace_back
#define psf push_front
#define mkp make_pair
#define fst first
#define scd second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(bit, n)  for(int bit = 0; (bit) < (1 << (n)); ++(bit))
#define ifbit(bit, i)   if((bit) & (1 << (i)))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    int max_a = 0;
    Vi a(n);
    rep(i, n){
        cin >> a[i];
        chmax(max_a, a[i]);
    }

    Vi d; d = a;
    sort(all(d));
    int cnt = 0;
    rep(i, n){
        if(d[i] == max_a){
            ++cnt;
            d[i] = 0;
        }
    }

    sort(all(d));

    if(cnt == 1){
        rep(i, n){
            if(a[i] != max_a)
                cout << max_a << endl;
            else cout << d[n-1] << endl;
        }
    }

    else if(cnt >= 2){
        rep(i, n){
            cout << max_a << endl;
        }
    }

return 0;
}
//  [c]
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_asc(const void* a, const void* b) {
    return *((size_t*)a) < *((size_t*)b) ? -1 : 1;
}

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_i64_desc(const void* a, const void* b) {
    return *((int64_t*)a) > * ((int64_t*)b) ? -1 : 1;
}

int compare_c_asc(const void* a, const void* b) {
    return *((char*)a) < *((char*)b) ? -1 : 1;
}

int compare_c_desc(const void* a, const void* b) {
    return *((char*)a) > * ((char*)b) ? -1 : 1;
}

static size_t powSz(const size_t base, const size_t exp) {
    if (exp == 0) {
        return 1;
    }

    if (exp == 1) {
        return base;
    }

    if (exp % 2 == 0) {
        return powSz(base * base, exp / 2);
    }
    else {
        return base * powSz(base, exp - 1);
    }
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

typedef struct {
    uint64_t A;
    uint64_t idx;
    uint64_t order;
} _info;

static _info info[200000];

static int compare_num(const void* a, const void* b) {
    const _info* aP = (_info*)a;
    const _info* bP = (_info*)b;

    return aP->A > bP->A ? -1 : 1;
}

static int compare_idx(const void* a, const void* b) {
    const _info* aP = (_info*)a;
    const _info* bP = (_info*)b;

    return aP->idx < bP->idx ? -1 : 1;
}

int main(void) {
    uint64_t N;

    scanf("%"PRIu64, &N);

    for (uint64_t i = 0; i < N; i++) {
        scanf("%"PRIu64, &(info[i].A));
        info[i].idx = i;
    }

    qsort(info, (size_t)N, sizeof(_info), compare_num);

    for (uint64_t i = 0; i < N; i++) {
        info[i].order = i;
    }

    uint64_t orderIdx[2];

    orderIdx[0] = info[0].idx;
    orderIdx[1] = info[1].idx;

    qsort(info, (size_t)N, sizeof(_info), compare_idx);

    for (uint64_t i = 0; i < N; i++) {
        printf("%"PRIu64"\n", info[i].order == 0 ? info[orderIdx[1]].A : info[orderIdx[0]].A);
    }

    return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef struct segment_tree_void {
  void *array;
  int32_t size;
  size_t val_size;
  void (*func) (void *, const void *, const void *);
} segment_tree;

static inline void segment_tree_memcpy (void *dst, const void *src, size_t size) {
  uint8_t *p = dst;
  const uint8_t *q = src;
  while (size--) {
    *p++ = *q++;
  }
}

segment_tree* new_segment_tree (const void *ini, const int32_t n, const size_t val_size, void (*func) (void *, const void *, const void *)) {
  int32_t k = 1;
  while (k < n) k *= 2;
  segment_tree *s = (segment_tree *) calloc (1, sizeof (segment_tree));
  s->array = calloc (2 * k, val_size);
  s->size = k;
  s->val_size = val_size;
  s->func = func;
  for (int32_t i = k; i < 2 * k; ++i) {
    segment_tree_memcpy ((uint8_t *)s->array + i * val_size, ini, val_size);
  }
  uint8_t *a = s->array;
  for (int32_t i = k - 1; i > 0; --i) {
    func (a + i * val_size, a + (2 * i) * val_size, a + (2 * i + 1) * val_size);
  }
  return s;
}

void update (segment_tree * const s, int32_t k, const void *val) {
  k += s->size;
  uint8_t * const p = s->array;
  const size_t size = s->val_size;
  segment_tree_memcpy (p + k * size, val, size);
  for (k >>= 1; k > 0; k >>= 1) {
    s->func (p + k * size, p + 2 * k * size, p + (2 * k + 1) * size);
  }
}

void update_tmp (segment_tree * const s, int32_t k, const void *val) {
  k += s->size;
  uint8_t * const p = s->array;
  const size_t size = s->val_size;
  segment_tree_memcpy (p + k * size, val, size);
}

void update_all (segment_tree * const s) {
  uint8_t * const a = s->array;
  const size_t size = s->val_size;
  for (int32_t i = s->size - 1; i > 0; --i) {
    s->func (a + i * size, a + (2 * i) * size, a + (2 * i + 1) * size);
  }
}

void find (const segment_tree *s, int32_t l, int32_t r, void *res) {
  int32_t lindex[64];
  int32_t rindex[32];
  int32_t llen = 0;
  int32_t rlen = 0;
  for (l += s->size, r += s->size; l < r; l >>= 1, r >>= 1) {
    if (l & 1) lindex[llen++] = l++;
    if (r & 1) rindex[rlen++] = --r;
  }
  while (rlen > 0) {
    lindex[llen++] = rindex[--rlen];
  }
  const uint8_t *p = s->array;
  segment_tree_memcpy (res, p + lindex[0] * s->val_size, s->val_size);
  for (int32_t i = 1; i < llen; ++i) {
    s->func (res, res, p + lindex[i] * s->val_size);
  }
}

typedef int32_t i32;

void func_max (void *c, const void *a, const void *b) {
  i32 p = *(i32 *)a;
  i32 q = *(i32 *)b;
  *(i32 *)c = p > q ? p : q;
}

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  const i32 ini = -1;
  segment_tree *s = new_segment_tree (&ini, n + 2, sizeof (i32), func_max);
  for (i32 i = 1; i <= n; ++i) {
    i32 a;
    scanf ("%" SCNi32, &a);
    update_tmp (s, i, &a);
  }
  update_all (s);
  for (i32 i = 1; i <= n; ++i) {
    i32 x, y;
    find (s, 0, i, &x);
    find (s, i + 1, n + 2, &y);
    i32 z = x > y ? x : y;
    printf ("%" PRIi32 "\n", z);
  }
}

int main (void) {
  run();
  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

int cmp(const void *a, const void *b){
	return **(int**)b - **(int**)a;
}

int main(void){
	int n, **a;
	scanf("%d", &n);
	a = malloc(sizeof(int*) * n);
	for(int i = 0; i < n; i++){
		a[i] = malloc(sizeof(int) * 2);
		scanf("%d", a[i]);
		a[i][1] = i;
	}
	qsort(a, n, sizeof(int*), cmp);
	for(int i = 0; i < n; i++)
		printf("%d\n", a[0][1] == i ? a[1][0] : a[0][0]);
	return 0;
}
//  [javascript]
function Main(input) {
    input = input.split("\n").map(Number);
    var flag = false;
    var max = 0;
    input.shift();
    input.forEach(function(val){
        if(max<val){
            max = val;
            flag = false;
        }else if(max == val){
            flag = true;
        }
    })
    var next = 0;
        input.forEach(function(val){
            if(next<val&&val!=max) next = val;
    })
    input.forEach(function(val){
        console.log((flag||(val!=max))?max:next);
    })
}Main(require("fs").readFileSync("/dev/stdin","utf8").trim());
//  [javascript]
"use strict";
const main = arg => {
  let A = arg.split("\n").map(n=>n*1);
  let N = A[0];
  A = A.slice(1, N+1);
  let AA = arg.split("\n").map(n=>n*1).slice(1, N+1);
  let sortNum = AA.sort((a,b)=> {return b - a })
  let max = sortNum[0];
  let secondMax = sortNum[1];
  for(let i = 0; i < N; i++){
	if(max != A[i]){
      console.log(max)
    }else{
      console.log(secondMax);
    };
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const n = parseInt(args[0][0], 10)
	const a = args.slice(1, n + 1).map(arg => parseInt(arg[0], 10))
	const sortedA = a.slice().sort((t1, t2) => t2 - t1)

	for (let i = 0; i < n; i++) {
		if (a[i] !== sortedA[0]) console.log(sortedA[0])
		else console.log(sortedA[1])
	}
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [go]
package main

import (
	"fmt"
	"sort"
)

func delete(s []int, i int) []int {
	s = append(s[:i],s[i+1:]...)
	t := make([]int,len(s))
	copy(t, s)
	return t
}

func main() {
	var n int
	fmt.Scan(&n)
	A := make([]int, n)
	B := make([]int, n)
	for i:=0;i<n;i++ {
		var m int
		fmt.Scan(&m)
		A[i] = m
	}
	copy(B,A)
	
	sort.Ints(B)
	
	ans := 0
	
	for _,v := range A{
		if v == B[n-1] {
			ans = B[n-2]
		} else {
			ans = B[n-1]
		}
		
		fmt.Println(ans)
		
	}
}
//  [go]
package main
import (
  "fmt"
  "sort"
)

func main() {
  var n int
  fmt.Scan(&n)
  a := aArray(n)
  b := make([]int, 0)
  for _, v := range a {
    b = append(b, v)
  }
  sort.Sort(sort.IntSlice(b))
  size := len(b)
  max := b[size-1]
  big := b[size-2]
  ind := index(max, a)
  switch {
    case max == big:
    for i := 0; i < n; i++{
      fmt.Println(max)
    }
    case max != big:
    for i := 0; i < n; i++{
        if i == ind {
          fmt.Println(big)
        }else{
          fmt.Println(max)
        }
      }
    }
}

func aArray(n int) []int{
  var d int
  a := make([]int, 0)
  for i := 0; i < n; i++ {
    fmt.Scan(&d)
   	a = append(a, d)
  	}
  return a
}
  

func index(m int, a []int) int {
  var ind int
  for i, v := range a {
    if ind == 0 {
      switch {
    	case v == m :
      		ind = i
      }
    }
  }
  return ind
}
//  [go]
package main

import "fmt"
//import "math"

func main(){
	var N int
	var A [200000]float64
	var maxtmp, max float64
	var maxIndex int

	fmt.Scan(&N)
	for i:= 0 ; i < N ; i++ {
		fmt.Scan(&A[i])
	}
	
	maxtmp = 0
	for i := 0 ; i < N ; i++ {
		if maxtmp < A[i]{
			maxtmp = A[i]
			maxIndex = i
		}
	}
	max = maxtmp
	maxtmp = 0
	if maxIndex == 0 {
		for j := 1 ; j < N ; j++{
			if maxtmp < A[j] {
				maxtmp = A[j]
			}
		}
	}else if maxIndex == N - 1{
		for j := 0 ; j < N - 1 ; j++{
			if maxtmp < A[j] {
				maxtmp = A[j]
			}
		}
	}else {
		for j := 0 ; j < maxIndex - 1 ; j++{
			if maxtmp < A[j]{
				maxtmp = A[j]
			}
		}
		for j := maxIndex + 1 ; j < N ; j++{
			if maxtmp < A[j] {
				maxtmp = A[j]
			}
		}
	}
	for i := 0 ; i < N ; i++ {
		if i == maxIndex {
			fmt.Println(maxtmp)
		}else{
			fmt.Println(max)
		}
	}

		/*if i == 0 {
			for j := 1 ; j < N ;j++{
				if maxtmp < A[j]{
					maxtmp = A[j]
				}
			}
		}else if i == N - 1{
			for j := 0 ; j < N - 1 ; j++{
				if maxtmp < A[j]{
					maxtmp = A[j]
				}
			}
		}else{
			for j := 0 ; j < i - 1 ; j++{
				if maxtmp < A[j]{
					maxtmp = A[j]
				}
			}
			for j := i + 1 ; j < N ; j++{
				if maxtmp < A[j] {
					maxtmp = A[j]
				}
			}
		}*/

		
	
}
//  [ruby]
n = gets.to_i
pys = []
n.times do
  pys << gets.split.map(&:to_i)
end

sorting = pys.sort

i = 0
maxp = pys.max

while i < n
	if maxp == pys[i]
		puts sorting[-2]
	else
		puts maxp
	end
	i += 1
end
//  [ruby]
n = gets.to_i
a = []
n.times do |i|
  a[i] = gets.chomp.split(" ").map(&:to_i)
end
b = a.sort.reverse
n.times do |i|
  if a[i] == b[0]
    puts b[1]
  else
    puts b[0]
  end
end
//  [ruby]
n=gets.chomp.to_i
a=[]
for i in 0..n-1
  a[i]=[gets.chomp.to_i,i]
end
max,nma=a.sort!.reverse![0],a[1]
for i in 0..n-1
  unless i==max[1]
    puts max[0]
  else
    puts nma[0]
  end
end
//  [swift]
let A=(0..<Int(readLine()!)!).map{_ in Int(readLine()!)!},B=A.sort(>);A.forEach{print($0==B[0] ?B[1]:B[0])}
//  [swift]
let n=Int(readLine()!)!
var arr:[Int]=[]
var max_1 = 0
var max_2 = 0
var tmp = 0
for _ in 0..<n {
    tmp = Int(readLine()!)!
    arr.append(tmp)
  	if( tmp > max_1 ) {
      max_2 = max_1
      max_1 = tmp
    }
  	else if( tmp > max_2 ) {
      max_2 = tmp
    }
}

for i in 0..<n {
  	if( arr[i] != max_1 ) {
      print( max_1 )
    } else {
		print(max_2)
    }
}
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let n=tn()
  let ar=tnn(n)
  let m=ar.reduce((a,b)=>a>b?a:b)
  let m2=0
  let c=0
  for(let i=0;i<n;i++){
    if(m==ar[i])c++
    else m2=max(m2,ar[i])
    if(c==2){
      m2=m
      break
    }
  }
  for(let i=0;i<n;i++){
    to(ar[i]!=m?m:m2)
  }
}
main()
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let n=tn()
  let ar=tnn(n)
  let descar=desc(ar)
  let m=descar[0]
  let m2=descar[1]
  for(let i=0;i<n;i++){
    to(ar[i]!=m?m:m2)
  }
}
main()
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const n = Number(stdin.split('\n')[0])
const [_, ...a] = stdin.split('\n').map(Number)

const ans = () => {
  const sorted = [...a].sort((a, b) => b - a)
  const max = sorted[0]
  const next = sorted[1]

  const resArr = []

  for (let i = 0; i < n; i++) {
    if (a[i] !== max) {
      resArr.push(max)
    } else {
      resArr.push(next)
    }
  }

  for (let i = 0; i < n; i++) {
    console.log(resArr[i])
  }
}

ans()
//  [python]
a = list(map(int, input().split()))

for i in range(5):
  if a[i] == 0:
    print(i+1)
    break
//  [java]
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        int[] x = new int[5];
        for (int i = 0; i < x.length; i++) {
            x[i] = sc.nextInt();
        }

        for (int i = 0; i < x.length; i++) {
            if (x[i] == 0) {
                System.out.println(i+1);
                return;
            }
        }
    }
}
//  [java]
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int inp;
    for(int a=0; a<5; a++){
      inp=scan.nextInt();
      if(inp==0){
        System.out.println(a+1);
      } 
    }
  }
}
//  [java]
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    
        var sc = new Scanner(System.in);
    
        for(int i = 1; i <= 5; i++){
            int x = Integer.parseInt(sc.next());
            if(x == 0){
                System.out.println(i);
                break;
            }
        }
    }
}
//  [c]
#include<stdio.h>
int main(void){
int x[5];
for(int i=0;i<5;i++){
scanf("%d",&x[i]);
if(x[i]==0){
printf("%d",i+1);
}
}
return 0;}
//  [c]
#include<stdio.h>
int main()
{
    int x,i;
    for(i=1;i<=5;i++)
    {
        scanf("%d",&x);
        if(!x)
        {
            printf("%d",i);
            return 0;
        }
    }
}
//  [c]
#include<stdio.h>
void main()
{
  int x1,x2,x3,x4,x5;
  scanf("%d %d %d %d %d",&x1,&x2,&x3,&x4,&x5);
  if(x1==0)
    printf("1");
  else if(x2==0)
    printf("2");
  else if(x3==0)
    printf("3");
  else if(x4==0)
    printf("4");
  else if(x5==0)
    printf("5");
}
//  [javascript]
function Main(input) {
  input = input.split("\n");
  const S = input[0].split(" ");
  S.unshift("x");
  console.log(S.indexOf("0"));
}

// デバッグ用
function debug() {
  var input = document.getElementById("input").value;
  Main(input);
}

//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
let main = (array) => {
    const args = array.trim().split(" ")
    console.log(args.findIndex(element => element == "0") + 1)
}

main(require("fs").readFileSync("/dev/stdin", "utf8"))
//  [javascript]
function Main(input) {
  const numbers = input.split(' ');
  for (var i=0; i<numbers.length; i++) {
    if (numbers[i] == 0) {
      const ans = i + 1;
      console.log(ans.toString());
      break;
    }
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	for i := 1; i <= 5; i++ {
		x := nextInt()
		if x == 0 {
			fmt.Fprintf(out, "%d\n", i)
			break
		}
	}
}
//  [ruby]
require 'pp'

x = gets.split.map(&:to_i)
puts x.find_index(0) + 1
//  [ruby]
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}


# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
x_list = gets_i_list

x_list.each_with_index do |x, i|
  if x == 0
    puts i+1
    exit
  end
end
//  [ruby]
s = getter = -> {
   require 'stringio'
  _in = StringIO.new
  while l = gets
    _in << l
  end
  _in.string
}.call
puts (s.split(' ').index('0') + 1)
//  [swift]
import Foundation
// Decimal型の有効桁数は38桁
let line = readLine()!.components(separatedBy: " ").map { Decimal(string: $0)! }

for i in 0..<5 {
    if line[i] == 0 {
        print(i + 1)
        exit(EXIT_SUCCESS)
    }
}
//  [swift]
import Foundation
 
let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ")
 
let a = Int(split[0])!
let b = Int(split[1])!
let c = Int(split[2])!
let d = Int(split[3])!
let e = Int(split[4])!

if (a==0){
    print(1)
}else if (b==0){
    print(2)
}else if (c==0){
    print(3)
}else if (d==0){
    print(4)
}else if (e==0){
    print(5)
}
//  [swift]
import Foundation

var str = readLine()!
str = str.replacingOccurrences(of: " ", with: "")
for (i, v) in str.enumerated() {
    if v == "0" {
        print(i + 1)
    }
}
//  [typescript]
import { readFileSync } from 'fs'
import { reverse } from 'dns'
import { start } from 'repl'
 
let lines: string[] = [];
const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
 
reader.on('line', function (line: string) {
    lines.push(line);
});
reader.on('close', function () {
    let x = lines[0].split(' ').map( _ => parseInt(_))
    /* let p = lines[1].split(' ').map( _ => parseInt(_)) */

    for(let i = 0; i < 5; i++) {
        if(x[i] == 0) {
            console.log(i+1)
        }
    }
});
//  [typescript]
import * as fs from "fs";

// one line
const input = fs.readFileSync("/dev/stdin", "utf8").replace("\n", "").split(" ");

console.log(input.indexOf("0") + 1);
//  [typescript]
import * as fs from "fs";
const x = fs.readFileSync("/dev/stdin", "utf8").split(" ").map(item => parseInt(item));

console.log(solve(x)+1);

function solve(x: number[]): number {
    return x.findIndex((item) => item == 0)
}
//  [python]
import numpy as np

S = input()
N = len(S)
move = 10 ** 100

U = N + 1
D = move.bit_length()

dbl = np.zeros((D, U), dtype=int)
for i, s in enumerate(S, start=1):
    if s == "R":
        dbl[0, i] = i + 1
    else:
        dbl[0, i] = i - 1

for h in range(D - 1):
    dbl[h + 1] = dbl[h, dbl[h]]

child = np.arange(1, N + 1)
for i in reversed(range(D)):
    if move & (1 << i):
        child = dbl[i, child]

ans = np.bincount(child, minlength=N + 1)
print(*ans[1:])
//  [python]
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

#別に誰も10^100なんて数が必要とはいってないのだ
def resolve():
    S=input()
    #シミュレーション真面目にやると|s|^2回必要なのでTLEするよ（乱択でごまかす方法をおもいつきませんでした）
    #状態を圧縮するとシミュレーションできませんか？
    #Sのうち、連続する2文字が”RL”か、文末にだけ1以上がある
    #RLの効果が及ぶところごとに分割しよっかLRの真ん中で分割
    N=len(S)
    sub=[N]#kugiri
    sub2=[]#"RL"のLの位置
    for i in range(N-1):
        cont=()
        if S[i]=="L"and S[i+1]=="R":
            sub.append(i+1)
        if S[i]=="R"and S[i+1]=="L":
            sub2.append(i+1)
    sub.sort(reverse=True)
    #print(sub,sub2)

    ans=[0]*N
    temp=[0,0]
    ind=0
    for i in range(N):
        l=sub2[ind]
        temp[(l-i)%2]+=1
        if i+1 in sub:
            ans[l]+=temp[0]
            ans[l-1]+=temp[1]
            temp=[0,0]
            ind+=1
            sub.pop()
            
            
    
    print(*ans)
    
    
#%%submit!
resolve()
//  [python]
import numpy as np
s=input()
prev='R'
a=0
x=np.zeros(len(s)).astype(np.uint32)
b=0
for i in range(len(s)):
    if s[i]==prev:
        a+=1
        continue
    else:
        if prev=='R':
            prev='L'
            x[b+a-1]+=(a-a//2)
            x[b+a]+=a//2
            b+=a
        else:
            prev='R'
            x[b]+=(a-a//2)
            x[b-1]+=a//2
            b+=a 
        a=1
x[b]+=(a-a//2)
x[b-1]+=a//2
p=''
for i in range(len(s)):
    p+=str(x[i])+' '
print(p[:-1])
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solveD();
    }

    private void solveD() {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out)) {

            char[] arr = br.readLine().toCharArray();
            int[] result = new int[arr.length];

            int nl = -1;
            int nr = -1;
            for (int i = 0; i < arr.length; i++) {
                char directrion = arr[i];

                if (directrion == 'R') {
                    if (i > nl) {
                        for (int j = i; j < arr.length; j++) {
                            if (arr[j] == 'L') {
                                nl = j;
                                break;
                            }

                        }
                    }

                    boolean isOdd = (nl - i) % 2 == 0;
                    result[isOdd ? nl : nl - 1] += 1;
                    continue;
                } else {

                    if (i > nr) {
                        for (int j = i; j >= 0; j--) {
                            if (arr[j] == 'R') {
                                nr = j;
                                break;
                            }
                        }
                    }

                    boolean isOdd = (nr - i) % 2 == 0;
                    if (isOdd) {
                        result[nr] += 1;
                    } else {
                        result[nr + 1] += 1;
                    }
                }

            }

            for (int i = 0; i < result.length - 1; i++) {
                pw.print(result[i] + " ");
            }
            pw.println(result[result.length - 1]);
            pw.flush();
        } catch (IOException e) {

        }
    }
}
//  [java]
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    char[] S = (scn.nextLine() + "E").toCharArray();

    int[] answer = new int[S.length - 1];
    Arrays.fill(answer, 0);

    char prevChar = S[0];
    int prevBorderInd = 0;
    for (int i = 0; i < S.length; i++) {
      if (S[i] != prevChar) {
        if (S[i] == 'L') {
          if ((i - prevBorderInd) % 2 == 0) {
            answer[i] += (i - prevBorderInd) / 2;
            answer[i - 1] += (i - prevBorderInd) / 2;
          } else {
            answer[i] += (i - prevBorderInd) / 2;
            answer[i - 1] += (i - prevBorderInd) / 2 + 1;
          }
          prevChar = 'L';
        }

        if (S[i] == 'R' || S[i] == 'E') {
          if ((i - prevBorderInd) % 2 == 0) {
            answer[prevBorderInd] += (i - prevBorderInd) / 2;
            answer[prevBorderInd - 1] += (i - prevBorderInd) / 2;
          } else {
            answer[prevBorderInd] += (i - prevBorderInd) / 2 + 1;
            answer[prevBorderInd - 1] += (i - prevBorderInd) / 2;
          }
          prevChar = 'R';
        }
        prevBorderInd = i;

      }

    }
    for (int ans : answer) {
      System.out.printf("%d ", ans);
    }

  }
}
//  [cpp]
#include <bits/stdc++.h>
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
#define check cout<<"?\n";

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();
    string s; cin >> s;
    int n = (int)s.size();
    vector<int> ans(n, 1);
    for(int i = 0; i < n; ++i){
        int cur = 1, aux = i;
        if(s[i] == 'R'){
            while(s[aux + 1] == 'R'){
                ++aux;
                ++cur;
            }
            if(cur > 1){
                if(cur & 1){
                    ++ans[cur + i - 1];
                }else{
                    ++ans[cur + i];
                }
            }
        }else{
            while(s[aux - 1] == 'L'){
                --aux;
                ++cur;
            }
            if(cur > 1){
                if(cur & 1){
                    ++ans[i - cur + 1];
                }else{
                    ++ans[i - cur];
                }
            }
        }
        if(cur > 1) --ans[i];
        //cout << i << ' ' << s[i] << " mov: " << cur << '\n';
    }
    for(auto &i: ans){
        cout << i << ' ';
    }
    return 0;
}
//  [cpp]
#include<iostream>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);
    
    string s;
    cin >> s;
    map<char, int> mp{{'L', -1}, {'R', 1}};
    vector<int> ans(s.size(), 0);

    for (int i = 0; i < s.size(); i++) {
        int t = i, cnt = 1;
        char now = s[i];
        int m = mp[now];
        while(now == s[t + m]) {
            t += m;
            cnt++;
        }
        if (cnt % 2 == 0) ans[i + m * cnt]++;
        else ans[i + m * (cnt - 1)]++;
    }


    for (int i = 0; i < s.size(); i++) cout << ans[i] << ' ';
    cout << endl;
}
//  [c]
#include <stdio.h>
#include <string.h>
#define max(a, b) ((a)<(b) ? (b) : (a))
#define swap(type, x, y) do{ type t = x; x = y; y = t; }while(0)
int main(){
  char s[100005];  scanf("%s", s);
  int lcount = 0, rcount = 0;
  int lpos, rpos, ave;
  int table[100005] = {0};
  int flag;
  for(int i=0; i<strlen(s); i++){
    if(s[i]=='R'){
      if(lcount > 0){
	lpos = i - lcount, rpos = i - lcount - 1;
	ave = (lcount + rcount) / 2, flag = (lcount + rcount) % 2;
	if(max(lcount, rcount) % 2 == 1)  swap(int, rpos, lpos);
	if(lcount > rcount && flag){
	  rcount = ave + 1,  lcount = ave;
	}else if(lcount < rcount && flag){
	  lcount = ave + 1,  rcount = ave;
	}else{
	  lcount = ave,  rcount = ave;
	}
	table[lpos] = lcount;
	table[rpos] = rcount;
	lcount = rcount = 0;
      }
      rcount++;
    }else{
      lcount++;
    }
  }
  lpos = strlen(s) - lcount;
  rpos = lpos - 1;
  if(max(lcount, rcount) % 2 == 1)  swap(int, rpos, lpos);
  ave = (lcount + rcount) / 2;
  flag = (lcount + rcount) % 2;
  if(lcount > rcount && flag){
    rcount = ave + 1;
    lcount = ave;
  }else if(lcount < rcount && flag){
    rcount = ave;
    lcount = ave + 1;
  }else{
    lcount = rcount = ave;
  }
  table[lpos] = lcount;
  table[rpos] = rcount;
  for(int i=0; i<strlen(s); i++)
    printf("%d ", table[i]);
  puts("");
  return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>
#define MAX 100010
int ans[MAX]={};

int main(){
  char str[MAX];
  scanf(" %s",str);
  int i;
  char temp='R';
  int count=0,j=0,len=strlen(str);
  for(i=0;i<len;i++) {
    if (temp==str[i]) {
      count++;
      continue;
    }
    if(temp=='R'){
      j=i;
      ans[j]+=count/2;
      ans[j-1]+=(count+1)/2;
    }else{
      ans[j-1]+=count/2;
      ans[j]+=(count+1)/2;
    }
    count=1;
    temp=str[i];
  }
  
  ans[j-1]+=count/2;
  ans[j]+=(count+1)/2;
  for(i=0;i<strlen(str);i++)
    printf("%d ",ans[i]);
  return 0;
}


/// confirm df==0 ///
//  [c]
#include <stdio.h>
#include <string.h>

#define MAX 100001

int main(void){
  int i,j;

  char str[MAX];
  scanf(" %s",str);

  long ans[MAX];
  for(i=0;i<MAX;i++){
    ans[MAX]=0;
  }

  long r_num=0,l_num=0,repeat_place;
  for(i=0;i<strlen(str);i++){
    if(str[i]=='R'){
      if(l_num==0){
        r_num++;
      }else{
        if(l_num%2==0){
          ans[repeat_place]+=l_num/2;
          ans[repeat_place+1]+=l_num/2;
        }else{
          ans[repeat_place]+=l_num/2;
          ans[repeat_place+1]+=l_num/2+1;
        }
        l_num=0;
        r_num++;
      }
    }else{
      if(r_num==0){
        l_num++;
      }else{
        repeat_place=i-1;
        if(r_num%2==0){
          ans[repeat_place]+=r_num/2;
          ans[repeat_place+1]+=r_num/2;
        }else{
          ans[repeat_place]+=r_num/2+1;
          ans[repeat_place+1]+=r_num/2;
        }
        r_num=0;
        l_num++;
      }
    }
  }

  if(l_num%2==0){
    ans[repeat_place]+=l_num/2;
    ans[repeat_place+1]+=l_num/2;
  }else{
    ans[repeat_place]+=l_num/2;
    ans[repeat_place+1]+=l_num/2+1;
  }

  for(i=0;i<strlen(str);i++){
    printf("%ld ",ans[i]);
  }
  printf("\n");

  return 0;
}
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    tmp0 = input[0].split(" ");
    // tmp1 = input[1].split(" ");

    S = input[0]

    //分割位置導出
    splitIndex = []
    beforeRL = S[0]
    for(var i=1; i < S.length; i++)
    {
      if(beforeRL === 'L' && S[i] === 'R')
      {
        splitIndex.push(i)
      }
      beforeRL = S[i]
    }
    splitIndex.push(S.length)
    // console.log(splitIndex)

    start = 0
    tmpStr = []
    for(var i=0; i < splitIndex.length; i++)
    {
      tmpStr.push(S.substr(start, splitIndex[i] - start)) // start, length
      start = splitIndex[i]
    }
    // console.log(tmpStr)

    var finalR = []
    var finalL = []
    for(var i=0; i < tmpStr.length; i++)
    {
      var Rcnt = tmpStr[i].split('R').length - 1
      var Lcnt = tmpStr[i].split('L').length - 1
      // console.log(`R: ${Rcnt}, L: ${Lcnt}`)
      finalR.push(Math.ceil(Rcnt/2) + Math.floor(Lcnt/2))
      finalL.push(Math.ceil(Lcnt/2) + Math.floor(Rcnt/2))
    }
    // console.log(finalR)
    // console.log(finalL)

    var finalCnt = 0
    for(var i=0; i < S.length-1; i++)
    {
      afterRL = S[i+1]
      // console.log(`S[i] : ${S[i]}, afterRL: ${afterRL}`)
      if(S[i] === 'R' && afterRL === 'L')
      {
        process.stdout.write(finalR[finalCnt] + ' ' + finalL[finalCnt] + ' ');
        i++
        finalCnt++
        if(i === S.length-2)
        {
          process.stdout.write('0');
        }
        continue
      }
      process.stdout.write('0 ');
      if(i === S.length-2)
      {
        process.stdout.write('0');
      }
    }
}
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main("RRRLLRLLRRRLLLLL\n");
//  [javascript]
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
	var list = nextCharArray();
	var N = list.length;
	var output = new Array(N).fill(0);
	var count = 0;
	for(var i = 0; i < N - 1; i++){
		if(list[i] == "R"){
			count++;
			if(list[i + 1] == "L"){
				output[i] = count;
				count = 0;
			}
		}
	}
	count = 0;
	for(var i = N - 1; i > 0; i--){
		if(list[i] == "L"){
			count++;
			if(list[i - 1] == "R"){
				output[i] = count;
				count = 0;
			}
		}
	}
	myerr(output);
	for(var i = 0; i < N - 1; i++){
		if(list[i] == "R" && list[i + 1] == "L"){
			if(output[i] % 2 == (output[i + 1]) % 2){
				var avg = (output[i] + output[i + 1]) / 2;
				output[i] = avg;
				output[i + 1] = avg;
			}else{
				var avg = Math.floor((output[i] + output[i + 1]) / 2);
				if(output[i] % 2 == 1){
					output[i] = avg + 1;
					output[i + 1] = avg;
				}else{
					output[i] = avg;
					output[i + 1] = avg + 1;
				}
			}
		}
	}
	myout(myconv(output,8));
}
//  [javascript]
module.exports=function(e){var r={};function n(t){if(r[t])return r[t].exports;var o=r[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=r,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,r){if(1&r&&(e=n(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)n.d(t,o,function(r){return e[r]}.bind(null,o));return t},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},n.p="",n(n.s=0)}([function(e,r,n){n(1)(n(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(e,r){e.exports=function(e){for(var r=e[0],n=r.length,t=new Array(n).fill(0),o=[],u=0;u<n-1;u++)"R"==r[u]&&"L"==r[u+1]&&o.push(u);for(var i=0,f=0,l=o[0],c=0;c<n;c++)c!=l?"R"==r[c]?(l-c)%2==0?t[l]+=1:t[l+1]+=1:(c-i)%2==0?t[i]+=1:t[i+1]+=1:(t[c]+=1,i=l,l=o[++f]);console.log(t.join(" "))}},function(e,r){e.exports=require("fs")}]);
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	S := readLine()
	fmt.Printf("%s\n", ABC136D(S))
}

// ABC136D ...
func ABC136D(S string) (resstr string) {
		res := make([]int, len(S))

	succ := 1
	for i := 1; i < len(S); i++ {
		if succ != 0 && S[i] == 'L' {
			if succ%2 == 0 {
				res[i-1] += succ / 2
				res[i] += succ / 2
			} else {
				res[i-1] += succ/2 + 1
				res[i] += succ / 2
			}
			succ = 0
		} else if S[i] == 'R' {
			succ++
		}
	}

	succ = 1
	for i := len(S) - 2; i >= 0; i-- {
		if succ != 0 && S[i] == 'R' {
			if succ%2 == 0 {
				res[i] += succ / 2
				res[i+1] += succ / 2
			} else {
				res[i] += succ / 2
				res[i+1] += succ/2 + 1
			}
			succ = 0
		} else if S[i] == 'L' {
			succ++
		}
	}

	for i := 0; i < len(res)-1; i++ {
		resstr += strconv.Itoa(res[i]) + " "
	}
	resstr += strconv.Itoa(res[len(res)-1])

	return
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	// sc.Split(bufio.ScanWords)
	// S := read()
	var S string
	fmt.Scan(&S)
	prev := "R"
	length := 1
	leftLength := 0
	for i := 1; i < len(S); i++ {
		cur := string(S[i])
		if prev == "L" && cur == "R" {
			gather(length, leftLength)
			fmt.Print(" ")
			length = 0
			leftLength = 0
		}
		if prev == "R" && cur == "L" {
			leftLength = length
		}
		length++
		if i == len(S)-1 {
			gather(length, leftLength)
			fmt.Println("")
		}
		prev = cur
	}
}

func gather(len int, leftLen int) {
	if len <= 1 {
		panic("here")
	}
	res := []int{}
	left := 0
	right := 0
	for i := 1; i <= len; i++ {
		res = append(res, 0)
		if i <= leftLen {
			if i%2 == leftLen%2 {
				left++
			} else {
				right++
			}
		} else {
			if (i-leftLen)%2 == 1 {
				right++
			} else {
				left++
			}
		}
	}
	res[leftLen-1] = left
	res[leftLen] = right
	for i := 0; i < len; i++ {
		fmt.Printf("%d", res[i])
		if i != len-1 {
			fmt.Print(" ")
		}
	}
}