akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); i++)

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, 0, n) cin >> a[i];

  auto check = [&](int x) {
    int ret = 0;
    rep(i, 0, n)
    {
      int t = (a[i] + x - 1) / x - 1;
      ret += t;
    }
    return ret <= k;
  };

  int l = 0, r = 1e9 + 1;
  while (r - l > 1)
  {
    int m = (l + r) / 2;
    if (check(m))
      r = m;
    else
      l = m;
  }

  cout << r << endl;

  return 0;
}

Measured memory_bytes: 4044
// AOJ 2292 Common Palindromes
// 2019.8.16 bal4u

#include <stdio.h>
#include <string.h>

typedef long long ll;

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int ins(char *s)  // 文字列の入力　スペース以下の文字で入力終了
{
	char *p = s;
	do *s = gc();
	while (*s++ > ' ');
	*--s = 0;
	return s - p;
}

#define MAX 100010
//// 回文木の構築
typedef struct { int par, son[30], suffix_link, len, cnt; } NODE;
NODE node[MAX]; int sz = 2;
int last;
char S[MAX]; int W;  // 文字列

void init_palindromic_tree() { // 回文木の初期化
	int i;
	
	for (i = 0; i < MAX; i++) {
		node[i].par = -1;
		memset(node[i].son, -1, sizeof(node[i].son));
	}
	node[0].suffix_link = -1, node[0].len = -1;
	node[1].par = 0;
}

void add_palindromic_tree(int idx) { // 文字を回文木に追加。文字位置 S[idx]
	char c = S[idx]; int a = S[idx] - '>';
	int t = last;

	while (1) {
		if (idx-1-node[t].len >= 0 && S[idx-1-node[t].len] == c) break;
		t = node[t].suffix_link;
	}

	if (node[t].son[a] > 0) {
		last = node[t].son[a], node[last].cnt++;
		return;
	}

	last = sz++;
	node[t].son[a] = last;

	node[last].len = node[t].len + 2, node[last].par = t, node[last].cnt = 1;

	if (node[last].len == 1) node[last].suffix_link = 1;
	else while (1) {
		t = node[t].suffix_link;
		if (idx-1-node[t].len >= 0 && S[idx-1-node[t].len] == c) {
			node[last].suffix_link = node[t].son[a];
			break;
		}
	}
}

char *ss; int ws;
char *tt; int wt; 
int f[2][MAX];

int main()
{
	int i, t; ll ans;
	
	ws = ins(ss = S);
	S[ws] = '>', S[ws+1] = '@';
	wt = ins(tt = ss + ws + 2);
	W = ws + wt + 2;
	
	init_palindromic_tree();
	for (i = 0; i < ws; i++) {
		add_palindromic_tree(i);
		f[0][last]++;
	}
	add_palindromic_tree(i++), add_palindromic_tree(i++);
	for ( ; i < W; i++) {
		add_palindromic_tree(i);
		f[1][last]++;
	}

	ans = 0;
	for (i = sz-1; i > 1; i--) {
		ans += (ll)f[0][i] * f[1][i];
		f[0][node[i].suffix_link] += f[0][i];
		f[1][node[i].suffix_link] += f[1][i];
	}
	printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 15860
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n-1)]

z=[[] for _ in range(n)]
for a,b in ab:
    z[a-1].append(b-1)
    z[b-1].append(a-1)
dis1=[0 for _ in range(n)]
dis2=[0 for _ in range(n)]

from collections import deque
que=deque([])
que.append((0,-1,0))
while que:
    v,p,d=que.pop()
    dis1[v]=d
    for t in z[v]:
        if t==p:
            continue
        que.append((t,v,d+1))
que.append((n-1,-1,0))
while que:
    v,p,d=que.pop()
    dis2[v]=d
    for t in z[v]:
        if t==p:
            continue
        que.append((t,v,d+1))
#print(dis1,dis2)
x,y=0,0
for i in range(n):
    if dis1[i]<=dis2[i]:
        x+=1
    else:
        y+=1
#print(x,y)
if x>y:
    print("Fennec")
else:
    print("Snuke")

Measured memory_bytes: 79064
// https://atcoder.jp/contests/arc083/tasks/arc083_b

package main

import "fmt"
import "bufio"
import "os"
import "strconv"

func main() {
	var N int
	fmt.Scan(&N)

	var A = make([][]int, N)

	sum := 0
	for i := 0; i < N; i++ {
		A[i] = make([]int, N)

		for j := 0; j < N; j++ {
			var a int
			fmt.Scan(&a)
			A[i][j] = a
			sum += a
		}
	}

	dupes := 0
	for k := 0; k < N; k++ {
		for i := 0; i < N; i++ {
			if i == k || A[i][k] == 0 {
				continue
			}
			for j := i + 1; j < N; j++ {
				if k == j || A[k][j] == 0 {
					continue
				}
				if A[i][j] > A[i][k]+A[k][j] {
					fmt.Println(-1)
					return
				} else if A[i][j] == A[i][k]+A[k][j] {
					dupes += A[i][j]
					A[i][j] = 0
					A[j][i] = 0
				}
			}
		}
	}

	fmt.Println((sum/2 - dupes))
}

var _sw = bufio.NewScanner(os.Stdin)

func init() {
	_sw.Split(bufio.ScanWords)
}

func nextInt() int {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	i, e := strconv.Atoi(_sw.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 4736
A=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N=int(input())
print(A[N-1])

Measured memory_bytes: 3316
n, m, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = Array.new(n + 1, 0)
n.times do |i|
  c[i + 1] = c[i] + a[i]
end
d = Array.new(m + 1, 0)
m.times do |i|
  d[i + 1] = d[i] + b[i]
end
cnt = 0
0.upto(n) do |i|
  break if c[i] > k
  e = d.bsearch_index{ |dd| dd > k - c[i]}
  if e.nil?
    cnt = i + m if cnt < i + m
  else
    cnt = i + e - 1 if cnt < i + e - 1
  end
end
puts cnt

Measured memory_bytes: 44844
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
double PI = 3.1415926535897932;
lint MOD;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

void dfs1(int cur, int par, vector<vector<int>> &g, vector<lint> &dp) {
  lint ret = 1;
  for (auto nxt : g[cur]) {
    if (nxt == par) continue;
    dfs1(nxt, cur, g, dp);
    ret *= (dp[nxt] + 1);
    ret %= MOD;
  }
  dp[cur] = ret;
}

void dfs2(int cur, int par, vector<vector<int>> &g, vector<lint> &dp, vector<lint> &ans, lint Dpar) {
  lint ret = Dpar + 1;
  if (Dpar == -1) ret = 1;
  ret %= MOD;
  vector<int> chs;
  for (auto nxt : g[cur]) {
    if (nxt == par) continue;
    ret *= (dp[nxt] + 1);
    ret %= MOD;
    chs.push_back(nxt);
  }
  ans[cur] = ret;

  // 左右から累積
  size_t sz = chs.size();
  vector<lint> accLeft(sz + 2, 1);
  vector<lint> accRight(sz + 2, 1);
  for (int i = 1; i <= sz; i++) {
    accLeft[i] = (dp[chs[i - 1]] + 1);
    accRight[i] = (dp[chs[i - 1]] + 1);
  }

  for (int i = 1; i <= sz; i++) {
    accLeft[i] *= accLeft[i - 1];
    accLeft[i] %= MOD;
  }

  for (int i = sz; i >= 1; i--) {
    accRight[i] *= accRight[i + 1];
    accRight[i] %= MOD;
  }

  for (int i = 1; i <= sz; i++) {
    lint nxtDpar = accLeft[i - 1] % MOD * accRight[i + 1] % MOD;
    int nxt = chs[i - 1];
    if (Dpar != -1) {
      nxtDpar *= (Dpar + 1);
      nxtDpar %= MOD;
    }
    dfs2(nxt, cur, g, dp, ans, nxtDpar);
  }
}

int main() {
  
  int n; cin >> n;
  cin >> MOD;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b; cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<lint> dp(n);
  vector<lint> ans(n);
  dfs1(0, -1, g, dp);
  dfs2(0, -1, g, dp, ans, -1);
  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


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

using namespace std;

#ifdef NeverBeRed
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef TurnRed
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;
	int c = 0;
	for (int i = 1; i <= n; ++i)
		c += i & 1;
	cout << (double) c / n << "\n";

	return 0;
}


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

int allsum(int X){
    int count = 0;
    string str = to_string(X);
    for(int i=0;i<str.length();i++){
        count += str[i] - '0';
    }
    return count;
}

int main() {
    int N;
    cin >> N;
    int min = N;
    for(int i=1;i<=N/2;i++){
        int A = allsum(i);
        int B = allsum(N-i);
        if(min > A+B) min = A+B;
    }
    cout << min << endl;
}

Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	std::string S;
	std::cin >> S;
	std::cout << S.substr(0, S.size() - 8) << "\n";
}


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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

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

void solve()
{
    string s, t, u;
    in2(s, t);
    int a, b;
    in2(a, b);
    in(u);
    if (s == u)
    {
        a--;
    }
    if (t == u)
    {
        b--;
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 333
	#define mod 998244353ll
	typedef long long ll;
	typedef double db;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
	void file()
	{
		#ifdef NTFOrz
		freopen("a.in","r",stdin);
		#endif
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		cout<<(clock()-t)/1000.0<<'\n';
		#endif
	}
	#ifdef mod
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

ll C[sz<<1][sz<<1];

int n;
char s[sz];
bool dp[sz][sz][sz];
int suf[sz];

int main()
{
	file();
	rep(i,0,sz*2-1) C[i][0]=1;
	rep(i,1,sz*2-1) rep(j,1,i) (C[i][j]=C[i-1][j]+C[i-1][j-1])%=mod;
	cin>>(s+1); n=strlen(s+1);
	drep(i,n,1) suf[i]=suf[i+1]+(s[i]=='1');
	dp[0][0][0]=1;
	rep(i,0,n-1) rep(x,0,i) rep(y,0,i-x) if (dp[i][x][y])
	{
		if (x) dp[i+1][x-1+(s[i+1]=='0')][y+(s[i+1]=='1')]=1;
		if (y) dp[i+1][x+(s[i+1]=='0')][y-1+(s[i+1]=='1')]=1;
		dp[i+1][x][y]=1;
		if (i==n-1) continue;
		dp[i+2][x+(s[i+1]=='0')][y+(s[i+1]=='1')]=1;
		dp[i+2][x+(s[i+2]=='0')][y+(s[i+2]=='1')]=1;
	}
	ll ans=0;
	rep(i,1,n) rep(x,0,i) rep(y,0,i-x) if (dp[i][x][y])
	{
		int a=suf[i],b=n-i+1-a;
		(ans+=(a==0?(!x):C[x+a-1][a-1])*(b==0?(!y):C[y+b-1][b-1])%mod)%=mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 15284
void main()
{
    long n, m;
    rdVals(n, m);
    Edge[] edge = m.rdCol!Edge;

    long[][] dist = new long[][](n, n);
    foreach (i; 0 .. n)
    {
        foreach (j; 0 .. n)
        {
            if (i == j) dist[i][j] = 0;
            else dist[i][j] = inf;
        }
    }

    foreach (ref e; edge)
    {
        --e.a, --e.b;
        dist[e.a][e.b] = dist[e.b][e.a] = e.c;
    }

    foreach (i; 0 .. n)
    {
        foreach (j; 0 .. n)
        {
            foreach (k; 0 .. n)
            {
                dist[j][k] = min(dist[j][k], dist[j][i]+dist[i][k]);
            }
        }
    }

    long cnt;
    foreach (e; edge)
    {
        bool ok;
        foreach (i; 0 .. n)
        {
            if (dist[e.a][i] + e.c == dist[e.b][i]) ok = true;
        }
        if (ok) ++cnt;
    }

    writeln(m - cnt);
}

struct Edge
{
    long a, b, c;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 508
from collections import Counter
n = int(input())
x = list(map(int,input().strip().split()))

rate = []
over = 0
for i in range(n):
  if x[i]//400 >=8:
    over += 1
  else:
    rate.append(x[i]//400)
elem = len(set(rate))

_min = elem
_max = elem +over
if elem  == 0:
  _min = 1
#if elem + over >=8:
#  _max = 8 

print(str(_min),str(_max))

Measured memory_bytes: 3316
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int i,j,k,h,w;
    vector<int> vx,vy;
    while(1){
        cin>>h>>w;
        if(h==0 && w==0){
            break;
        }
        else{
            vx.push_back(h);
            vy.push_back(w);
        }
    }
    for(i=0; i<vx.size(); i++){
        for(j=0; j<vx[i]; j++){
            for(k=0; k<vy[i]; k++){
                if(j==0 || j==vx[i]-1){
                    cout<<"#";
                }
                else{
                    if(k==0 || k==vy[i]-1){
                        cout<<"#";
                    }
                    else{
                        cout<<".";
                    }
                }
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int n;
	cin >> n;
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		sum += tmp - 1;
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
k = int(input())
if k % 2 == 0 or k % 5 == 0:
    x = -1
else:
    m = 7
    n = 7
    x = 1
    while n % k != 0:
        m = (m * 10) % k
        n += m
        x += 1
print(x)

Measured memory_bytes: 9160
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vll vector <pll>
#pragma 03
using namespace std; 
int main(){
	int m1, m2, d1, d2;
	cin >> m1 >> d1 >> m2 >> d2;
	if (d2 == 1) cout << 1 << endl;
	else cout << 0 << endl;
 	return 0;
}

 


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, t;
    cin >> n >> t;
    VI a(n);
    REP(i, n) cin >> a[i];
    VI max_a(n);
    max_a.back() = a.back();
    FORR(i, n - 2, 0) max_a[i] = max(max_a[i + 1], a[i]);
    VI profit(n - 1);
    REP(i, n - 1) profit[i] = max_a[i + 1] - a[i];
    sort(ALL(profit), greater<int>());
    int ans = 1;
    FOR(i, 1, profit.size() - 1)if(profit[i] == profit.front()) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main(){
    int x;
    vector<int> xs;

    for(int i=0; i<3; i++){
        cin >> x;
        xs.push_back(x);
    }

    sort(xs.begin(),xs.end(),greater<int>());

    int ans = 0;
    for(int i=1; i<3; i++){
        ans += (xs[i-1] - xs[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<iostream>
#include<queue>
#include<cstring>
#include<string>
using namespace std;
typedef long long LL;
int main(){
	int a,b;
	cin >> a >> b;
	cout << (a + b) % 24 << endl;
	return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5 + 10 , M = 5e5+10 ,  MOD = 1e9+7;
const int OO = 0x3f3f3f3f;
const double EPS = 1e-3;
#define M_PI 3.14159265358979323846
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define pb push_back
#define F first
#define S second
#define all(v) ((v).begin()) , ((v).end())
#define sz(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 

int n, m;
char grid[105][105];
bool row[105] , col[105];



int main() {

    //ios_base::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
	

    scanf("%d %d",&n,&m);
    for(int i = 0 ; i < n ; ++i)
        scanf("%s", grid[i]);

   
    for(int i = 0 ; i < n ; ++i){
        for(int j = 0 ; j < m ; ++j)
            if(grid[i][j] == '#')
                row[i] = 1 , col[j] = 1;
    }
   
    bool f = 0;
    for(int i = 0 ; i < n ; ++i){
        if(row[i]){
            for(int j = 0 ; j < m ; ++j){
                if(col[j])
                    printf("%c",grid[i][j]);
            }
            puts("");
        }
    }

    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  ll ans = 0;
  vector<ll> a(n);
  vector<ll> b(n);
  rep(i, n) {
    cin >> a[i] >> b[i];
  }

  for(int i=n-1; i>=0; i--) {
    ll now = a[i] + ans;
    ll rem = now%b[i];
    if (rem != 0) {
      ans += b[i] - rem;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define max(a,b) (a>b?a:b)
using namespace std;
const int N=200050;
int gi(){
    char ch=getchar(); int x=0,q=0;
    while(ch<'0'||ch>'9') q=ch=='-'?1:q,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return q?-x:x;
}
int a[N];
int main(){
    int n=gi(),s;
    for (int i=1; i<=n; ++i)
	s=gi(),a[s]=max(a[s],a[s-1]+1);
    int ans=0;
    for (int i=1; i<=n; ++i)
	ans=max(ans,a[i]);
    cout<<n-ans;
    return 0;
}


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

constexpr int inf = 2e9;

int main() {
    int n, q; cin >> n >> q;
    string s; cin >> s;
    vector<char> t(q), d(q);
    for(int i = 0; i < q; ++i) {
        cin >> t[i] >> d[i];
    }

    int l = 0, r = 0;
    {
        auto check = [&] (int x) {
            int cur = x;
            for(int i = 0; i < q; ++i) {
                if(t[i] == s[cur]) {
                    cur += (d[i] == 'L' ? -1 : 1);
                }
                if(cur < 0) return true;
                if(cur >= n) return false;
            }
            return false;
        };
        int lb = -1, ub = n;
        while(ub - lb > 1) {
            const int mid = (ub + lb) >> 1;
            (check(mid) ? lb : ub) = mid;
        }
        l = lb;
    }
    {
        auto check = [&] (int x) {
            int cur = x;
            for(int i = 0; i < q; ++i) {
                if(t[i] == s[cur]) {
                    cur += (d[i] == 'L' ? -1 : 1);
                }
                if(n <= cur) return true;
                if(cur < 0) return false;
            }
            return false;
        };
        int lb = -1, ub = n;
        while(ub - lb > 1) {
            const int mid = (ub + lb) >> 1;
            (check(mid) ? ub : lb) = mid;
        }
        r = ub;
    }
    //cout << l << " " << r << endl;
    cout << max(0, r - l - 1) << endl;
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    int x,n;
    int mp[209];
    MEM(mp,0);
    cin>>x>>n;
    for(int i=0; i<n; i++)
    {
        int a;
        cin>>a;
        mp[a]++;
    }
    int mx=1234;
    int ans;
    for(int i=0;i<200;i++)
    {
        if(mp[i]==0 and abs(i-x)<mx)
        {
            mx=abs(i-x);
            ans=i;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3632
from itertools import product
import sys
def input():
    return sys.stdin.readline()[:-1]
N, M = map(int, input().split())
xyz = [None] * N
for i in range(N):
    _x, _y, _z = map(int, input().split())
    xyz[i] = [_x, _y, _z]
ans = 0
for i, j, k in product([0, 1], repeat=3):
    sx, sy, sz = (-1)**i, (-1)**j, (-1)**k
    xyz.sort(key = lambda v : -(sx * v[0] + sy * v[1] + sz * v[2]))
    X, Y, Z = 0, 0, 0
    for i in range(M):
        X += xyz[i][0]
        Y += xyz[i][1]
        Z += xyz[i][2]
    ans = max(ans, abs(X) + abs(Y) + abs(Z))
print(ans)


Measured memory_bytes: 3304
# https://atcoder.jp/contests/abc067/tasks/arc078_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))
    total = sum(A)
    INF = int(1e15)
    ans = INF
    acc = 0
    for i in range(len(A) - 1):
        acc += A[i]
        ans = min(ans, abs(total - 2 * acc))

    print(ans)

if __name__ == '__main__':
    main()


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



i64 n;
vector<int> six, nine;
int dp[101010];
void solve(){
	cin >> n;
	
	for(int i = 6; i <= n; i*=6) six.push_back(i);
	for(int i = 9; i <= n; i*=9) nine.push_back(i);
	
	fill(dp,dp+n+1, INF);
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		chmin(dp[i+1],dp[i]+1);
		for(int j = 0; j < six.size(); j++){
			if(i+six[j] > n) break;
			chmin(dp[i+six[j]],dp[i]+1);
		}
		for(int j = 0; j < nine.size(); j++){
			if(i+nine[j] > n) break;
			chmin(dp[i+nine[j]],dp[i]+1);
		}
	}
	cout << dp[n] << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef  long long ll;
using namespace std;
const int maxn = 3e5 + 100;
int main() {
	ios::sync_with_stdio(0);
	ll n, m;
	cin >> n >> m;
	if (n % m)
		cout << n / m + 1 << endl;
	else
		cout << n / m << endl;
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  test
//
//  Created by 田宇航 on 2019/8/4.
//  Copyright © 2019 田宇航. All rights reserved.
//

#include <iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define rep(i,n,m) for(int i=n;i<=m;++i)
inline int read()
{
    int x=0,f=1;
    char c=getchar();
    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;
}
int main(int argc, const char * argv[]) {
    int a,b,c;
    cin>>a>>b>>c;
    int x=a-b;
    if(x>=c) cout<<"0"<<endl;
    else cout<<c-x<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,cnt=0,i,j,p;
    cin >> n;
    vector<int>v;
    for( i = 0; i < n; i++)
    {
        cin >> p;
        v.push_back(p);
    }

       for( j = 0; j < n; j++)
        {
        if(v[j]!= j+1)
        {
          cnt++;
        }
    }
    if(cnt < 3) cout << "YES\n" << endl;
    else cout << "NO\n" << endl;
 }



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
  Scanner in = new Scanner(System.in)
	  .useDelimiter("[^0-9]+");
  int cho = 0, daia = 0;
  while (in.hasNext()) {
	long a = in.nextLong();
	long b = in.nextLong();
	long c = in.nextLong();
	if (a == b) {
	  daia++;
	} else if (a * a + b * b == c * c) {
	  cho++;
	}
  }
  System.out.println(cho);
  System.out.println(daia);
}
}

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

int main(){
    int N,M,X; cin >> N >> M >> X;
    vector <bool> A(N+1,true);
    int ans1=0;
    int ans2=0;
    for (int i=1; i<=M; i++){
        int num; cin >> num;
        A[num]=false;
    }
    
    for (int i=X; 0<=i; i--){
        if (A[i]==false) ans1++;
    }
    for (int i=X; i<=N; i++){
        if (A[i]==false) ans2++;
    }
    int ans;
    ans=min(ans1,ans2);
    cout << ans;
    
}

Measured memory_bytes: 256
/**
	������������ Author : Avi J Patel ������������
	������������ University : DA-IICT ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define N 100000
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 1000005
#define large 10000000000000001

#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
/*
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}*/ 
int main()
{
	int n;
	cin>>n;
	priority_queue<ld, vector<ld>, greater<ld> > pq; 
	for(int i=0;i<n;i++)
	{
		int a1;
		cin>>a1;
		pq.push(a1);
	}

	for(int i=n-1;i>=1;i--)
	{
		ld r1=pq.top();
		pq.pop();
		ld r2=pq.top();
		pq.pop();
		pq.push((r1+r2)/2.0);
	}
	std::cout<<std::setprecision(9);
	cout<<pq.top();
	return 0;
}







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

int main() {
  string s;
  cin >> s;
  for(int i = 0; i < 3; i++){
    if(s.at(i) == '1')
      s.at(i) = '9';
    else
      s.at(i) = '1';
  }
  cout << s << endl;
}

Measured memory_bytes: 256
s = input()
months = ["{:02d}".format(n) for n in range(1,13)]
if (s[:2] in months) & (s[2:] in months):
    print("AMBIGUOUS")
elif s[:2] in months:
    print("MMYY")
elif s[2:] in months:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;cin >> s;
  int K;cin >> K;
  int n=s.size();
  ll dp[n+1][2][K+2];
  memset(dp,0,sizeof(dp));
  dp[0][0][0]=1;
  for(int i=0;i<n;i++){
    int p=s[i]-'0';
    for(int j=0;j<2;j++){
      for(int k=0;k<=K;k++){
        for(int l=0;l<=(j?9:p);l++){
          dp[i+1][j||(l<p)][k+(l!=0)]+=dp[i][j][k];
        }
      }
    }
  }
  cout << dp[n][0][K]+dp[n][1][K] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){

  while(1){
	int n,q;
	cin >> n >> q;

	if(n==0&&q==0)
	  break;

	int m[100];
	int ninzu[200]={0};
	int day;
	int now=150;

	REP(i,n){
	  cin >> m[i];
	  REP(j,m[i]){
		cin >> day;
		day--;
		ninzu[day]++;
	  }
	}

	REP(k,100){
	  if(ninzu[k]>=q&&ninzu[k]>ninzu[now]){
		//cout << ninzu[now] << " " << ninzu[k] << endl;
		now=k;
	  }
	}

	if(now==150) now = -1;

	cout << now+1 <<endl;

  }

}

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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

int main()
{
	int n;
	int x, y, b, p;
	n = in();
	for(int i = 0; i < n; i++)
	{
		scanf("%d%d%d%d", &x, &y, &b, &p);
		if( b >= 5 && p >= 2 )
		{
			printf("%d\n", (int)((x * b + y * p) * 0.8));
		}
		else
		{
			printf("%d\n", min(x * b + y * p, (int)((x * max(b, 5) + y * max(p, 2)) * 0.8)));
		}
	}
	return (0);
}

Measured memory_bytes: 1192
fn main() {
    let n = read::<usize>();

    for i in 1..10 {
        for j in 1..10 {
            if i * j == n {
                println!("Yes");
                return
            }
        }
    }
    println!("No");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N, U, V;
    cin >> N >> U >> V;
    --U; --V;
    vector<vector<int>> G(N, vector<int>());
    for (int n = 0; n < N-1; ++n) {
        int A, B;
        cin >> A >> B;
        --A; --B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    
    queue<int> Q;
    vector<int> Used(N);
    vector<int> Rank(N);
    Q.push(V);
    Rank[V] = 0;
    Used[V] = 1;
    while (!Q.empty()) {
        int Tmp = Q.front(); Q.pop();
        for (int Next : G[Tmp]) {
            if (Used[Next]) {
                continue;
            }
            Used[Next] = 1;
            Rank[Next] = Rank[Tmp] + 1;
            Q.push(Next);
        }
    }
    
    Used.assign(N, 0);
    vector<int> Tak(N, -1);
    Q.push(U);
    Used[U] = 1;
    Tak[U] = 0;
    while (!Q.empty()) {
        int Tmp = Q.front(); Q.pop();
        for (int Next : G[Tmp]) {
            if (Used[Next]) {
                continue;
            }
            Used[Next] = 1;
            if (Rank[Next] > Tak[Tmp] + 1) {
                Tak[Next] = Tak[Tmp] + 1;
                Q.push(Next);
            }
        }
    }
    
    int MaxRank = 0;
    for (int n = 0; n < N; ++n) {
        if (Tak[n] < 0) {
            continue;
        }
        MaxRank = max(MaxRank, Rank[n]);
    }
    
    cout << MaxRank - 1 << endl;

    return 0;
}


Measured memory_bytes: 7040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] A = new int[n];

		for(int i=0; i<n; i++) {
			A[i] = scan.nextInt();
			if(i==n-1) {
				System.out.println(A[i]);
			} else {
				System.out.print(A[i]+" ");
			}
		}
		scan.close();
		for(int i=1; i<=n-1; i++) {
			int v = A[i];
			int j = i - 1;
			while(j>=0 && A[j] > v) {
				A[j+1] = A[j];
				j--;
			}
			A[j+1] = v;
			for(int k=0; k<n; k++) {
				if(k==n-1) {
					System.out.println(A[k]);
				} else {
					System.out.print(A[k]+" ");
				}
			}
		}
	}

}



Measured memory_bytes: 32624
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int64_t N;
  cin >> N;

  map<string, int64_t> str_cnt;
  int64_t mx = 0;
  for (int64_t n = 0; n < N; ++n) {
    string S;
    cin >> S;
    ++str_cnt[S];
    mx = max(mx, str_cnt[S]);
  }
  vector<string> vec;
  vec.reserve(N);
  for (auto &p : str_cnt) {
	if (p.second == mx) {
      vec.push_back(p.first);
    }
  }
  sort(vec.begin(), vec.end());
  for (size_t i = 0, size = vec.size(); i < size; ++i) {
    cout << vec[i] << endl;
  }
  return 0;
}


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

int main() {
    string s;
    int cnt = 0;
    int max = -1;
    cin >> s;
    for (char c: s) {
        if (c == 'R')
            cnt++;
        else
            cnt = 0;

        if (max < cnt)
            max = cnt;
    }
    cout << max << endl;
}

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

#[allow(dead_code)]
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 n = read::<usize>();
    let mut seq = vec![0; n];
    for i in 0..n {
        seq[i] = read::<usize>();
    }
    let mut sorted_seq = seq.clone();
    sorted_seq.sort();
    sorted_seq.reverse();
    for i in 0..n {
        if seq[i] == sorted_seq[0] {
            println!("{}", sorted_seq[1]);
        } else {
            println!("{}", sorted_seq[0]);
        }
    }
}


Measured memory_bytes: 9724
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll unsigned long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


ll zz(ll n){
	return n*(n+1)/2;
}

int main(){
	fio; cout<<fixed<<setprecision(25);	
	ll n ; cin >> n;
	ll ans = 0;

	for(ll i = 1 ; i <= n ; ++i){
		ll l = n/i;
		ans += i*zz(l);
	}
	cout << ans << endl;






	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,d[110];
    while(cin>>n)
    {
        for(int i=0;i<n;i++)
            cin>>d[i];
        sort(d,d+n);
        int cnt=1;
        for(int i=1;i<n;i++)
            if(d[i]!=d[i-1])
                cnt++;
        cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import numpy as np

N,A,B,C,D = map(int,input().split())
S = np.array((False,)+tuple(map(lambda x: x == '#',input()))+(False,))

def check1(i,j):
    return not np.any(S[i:j] & S[i+1:j+1])

def check2(i,j):
    return np.any((~S[i-1:j])&(~S[i:j+1])&(~S[i+1:j+2]))

if C < D:
    print('Yes' if check1(A,C) and check1(B,D) else 'No')
else:
    print('Yes' if check2(B,D) and check1(A,C) else 'No')

Measured memory_bytes: 21512
#include<bits/stdc++.h>
#include<numeric>
#define int long long
#define ld long double
#define all(x) x.begin(),x.end()
const int maxn=1000000;
#define what_is(x) cerr << #x << " is " << x << endl;
const int MOD = 1e9 + 7;
using namespace std;
string abc="abcdefghijklmnopqrstuvwxyz";
int powmod(int a, int b, int MOD = MOD){
    if(!a and !b)    return 1ll;
    if(!a)    return a;
    int res = 1ll;
    b %= (MOD - 1ll), a %= MOD;
    while(b){
        if(b%2 == 1)    res = (res * a) % MOD;
        a = (a * a) % MOD;
        b /= 2;
    }
    return res;
}
int popcount(uint32_t n)
{
    n = n - ((n >> 1) & 0x55555555);
    n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
    return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
bool check(int n) {return (((double)sqrt(n)-floor((double)sqrt(n)))==0);}
vector<bool> sieve(maxn + 1, true);
void fillprime() {
    sieve[0] = sieve[1] = false;
    for (int i = 2; i <= maxn; ++i) {
        if (sieve[i] && (int) i * i <= maxn) {
            for (int j = i * i; j <= maxn; j += i) {
                sieve[j] = false;
            }
        }
    }
}
const int nn=1e5+5;
bool isPowerOfTwo(int n)
{
    if(n==0)
        return false;

    return (ceil(log2(n)) == floor(log2(n)));
}
void solve() {
  int n,k;
  cin>>n>>k;
  int arr[n];
  for(int i=0;i<n;++i) cin>>arr[i];
  sort(arr,arr+n);
  int sum=0;
  for(int i=0;i<k;++i) sum+=arr[i];
  cout<<sum;
}
int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    //int t;cin>>t;while(t--)
        solve();
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
 os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os << "(" << P.first << "," << P.second << ")";}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif


#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector< pii >


// int mod=1e9+7;
// inline int mul(int a,int b){return (a*1ll*b)%mod;}
// inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
// inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
// inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
// inline int inv(int a){return power(a,mod-2);}
// inline void modadd(int &a,int &b){a+=b;if(a>=mod)a-=mod;} 

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int H, W;
	cin>>H>>W;
	int i,j,k;
	int ans = max(H, W);
	if(H==1||W==1){cout<<ans; return 0;}
	vi chn(W-1, -1);
	vi len(W-1,0);
	for(j=0;j<H;j++){
		string s;
		cin>>s;
		for(i=0;i<W-1;i++){
			int c = s[i]==s[i+1]? 0:1;
			if(c==chn[i] or chn[i]==-1)len[i]++;
			else len[i]=1;
			chn[i] = c;
		}
		vi lef(W-1, 0);
		vi rig(W-1, 0);
		vi cur;
		// trace(len);
		for(i=0;i<W-1;i++){
			int cu = len[i];
			while(!cur.empty()){
				int x = cur.back();
				if(len[x]<=cu)break;
				rig[x] = i-x;
				cur.pop_back();
			}
			cur.pb(i);

		}
		for(auto z:cur)rig[z] = W-z-1;

		cur.clear();
		for(i=W-2;i>=0;i--){
			int cu = len[i];
			while(!cur.empty()){
				int x = cur.back();
				if(len[x]<=cu)break;
				lef[x] = x-i;
				cur.pop_back();
			}
			cur.pb(i);
		}
		for(auto z:cur)lef[z] = 1+z;
		// trace(lef, rig);
		for(i=0;i<W-1;i++)ans = max(ans, len[i]*(lef[i]+rig[i]));

	}	
	cout<<ans<<"\n";	
}


Measured memory_bytes: 256
def selection_sort(a,n):
    count=0
    for i in range(n):
        ch=False
        minj=i
        for j in range(i,n):
            if a[j] < a[minj]:
                minj = j
                ch = True
        if(ch):
            count+=1
        a[i],a[minj] = a[minj],a[i]
    return count

if __name__ == "__main__":
    n=int(input())
    a=list(map(int,input().split()))
    count=selection_sort(a,n)
    print(*a)
    print(count)


Measured memory_bytes: 5608