QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#119984#5512. Stone Arranging 2binminh0160 80ms17816kbC++236.6kb2023-07-06 09:36:332023-07-06 09:36:34

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-06 09:36:34]
  • 评测
  • 测评结果:60
  • 用时:80ms
  • 内存:17816kb
  • [2023-07-06 09:36:33]
  • 提交

answer

#pragma GCC optimize("Ofast")
#pragma GCC target("sse4")
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define int128 __int128_t
#define double long double
#define gcd __gcd
#define lcm(a, b) ((a)/gcd(a, b)*(b))
#define sqrt sqrtl
#define log2 log2l
#define log10 log10l
#define floor floorl
#define to_string str
#define yes cout << "YES"
#define no cout << "NO"
#define trav(i, a) for (auto &i: (a))
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (int)a.size()
#define Max(a) *max_element(all(a))
#define Min(a) *min_element(all(a))
#define Find(a, n) (find(all(a), n) - a.begin())
#define Count(a, n) count(all(a), n)
#define Upper(a, n) (upper_bound(all(a), n) - a.begin())
#define Lower(a, n) (lower_bound(all(a), n) - a.begin())
#define next_perm(a) next_permutation(all(a))
#define prev_perm(a) prev_permutation(all(a))
#define sorted(a) is_sorted(all(a))
#define sum(a) accumulate(all(a), 0)
#define sumll(a) accumulate(all(a), 0ll)
#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define Unique(a) Sort(a), (a).resize(unique(all(a)) - a.begin())
#define pb push_back
#define eb emplace_back
#define open(s) freopen(s, "r", stdin)
#define write(s) freopen(s, "w", stdout)
#define fileopen(s) open((string(s) + ".inp").c_str()), write((string(s) + ".out").c_str());
#define For(i, a, b) for (auto i = (a); i < (b); i++)
#define Fore(i, a, b) for (auto i = (a); i >= (b); i--)
#define FOR(i, a, b) for (auto i = (a); i <= (b); i++)
#define ret(s) return void(cout << s);

const int mod = 1e9 + 7, mod2 = 998244353;
const double PI = acos(-1);
const ull npos = string::npos;
const int dx[] = {0, 0, -1, 1}, dy[] = {-1, 1, 0, 0};
using pii = pair<int, int>;
using pll = pair<ll, ll>;
mt19937 mt(chrono::system_clock::now().time_since_epoch().count());
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vdo;
typedef vector<vdo> vvdo;
typedef vector<string> vs;
typedef vector<pii> vpair;
typedef vector<vpair> vvpair;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef priority_queue<int> pq;
typedef priority_queue<int, vi, greater<int>> pqg;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vll, greater<ll>> pqgll;
 
ll power(ll a, ll b, int m){ll x = 1;a%=m;while (b) {if (b & 1) x = x*a % m;a = a*a % m;b>>=1;}return x;}
ll power(ll a, ll b){ll x = 1;while (b) {if (b & 1) x = x*a;a = a*a;b>>=1;}return x;}
ll ceil(ll a, ll b){return (a + b - 1)/b;}
ll to_int(const string &s){ll x = 0; for (int i = (s[0] == '-'); i < sz(s); i++) x = x*10 + s[i] - '0';return x*(s[0] == '-' ? -1: 1);}
bool is_prime(ll n) {if (n < 2) return 0;if (n < 4) return 1;if (n % 2 == 0 || n % 3 == 0) return 0;for (ll i = 5; i*i <= n; i+=6) {if(n % i == 0 || n % (i + 2) == 0) return 0;}return 1;}
bool is_square(ll n) {ll k = sqrt(n); return k*k == n;}
ll factorial(int n) {ll x = 1;for (int i = 2; i <= n; i++) x*=i;return x;}
ll factorial(int n, int m) {ll x = 1;for (ll i = 2; i <= n; i++) x = x*i % m;return x;}
bool is_power(ll n, ll k) {while (n % k == 0) n/=k;return n == 1ll;}
string str(ll n) {if (n == 0) return "0"; string s = ""; bool c = 0; if (n < 0) c = 1, n = -n; while (n) {s+=n % 10 + '0'; n/=10;} if (c) s+='-'; Reverse(s); return s;}
string repeat(const string &s, int n) {if (n < 0) return ""; string x = ""; while (n--) x+=s; return x;}
string bin(ll n) {string s = ""; while (n) {s+=(n & 1) + '0'; n>>=1;} Reverse(s); return s;}
void sieve(vector<bool> &a) {int n = a.size(); a[0] = a[1] = 0; for (int i = 4; i < n; i+=2) a[i] = 0; for (int i = 3; i*i < n; i+=2) {if (a[i]) {for (int j = i*i; j < n; j+=(i << 1)) a[j] = 0;}}}
void sieve(vector<int> &a) {int n = a.size(); for (int i = 2; i < n; i+=2) a[i] = 2; for (int i = 3; i*i < n; i+=2) {if (!a[i]) {for (int j = i; j < n; j+=(i << 1)) a[j] = i;}} for (int i = 3; i < n; i+=2) {if (!a[i]) a[i] = i;}}
void sieve(int a[], int n) {for (int i = 2; i < n; i+=2) a[i] = 2; for (int i = 3; i*i < n; i+=2) {if (!a[i]) {for (int j = i; j < n; j+=(i << 1)) a[j] = i;}} for (int i = 3; i < n; i+=2) {if (!a[i]) a[i] = i;}}
vector<pii> factorize(int n) {vector<pii> a; for (int i = 2; i*i <= n; i++) {if (n % i == 0) {int k = 0; while (n % i == 0) k++, n/=i; a.emplace_back(i, k);}} if (n > 1) a.emplace_back(n, 1); return a;}
int rand(int l, int r) {return uniform_int_distribution<int>(l, r)(mt);}
int Log2(int n) {return 31 - __builtin_clz(n);}
template<class T> void compress(vector<T> &a) {vector<T> b; for (T &i: a) b.push_back(i); sort(all(b)); b.resize(unique(all(b)) - b.begin()); for (T &i: a) i = lower_bound(all(b), i) - b.begin() + 1;}

template<class A, class B> istream& operator>>(istream& in, pair<A, B> &p) {in >> p.first >> p.second; return in;}
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &p) {out << p.first << ' ' << p.second; return out;}
template<class T> istream& operator>>(istream& in, vector<T> &a) {for (auto &i: a) in >> i; return in;}
template<class T> ostream& operator<<(ostream& out, const vector<T> &a) {for (auto &i: a) out << i << ' '; return out;}
template<class T> istream& operator>>(istream& in, vector<vector<T>> &a) {for (auto &i: a) in >> i; return in;}
template<class T> ostream& operator<<(ostream& out, const vector<vector<T>> &a) {for (auto &i: a) out << i << '\n'; return out;}
template<class T> istream& operator>>(istream& in, deque<T> &a) {for (auto &i: a) in >> i; return in;}
template<class T> ostream& operator<<(ostream& out, const deque<T> &a) {for (auto &i: a) out << i << ' '; return out;}
// istream& operator>>(istream& in, __int128_t &a) {string s; in >> s; a = 0; for (auto &i: s) a = a*10 + (i - '0'); return in;}
// ostream& operator<<(ostream& out, __int128_t a) {string s = ""; while (a > 0) {s+=(int)a % 10 + '0'; a/=10;} Reverse(s); out << s; return out;}

const int N = 2e5 + 3;
vi p[N];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    cout << fixed << setprecision(10);
    int n; cin >> n;
    vector<int> a(n), b;
    for(auto &i: a) cin >> i, b.pb(i);
    Unique(b);
    trav(i,a) i = Lower(b, i);
    For(i,0,n){
        if (sz(p[a[i]])){
            vi s;
            Fore(j,i-1,p[a[i]].back()+1){
                if (a[j] != a[i]) {
                    s.pb(j);
                    p[a[j]].pop_back();
                    a[j] = a[i];
                }
            }
            while (sz(s)) p[a[i]].pb(s.back()), s.pop_back();
        }
        p[a[i]].pb(i);
    }
    trav(i,a) cout << b[i] << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 25
Accepted

Test #1:

score: 25
Accepted
time: 2ms
memory: 8132kb

input:

1
1

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 1ms
memory: 8164kb

input:

2
1
1

output:

1
1

result:

ok 2 lines

Test #3:

score: 0
Accepted
time: 2ms
memory: 8160kb

input:

3
1
1
1

output:

1
1
1

result:

ok 3 lines

Test #4:

score: 0
Accepted
time: 1ms
memory: 8204kb

input:

2000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 2000 lines

Test #5:

score: 0
Accepted
time: 3ms
memory: 8196kb

input:

1
2

output:

2

result:

ok single line: '2'

Test #6:

score: 0
Accepted
time: 1ms
memory: 8160kb

input:

2
2
2

output:

2
2

result:

ok 2 lines

Test #7:

score: 0
Accepted
time: 2ms
memory: 8164kb

input:

3
2
2
2

output:

2
2
2

result:

ok 3 lines

Test #8:

score: 0
Accepted
time: 1ms
memory: 8184kb

input:

2000
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 2000 lines

Test #9:

score: 0
Accepted
time: 0ms
memory: 8232kb

input:

2000
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
33497...

output:

334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
...

result:

ok 2000 lines

Test #10:

score: 0
Accepted
time: 3ms
memory: 8248kb

input:

2000
2
1
2
2
1
1
1
2
2
2
1
1
2
2
1
1
2
2
2
2
2
1
2
1
2
2
1
2
2
2
2
2
1
1
1
2
2
2
2
2
1
2
2
2
2
2
1
1
1
1
2
1
2
1
1
2
1
1
2
2
2
1
1
1
1
1
1
2
2
2
1
1
1
2
1
2
2
1
1
2
1
1
1
2
1
1
1
2
1
2
1
2
2
2
1
2
2
1
2
2
2
2
1
2
1
1
2
2
1
2
1
1
2
2
1
1
1
1
1
1
2
1
2
2
2
2
1
2
1
2
2
1
1
1
1
2
1
2
1
1
1
1
2
2
1
1
1
1...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 2000 lines

Test #14:

score: 0
Accepted
time: 2ms
memory: 8240kb

input:

2000
2
1
2
1
1
1
2
1
1
2
2
2
1
2
1
2
1
2
1
2
1
2
2
2
1
2
2
2
1
1
2
2
1
2
1
1
1
2
2
1
2
1
1
1
1
1
2
2
2
1
2
1
2
2
2
2
2
1
2
2
2
1
2
1
2
1
1
1
2
2
1
2
2
2
1
2
1
2
2
1
1
2
2
1
1
2
2
2
2
2
2
1
2
2
1
1
1
1
2
1
1
1
1
1
2
2
1
2
2
2
2
2
2
2
1
2
2
1
1
1
1
1
1
1
2
1
2
1
1
1
1
1
2
2
2
1
2
1
1
1
1
2
1
2
1
1
1
1...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 2000 lines

Test #15:

score: 0
Accepted
time: 1ms
memory: 8204kb

input:

2000
81888042
43067133
107207954
11840122
12213120
1564709
591852273
88838690
961663051
516561909
168803248
844631608
873195256
827482724
743609376
619362989
538294587
82184630
144127319
243409882
211682139
271003483
663591071
168473717
654369346
16498799
591919038
700712177
385773734
618206739
8131...

output:

81888042
43067133
107207954
11840122
12213120
1564709
591852273
88838690
961663051
516561909
168803248
844631608
873195256
827482724
743609376
619362989
538294587
82184630
144127319
243409882
211682139
271003483
663591071
168473717
654369346
16498799
591919038
700712177
385773734
618206739
813177482...

result:

ok 2000 lines

Test #16:

score: 0
Accepted
time: 0ms
memory: 8296kb

input:

2000
885745611
10531340
864341459
215264744
300047319
287916141
644603625
884166447
420412412
20068650
590534965
653358937
990188463
990316905
998312402
558306521
958686996
980116759
160902156
540498688
104465002
553013905
427573746
519316677
185497721
791572866
825112521
486213608
474133783
1868877...

output:

885745611
10531340
864341459
215264744
300047319
287916141
644603625
884166447
420412412
20068650
590534965
653358937
990188463
990316905
998312402
558306521
958686996
980116759
160902156
540498688
104465002
553013905
427573746
519316677
185497721
791572866
825112521
486213608
474133783
186887702
27...

result:

ok 2000 lines

Test #17:

score: 0
Accepted
time: 1ms
memory: 8244kb

input:

2000
124748890
124748890
124748890
815254336
124748890
815254336
815254336
124748890
124748890
124748890
815254336
124748890
124748890
815254336
815254336
815254336
124748890
124748890
124748890
124748890
815254336
815254336
815254336
124748890
124748890
815254336
815254336
815254336
815254336
12474...

output:

124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
...

result:

ok 2000 lines

Test #18:

score: 0
Accepted
time: 3ms
memory: 8268kb

input:

2000
401665219
401665219
401665219
27125575
401665219
401665219
401665219
27125575
401665219
27125575
27125575
401665219
401665219
27125575
401665219
401665219
27125575
27125575
27125575
401665219
27125575
401665219
27125575
401665219
27125575
27125575
27125575
27125575
401665219
401665219
401665219...

output:

401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
...

result:

ok 2000 lines

Test #19:

score: 0
Accepted
time: 0ms
memory: 8204kb

input:

2000
810060218
522476642
810060218
522476642
522476642
522476642
810060218
810060218
810060218
522476642
522476642
810060218
810060218
810060218
810060218
810060218
522476642
810060218
810060218
522476642
810060218
810060218
810060218
522476642
522476642
522476642
810060218
810060218
522476642
52247...

output:

810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
...

result:

ok 2000 lines

Test #20:

score: 0
Accepted
time: 1ms
memory: 8140kb

input:

2000
401575885
661633480
401575885
661633480
661633480
661633480
401575885
661633480
401575885
401575885
661633480
401575885
661633480
401575885
401575885
401575885
661633480
401575885
661633480
661633480
401575885
401575885
401575885
661633480
661633480
661633480
401575885
661633480
401575885
66163...

output:

401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
...

result:

ok 2000 lines

Test #21:

score: 0
Accepted
time: 3ms
memory: 8188kb

input:

2000
8679749
689251055
488931635
8679749
689251055
488931635
488931635
488931635
689251055
488931635
488931635
488931635
488931635
8679749
689251055
689251055
488931635
8679749
488931635
689251055
8679749
689251055
488931635
8679749
488931635
8679749
8679749
689251055
488931635
8679749
488931635
867...

output:

8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679...

result:

ok 2000 lines

Test #22:

score: 0
Accepted
time: 3ms
memory: 8208kb

input:

2000
982030052
308022921
982030052
354850469
354850469
354850469
354850469
982030052
308022921
354850469
354850469
982030052
308022921
354850469
354850469
354850469
354850469
308022921
354850469
982030052
982030052
354850469
308022921
354850469
308022921
308022921
308022921
982030052
354850469
35485...

output:

982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
982030052
...

result:

ok 2000 lines

Test #23:

score: 0
Accepted
time: 2ms
memory: 8232kb

input:

2000
586535587
203412544
61851007
586535587
203412544
586535587
586535587
203412544
203412544
61851007
203412544
586535587
586535587
586535587
586535587
61851007
203412544
203412544
203412544
586535587
61851007
586535587
61851007
61851007
586535587
586535587
61851007
203412544
203412544
61851007
203...

output:

586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
586535587
...

result:

ok 2000 lines

Test #24:

score: 0
Accepted
time: 3ms
memory: 8212kb

input:

2000
590388927
590388927
68755410
590388927
590388927
68755410
590388927
590388927
68755410
68755410
923083310
68755410
590388927
590388927
923083310
68755410
923083310
68755410
590388927
923083310
923083310
590388927
590388927
590388927
923083310
590388927
590388927
590388927
68755410
590388927
923...

output:

590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
590388927
...

result:

ok 2000 lines

Test #25:

score: 0
Accepted
time: 2ms
memory: 8208kb

input:

2000
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
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time: 1ms
memory: 8232kb

input:

2000
754274998
822961596
932465876
339412345
177684528
963952164
141030764
517806972
680542461
968488186
80253359
782540517
56441822
356863563
600705089
728862566
319632076
362033128
807266164
872727071
658130967
851081128
980844898
361681389
206524648
205561797
386232279
672567842
956335507
1787127...

output:

754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
754274998
...

result:

ok 2000 lines

Test #28:

score: 0
Accepted
time: 7ms
memory: 13248kb

input:

2000
354854941
822325099
524749982
990951393
151897977
122977243
542161994
655100949
657272310
978121545
673586877
210362436
221729103
655831609
607486955
634591549
990298100
733294844
496109191
729492128
502001539
582808377
945935328
756682179
536380863
659042891
466968394
858574147
894569965
35301...

output:

354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
354854941
...

result:

ok 2000 lines

Subtask #2:

score: 35
Accepted

Test #29:

score: 35
Accepted
time: 13ms
memory: 10968kb

input:

200000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 200000 lines

Test #30:

score: 0
Accepted
time: 17ms
memory: 10944kb

input:

200000
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 200000 lines

Test #31:

score: 0
Accepted
time: 17ms
memory: 10940kb

input:

200000
2
1
1
2
2
2
2
2
1
1
1
1
2
2
2
1
1
1
2
1
2
2
2
1
1
2
1
1
2
1
2
2
1
2
1
2
1
2
1
2
2
1
1
1
2
1
1
2
2
1
2
1
2
2
2
2
2
1
2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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 200000 lines

Test #33:

score: 0
Accepted
time: 21ms
memory: 11004kb

input:

200000
1
2
2
2
2
2
1
1
1
1
1
2
1
2
2
2
1
1
2
2
2
1
2
1
1
1
2
1
1
1
2
2
1
1
1
2
2
1
2
2
2
2
2
1
1
1
1
2
1
2
2
1
1
1
2
1
2
2
1
1
1
1
2
1
1
1
2
2
1
2
2
1
1
1
1
1
2
2
1
1
2
2
1
1
2
1
1
2
1
2
2
2
1
2
1
1
2
1
2
2
2
1
1
2
1
2
1
2
2
2
1
2
1
2
2
1
1
1
1
1
1
1
2
1
2
1
2
1
1
1
1
1
2
1
1
1
2
2
1
2
1
2
1
2
1
1
1...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 200000 lines

Test #34:

score: 0
Accepted
time: 22ms
memory: 10960kb

input:

200000
2
1
2
2
1
2
2
2
2
1
1
2
1
1
1
2
1
2
2
2
2
2
1
2
1
2
1
1
2
2
2
2
1
1
2
2
2
2
1
2
1
2
1
2
2
2
1
2
2
1
1
2
2
1
2
1
2
1
2
2
1
1
1
2
1
2
2
1
2
2
1
1
1
1
1
1
2
1
1
2
1
1
2
1
2
2
2
2
2
1
1
1
1
2
2
2
2
2
2
2
2
2
1
1
1
1
2
1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
1
1
1
1
...

result:

ok 200000 lines

Test #36:

score: 0
Accepted
time: 25ms
memory: 10988kb

input:

200000
2
1
2
2
1
1
2
1
1
1
1
2
1
1
2
2
2
1
2
2
2
1
2
2
1
2
1
1
1
1
1
2
2
2
2
2
1
2
2
2
1
2
1
1
1
2
2
2
2
1
2
2
2
1
1
1
2
2
2
1
1
1
2
2
1
2
2
1
1
1
2
1
2
2
1
2
2
1
2
2
2
2
2
1
2
2
2
2
2
1
2
1
1
1
1
1
1
2
2
2
1
2
2
2
2
1
2
2
2
1
1
2
2
1
2
2
2
2
1
1
1
2
2
2
2
1
2
1
2
1
2
1
1
2
2
2
1
2
1
1
2
1
2
2
2
2
1...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 200000 lines

Test #37:

score: 0
Accepted
time: 18ms
memory: 10904kb

input:

200000
1
1
1
1
1
1
1
2
1
2
2
1
1
2
2
1
1
1
1
1
1
1
1
2
1
1
2
1
2
2
2
2
1
1
1
1
1
2
2
1
2
2
2
1
1
2
2
1
2
1
1
2
2
2
2
2
2
1
2
2
2
1
1
2
1
1
1
1
1
2
2
1
1
1
2
2
2
1
1
1
1
1
1
2
2
2
2
2
2
1
2
2
1
2
2
1
1
1
1
1
2
1
1
1
1
1
2
1
1
1
2
2
1
2
1
1
2
1
2
2
2
2
1
2
2
1
1
1
2
2
1
1
1
2
1
2
2
1
1
1
2
1
2
2
1
2
1...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 200000 lines

Test #38:

score: 0
Accepted
time: 12ms
memory: 11000kb

input:

200000
1
2
1
2
2
1
2
2
1
2
1
1
1
1
2
1
1
2
1
1
2
1
1
1
1
2
1
1
1
1
2
2
2
1
1
2
1
2
2
2
2
1
1
2
1
1
1
1
1
2
1
2
1
1
1
1
1
2
1
2
1
1
2
2
1
2
2
1
1
2
1
2
2
1
1
2
1
2
1
2
1
2
2
2
1
1
1
1
2
2
1
2
2
2
2
2
2
2
2
2
1
2
1
1
1
2
2
1
1
1
2
2
1
2
1
1
1
2
2
1
1
2
2
1
1
1
2
1
2
1
1
1
2
2
1
1
2
1
1
1
1
1
1
2
2
1
1...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 200000 lines

Test #39:

score: 0
Accepted
time: 14ms
memory: 10936kb

input:

200000
2
1
2
1
2
1
2
1
2
1
1
1
1
1
1
1
2
1
2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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 200000 lines

Test #41:

score: 0
Accepted
time: 15ms
memory: 10956kb

input:

200000
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 200000 lines

Test #42:

score: 0
Accepted
time: 14ms
memory: 10924kb

input:

200000
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 200000 lines

Subtask #3:

score: 0
Memory Limit Exceeded

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #44:

score: 40
Accepted
time: 18ms
memory: 11016kb

input:

200000
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112...

output:

112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
112158695
...

result:

ok 200000 lines

Test #45:

score: 0
Accepted
time: 75ms
memory: 17600kb

input:

200000
250476873
607663417
816584695
416887801
40507923
632697325
355037399
376333091
449846468
342424011
501902947
16542980
209029115
455616471
184456228
946136503
821755788
927220754
545327771
71059562
252945182
372354032
791593360
715215748
835496839
888884281
770814659
469859848
541466395
635835...

output:

250476873
607663417
816584695
416887801
40507923
632697325
355037399
376333091
449846468
342424011
501902947
16542980
209029115
455616471
184456228
946136503
821755788
927220754
545327771
71059562
252945182
372354032
791593360
715215748
835496839
888884281
888884281
888884281
888884281
888884281
888...

result:

ok 200000 lines

Test #46:

score: 0
Accepted
time: 80ms
memory: 17816kb

input:

200000
730854553
774060247
905166107
842852844
610874404
45072693
857310203
746448778
2880404
458629786
684688535
383045536
575666674
667101713
433737236
42709240
260009
356313805
899649746
608487864
4913697
612260239
268160771
235173667
431327074
183814364
252704380
530362648
613692311
980908780
18...

output:

730854553
774060247
905166107
842852844
610874404
45072693
857310203
746448778
2880404
458629786
684688535
383045536
575666674
667101713
433737236
42709240
260009
356313805
899649746
608487864
4913697
612260239
268160771
235173667
431327074
183814364
252704380
530362648
613692311
980908780
186414849...

result:

ok 200000 lines

Test #47:

score: 0
Accepted
time: 20ms
memory: 10988kb

input:

200000
95080575
894889317
894889317
894889317
894889317
95080575
894889317
95080575
894889317
894889317
95080575
894889317
894889317
95080575
894889317
95080575
95080575
95080575
894889317
894889317
894889317
894889317
95080575
95080575
95080575
95080575
894889317
95080575
894889317
95080575
8948893...

output:

95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
95080575
950...

result:

ok 200000 lines

Test #48:

score: 0
Accepted
time: 26ms
memory: 10944kb

input:

200000
84156727
84156727
84156727
22826910
22826910
22826910
22826910
22826910
84156727
22826910
84156727
22826910
84156727
22826910
22826910
84156727
22826910
84156727
22826910
22826910
84156727
84156727
22826910
22826910
22826910
84156727
84156727
84156727
84156727
22826910
22826910
22826910
22826...

output:

84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
84156727
841...

result:

ok 200000 lines

Test #49:

score: 0
Accepted
time: 36ms
memory: 10908kb

input:

200000
846174844
825766308
846174844
846174844
825766308
825766308
825766308
825766308
846174844
825766308
846174844
825766308
846174844
846174844
846174844
846174844
825766308
825766308
825766308
846174844
825766308
825766308
825766308
846174844
846174844
846174844
825766308
846174844
825766308
825...

output:

846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
846174844
...

result:

ok 200000 lines

Test #50:

score: 0
Accepted
time: 26ms
memory: 10940kb

input:

200000
284878254
271883883
271883883
271883883
284878254
271883883
271883883
271883883
284878254
271883883
284878254
284878254
271883883
284878254
271883883
284878254
284878254
271883883
271883883
284878254
284878254
284878254
284878254
284878254
284878254
271883883
271883883
284878254
284878254
284...

output:

284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
284878254
...

result:

ok 200000 lines

Test #51:

score: 0
Accepted
time: 31ms
memory: 10916kb

input:

200000
485288787
877726107
485288787
485288787
395956684
485288787
485288787
877726107
395956684
485288787
485288787
395956684
877726107
485288787
485288787
485288787
877726107
395956684
395956684
485288787
485288787
877726107
395956684
485288787
485288787
395956684
877726107
395956684
485288787
485...

output:

485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
485288787
...

result:

ok 200000 lines

Test #52:

score: 0
Accepted
time: 27ms
memory: 10956kb

input:

200000
104862700
417554809
417554809
104862700
417554809
417554809
417554809
417554809
104862700
104862700
304144070
304144070
304144070
417554809
417554809
104862700
104862700
417554809
304144070
104862700
104862700
417554809
417554809
104862700
417554809
417554809
104862700
417554809
304144070
104...

output:

104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
104862700
...

result:

ok 200000 lines

Test #53:

score: 0
Accepted
time: 34ms
memory: 10996kb

input:

200000
754561630
416697938
416697938
416697938
754561630
754561630
478132604
478132604
416697938
416697938
478132604
754561630
478132604
754561630
478132604
478132604
478132604
478132604
416697938
754561630
416697938
416697938
754561630
754561630
416697938
478132604
754561630
478132604
416697938
416...

output:

754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
754561630
...

result:

ok 200000 lines

Test #54:

score: 0
Accepted
time: 36ms
memory: 10944kb

input:

200000
292888742
82717528
292888742
890603073
292888742
292888742
82717528
292888742
890603073
890603073
292888742
890603073
82717528
292888742
890603073
82717528
82717528
82717528
82717528
82717528
82717528
82717528
82717528
292888742
82717528
292888742
890603073
82717528
82717528
890603073
2928887...

output:

292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
292888742
...

result:

ok 200000 lines

Test #55:

score: 0
Accepted
time: 55ms
memory: 13892kb

input:

200000
49325932
186703192
873322415
531334889
60364896
788782927
43971944
133980098
361927102
140042537
618176547
26846283
812632624
235061058
483259177
182449350
626786297
65009169
137519850
642748555
666006957
154935450
869074003
392810376
747451348
95422853
902636985
673907685
640487790
443196665...

output:

49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
49325932
493...

result:

ok 200000 lines

Test #56:

score: -40
Memory Limit Exceeded

input:

200000
646618254
713722924
43546573
887759847
12693460
460574880
667190315
368261956
382395349
608639536
867811670
635173789
503500652
924668037
720902268
973471112
110859216
473899212
9329958
935752781
272952497
859262899
92770693
3200179
760028284
777265163
995382226
587227965
186490308
78320046
1...

output:


result: