akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	sc := newScanner()
	var n = sc.readInt()
	var a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = sc.readInt()
	}
	var ho = 1000000007
	var gyaku = 500000004
	// var sum = 0
	var zen = 0
	var goo = 0
	for i := 0; i < n; i++ {
		zen = (zen + a[i]) % ho
		goo = (goo + (a[i]*a[i])%ho) % ho
	}
	ans := ((zen*zen)%ho - goo) % ho
	if ans < 0 {
		ans += ho
	}
	fmt.Println(ans * gyaku % ho)

}

//////////////////
//////////////////
//////////////////

func abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func reverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func reverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type scanner struct {
	bufScanner *bufio.Scanner
}

func newScanner() *scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &scanner{bufSc}
}

func (sc *scanner) readString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *scanner) readInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *scanner) readInt64() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 5864
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  long long k;
  cin>>n>>k;
  int a[n];
  REP(i, n) cin>>a[i];
  int ng = 0, ok = 1'000'000'000; //(ng, ok]
  while(ok - ng > 1){
    long long m = (ng + ok) / 2;
    long long temp = 0;
    REP(i, n) temp += (a[i] + m - 1) / m - 1;
    if(temp > k){
      ng = m;
    }else{
      ok = m;
    }
  }
  
  cout << ok << endl;
  
  return 0;
}


Measured memory_bytes: 4288
///

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll N = 750002;
const int mod = 1000000007;
const long long int inf = INT64_MAX;
#define pp pair<ll,ll>

typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++)    
void fastIO(void);
 
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);

int main()
{  
   ll n;
   cin>>n;
   vector<ll> a;
   ll temp;
   rep(i,n){ cin>>temp; a.push_back(temp);}
   sort(a.begin(),a.end());
   ll ans = 0;
   ll curr= 0;
   rep(i,n){
      for(ll j=i+1;j<n;j++){
         for(ll k=j+1;k<n;k++){
            if(a[k]<a[i]+a[j]){
               ans++;
            }
            else break;
         }
      }
   }
   cout<<ans<<endl;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   return ((a%mod)+(b%mod)+mod)%mod;
}
ll modpower(ll a, ll n){
   if(n==0)
      return 1;
   ll result = 1;
   while(n>0){
      if(n%2==1)
         result = modmulti(result,a);
      a = modmulti(a,a);
      n = n/2;
   }
   return result;
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}
 

Measured memory_bytes: 256
from sys import stdin
input = stdin.readline
N = int(input())
a = [int(input()) for _ in range(N)]
b = [-1] * N
botan = a[0]

cnt = 0

for i in range(N):
    if botan == 2:
        print(cnt + 1)
        exit()
    cnt += 1
    botan = a[botan - 1]

print(-1)


Measured memory_bytes: 7888
#include<bits/stdc++.h>
using namespace std;
int a[201]={0,1,9,30,76,141,267,400,624,885,1249,1590,2208,2689,3411,4248,5248,6081,7485,8530,10248,11889,13687,15228,17988,20053,22569,25242,28588,31053,35463,38284,42540,46581,50893,55362,61824,65857,71247,76884,84388,89349,97881,103342,111528,120141,128047,134580,146316,154177,164817,174438,185836,194157,207927,218812,233268,245277,257857,268182,288216,299257,313635,330204,347836,362973,383709,397042,416448,434025,456967,471948,499740,515581,536073,559758,583960,604833,633651,652216,683712,709065,734233,754734,793188,818917,846603,874512,909496,933081,977145,1006126,1041504,1073385,1106467,1138536,1187112,1215145,1255101,1295142,1342852,1373253,1422195,1453816,1502376,1553361,1595437,1629570,1691292,1726717,1782111,1827492,1887772,1925853,1986837,2033674,2089776,2145333,2197483,2246640,2332104,2379085,2434833,2490534,2554600,2609625,2693919,2742052,2813988,2875245,2952085,3003306,3096024,3157249,3224511,3306240,3388576,3444609,3533637,3591322,3693924,3767085,3842623,3912324,4027884,4102093,4181949,4270422,4361548,4427853,4548003,4616104,4718640,4812789,4918561,5003286,5131848,5205481,5299011,5392008,5521384,5610705,5739009,5818390,5930196,6052893,6156139,6239472,6402720,6493681,6623853,6741078,6864016,6953457,7094451,7215016,7359936,7475145,7593865,7689630,7886244,7984165,8130747,8253888,8403448,8523897,8684853,8802826,8949612,9105537,9267595,9376656,9574704,9686065,9827097,9997134,10174780,10290813,10493367,10611772,10813692};
int main(){
	int k;
	cin>>k;
	cout<<a[k]<<endl;
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>

bool is_lozenge(int side_a, int side_b)
{
	return (side_a == side_b);
}

bool is_rectangle(int side_a, int side_b, int diagonal)
{
	return (side_a * side_a + side_b * side_b == diagonal * diagonal);
}

int main()
{
	char dummy;
	int side_a, side_b, diagonal;
	int no_rectangles = 0, no_lozenges = 0;
	while (std::cin >> side_a >> dummy >> side_b >> dummy >> diagonal) {
//		std::cout << side_a << " " << side_b << " " << diagonal << std::endl;
		if (is_rectangle(side_a, side_b, diagonal) && is_lozenge(side_a, side_b)) {
//			std::cout << "square" << std::endl;
			// ·û`©ÂH`Í³û`Å é
			// DO NOTHING
		} else if (is_rectangle(side_a, side_b, diagonal)) {
//			std::cout << "rectangle" << std::endl;
			no_rectangles++;
		} else if (is_lozenge(side_a, side_b)) {
//			std::cout << "lozenge" << std::endl;
			no_lozenges++;
		} else {
			// DO NOTHING
		}
	}
	std::cout << no_rectangles << std::endl;
	std::cout << no_lozenges   << std::endl;
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i, n) for (int i = n-1; i >= 0; i--)
#define REP(i,k,n) for(int i=k;i<n;i++)
int main(){
    int dp[100000] = {};
    rep(i,100000) dp[i]=-1;
    dp[0] = 0;
    int n,W;
    int v[110];
    int w[110];
    cin >> n >> W;
    rep(i,n) cin >> v[i] >> w[i];
    rep(i,n){
        rrep(k,W){
            if(k+w[i]<=W && dp[k]>=0) dp[k+w[i]] = max(dp[k+w[i]],dp[k] + v[i]);

            // cout << dp[k] << " ";
        }

        // cout << endl;
    }
    int ma = 0;
    rep(i,W+1){
        ma = max(ma,dp[i]);
    }
    cout << ma << endl;
    return 0;
}


Measured memory_bytes: 3488
// 解き直し.
// https://img.atcoder.jp/abc161/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
char S[202020];
int L[202020], R[202020];

int main(){
    
    // 1. 入力情報.
    int N, K, C;
    scanf("%d %d %d", &N, &K, &C);
    scanf("%s", S);
    int l = strlen(S);
    
    // 2. 解説通り.
    // 2-1. L を 更新.
    int a = 0, x = 1;
    while(x <= K){
        if(S[a] == 'o'){
            L[x] = a + 1;
            a += C;
            x++;
        }
        a++;
    }
    
    // 2-2. R を 更新.
    int b = l - 1, y = K;
    while(y > 0){
        if(S[b] == 'o'){
            R[y] = b + 1;
            b -= C;
            y--;
        }
        b--;
    }
    // rep(i, x) printf("L[%d]=%d R[%d]=%d\n", i, L[i], i, R[i]);
    
    // 3. 必ず働く日を集計.
    vector<int> ans;
    repx(i, 1, K + 1) if(L[i] == R[i]) ans.pb(L[i]);
    
    // 4. 出力.
    for(auto &p : ans) printf("%d\n", p);
    return 0;
    
}

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

int main() {
  string s, t;
  cin>>s>>t;
  int cnt = 0;
  for (int i=0; i<3; i++) {
    if (s[i] == t[i]) {
      ++cnt;
    }
  }

  cout<<cnt<<endl;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

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; }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int matrix[50][26];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  vector<string> s;
  rep(i,n){
    string s; cin>>s;
    rep(j,s.size()){
      matrix[i][s[j]-'a']++;
    }
  }
  rep(i,26){
    int tmp=50;
    rep(j,n){
      chmin(tmp,matrix[j][i]);
    }
    rep(j,tmp){
      cout<<char('a'+i);
    }
  }
  cout<<endl;
}

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

using namespace std;

const int MOD = 1e9 + 7;
const long long INF = 1e18;
const int MaxN = 404;

long long dp[MaxN][MaxN];
int a[MaxN];
int n;

long long sum[MaxN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);

    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        cin >> a[i];
        if(i > 1)
            dp[i - 1][i] = a[i - 1] + a[i];

        sum[i] = a[i] + sum[i - 1];
    }

    for(int len = 3; len <= n; ++len)
    {
        for(int i = 1; i + len - 1 <= n; ++i)
        {
            int j = i + len - 1;
            dp[i][j] = INF;

            for(int pref = i; pref < j; ++pref)
                dp[i][j] = min(dp[i][j], dp[i][pref] + dp[pref + 1][j] + sum[j] - sum[i - 1]);
        }
    }

    cout << dp[1][n] << '\n';

    return 0;
}



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

using namespace std;
using ll = long long;

int main(void) {
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> q(n);
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    v[i] = i + 1;
  }
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> q[i];
  }
  sort(v.begin(), v.end());
  int c = 0;
  int P, Q;
  do {
    if (v == p) {
      P = c;
    }
    if (v == q) {
      Q = c;
    }
    c++;
  } while (next_permutation(v.begin(), v.end()));
  cout << abs(P - Q) << endl;;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int a,b,c,d,e,f;
	cin >>a>>b>>c>>d>>e>>f;


	double con = 0.0;
	int water = 0,sugar = 0;
	for(int w = 0; w <=10; w++){
		for(int x = 0; x <= 10; x++){
			for(int y = 0; y <= f; y++){
				for(int z = 0; z <= f; z++){
					int water_weight = a*w+b*x, sugar_weight = c*y+d*z;
					int total = 100*water_weight + sugar_weight;
					if(total <= f && sugar_weight <= water_weight*e){
						if(con < (double)sugar_weight/total){
							con = (double)sugar_weight/total;
							water = 100*water_weight;
							sugar = sugar_weight;
						}
					}
				}
			}
		}
	}
  if(con == 0) water = 100*a;

	cout << water+sugar << " " << sugar << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif

static void B_task();

int main()
{
	B_task();
	
	fflush(stdout);
	return 0;
}

class B_set {
public:
	std::string city = "";
	int num = 0;
	int point = 0;

	static bool sort_point_dsc(const B_set& a, const B_set& b) {
		return (a.point > b.point);
	}
};
static void B_task() 
{
	int N;
	scanf(" %d", &N);

	int point;
	char name[100][11] = { 0 };
	std::vector<B_set> rest;
	std::set<std::string> cities;
	B_set restrant;

	for (int i = 0; i < N; i++) {
		scanf(" %s %d", name[i], &point);
		
		restrant.city = name[i];
		restrant.point = point;
		restrant.num = i + 1;
		rest.push_back(restrant);
		cities.insert(restrant.city);
	}
	
	std::sort(rest.begin(), rest.end(), B_set::sort_point_dsc);

	int i = 0;
	while (i < N) {
		for (auto name = cities.begin(); name != cities.end(); name++) {
			for (int j = 0; j < N; j++) {
				if (*name == rest[j].city) {
					printf("%d\n", rest[j].num);
					i++;
				}
			}
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(char, a, b, c, d);
    Cout(('a' <= a && a <= 'z') ? "a" : "A");
}


Measured memory_bytes: 3592
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N;
Int A[100000+10];

int main(void) {
    cin>>N;

    Int x = 0;
    for(int i = 1;i <= N;i++) {
        Int t;
        cin>>t;
        A[i] = t;
        
        if(i&1)
            x+=t;
        else
            x-=t;
    }

    cout<<x<<" ";
    x /= 2;
    for(int i = 1;i <= N-1;i++) {
        cout<<2*(A[i]-x)<<" ";
        x = A[i]-x;
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int h,w;
  cin >> h >> w;
  int dp[h][w];
  int k[h][w];
  k[0][0]=0;
  dp[0][0]=0;
  rep(i,h)rep(j,w)dp[i][j]=1000000000;
  int ch,cw,dh,dw;
  cin >> ch >> cw >> dh >> dw;
  ch--;
  cw--;
  dh--;
  dw--;
  rep(i,h){
    string s;
    cin >> s;
    rep(j,w){
      if(s[j]=='#')k[i][j]=1;
      else k[i][j]=0;
    }
  }
  priority_queue<pair<int,pair<int,int>>, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int>>>> q;
  q.push(make_pair(0,make_pair(ch,cw)));
  while(q.size()!=0){
    pair<int,pair<int,int>> p=q.top();
    q.pop();
    int a=p.first,b=p.second.first,c=p.second.second;
    if(a>=dp[b][c])continue;
    dp[b][c]=a;
    if(b!=0){
      if(k[b-1][c]==0)q.push(make_pair(a,make_pair(b-1,c)));
    }
    if(b!=h-1){
      if(k[b+1][c]==0)q.push(make_pair(a,make_pair(b+1,c)));
    }
    if(c!=0){
      if(k[b][c-1]==0)q.push(make_pair(a,make_pair(b,c-1)));
    }
    if(c!=w-1){
      if(k[b][c+1]==0)q.push(make_pair(a,make_pair(b,c+1)));
    }
    rep(i,5){
      rep(j,5){
        if(b-2+i>=0&&b-2+i<h&&c-2+j>=0&&c-2+j<w){
          if(k[b-2+i][c-2+j]==0){
            q.push(make_pair(a+1,make_pair(b-2+i,c-2+j)));
          }
        }
      }
    }
  }
  if(dp[dh][dw]>=100000000)cout << -1 << endl;
  else cout << dp[dh][dw] << endl;
}


Measured memory_bytes: 14136
H,W = map(int,input().split())
S = [[0 for j in range(W)] for i in range(H)]
for i in range(H):
    S[i] = list(input())
for i in range(H):
    for j in range(W):
        if (S[i][j] == '.'):
            count = 0
            for a in range(-1,2):
                for b in range(-1,2):
                    if(0<=i+a<=H-1 and 0<=j+b<=W-1):
                        if(S[i+a][j+b] == '#'):
                            count += 1
            S[i][j] = count
    print(*S[i], sep='')

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> data(H);
  for (int i = 0; i < H; i++) {
    cin >> data.at(i);
  }
  vector<vector<char>> answer(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (data.at(i).at(j) == '#') answer.at(i).at(j) = '#';
      if (data.at(i).at(j) == '.') {
        int count = 0;
        if (i != 0) {
        if (j != 0) {
          if (data.at(i-1).at(j-1) == '#') count++;
        }
        if (data.at(i-1).at(j) == '#') count++;
        if (j != W-1) {
          if (data.at(i-1).at(j+1) == '#') count++;
        }
        }
        if (j != 0) {
        if (data.at(i).at(j-1) == '#') count++;
        }
        if (j != W-1) {
        if (data.at(i).at(j+1) == '#') count++;
        }
        if (i != H-1) {
        if (j != 0) {
        if (data.at(i+1).at(j-1) == '#') count++;
        }
        if (data.at(i+1).at(j) == '#') count++;
        if (j != W-1) {
        if (data.at(i+1).at(j+1) == '#') count++;
        }
        }
        answer.at(i).at(j) = '0' + count;
      }
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << answer.at(i).at(j);
      if (j == W-1) cout << endl;
    }
  }
}

        


        

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long R = sc.nextLong();

        if(N >= 10){
            System.out.println(R);
        }else{
            System.out.println(R + 100*(10 - N));
        }
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);

int solve(const int N, const vector<int>&a) {
	//aは0か1
	const int c = N - 1;//center

	if (a[c] == a[c - 1] || a[c] == a[c + 1]) {
		return a[c];
	}
	int L = -1, R = 2 * N;
	for (int i = c - 1; 0 <= i; i--) {
		if (a[i] == a[i + 1]) {
			L = i;
			break;
		}
	}
	for (int i = c + 1; i < 2 * N - 1; i++) {
		if (a[i] == a[i - 1]) {
			R = i;
			break;
		}
	}

	if (L == -1 && R == 2 * N) {
		return (N % 2) ? a[c] : (a[c] ^ 1);
	}
	if (L == -1) {
		return a[R];
	}
	if (R == 2 * N) {
		return a[L];
	}
	if (a[L] == a[R]) {
		return a[L];
	}

	int Ldist = c - L;
	int Rdist = R - c;
	if (Ldist < Rdist)return a[L];
	return a[R];
}

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

	int N;
	cin >> N;
	vector<int>a(2 * N - 1), bin(2 * N - 1);
	rep(i, 2 * N - 1)cin >> a[i];

	int lb = 0, ub = 2 * N;//真の解[lb,ub)
	while (lb + 1 < ub) {
		const int med = (lb + ub) / 2;
		rep(i, 2 * N - 1)bin[i] = a[i] < med ? 0 : 1;
		const int res = solve(N, bin);
		if (res == 0)ub = med;
		else lb = med;
	}

	cout << lb << endl;

	return 0;
}

Measured memory_bytes: 3456
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
#define NIL -2100000000
int heap[500010];
int n;

int parent(int i){
	return i/2;
}
int rightchild(int i){
	return 2*i+1;
}
int leftchild(int i){
	return 2*i;
}
void maxHeapify(int i){
	int l =leftchild(i);
	int r =rightchild(i);
	int largest =i;
	if(l <= n&&heap[l] >heap[i]){
		largest = l;
	}
	if(r <=n&&heap[r] >heap[largest]){
		largest = r;
	}
	if(largest !=i){
		swap(heap[i],heap[largest]);
		maxHeapify(largest);
	}
}
void buildHeap(){
	for(int i =n/2;i >=1;i--){
		maxHeapify(i);
	}
}
int main(){
	cin>>n;
	for(int i =0;i <=500000;i++){
		heap[i]=NIL;
	}
	for(int i =1;i <= n;i++){
		int x;
		cin>>x;
		heap[i]=x;
	}
	buildHeap();
	for(int i =1;i <=n;i++){
		cout <<" "<<heap[i];
	}
	cout <<endl;
	return 0;
}

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

using namespace std;

const int Mod = 924844033, Nmax = 2005;
typedef long long ll;

int dp[Nmax][Nmax][4], sz[Nmax], n, k;
bool Not[Nmax];
ll fact[Nmax];

void add_to(int &x, int y) { x += y; if(x>=Mod) x-=Mod; }

int solve()
{
    int i, j, mask;

    dp[1][0][0] = 1;

    for(i=1; i<=n; ++i)
        for(j=0; j<=i; ++j)
        {
            if(Not[i]) dp[i][j][1] = dp[i][j][2] = dp[i][j][3] = 0;

            for(mask = 0; mask < 4; ++ mask)
            {
                add_to( dp[i+1][j][0], dp[i][j][mask] );

                if(!(mask & 1)) add_to( dp[i+1][j+1][2], dp[i][j][mask] );
                if(!(mask & 2)) add_to( dp[i+1][j+1][1], dp[i][j][mask] );
                if(!(mask & 3)) add_to( dp[i+1][j+2][3], dp[i][j][mask] );
            }
        }

    fact[0] = 1;
    for(i=1; i<=n; ++i) fact[i] = fact[i-1] * i % Mod;

    ll ans = fact[n];
    for(i=1; i<=n; ++i)
    {
        ll all = (ll) dp[n][i][0] + dp[n][i][1] + dp[n][i][2] + dp[n][i][3];
        all %= Mod;

        ans += all * fact[n-i] * ((i&1) ? -1 : 1);
        ans += Mod;
        ans %= Mod;
    }
    return ans;
}

int main()
{
//    freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    cin >> n >> k;

    int i;
    for(i=1; i<=k; ++i)
        sz[i] = (n-i) / k + 1;

    int sum = 0;
    for(i=1; i<=k; ++i)
    {
        Not[sum+1] = 1;
        sum += sz[i];
    }

    cout << solve() << '\n';
    return 0;
}


Measured memory_bytes: 61312
N = int(input())
A = list(map(int, input().split()))
abs_sum = 0
abs_min = 10 ** 10
minus_count = 0
for i in range(N):
    if A[i] < 0:
        minus_count += 1
    a_abs = abs(A[i])
    abs_sum += a_abs
    abs_min = min(abs_min, a_abs)
if minus_count % 2 == 0:
    print(abs_sum)
else:
    print(abs_sum - abs_min * 2)


Measured memory_bytes: 14412
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        y >>= 1;
    }
    return res;
}

ll inv(ll n){
    return fast(n,mod-2);
}


void pre(){



}


void solve(){

    ll a,b;
    cin >> a >> b;
    if(a > b){
        for(ll i=1;i<=a;i++)
            cout  << b;
    }else{
        for(ll i=1;i<=b;i++){
            cout << a;
        }
    }

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int a,b;
    cin >> a >> b;

    if(a<b){
        rep(i,1,b)cout << a;
        cout << endl;
    }else{
        rep(i,1,a)cout << b;
        cout << endl;
    }

    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int size = s.size();
  char S[size];
  for (int i = 0;i < size; i++) {
    S[i] = s.at(i);
  }
  if (size == 1) {
    cout << s <<endl;
  }
  else {
    long long int sumsum=0;
    for (int bit = 0; bit < (1<<size-1); bit++) {
      char pm[size];
      for (int i = 0; i < size - 1;i++) {
        if (bit & (1<<i)) {
          pm[size-2-i]='+';
        }
        else {
          pm[size-2-i]='-';
        }
      }
      long long int ss[300]={};
      int k = 0;
      ss[0]=S[0]-'0';
      long long int sum=0;
      for (int i = 0; i<size-1;i++) {
        if (pm[i]=='-') {
          long long int b = S[i+1]-'0';
          ss[i-k] = ss[i-k]*10+b;
          k++;
        }
        else {
          sum += ss[i-k];
          int p = S[i+1]-'0';
          ss[i-k+1]=p;
        }
      }
      sumsum+=sum+ss[size-1-k];
    }
    printf("%lld\n", sumsum);
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
  vector<int>dp(3);
  for(int day=0;day<n;day++)
  {  
    vector<int>c(3);
    vector<int>new_dp(3,0);
    for(int i=0;i<3;i++)
    {
      cin>>c[i];
    }
    for(int i=0;i<3;i++)
    {
      for(int j=0;j<3;j++)
      {
        if(i!=j)
        {
          new_dp[j]=max(new_dp[j],dp[i]+c[j]);
        }
      }
    }
    dp=new_dp;
  }
  cout<<max({dp[0],dp[1],dp[2]});
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<map>
#include<algorithm>
#include<stack>
#define P pair<int,int>
using namespace std;

int main() {
	int a;
	while (scanf("%d", &a), a) {
		stack<P>b;
		for (int c = 1; c <= a; c++) {
			int d;
			scanf("%d", &d);
			if (c & 1) {
				if (b.size() && b.top().second == d)b.top().first++;
				else b.push(P(1, d));
			}
			else {
				if (b.size() && b.top().second == d) {
					b.top().first++;
				}
				else {
					P x = b.top(); b.pop();
					P y = P(0, 0);
					if (b.size()) {
						y = b.top();
						b.pop();
					}
					b.push(P(x.first + y.first + 1, d));
				}
			}
		}
		int k = 0;
		while (b.size()) {
			P s = b.top(); b.pop();
			if (s.second == 0)k += s.first;
		}
		cout << k << endl;
	}
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 8010
#define INF 1000000005
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 998244353;
int main(){
    int n;
    cin>>n;
    int p=n%10;
    if(p==3){
        OUT("bon");
    }else if(p==0||p==1||p==6||p==8){
        OUT("pon");
    }else OUT("hon");
    return 0;
}

Measured memory_bytes: 3632
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <tuple>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<vector<PII> > VVPII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int DX[] = {0, 1, 0, -1};
const int DY[] = {-1, 0, 1, 0};

//other
//--------------------------------------------
#define RANGE(a, c, b) ((a <= b) && (b < c))

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int dijkstra(int from, int to, VVPII & nodes, int n){
	VI dist(nodes.size(), (int) 10e7);

	priority_queue<PII, vector<PII>, greater<PII> > q;
	q.emplace(0, from);
	dist[from] = 0;
	while(!q.empty()){
		int cost = q.top().first; // cost
		int place = q.top().second; // current place
		q.pop();
		if(dist[place] < cost) continue;
		for(PII node : nodes[place]){
			if(node.first + dist[place] < dist[node.second]){
				dist[node.second] = node.first + dist[place];
				q.emplace(dist[node.second], node.second);
			}
		}
	}
	REP(i, n){

	}
	return dist[to];
}


int main(int argc, char const *argv[])
{
	int n, m;
	cin >> n >> m;
	char c;
	VVPII nodes(m);

	REP(i, m){
		int from, to, value;
		cin >> from >> c >> to >> c >> value;
		nodes[from].PB(MP(value, to));
		cin >> c >> value;
		nodes[to].PB(MP(value, from));
	}

	int start, goal, money, price;
	cin >> start >> c >> goal >> c;
	cin >> money >> c >> price;
	int go = dijkstra(start, goal, nodes, n);
	int back = dijkstra(goal, start, nodes, n);
	int reward = money - (price + go + back);
	cout << reward << endl;
	return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-4;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int s[1 << 14], p[1 << 14];
int dp[1 << 14];
int main() {
	int c, n, m; cin >> c >> n >> m;
	rep(i, n) {
		cin >> s[i] >> p[i];
	}
	fill(dp, dp + 10001, -1); dp[0] = 0;
	rep(i, n) {
		per(j, c) {
			if (dp[j] < 0||j+s[i]>c)continue;
			dp[j + s[i]] = max(dp[j+s[i]],dp[j] + p[i]);
		}
	}
	rep1(i, c) {
		dp[i] = max(dp[i], dp[i - 1]);
	}
	rep1(i, m) {
		cout << i * dp[c / i] << endl;
	}
	return 0;
}



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

struct UnionFind {
    vector<int> parent;
    UnionFind(int N) {
        parent=vector<int>(N,-1);
    }
    int root(int x) {
        if (parent[x] < 0) return x;
        return parent[x] = root(parent[x]);
    }
    int size(int x){
        return -parent[root(x)];
    }
    bool unite(int x, int y) {
        x=root(x);
        y=root(y);
        if (x==y) return false;
        if(size(x)<size(y)) swap(x,y);
        parent[x]+=parent[y];
        parent[y]=x;
        return true;
    }
    bool same(int x, int y) {
        return root(x)==root(y);
    }
};

int main(){

    int n,m;
    cin>> n >> m;

    UnionFind tree(n);

    rep(i,m){
        int s,t,u;
        cin>> s >> t >> u;
        s--;
        t--;
        tree.unite(s,t);
    }

    int ans=n;
    vector<bool> f(n,true);
    rep(i,n){
        if(f[tree.root(i)]){
            f[tree.root(i)]=false;
            ans-=tree.size(i)-1;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {

	int n;
	cin >> n;
	int a[n];

		for (int i = 0; i < n; i++) cin >> a[i];
	    cout << a[n - 1];
		for (int i = n - 2; i >= 0; i--) cout << " " << a[i];
		cout << endl;

	return 0;

}

Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = false;
bool f = false;
bool used[210];
bool graph[100][100];
bool visited[8];
int abc[26] = { 0 };
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

int main() {
	int n, c, x[100000], y[100000], z[100000], s[200010][35] = { 0 }, t[200010] = {0};
	std::cin >> n >> c;
	for (int i = 0;i < n;i++) {
		std::cin >> x[i] >> y[i] >> z[i];
	}
	for (int i = 0;i < n;i++) {
		s[x[i] * 2 - 1][z[i]]++, s[y[i] * 2 + 1][z[i]]--;
		}
	for (int i = 1;i <= c;i++) {
		for (int j = 1;j < 200002;j++) {
			s[j][i] += s[j - 1][i];
		}
	}

	for (int i = 1;i <= c;i++) {
		for (int j = 1;j < 200002;j++) {
			if (s[j][i] != 0)s[j][i] = 1;
		}
	}
	for (int i = 1;i <= c;i++) {
		for (int j = 1;j < 200002;j++) {
			t[j] += s[j][i];
		}
	}
	int ans = 0;
	for (int i = 1;i <200002;i++) {
		ans = max(ans, t[i]);
	}
	std::cout << ans << std::endl;
	}

Measured memory_bytes: 29568
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

constexpr int dx[] = {-1, 0, 1, 0};
constexpr int dy[] = {0, -1, 0, 1};

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	ll ab = 4 * a * b;
	ll cab = square(c - a - b);
	bool check = c - a - b > 0;
	if(check && ab < cab) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
//Author : pakhandi
//
using namespace std;

#include<bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)
#define ss(s) scanf("%s", s)
#define sc(c) scanf("%c", &c)
#define sd(f) scanf("%lf", &f)

#define pi(n) printf("%d\n", n)
#define pll(l) printf("%lld\n", l)
#define ps(s) printf("%s\n", s)
#define pc(c) printf("%c\n", c)
#define pd(f) printf("%lf\n", f)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define mclr(strn) strn.clear()
#define ignr cin.ignore()
#define PB push_back
#define SZ size
#define MP make_pair
#define fi first
#define sec second

int flag[4];

int main()
{
	int i, j;

	string str1;
	cin>> str1;

	fl(i,0,str1.SZ())
	{
		if(str1[i] == 'N')
			flag[0] = 1;
		else if(str1[i] == 'S')
			flag[1] = 1;
		else if(str1[i] == 'E')
			flag[2] = 1;
		else
			flag[3] = 1;
	}

	if(flag[0] == flag[1] && flag[2] == flag[3])
		cout<<"Yes";
	else
		cout<<"No";


	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
 
    int cont = 0;
    string s;
    cin >> s;
    vector<int> mark(90, 0);
    for(int i = 0; i < s.length(); i++){
        int num = s[i];
        mark[num]++;
    }

    for(int i = 65; i <= 90; i++){
        if(mark[i] == 2) cont++;
    }

    if(cont == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define fi first 
#define se second

#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>

#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>

const ll HMOD = (ll)1e9 + 7;
const ll LMOD = 998244353;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;
const long double EPS = 1e-10;


void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}


int main() {
	int K; cin >> K;
	cout << ((K & 1) ? (K / 2)*(K / 2 + 1) : (K / 2)*(K / 2)) << endl;
	return 0;
}



Measured memory_bytes: 256
import std.stdio, std.string, std.array, std.conv;

void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.chomp.split.to!(int[]);
    foreach_reverse (i; 0 .. n) {
        a[i].write;
        if (i != 0) " ".write;
        else writeln;
    }
}


Measured memory_bytes: 2476
import collections
import sys
input = sys.stdin.readline

N = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)
ans = 0
for w in c.keys():
  if int(w) > c[w]:
    ans += c[w]
  elif int(w) < c[w]:
    ans += c[w] - int(w)
print(ans)

Measured memory_bytes: 64424