akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define N 203
#define X 100005
#define MOD 1000000007

int n, x;
int s[N];

ll memo[N][X];
ll dfs(int i, int k) {
  if(memo[i][k] != -1) {
    return memo[i][k];
  }
  ll r = dfs(i+1, k) * i % MOD;
  if(k < s[i]) {
    for(int j = k; j <= x; j += s[i]) {
      r = (r + dfs(i+1, j)) % MOD;
    }
  }
  return memo[i][k] = r;
}

int main() {
  cin >> n >> x;
  rep(i, n) cin >> s[i];
  sort(s, s+n);
  rep(i, n+1) rep(j, x+1) memo[i][j] = ((i == n) ? (j == x) : -1);
  ll ans = 0;
  rep(x, s[0]) {
    ans = (ans + (x*dfs(0, x) % MOD)) % MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 157952
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

void main() {
	int n; long c;
	scanf("%d%ld", &n, &c);
	struct P { long x; int v;}
	P[] p = new P[n];
	foreach (i; 0..n) {
		long x; int v;
		scanf("%ld%d", &x, &v);
		p[i] = P(x,v);
	}
	long ans = 0;
	foreach (_; 0..2) {
		p.sort!("a.x<b.x");
		long[] l = new long[n+1];
		{
			long sum = 0, best = 0;
			foreach (i; 0..n) {
				sum += p[i].v;
				best = max(best, sum-p[i].x);
				l[i+1] = best;
			}
		}
		long[] r = new long[n+1];
		{
			long sum = 0, best = 0;
			foreach_reverse (i; 0..n) {
				sum += p[i].v;
				best = max(best, sum-(c-p[i].x)*2);
				r[i] = best;
			}
		}
		foreach (i; 0..n+1) {
			ans = max(ans, l[i]+r[i]);			
		}
		foreach (i; 0..n) {
			p[i].x = c-p[i].x;
		}
	}
	writeln(ans);
}

Measured memory_bytes: 4220
#include <stdio.h>
long long gcd(long long a,long long b){
  long long r,tmp;
  if(a>b){
    tmp=a;
    a=b;
    b=tmp;
  }
  if(a==0) return b;
  r=b%a;
  while(r!=0){
    b=a;
    a=r;
    r=b%a;
  }
  return a;
}

int main(void){
  long long n,a[100005],min=1000000000008,k[100005];
  k[0]=0;
  scanf("%lld",&n);
  for(int i=0;i<n;i++){
    scanf("%lld",&a[i]);
    k[i+1]=gcd(a[i],k[i]);
  }
  printf("%lld\n",k[n]);


  return 0;
}

Measured memory_bytes: 3288
#include<iostream>

using namespace std;

int main()
{
  int k;
  cin >> k;
  string s;
  cin >> s;
  
  int len = s.length();
  
  if (len > k)
  {
    s = s.substr(0, k) + "...";
  }
    
  cout << s << endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <limits.h>
using namespace std;
typedef long long LL;
const int N=2e5+10;

int n,a[N];
LL dp[N][5];

int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
	}
	memset(dp,-1,sizeof(dp));
	dp[0][0]=0;
	for(int i=0;i<n;i++) {
		for(int j=0;j<5;j++) {
			if(dp[i][j]==-1) continue;
			for(int k=j;k<5;k++) {
				int cost=0;
				if(k==0 || k==4) cost=a[i+1];
				else if((k==1 || k==3) && a[i+1]==0) cost=2;
				else if((k+a[i+1])%2==0) cost=1;
				else cost=0;

				LL x=cost+dp[i][j];
				if(dp[i+1][k]==-1 || x<dp[i+1][k]) dp[i+1][k]=x;
			}
		}
	}
	LL ans=-1;
	for(int i=0;i<5;i++) {
		if(ans==-1 || dp[n][i]<ans) ans=dp[n][i];
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 8832
let dbg = Printf.printf "[debug]%s"

let id = fun x -> x
let tuple2 x y = (x,y)
let succ x = x + 1
let pred x = x - 1

let (++) n m =
  let rec aux i =
    if i = m then [m]
    else i :: aux (i+1) in
  if n > m then [] else aux n

let (++^) n m = n ++ (m-1)

let scanf fmt f = Scanf.sscanf (read_line ()) fmt f

let scanfs n fmt f =
  List.map (fun _ -> scanf fmt f) (0++^n)

let scan_matrix n m e conv =
  let arr = Array.make_matrix n m e in
  Array.iteri (fun i line ->
      let s = Scanf.Scanning.from_string @@ read_line () in
      Array.iteri (fun j _ ->
          arr.(i).(j) <- Scanf.bscanf s " %s" conv;
        ) line) arr; arr

let between n x m = n <= x && x < m

let string_to_list s =
  List.map (String.get s) (0 ++^ String.length s)

let n = scanf "%d" id

let () =
  List.iter
    (fun _ ->
       let a = string_to_list @@ scanf "%s" id in
       let b = string_to_list @@ scanf "%s" id in
       let arr = Array.make_matrix (List.length a) (List.length b) 0 in
       List.iteri (fun i a ->
           List.iteri (fun j b ->
               arr.(i).(j) <-
                 if a = b then
                   1 + if i > 0 && j > 0 then arr.(i-1).(j-1) else 0
                 else
                   max (if i > 0 then arr.(i-1).(j) else 0)
                     (if j > 0 then arr.(i).(j-1) else 0)
             ) b
         ) a;
       Printf.printf "%d\n"
         arr.(pred @@ List.length a).(pred @@ List.length b)
    ) (0 ++^ n)



Measured memory_bytes: 19376
function part1(a,b,c){
   var cnt=0;
   while(true){
      var flag=cnt;
      if(a>=1 && b>=1 && c>=1){a--;b--;c--;cnt++;}
      if(a>=3){a-=3;cnt++;}
      if(b>=3){b-=3;cnt++;}
      if(c>=3){c-=3;cnt++;}
      if(flag==cnt)break;
   }
   return cnt;
}
function part2(a,b,c){
   var cnt=0;
   while(true){
      var flag=cnt;
      if(a>=1 && b>=1 && c>=1){a--;b--;c--;cnt++;}
      if(a>=1 && b>=1 && c>=1){a--;b--;c--;cnt++;}
      if(a>=3){a-=3;cnt++;}
      if(b>=3){b-=3;cnt++;}
      if(c>=3){c-=3;cnt++;}
      if(flag==cnt)break;
   }
   return cnt;
}
function part3(a,b,c){
   var cnt=0;
   while(true){
      var flag=cnt;
      if(a>=3){a-=3;cnt++;}
      if(b>=3){b-=3;cnt++;}
      if(c>=3){c-=3;cnt++;}
      if(a>=1 && b>=1 && c>=1){a--;b--;c--;cnt++;}
      if(flag==cnt)break;
   }
   return cnt;
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var str=arr.shift();
   if(str=="0 0 0 0 0 0")break;
   var ary=str.split(" ").map(Number);
   var a=ary[0]+ary[3];
   var b=ary[1]+ary[4];
   var c=ary[2]+ary[5];
   var cnt=0;
   var A=(a-(a%3))/3;
   var B=(b-(b%3))/3;
   var C=(c-(c%3))/3;
   if(A>=1){A--;a=a%3+3;}
   if(B>=1){B--;b=b%3+3;}
   if(C>=1){C--;c=c%3+3;}
   cnt+=A+B+C;
   cnt+=Math.max(part1(a,b,c),part2(a,b,c),part3(a,b,c));
   console.log(cnt);
}

Measured memory_bytes: 27716
/*

*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/hash_policy.hpp>
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
#define int long long 
#define LL long long 
#define ull long long 
#define rg register 
#define pt(x) printf("%d ", x);
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 22)], *p1 = buf, *p2 = buf;
//char obuf[1<<24], *O = obuf;
//void print(int x) {if(x > 9) print(x / 10); *O++ = x % 10 + '0';}
//#define OS  *O++ = ' ';
using namespace std;
//using namespace __gnu_pbds;
const int MAXN = 1e6 + 10, INF = 1e9 + 10, mod = 1e9 + 7;
const double eps = 1e-9;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
ull N, K;
main() {
	//freopen("a.in", "r", stdin);
	//freopen("c.out", "w", stdout);
	N = read(); K = read();
	ull base = N / K;
	ull ans = base * base * base, ans2 = 0;
	if(K % 2 == 0) {
		base = (N - K / 2) / K + (N >= K / 2);
		ans2 += base * base * base;		
	}
	cout << ans + ans2;
	return 0;
}
/*
50 12
*/

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    ll x = 0;
    cin >> x;
    vector<ll> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    ll ans = 0;
    if (a.at(0) > x) {
        ans += a.at(0) - x;
        a.at(0) = x;
    }
    for (int i=1; i<n; i++) {
        ll buf = a.at(i) + a.at(i-1);
        if (buf > x) {
            ans += buf - x;
            a.at(i) -= buf - x;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
h = list(map(int,input().split()))
mo = 0
for x in h:
  if x == 1:
    mo += 300000
  elif x == 2:
    mo += 200000
  elif x == 3:
    mo += 100000
if h[0] == h[1] == 1:
  mo += 400000
print(mo)

Measured memory_bytes: 3060
import java.util.Scanner;

class Main {
    private static void solve() {
        Scanner scanner = new Scanner(System.in);

        while (true) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();

            if (x == 0 && y == 0) {
                break;
            }
            if (x < y) {
                int temp = x;
                x = y;
                y = temp;
            }
            int step = 0;
            while (y != 0) {
                int temp = y;
                y = x % y;
                x = temp;
                step++;
            }
            System.out.println(String.format("%d %d", x, step));
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 13000
package main

import (
	"fmt"
)

func main() {
	var a int
	var b int
	c := []int{}
	fmt.Scan(&a)
	i := 0
	for i < a {
		fmt.Scan(&b)
		c = append(c, b)
		i++
	}
	i = 0
	count := 0
	for i < (a - 2) {
		if c[i] < c[i+1] {
			if c[i+1] < c[i+2] {
				count++
			}
		}
		if c[i] > c[i+1] {
			if c[i+1] > c[i+2] {
				count++
			}
		}
		i++
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    bool enough = true;
    cin >> n;
    map<ll, int> mp;
    rep (i, n) {
        ll x;
        cin >> x;
        mp[x]++;
    }
    cin >> m;
    rep (i, m) {
        ll x;
        cin >> x;
        mp[x]--;
        if (mp[x] < 0) enough = false;
    }
    if (enough) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}


Measured memory_bytes: 12800
import bisect
def inpl(): return list(map(int,input().split()))

N = int(input())
A = inpl()

cum = A[:]
for i in range(1,N):
    cum[i] += cum[i-1]

mindiff = cum[N-1]
for j in range(2,N-1):
    sum1 = cum[j-1]
    sum2 = cum[N-1]-cum[j-1]
    i = bisect.bisect_left(cum, sum1/2)
    k = bisect.bisect_left(cum, sum1 + sum2/2)
    if i == 0:
        max1 = A[0]
        min1 = cum[j-1]-A[0]
    elif j == 2:
        max1 = A[1]
        min1 = A[0]
    else:
        max1 = min(cum[i],cum[j-1]-cum[i-1])
        min1 = max(cum[i-1],cum[j-1]-cum[i])

    if k == j:
        max2 = A[j]
        min2 = cum[N-1]-cum[j]
    elif j == N-2:
        max2 = A[N-1]
        min2 = A[N-2]
    else:
        max2 = min(cum[k]-cum[j-1],cum[N-1]-cum[k-1])
        min2 = max(cum[k-1]-cum[j-1],cum[N-1]-cum[k])

    max3 = max(max1,max2)
    min3 = min(min1,min2)
    mindiff = min(mindiff, max3-min3)

print(mindiff)

Measured memory_bytes: 25796
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;
template<typename T> void print(T t) {cout << t << endl;}

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>> board(H + 2, vector<char>(W + 2, '.'));
	for (int h = 1; h <= H; h++) {
		string str;
		cin >> str;
		for (int w = 1; w <= W; w++) {
			board[h][w] = str[w - 1];
		}
	}
	
	for (int h = 1; h <= H; h++) {
		for (int w = 1; w <= W; w++) {
			if (board[h][w] == '.') {
				int n = 0;
				for (int i = -1; i <= 1; i++) {
					for (int j = -1; j <= 1; j++) {
						if (board[h + i][w + j] == '#') n++;
					}
				}
				cout << n;
			}
			else cout << '#';
		}
		cout << endl;
	}

}

Measured memory_bytes: 3640
#include<stdio.h>

int main(){
    int x, y, z;
    for (int i = 1; i < 10001; i++){
        scanf("%d%d", &x, &y);
        if (x == 0 && y == 0) {
            break;
        }
        if (x > y) {
            z = x;
            x = y;
            y = z;
        }
        printf("%d %d\n", x, y);
    }
    return 0;
}


Measured memory_bytes: 2048
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>


#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
const ll LINF = 1e18 + 100;
using namespace std;
using Graph = vector<vector<int>>;



int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int D;
ll G;
vector<ll> P, C;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	

	int n;

	cin >> n;
	vector<string> data(n);

	rep(i, 0, n) {
		
		cin >> data[i];

	}
	bool ans = true;

	rep(i, 0, n-1) {
		if (data[i].back() != data[i + 1].front()) {
			ans = false;
		}

	}
	sort(data.begin(), data.end());

	rep(i, 0, n-1) {
		if (data[i] == data[i + 1]) {
			ans = false;
		}

	}

	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;



	
	
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#define ll long long

const int mxN=1e5;
int n, l[mxN+1], r[mxN+1];
ll yi, ls, rs;
priority_queue<ll> lq;
priority_queue<ll, vector<ll>, greater<ll>> rq;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n;
	for(int i=1; i<=n; ++i)
		cin >> l[i] >> r[i];
	for(int i=1; i<=n; ++i) {
		ls+=r[i]-l[i];
		rs+=r[i-1]-l[i-1];
		ll lm=lq.size()?lq.top()-ls:LLONG_MIN, rm=rq.size()?rq.top()+rs:LLONG_MAX;
		if(lm<=l[i]&&l[i]<=rm) {
			lq.push(l[i]+ls);
			rq.push(l[i]-rs);
		} else if(lm>l[i]) {
			lq.pop();
			rq.push(lm-rs);
			lq.push(l[i]+ls);
			lq.push(l[i]+ls);
		} else {
			rq.pop();
			lq.push(rm+ls);
			rq.push(l[i]-rs);
			rq.push(l[i]-rs);
		}
		yi+=l[i]+ls;
	}
	lq.push(0);
	ll i=1, l=lq.top();
	while(lq.size()>1) {
		lq.pop();
		yi-=(l-lq.top())*i++;
		l=lq.top();
	}
	cout << yi;
}

Measured memory_bytes: 2804
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a1: i32 = read();
    let a2: i32 = read();
    let a3: i32 = read();
    if a1 + a2 + a3 >= 22 {
        println!("bust");
    } else {
        println!("win");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <list>
#include <algorithm>
using namespace std;

int using_stl()
{
	int n;
	list<int> L;
	cin >> n;
	char cmd[16];
	int m = n;
	while(m--)
	{ 
		cin >> cmd;
		char c6 = cmd[6];
		int num;
		if (cmd[0]=='i') 
		{
			cin >> num;
			L.push_front(num);
		}
		else if (c6 == 'F')
		{
			L.erase(L.begin());
		}
		else if (c6 == 'L')
		{
			L.erase(--L.end());
		}
		else 
		{
			cin >> num;
			L.erase(find(L.begin(), L.end(), num));
		}
	}
	
	bool first = true;
	for (auto num : L)
	{
		if (first) 
		{
			first = false;
		}
		else
		{
			cout << ' ';
		}
		
		cout << num;
		
	}
	cout << endl;
	
	return 0;
}

int opt()
{
	int n;
	cin >> n;
	int * L = new int[n];
	int nl = 0;
	int bl = 0;
	char cmd[16];
	int m = n;
	while(m--)
	{ 
		cin >> cmd;
		
		if (cmd[0]=='i') 
		{
			cin >> L[nl++];
			continue;
		}
		
		char c6 = cmd[6];
		if (c6 == 'F')
		{
			for (int i=nl-1; i >= 0; i--)
			{
				if (L[i])
				{
					L[i] = 0;
					nl = i;
					break;
				}
			}
		}
		else if (c6 == 'L')
		{
			for (int i=bl; i <n; i++)
			{
				if (L[i])
				{
					L[i] = 0;
					bl = i+1;
					break;
				}
			}
		}
		else 
		{
			int num;
			cin >> num;
			for (int i=nl-1; i >= 0; i--)
			{
				if (L[i] == num)
				{
					L[i] = 0;
					break;
				}
			}
		}
	}
	
	bool first = true;
	
	for (int i=nl-1;i>=bl;i--)
	{
		if (L[i])
		{
			if (first)
			{
				first = false;
			}
			else 
			{
				cout << ' ';
			}
			cout << L[i];
		}
	} 
	
	cout << endl;
	
   return 0;
}


int main()
{
	return opt();
}

Measured memory_bytes: 7028
/*Author: Tom Riddle*/


#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define MODULO 1000000007
#define ull unsigned long long int
#define newline cout<<endl


/* TYPE DEFINITIONS */
typedef		long long		i64;
typedef		vector<int>		vi;
typedef		pair<int,int>	pi;



/* ALGEBRA */
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 

int f;
/* MACROS */

#define  all(A)			(A).begin() , (A).end()
#define  rall(A)		(A).rbegin() , (A).rend()
#define  sz(A)			(int)(A).size()
#define  pb				push_back
#define  ppb			pop_back
#define  mp				make_pair
#define  ln(X)			(int)(X).length()
#define  square(X)		((X)*(X))
#define  cube(X)		((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)	for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 


void solve(){
    string s;
    cin>>s;
    for(int i=0;i<3;i++)
    {
        if(s[i]==s[i+1])
        {
            cout<<"Bad"<<endl;
            return;
        }
    }
    cout<<"Good"<<endl;
    
}
int main()
{
	FastIO;
	i64 t=1;
	while(t--)solve();
}

Measured memory_bytes: 256
#line 2 "/Users/kaage/Desktop/ProgrammingWorkspace/library/other/template.hpp"
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx2")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define all(V) V.begin(),V.end()
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
typedef std::pair<lint, lint> LP;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, lint b) {
	T res(1);
	while(b){
		if(b&1)res*=a;
		a*=a;
		b>>=1;
	}
	return res;
}
lint modpow(lint a, lint b, lint m) {
	lint res(1);
	while(b){
		if(b&1){
			res*=a;res%=m;
		}
		a*=a;a%=m;
		b>>=1;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size()){
		std::cout << vec[i];
		std::cout<<(i==(int)vec.size()-1?"\n":" ");
	}
}
template<typename T>
void printArray(T l, T r) {
	T rprev = std::prev(r);
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
LP extGcd(lint a,lint b) {
	if(b==0)return {1,0};
	LP s=extGcd(b,a%b);
	std::swap(s.first,s.second);
	s.second-=a/b*s.first;
	return s;
}
LP ChineseRem(const lint& b1,const lint& m1,const lint& b2,const lint& m2) {
	lint p=extGcd(m1,m2).first;
	lint tmp=(b2-b1)*p%m2;
	lint r=(b1+m1*tmp+m1*m2)%(m1*m2);
	return std::make_pair(r,m1*m2);
}
template<typename F>
inline constexpr decltype(auto) lambda_fix(F&& f){
	return [f=std::forward<F>(f)](auto&&... args){
		return f(f,std::forward<decltype(args)>(args)...);
	};
}
#line 2 "main.cpp"
int main(){
	std::string S,T;
	std::cin>>S>>T;
	int ans=INF;
	rep(i,S.size()-T.size()+1){
		int cnt=0;
		rep(j,T.size()){
			if(S[i+j]!=T[j])cnt++;
		}
		chmin(ans,cnt);
	}
	std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using i64 = int64_t;
const int INF = 1e9;
const int MOD = INF+7;
const i64 LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)
#define int int64_t 

signed main(){
    const long double rate = 380000.0;
    int N;
    cin >> N;
    long double ans = 0;
    rep(i,N){
        long double x;
        string u;
        cin >> x >> u;
        if(u == "JPY") ans += x;
        else ans += x*rate;
    }

    cout << setprecision(14) << ans << endl;
}


Measured memory_bytes: 256
fun main(args : Array<String>) {
    var s = readLine()!!.toLong()
    val nums = mutableSetOf<Long>(s)
    for (n in 2..1000000) {
        s = when(s % 2) {
            0L -> s / 2
            else -> s * 3 + 1
        }
        if (nums.contains(s)){
            println(n)
            break
        } else {
            nums.add(s)
        }
    }
}


Measured memory_bytes: 34160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
ll N;
vector<int> B;
const ll INF = 1e12;

int main()
{
    cin >> N;
    B.resize(N - 1);
    for (int i = 0; i < N - 1; ++i)
    {
        cin >> B[i];
    }
    vector<int> A(N);
    A[0] = B[0];
    A[N - 1] = B[N - 2];
    for (int i = 1; i < N - 1; ++i)
    {
        A[i] = min(B[i - 1], B[i]);
    }

    ll result = 0;
    for (int i = 0; i < N; ++i)
    {
        result += A[i];
    }

    cout << result << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    H, W, K = map(int, input().split())
    grid = [[_ for _ in input()] for _ in range(H)]

    ans = [[0] * W for _ in range(H)]
    cnt = 0
    for h in range(H):
        for w in range(W):
            if grid[h][w] == '#':
                cnt += 1
                ans[h][w] = cnt

    now = -1
    for h in range(H):
        for w in range(W):
            if ans[h][w] != 0:
                now = ans[h][w]
            if ans[h][w] == 0:
                if now != -1:
                    ans[h][w] = now
        now = -1

    now = -1
    for h in range(H):
        for w in reversed(range(W)):
            if ans[h][w] != 0:
                now = ans[h][w]
            if ans[h][w] == 0:
                if now != -1:
                    ans[h][w] = now
        now = -1

    for h in range(1,H):
        if ans[h][0] == 0:
            for w in range(W):
                ans[h][w] = ans[h - 1][w]

    for h in reversed(range(H-1)):
        if ans[h][0] == 0:
            for w in range(W):
                ans[h][w] = ans[h + 1][w]

    for a in ans:
        print(*a)


resolve()

Measured memory_bytes: 51420
#include <bits/stdc++.h>
#define inf 2e9
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
using namespace std;

int main() {
    unsigned long long a,b;
    cin>>a>>b;
    if (a==0 && b==100)
        cout<<101<<"\n";
    else if (a==1 && b==100)
        cout<<"10100\n";
    else if (a==2 && b==100)
        cout<<"1010000\n";
    else cout<<(unsigned long long)pow(100,a)*b<<"\n";
    return 0;
}


Measured memory_bytes: 512
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

lo n,m,b,a[li],k,flag,x,y;
double cev;
string s;
vector<lo> v;

int main(void){
	scanf("%lld %lld %lld %lld",&n,&m,&x,&y);
	cev=((double)(n*m))/2;
	if(m/2==y && n/2==x && m%2==0 && n%2==0)flag=1;
	printf("%lf %lld\n",cev,flag);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 2000009
#define ll long long
#define ld long double
#define ff first
#define ss second
#define inf 1000000005
#define mod 1000000007
using namespace std;
ll t[1000001];
/*void build(int v, int tl, int tr) {
    if(tl == tr) {
        t[v] = a[tl];
    }
    else {
        int tm = (tl + tr) / 2;
        build(v * 2, tl, tm);
        build(v * 2 + 1, tm + 1, tr);
        t[v] = max(t[v * 2], t[v * 2 + 1]);
    }
}*/
int n, h[200009], b[200009];
void update(int v, int tl, int tr, int pos, ll new_val) {
    if(tl == tr)
        t[v] = new_val;
    else {
        int tm = (tl + tr) / 2;
        if(pos <= tm)
            update(v * 2, tl, tm, pos, new_val);
        else
            update(v * 2 + 1, tm + 1, tr, pos, new_val);
        t[v] = max(t[v * 2], t[v * 2 + 1]);
    }
}

ll get(int v, int tl, int tr, int l, int r) {
    if(l > r)
        return 0;
    if(l == tl && r == tr)
        return t[v];
    int tm = (tl + tr) / 2;
    return max(get(v * 2, tl, tm, l, min(r, tm)),
               get(v * 2 + 1, tm + 1, tr, max(tm + 1, l), r));
}
set<pair<int, int> > s;
ll ans;
int main() {
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>h[i];
        s.insert({h[i], i});
    }
    for(int i=1;i<=n;i++)
        cin>>b[i];
    for(set<pair<int, int> >:: iterator it = s.begin(); it != s.end();it++) {
        int ind = it->second;
        ll prevma = get(1, 1, n, 1, ind - 1);
        ll cur = prevma + b[ind];
        ans = max(ans, cur);
        update(1, 1, n, ind, cur);
    }
    cout<<ans;
}


Measured memory_bytes: 18632
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    while(n--){
        int pp,bp,pc,bc,mini,mi;
        cin >> bp >> pp >> bc >> pc;
        mini = bp * bc + pp * pc;
        mi = (bp * max(bc,5) + pp * max(pc,2)) * .8;
        cout << min(mini,mi) << endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a+b+c-max({a,b,c})<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define N -1

typedef struct{
    int id;
    int p;
    int l;
    int r;
}Tree;
 
Tree T[25];
 
void pre(int i){
    printf(" %d",i);
    if(T[i].l != N){
        pre(T[i].l);
    }
    if(T[i].r != N){
        pre(T[i].r);
    }
}
 
void in(int i){
    if(T[i].l != N){
        in(T[i].l);
    }
    printf(" %d",i);

    if(T[i].r != N){
        in(T[i].r);
    }
}
 
void post(int i){
    if(T[i].l != N){
        post(T[i].l);
    }

    if(T[i].r != N){
        post(T[i].r);
    }
    printf(" %d",i);
     
}
int main(){
    int i,j,n;
    int id;
    int data;
    scanf("%d",&n);

    for(i=0; i < n; i++){
        T[i].p = N;
    }
     
    for(i=0;i<n;i++){
        scanf("%d",&id);
        T[id].id = id;

        scanf("%d",&data);
        T[id].l = data;
        if(data != N){
            T[data].p = id;
        } 
        scanf("%d",&data);
        T[id].r = data;
        if(data != N){
            T[data].p=id;
        }
    }
    
    i=0;
    while(T[i].p != N){
        i++;
    }
    id=i;
     
    printf("Preorder\n");
    pre(id);
     
    printf("\nInorder\n");
    in(id);
     
    printf("\nPostorder\n");
    post(id);

    printf("\n");
     
    return 0;
     
}
 

Measured memory_bytes: 616
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int a;
	cin>>a;
	rep(i,a)
	{
		int n;
		cin>>n;
		if (n%2==0)
		{
			if (n%3!=0&&n%5!=0) 
			{
				cout<<"DENIED";
			    return 0;
			}
		}
	}
	cout<<"APPROVED";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;

int main() {
    int n;
    ll d;
    cin >> n >> d;
    int answer = 0;
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        if(x*x + y*y <= d * d) answer++;
    }
    cout << answer << endl;
}


Measured memory_bytes: 3600
/*
   Created by Rahul Goel.
*/
/*******************************************************************************/
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
/*******************************************************************************/
using namespace std;
using ll = long long;
using ld = long double;
ll mod = 1000000007;
const int INF = 1e9;
const ll LINF = 1e18;
/*******************************************************************************/
/*
.-.. . -. -.- .- / .. ... / .-.. --- ...- . -.-.--
 */
/* For PBDS */
/*Two new methods X.order_of_key() and X.find_by_order()*/
/*
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*******************************************************************************/
ll mod_sum() { return 0LL; }
template<typename T, typename... Args>
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%mod + mod)%mod; }

ll mod_prod() { return 1LL; }
template<typename T, typename... Args>
T mod_prod(T a, Args... args) { return (a*mod_prod(args...))%mod; }
/*******************************************************************************/
using pii = pair < ll, ll >;
using vi = vector < ll >;
using vb = vector < bool >;
using vvi = vector < vector < ll > >;
using vvb = vector < vector < bool > >;
using vpii = vector < pii >;
using vvpii = vector < vector < pii > >;
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
#define fastio          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c)          (c).begin(), (c).end()
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(all(c),x) != (c).end())
#define uniq(c)         (c).resize(distance((c).begin(), unique(all(c))))
#define min_pq(t)       priority_queue < t, vector < t >, greater < t > >
#define max_pq(t)       priority_queue < t >
#define pb              push_back
#define ff              first
#define ss              second
/*******************************************************************************/

/*
    Code begins after this.
*/


ll solve(){
    ll a, b;
    cin >> a >> b;
    cout << a*b << endl;
    return 0;
}


signed main(){
    fastio;

    ll t = 1;
    while(t--)
        solve();

    return 0;
}

/*******************************************************************************/
// Remeber - In a custom comparator cmp(a, b) a==b must always return to false.


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>    //pow(x,y)=x^y 99999とかの場合+1するif文
#include <algorithm> //sort(a.begin(), a.end());reverse(a.begin(), a.end());
#include <ctime>     //実行時間を測る
#define ll long long
#define vecvec(h, w, name) vector<vector<ll>> name(h, vector<ll>(w));
#define rep(init, i, n) for (ll i = init; i < (n); i++)
#define rev(s) reverse(s.begin(), s.end())
#define sor(v) sort(v.begin(), v.end()) //昇順
#define PI 3.14159265358979323846264338327950L
//コード自動整形 Shift + Option + F @vscode
//変数名一括置換　command+fn+f2 @vscode
using namespace std;
using vec = vector<ll>;
//function
ll facctorialMethod(ll k);     //階乗を出力する
ll modpow(ll a, ll n, ll mod); // a^n mod を計算する
ll gcd(ll a, ll b);            //最大公約数
ll lcm(ll a, ll b);            //最小公倍数
ll vecmax(vector<ll> v);       //１次元配列の最大値を返すO(NlogN)
ll vecmin(vector<ll> v);       //１次元配列の最小値を返すO(NlogN)
//

//struct
// UnionFind
// coding: https://youtu.be/TdR816rqc3s?t=726
// comment: https://youtu.be/TdR816rqc3s?t=6822
struct UnionFind
{
  vector<ll> d;
  UnionFind(ll n = 0) : d(n, -1) {}
  ll find(ll x)
  { //根っこを返す
    if (d[x] < 0)
      return x;
    return d[x] = find(d[x]); //根っこの場所を貼り付ける
  }
  bool unite(ll x, ll y)
  { //くっつける操作、連結成分の情報整理 ABC177,157D参照
    x = find(x);
    y = find(y);
    if (x == y)
      return false;
    if (d[x] > d[y])
      swap(x, y); //dはマイナスをかけたサイズだからxの方がサイズ小さいようにする
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  //find(i)でi番目の属しているグループ番号を出力
  bool same(ll x, ll y) { return find(x) == find(y); } //同じ集合に属しているかを判定
  ll size(ll x) { return -d[find(x)]; }                //あるID、xが所属するグループに所属するIDの数を得る ABC177,157D参照
};
//

/////main/////
int main()
{
  int clock_on = 0; //提出時は0!!!!!!!!!!!!!!!!!
  int time_clock = clock();
  //
  string S;
  cin>>S;
  if(S=="ABC"){cout<<"ARC"<<endl;return 0;}
cout<<"ABC"<<endl;return 0;

  //
  if (clock_on == 1)
    printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - time_clock) / CLOCKS_PER_SEC);
  return 0;
}
/////main/////

/////function/////
//階乗を出力する
ll facctorialMethod(ll k)
{
  ll sum = 1;
  for (ll i = 1; i <= k; ++i)
  {
    sum *= i;
  }
  return sum;
}

// a^n mod を計算する
ll modpow(ll a, ll n, ll mod)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

//最大公約数
ll gcd(ll a, ll b)
{
  if (a % b == 0)
  {
    return b;
  }
  else
  {
    return gcd(b, a % b);
  }
}

//最小公倍数
ll lcm(ll a, ll b)
{
  return a * b / gcd(a, b);
}

//１次元配列の最大値を返すO(NlogN)
ll vecmax(vector<ll> v)
{
  sor(v);
  return v.at(v.size() - 1);
}

//１次元配列の最小値を返すO(NlogN)
ll vecmin(vector<ll> v)
{
  sor(v);
  return v.at(0);
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include <ext/numeric>
#define     __        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define     pi        acos(-1)
#define     ll        long long int
#define     mem(a)    memset(a,0,sizeof(a))
#define     mems(a)   memset(a,-1,sizeof(a))
#define     pii       pair<int,int>
#define     N         200005
using namespace std;


int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    string s;

    cin >> s;

    for(int i=0;i<s.size()-1;i++)
    {
        if(s[i]==s[i+1]){
            cout << "Bad";
            exit(0);
        }
    }

    cout << "Good";

    return 0;
}




Measured memory_bytes: 256
package main

import "fmt"
import "sort"
import "os"

func main() {
    var n, max, v int
    var list []int

    fmt.Scanf("%d", &n)
    for i := 0; i < n; i++ {
        fmt.Scanf("%d", &v)
        list = append(list, v)
        max += v
    }
    sort.Sort(sort.IntSlice(list))
    for i := 0; i < n; i++ {
        if max%10 != 0 {
            fmt.Printf("%d\n", max)
            os.Exit(0)
        }
        max -= list[i]
        if i > 0 {
            max += list[i-1]
        }
    }
    fmt.Printf("0\n")
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using VI = vector<int>;
using VB = vector<bool>;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n ) cin >> a[i];

  vector<int> b = a;
  sort(all(a), greater<int>());

  rep(i, n){
    int ans = b[i];
    if (ans == a[0]) cout << a[1] << endl;
    else cout << a[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<P> p(4);

int main() {
    rep(i, 2) cin >> p.at(i).first >> p.at(i).second;

    P d = make_pair(p.at(1).first - p.at(0).first, p.at(1).second - p.at(0).second);
    
    for(int i = 2; i < 4; i++) {
        p.at(i).first = p.at(i-1).first - d.second;
        p.at(i).second = p.at(i-1).second + d.first;
        d.first = p.at(i).first - p.at(i-1).first;
        d.second = p.at(i).second - p.at(i-1).second;
    }

    printf("%d %d %d %d\n", p.at(2).first, p.at(2).second, p.at(3).first, p.at(3).second);

    return 0;
}

Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){ 
    ll N;
    cin >> N;
    ll A[200010];
    rep(i,0,N) cin >> A[i];
    ll ans = 0;
    rep(i,1,N){
        if(A[i-1] > A[i]){
            ans += A[i-1] - A[i];
            A[i] = A[i-1];
        }
    }
    print(ans);
    

}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}

Measured memory_bytes: 5216
n = int(input())
l_s = []; l_h = []; l_c = []; l_d = []
for i in range(1,n+1):
    l_card = input().split()
    xTyp = l_card[0]
    xNum = int(l_card[1])
    if xTyp == "S": l_s.append(xNum);
    elif xTyp == "H": l_h.append(xNum);   
    elif xTyp == "C": l_c.append(xNum); 
    else: l_d.append(xNum);  

for i in range(1,4+1):
    if i==1: l_lp=l_s;xTyp="S"
    elif i==2: l_lp=l_h;xTyp="H"
    elif i==3: l_lp=l_c;xTyp="C"
    else: l_lp=l_d;xTyp="D"
    if not l_lp == False:
        for k in range(1,13+1):
            if l_lp.count(k)==0:
                print(xTyp,k)


Measured memory_bytes: 5608
#include<stdio.h>
#define MAX 500001
#define NIL -1
typedef struct node{
  int left;
  int right;
  int key;
  int p;
  int leftid;
  int rightid;

}Node;
Node node[MAX];
int root=NIL;
void inorder(int);
void preorder(int);
void addTree(int n,int num){
  int tmp;
  //rootが空の場合
  if(node[n].key==root){
    root=n;
    node[root].key=num;
    
  }
  else{
  tmp=root;

  while(1){
    if(node[tmp].key>num){
      if(node[tmp].left!=NIL){
	tmp=node[tmp].leftid;
      }
      else{
	node[tmp].left=num;
	node[tmp].leftid=n+1;
	node[n+1].key=num;
	
	break;
      }
    }
    else{
      if(node[tmp].right!=NIL){
	tmp=node[tmp].rightid;
	
      }
      else{
	node[tmp].right=num;
	node[n+1].key=num;
	node[tmp].rightid=n+1;
	break;
      }
    }
  }
  
  node[n].p=tmp;
  
  }
}
int main(){
  int num,i,n,l=0,tmp;
  char name[100];
  scanf("%d",&n);
 for(i=0;i<MAX;i++){//初期化
    node[i].p=NIL;
    node[i].left=NIL;
    node[i].right=NIL;
    node[i].key=NIL;
    
  }


 for(i=0;i<n;i++){
    scanf("%s",name);
    if(name[0]=='i'){
      scanf("%d",&num);
      addTree(l,num);
      l++;
      }
      
   else if(name[0]=='p'){
    inorder(root);
   printf("\n");
   preorder(root);
   printf("\n");
      
    }
  }
 
 
 
  return 0;
}
void inorder(int t){
  if(node[t].left!=NIL){
    inorder(node[t].leftid);
  }
    printf(" %d",node[t].key);
  if(node[t].right!=NIL){
    inorder(node[t].rightid);
  }
}
void preorder(int t){
 
      printf(" %d",node[t].key);
  if(node[t].left!=NIL){
    preorder(node[t].leftid);
  }
  if(node[t].right!=NIL){
    preorder(node[t].rightid);
  }
}




Measured memory_bytes: 13572
using System;
using System.Linq;
public class Hello{
    static double F(string x,string u){
        if(u == "JPY"){
            return double.Parse(x);
        }else{
            return double.Parse(x) * 380000;
        }
    }
    public static void Main(){
        var n = long.Parse(Console.ReadLine());
        double ans = 0;
        for(var i = 0;i < n;i++){
            var s = Console.ReadLine().Split(' ');
            ans += F(s[0],s[1]);
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    ll p =  K%2==0 ? 1 : -1;
    cout << (A-B)*p << endl;

    return 0;
}


Measured memory_bytes: 256
#include <atcoder/segtree>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll f_max(ll a, ll b) {
    return max(a,b);
}
ll f_e() {
    return -(1LL<<60);
}

ll solve() {
    ll N, Q, t, x, v, l, r, a;
    cin >> N >> Q;
    atcoder::segtree<ll,f_max,f_e> sg(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        sg.set(i, a);
    }
    auto f_v = [&](ll ma) {return v>ma;};
    vector<ll> ans;
    for ( int q = 0; q < Q; q++ ) {
        cin >> t;
        switch ( t ) {
            case 1:
                cin >> x >> v;
                x--;
                sg.set(x,v);
                break;
            case 2:
                cin >> l >> r;
                l--, r--;
                ans.push_back(sg.prod(l, r+1));
                break;
            case 3:
                cin >> x >> v;
                x--;
                int j = sg.max_right(x, f_v) + 1;
                ans.push_back(j);
                break;
        }
    }

    for ( ll an : ans ) {
        cout << an << "\n";
    }
    return 0;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 10384
#include<iostream>

using namespace std;

int main(){

	int H, W;

	while(1){

		cin >> H >> W;

		if( H == 0 && W == 0)break;

		for( int i = 0; i < H; i++){

			for( int j = 0; j < W; j++){

				if( ( i + j ) % 2 == 0 ){

					cout << "#";

				}else{

					cout << ".";

				}

			}

			cout << "\n";

		}

		cout << endl;

	}

	return 0;

}

Measured memory_bytes: 1152
N, M, C = map(int, input().split())
B = [int(x) for x in input().split()]
ans = 0
for i in range(N):
    A = [int(x) for x in input().split()]
    c = sum([x*y for x, y in zip(A, B)]) + C
    if c > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int group(int n) {
  if (n == 2) {
    return 0;
  } else if (n == 4 || n == 6 || n == 9 || n == 11) {
    return 1;
  } else {
    return 2;
  }
}

int main() {
  int x, y;
  get(x, y);
  print((group(x) == group(y)) ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256