akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>

using namespace std;

long long selector(long long num)
{
    return num < 2 ? 0 : num * (num - 1) / 2;
}

int main()
{
    long long N;

    cin >> N;

    long long A[N];
    map<long long, long long> counter;
    for (long long i = 0; i < N; i++)
    {
        cin >> A[i];
        if (counter.find(A[i]) == counter.end())
        {
            counter.insert(make_pair(A[i], 1));
        }
        else
        {
            counter[A[i]]++;
        }
    }

    long long sumMemo = 0;

    map<long long, pair<long long, long long>> memo;
    for (auto c : counter)
    {
        memo.insert(make_pair(c.first, make_pair(selector(c.second), selector(c.second - 1))));
        sumMemo += memo[c.first].first;
    }

    map<long long, long long> bannedMemo;
    for (auto m : memo)
    {
        long long calc = sumMemo - m.second.first + m.second.second;
        bannedMemo.insert(make_pair(m.first, calc));
    }

    for (long long i = 0; i < N; i++)
    {
        long long ans = bannedMemo[A[i]];

        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value
string S;
string T;

void solve() {

	cin >> S >> T;
  	bool ok = false;	
  
  	for(int i = S.length() - T.length(); i >= 0; i--){
      int j;
      for(j = 0; j < T.length(); j++){
        if(!(S[i + j] == T[j] || S[i + j] == '?')) break;
      }
      if(j == T.length()) {
        ok = true;
        for(j = 0; j < T.length(); j++){
          S[i + j] = T[j];
        }
        break;
      }
    }
  
  	if(!ok) {
      cout << "UNRESTORABLE" << endl;
      return;
    }
  
  	for(int i = 0; i < S.length(); i++){
      if (S[i] == '?') S[i] = 'a';
    }
  
  	cout << S << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int> > Matrix;

int main(){
    int x;
    cin >> x;
    vector<int> d;
    for (int b = 1; b <= x; b++){
        for (int p = 2; p <= 10; p++){
            int num = pow(b, p);
            d.push_back(num);
        }
    }
    sort(ALL(d));
    int t = 0;
    rep(i, d.size()){
        t = i;
        if (d[i] > x){
            break;
        } 
    }
    cout << d[t-1] << "\n";
}

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

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> l;
  rep(i, N)
  {
    int in;
    cin >> in;
    l.push_back(in);
  }
  sort(l.rbegin(), l.rend());
  int ans = 0;
  rep(i, K)
  {
    ans += l[i];
  }
  cout << ans << endl;
  return 0;
}

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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int N = input(), M = input();
    vector< int > A(N);
    cin >> A;
    
    int sum = whole(accumulate, A, 0);
    int cnt = 0;
    for (auto a: A) {
        if (a * 4 * M >= sum) cnt++;
    }
    
    cout << (cnt >= M ? "Yes" : "No") << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 256
/* AtCoder コピペ */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repEq(i, n) for (int i = 0; i <= (int)(n); i++)
#define repVector(i, v) for (auto i = v.begin(); i != v.end(); ++i)

#define ifBetween(n, a, b) if (n > a && n < b)
#define ifBetweenEq(n, a, b) if (n >= a && n <= b)

int main() {
	int N;
  	int total = 0;

  	cin >> N;
  
  	rep(i, N) {
    	total += i + 1;
    }
  
  	cout << total << endl;
}


Measured memory_bytes: 256
c = Array.new(2)
c[0] = gets.chomp
c[1] = gets.chomp
if (c[0][0] == c[1][2]) && (c[0][1] == c[1][1]) && (c[0][2] == c[1][0])
  print 'YES'
else
  print 'NO'
end


Measured memory_bytes: 1788
import * as fs from 'fs'


//in
// 5 7 5
//out
// Yes

let input: string[] = fs.readFileSync('/dev/stdin', 'utf8').split(' ');
input = input.sort();

const a = +input[0];
const b = +input[1];
const c = +input[2];


// 4 4 9

if (a == b && b !=c) {
    console.log('Yes');
} else if(b == c && a!=b) {
    console.log('Yes');
} else {
    console.log('No');
}

Measured memory_bytes: 7372
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define PAUSE system("pause");
#define FASTIO                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define FILEIO                     \
    freopen("in.txt", "r", stdin); \
    freopen("out.txt", "w", stdout);
template <typename T>
void read(T &x)
{
    x = 0;
    int flag = 1;
    char c = getchar();
    while (c < '0' || c > '9')
    {
        if (c == '-')
            flag = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9')
    {
        x = x * 10 + c - '0';
        c = getchar();
    }
    x *= flag;
}
const int MOD = 1e9 + 7, INF = 0x3f3f3f3f;

struct que
{
    int x, y, id;
} q[1000010];

int h, w;
char mp[1010][1010];

int main()
{
    int head = 0, tail = 0;
    cin >> h >> w;
    rep(i, 1, h) rep(j, 1, w)
    {
        cin >> mp[i][j];
        if (mp[i][j] == '#')
        {
            q[++tail].x = i;
            q[tail].y = j;
            q[tail].id = 0;
        }
    }
    while (++head <= tail)
    {
        int x = q[head].x, y = q[head].y;
        if (x > 1 && mp[x - 1][y] == '.')
        {
            q[++tail].x = x - 1;
            q[tail].y = y;
            q[tail].id = q[head].id + 1;
            mp[x - 1][y] = '#';
        }
        if (x < h && mp[x + 1][y] == '.')
        {
            q[++tail].x = x + 1;
            q[tail].y = y;
            q[tail].id = q[head].id + 1;
            mp[x + 1][y] = '#';
        }
        if (y > 1 && mp[x][y - 1] == '.')
        {
            q[++tail].x = x;
            q[tail].y = y - 1;
            q[tail].id = q[head].id + 1;
            mp[x][y - 1] = '#';
        }
        if (y < w && mp[x][y + 1] == '.')
        {
            q[++tail].x = x;
            q[tail].y = y + 1;
            q[tail].id = q[head].id + 1;
            mp[x][y + 1] = '#';
        }
    }
    cout << q[tail].id;
   return 0;
}


Measured memory_bytes: 12928
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
typedef long long ll;
typedef long double ld;

int main() {
	int a=0, b=0, c=0, flag=0;
	char s;
	rep(i, 100001) {
		scanf("%c", &s);
		if (s == 'a')a++;
		else if (s == 'b')b++;
		else if (s == 'c')c++;
		else break;
	}
	if (fabs(b - a) > 1 || fabs(c - b) > 1 || fabs(a - c) > 1)printf("NO");
	else printf("YES");
}


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

int  main() {

  int i,n;
vector<int> x(1000000);
  for(i=1;i>0;i++){
cin >> x[i];
    if(x[i]!=0){ cout << "Case" << " " << i << ":" <<" " << x[i] << endl;
  } else {break;}


}
  return 0;
}


Measured memory_bytes: 6516
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
    static void Main(string[] args){
    const int MOD = 1000000007;
    var N = int.Parse(Console.ReadLine());
    if(N%2==0){
        Console.WriteLine("0.5");
    }
    else{
        float ans=(N-N/2);
        ans=ans/N;
        Console.WriteLine(ans);
    }
    }
}

Measured memory_bytes: 11092
N = int(input())


def eratosthenes_sieve(n):
    if n < 2:
        return []

    is_primes = [True] * (n + 1)
    for x in range(2, int(n ** 0.5 + 1) + 1):
        if is_primes[x]:
            for mx in range(2 * x, n + 1, x):
                is_primes[mx] = False

    return [i for i in range(2, n + 1) if is_primes[i]]


P = eratosthenes_sieve(55555)
P = [p for p in P if p % 5 == 1]
print(' '.join(map(str, P[:N])))


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

const int DIM = 1e5 + 5;

bitset<DIM> oki;

int main( void ) {
    
    int n, ans = 0;
    cin >> n;
    
    for( int i = 1; i <= n; i ++ ) {
        int x;
        cin >> x;
        
        if( oki[x] == false ) {
            ans ++;
            oki[x] = true;
        }
    }
    
    if( (n - ans) & 1 )
        ans --;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split(" ")))
b = list(map(int,input().split(" ")))

c = 0
for i in range(n):
  # 街のモンスター一部倒す
  if a[i] >= b[i]:
    c += b[i]
  else:
    # 街のモンスター全て倒す
    c += a[i]
    # 余力
    d = b[i] - a[i]
    # 隣街のモンスター一部倒す
    if a[i + 1] >= d:
      c += d
      a[i + 1] = a[i + 1] - d
    # 隣街のモンスター全て倒す
    else:
      c += a[i + 1]
      a[i + 1] = 0
      
print(c)

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 2e5 + 5;

bool cmp(ii a, ii b){
	return a.second < b.second;
}

int main(){
	int n,i,j;
	ii pas[maxn];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&pas[i].first, &pas[i].second);
	}
	sort(pas, pas+n, cmp);
	ll time = 0;
	for(i=0;i<n;i++){
		time += pas[i].first;
		if(time > pas[i].second){printf("No\n"); return 0;}
	}
	printf("Yes\n");
	return 0;
};

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<ext/rope>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define mst(a,b) memset(a,b,sizeof(a))
#define lowbit(x) (x&(-x))
#define lson        (rt<<1)
#define rson        (rt<<1|1)
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;
typedef long long ll;
typedef long long LL;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 2e6 + 50;
ll a[maxn];

int main() {
#ifdef local
    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll x,y;
    cin>>x>>y;
    a[1]=x;
    for(int i=2;;++i){
        a[i]=a[i-1]*2;
        if(a[i]>y){
            cout<<i-1;return 0;
        }
    }



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j]
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
int main(){
    ll a,b,k; cin >> a >> b >> k;
    if(a>k){
        cout << a-k << " " << b;
    }
    else if(a+b>k) cout << 0 << " " << a+b-k;
    else cout << 0 << " " << 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
using namespace std::chrono;

#define ll long long
#define ld long double
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#ifdef LL
const ll inf = 1e9;
#else 
const ll inf = 1e18;
#endif

const int mod = 1e9 + 7;
const int mod2 = 998244353;

typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

high_resolution_clock::time_point curTime() { return high_resolution_clock::now(); }
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);} //Just add this as a third argument to sort() while sorting an array of pairs; NO NEED FOR ANY ARGUMENTS;
template <typename T>
T fact(T a, T mod){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=mod;} return res; }
template <typename T>
ll powmod(T a,T b,ll m){ ll ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
ll power(T a, T b){ ll ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}
template <typename T>
T gcd(T a,T b){ return (b?__gcd(a,b):a); }
template <typename T>
T lcm(T a, T b){ return (a*(b/gcd(a,b))); }
template <typename T>
T cl(T a, T b){ return (a+b-1)/b; }
template <typename T>
T set_bits(T a)
{ return __builtin_popcount(a); }
template <typename T>
T add_self(T& a, T b, T mod){ a+=b; if(a>=mod){ a-=mod; } }
template <typename T>
T to_upper(T s){ transform(s.begin(), s.end(), s.begin(), ::toupper); return s; }
template <typename T>
T to_lower(T s){ transform(s.begin(), s.end(), s.begin(), ::tolower); return s; }



int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    auto startTime = curTime();

    int n;
    cin>>n;

    ld p[n];
    for(int i=0;i<n;i++)
    {
        cin>>p[i];
    }

    //dp[i][j] is the probability of j heads in the first i coins
    
    vector<vector<ld>> dp(n+1, vector<ld>(n+1));
    for(int i=1;i<=n;i++) dp[i][0] = 1-p[i-1];
    dp[0][0]=1;
    dp[1][1] = p[0];
    for(int i=1;i<=n;i++)
    {
        dp[i][0] = dp[i-1][0]*(1-p[i-1]);
        for(int j=1;j<=n;j++)
        {
            if(i==1&&j==1) continue;
            dp[i][j] = dp[i-1][j-1]*p[i-1] + dp[i-1][j]*(1-p[i-1]);
        }
    }

    ld ans=0;
    /*for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=n;j++) cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/

    for(int i=(n/2)+1;i<=n;i++) ans+=dp[n][i];

    cout<<setprecision(10)<<ans<<endl;

    auto stopTime = curTime();
    auto duration = duration_cast<microseconds>(stopTime - startTime);
    //cout<<"Program ran for "<<(ld)duration.count()/1e6<<" "<<"seconds"<<endl;
}


Measured memory_bytes: 144216
fun main(args :Array<String>) {
    val (h, w, k) = readIntegerList()
    var count = 0
    val map = Array(h) { IntArray(w) { 0 } }
    for (i in 0 until h) {
        val tmp = readLine()!!.toCharArray()

        if (!(tmp.contains('#'))) {
            continue
        }

        count++
        var aa = false
        for (j in 0 until w) {
            map[i][j] = if (tmp[j] == '.') {
                count
            } else {
                if (aa) {
                    count++
                }
                aa = true
                count
            }
        }
    }

    // for (i in 0 until h) {
    //     val tmp = map[i].map(Int::toString).joinToString(" ")
    //     println(tmp)
    // }
    // println()

    for (i in 0 until h) {
        if (map[i][0] != 0) {
            var j = i - 1
            while (j >= 0 && map[j][0] == 0) {
                map[j] = map[i]
                j--
            }
        }
    }

    for (i in (h - 1) downTo 0) {
        if (map[i][0] != 0) {
            var j = i + 1
            while (j < h && map[j][0] == 0) {
                map[j] = map[i]
                j++
            }
        }
    }


    for (i in 0 until h) {
        val tmp = map[i].map(Int::toString).joinToString(" ")
        println(tmp)
    }
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)


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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


ll mod=1e9+7;
struct Matrix {
    vector<vector<long long> > val;
    Matrix(int n, int m, long long x = 0) : val(n, vector<long long>(m, x)) {}
    void init(int n, int m, long long x = 0) {val.assign(n, vector<long long>(m, x));}
    size_t size() const {return val.size();}
    inline vector<long long>& operator [] (int i) {return val[i];}
};
// O( n )
Matrix identity(int n) {
    Matrix A(n, n);
    for (int i = 0; i < n; ++i) A[i][i] = 1;
    return A;
}

// O( n^3 )
Matrix mul(Matrix A, Matrix B) {
    Matrix C(A.size(), B[0].size());
    for (int i = 0; i < (ll)C.size(); ++i)
        for (int j = 0; j < (ll)C[i].size(); ++j)
            for (int k = 0; k < (ll)A[i].size(); ++k)
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]%mod)%mod;
    return C;
}
// O( n^3 log e )
Matrix pow(Matrix A, ll e) {
    return e == 0 ? identity(A.size())  :
    e % 2 == 0 ? pow(mul(A, A), e/2) : mul(A, pow(A, e-1));
}

ostream &operator<<(ostream &os, Matrix &v) {
    os << "[";
    for (int i = 0; i < (ll)v.size(); i++){
        if (i > 0) os << endl << " ";
        os << "[";
        for (int j = 0; j < (ll)v[i].size(); os << v[i][j++])
            if (j > 0) os << " ";
        os << "]";
    }
    os << "]";
    return os;
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll L,A,B,M;cin>>L>>A>>B>>M;
  mod=M;
  ll X=0,s=A%mod;
  ll p10=1;
  for(ll d=1;d<=18&&L>0;d++){
    //debug(d);
    ll C=0;
    if(p10*10>A)C += (p10*10-1-A)/B+1;
    if(p10>A)C -= (p10-1-A)/B+1;
    //debug(C);
    Matrix Mat(3,3);
    Mat[0][0]=p10*10%mod;
    Mat[0][1]=1;
    Mat[1][1]=1;
    Mat[1][2]=B%mod;
    Mat[2][2]=1;
    Matrix D=pow(Mat,min(L,C));
    //cerr<<D<<endl;
    ll tmp=X*D[0][0]%mod+s*D[0][1]%mod+D[0][2];
    s=(X*D[1][0]%mod+s*D[1][1]%mod+D[1][2])%mod;
    X=tmp%mod;
    L-=C;
    //debug(X);
    //debug(s);
    p10*=10;
  }
  cout<<X<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int a, b;
    cin >> a >> b;
    cout << max( a + b , max(a - b , a * b)) << endl;

}

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

using namespace std;

int main()
{
    vector<int> vs;
    int x[3];

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

    sort(vs.begin(), vs.end());

    cout << vs[0] + vs[1] << endl;

    return 0;
}

Measured memory_bytes: 888
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    x,y,z=mi()
    print(x*y//2)



if __name__ == "__main__":
    main()

Measured memory_bytes: 61476
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] a){

		String str;
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

		try {
			str = bf.readLine();
			int count = Integer.parseInt(str);
			for(int i = 0; i < count; i++){
				str = bf.readLine();
				String[] arr = str.split(" ");
				int[] iArr = new int[]{Integer.parseInt(arr[0]),Integer.parseInt(arr[1]),Integer.parseInt(arr[2]),};
				Arrays.sort(iArr);
				String ans = "NO";
				if(Math.pow(iArr[0],2)+ Math.pow(iArr[1],2) == Math.pow(iArr[2],2)){
					ans = "YES";
				}
				System.out.println(ans);
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				bf.close();
			} catch (IOException e) {
			}
		}
	}
}

Measured memory_bytes: 10000
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,b,c=0,i;
cin>>n>>b;
int a[n];
for(i=0;i<n;i++)
{
cin>>a[i];
c=c+a[i];
}
if(c%(4*b)==0)
    c=c/(4*b);
else
    c=c/(4*b)+1;
for(i=0;i<n;i++)
{
if(a[i]>=c)
b--;
}
if(b<=0)
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,x;
  cin >> a>>b>>c>>d;
  x=a+b-c-d;
  if (x >0) {
    cout << "Left" << endl;
  }
  else if(x<0)
    cout << "Right" << endl;
  else
    cout << "Balanced" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n; cin>>n;
int cnt=0;
int a[n];
for(int i=0;i<n;++i) cin>>a[i];
for(int i=0;i<n;++i){
if(i){
 if(a[i]==a[i-1] && a[i-1]!=-1){ ++cnt; a[i]=-1; }
}
}
cout<<cnt<<endl;
return 0;
}


Measured memory_bytes: 256
for i in range(10**5):
    x,y = map(int,input().split())
    if x == 0 and y == 0:
        break
    else:
        ans = 0
        for i in range(1,x+1):
            for j in range(i+1,x+1):
                for k in range(j+1,x+1):
                    if i+j+k == y:
                        if i!=j!=k:
                            ans += 1
        print(ans)


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long int ll;
typedef vector< pair<int, int> > vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef pair<int, int> pii;

const ll INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;

int n, arr[nax], m;
int main()
{
    ios::sync_with_stdio(0);
    map<char, int> map1;
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            char ch; cin >> ch;
            map1[ch]++;
        }
    }
    if(n == 1 && m == 1)
    {
        cout << "Yes";
        return 0;
    }
    if(n == 1 || m == 1)
    {
        if(m == 1)
            swap(n, m);
        int twos = m / 2;
        int ones = m % 2;
        for(auto &x: map1)
        {
            while(twos && x.ss >= 2)
            {
                twos--;
                x.ss -= 2;
            }
        }
        for(auto &x: map1)
        {
            while(ones && x.ss >= 1)
            {
                ones--;
                x.ss -= 1;
            }
        }
        if(twos || ones)
            cout << "No";
        else
            cout << "Yes";
        return 0;
    }
    if(n % 2 == 0 && m % 2 == 0)
    {
        int fours = (n / 2) * (m / 2);
        for(auto &x: map1)
        {
            while(fours && x.ss >= 4)
            {
                fours--;
                x.ss -= 4;
            }
        }
        if(fours)
            cout << "No";
        else
            cout << "Yes";
        return 0;
    }
    if(n % 2 == 1 && m % 2 == 1)
    {
        int fours = (n / 2) * (m / 2);
        int twos = (n / 2) + (m / 2);
        int ones = 1;

        for(auto &x: map1)
        {
            while(fours && x.ss >= 4)
            {
                fours--;
                x.ss -= 4;
            }
        }
        for(auto &x: map1)
        {
            while(twos && x.ss >= 2)
            {
                twos--;
                x.ss -= 2;
            }
        }
        for(auto &x: map1)
        {
            while(ones && x.ss >= 1)
            {
                ones--;
                x.ss -= 1;
            }
        }
        if(fours || twos || ones)
            cout << "No";
        else
            cout << "Yes";
        return 0;
    }
    if(n % 2 == 1)
        swap(n, m);
        int fours = (n / 2) * (m / 2);
        int twos =  (n / 2);
        int ones = 0;

        for(auto &x: map1)
        {
            while(fours && x.ss >= 4)
            {
                fours--;
                x.ss -= 4;
            }
        }
        for(auto &x: map1)
        {
            while(twos && x.ss >= 2)
            {
                twos--;
                x.ss -= 2;
            }
        }
        for(auto &x: map1)
        {
            while(ones && x.ss >= 1)
            {
                ones--;
                x.ss -= 1;
            }
        }
        if(fours || twos || ones)
            cout << "No";
        else
            cout << "Yes";
    return 0;
}



Measured memory_bytes: 256
def Koyakusu(x, y):
    max = x if x > y else y
    min = x if x < y else y

    while max % min != 0:
        tmp = max % min
        max = min
        min = tmp
    
    return min


def maxKoyakusu(array):
    ans = array[0]
    for i in range(1, len(array)):
        ans = Koyakusu(ans, array[i])

    return ans


n, x = map(int, input().split())
a = [abs(int(i)-x) for i in input().split()]

print(maxKoyakusu(a))

Measured memory_bytes: 14224
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        BigInteger sum = BigInteger.ZERO;
        int tmpGcd;
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Map<String, Integer> tmpMap = new HashMap<>();
        for (int a = 1; a <= N; a++) {
            for (int b = 1; b <= N; b++) {
                for (int c = 1; c <= N; c++) {
                    tmpGcd = mygcd(a, b, tmpMap);
                    sum = sum.add(BigInteger.valueOf(mygcd(tmpGcd, c, tmpMap)));
                }
            }
        }
        System.out.println(sum);
    }

    public static int mygcd(int a, int b, Map<String, Integer> tmpMap) {
        if (a == b) {
            return a;
        }
        int tmpGcd;
        List<Integer> tmp = new ArrayList<Integer>();
        tmp.add(a);
        tmp.add(b);
        Collections.sort(tmp);
        String tmpStr = "" + tmp.get(0) + tmp.get(1);
        if (false && tmpMap.containsKey(tmpStr)) {
            tmpGcd = tmpMap.get(tmpStr);
        } else {
            tmpGcd = gcd(a, b);
            tmpMap.put(tmpStr, tmpGcd);
        }
        return tmpGcd;
    }

    public static int gcd(int num1, int num2) {
        if (num2 == 0)
            return num1;
        else
            return gcd(num2, num1 % num2);
    }

    public static int gcda(int a, int b) {
        int tmp, r;
        if (a < b) {
            tmp = a;
            a = b;
            b = tmp;
        }

        r = a % b;
        while (r != 0) {
            a = b;
            b = r;
            r = a % b;
        }
        return b;
    }

}

Measured memory_bytes: 67228
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
const ll INF = (ll)1e18 + 1;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n; cin >> n;
    int v[n],c[n];
    rep(i,n) cin >> v[i];
    rep(i,n) cin >> c[i];
    
    int ans = 0;
    
    rep(i,n) if(v[i]>c[i]) ans += v[i]-c[i];
    
    cout << ans << ln;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double PI=3.14159265358979323846;
ll dp;

int main(){
   ll n,k=2019,ans=0,a,b,c,d;
   string s;
   ll f[4000]={},f2[4000]={};

   cin>>s;

   rep(i,s.size()){
      rep(j,k){
         f2[((j*10)+(int)(s[i]-'0'))%k]+=f[j];
      }rep(j,k){
         f[j]=f2[j];
         f2[j]=0;
      }
      f[(int)(s[i]-'0')%k]++;
      ans+=f[0];
   }
   cout<<ans<<endl;;
}


Measured memory_bytes: 3788
N,T = map(int,input().split())
A = list(map(int,input().split()))
Ans = 0
for i in range(1,N):
    if A[i] > A[i-1]+T:
        Ans += T
    else:
        Ans += A[i] - A[i-1]
else:
    Ans += T
print(Ans)

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

int main(){
    ll A,B;
    cin >> A >> B;
    ll ans = 0;
    if (B - A <= 10){
        for (ll i = A; i <= B; i++){
            ans = ans ^ i;
        }
    }
    else{
        if (A % 4 == 1){
            ans = ans ^ A;
            ans = ans ^ (A + 1);
            ans = ans ^ (A + 2);
        }
        else if (A % 4 == 2){
            ans = ans ^ A;
            ans = ans ^ (A + 1);
        }
        else if (A % 4 == 3){
            ans = ans ^ A;
        }
        
        if (B % 4 == 0){
            ans = ans ^ B;
        }
        else if (B % 4 == 1){
            ans = ans ^ (B - 1);
            ans = ans ^ B;
        }
        else if (B % 4 == 2){
            ans = ans ^ (B - 2);
            ans = ans ^ (B - 1);
            ans = ans ^ B;
        }
    }
    cout << ans << endl;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int n; cin >> n;
  vector<int> u(n), k(n); 
  vector<vector<int>> v(n);
  REP(i, n) {
    cin >> u[i] >> k[i];
    REP(m, k[i]) {
      int p; cin >> p;
      v[i].push_back(p);
    }
  }

  vector<int> ans; ans.assign(n + 1, -1);
  queue<int> Q;
  Q.push(1); ans[Q.front()] = 0;
  while(!Q.empty()) {
    int i = Q.front();
    Q.pop();
    for(int m = 0; m < k[i - 1]; ++m) {
      if(ans[v[i - 1][m]] == -1) {
        Q.push(v[i - 1][m]);
        ans[v[i - 1][m]] = ans[i] + 1;
      }
    }
  }
  for(int i = 1; i < n + 1; ++i) {
    cout << i << " " << ans[i] << endl;
  }
}



Measured memory_bytes: 3168
#include<stdio.h>

int main()
{
  int N, i, j, v, k, array[100];

  scanf("%d", &N);

  for( i=0; i<N; i++ ) scanf("%d", &array[i]);

  

  for( i=1; i<N; i++ )
    {
      v = array[i];
      j = i - 1;

      for( k=0; k<N; k++ )
	{
	  printf("%d", array[k]);
	  if( k == N-1 )break;
	  printf(" ");
	}
	  
      printf("\n");
       
      while( j>=0 && array[j]>v )
	{
	  array[j+1] = array[j];
	  j--;
	  array[j+1] = v;
	}    
    }

  for( i=0; i<N; i++ )
    {
      printf("%d", array[i]);
      if( i == N-1 )break;
      printf(" ");
    }
  
  printf("\n");

  return 0;
}



  

  


  



Measured memory_bytes: 2144
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

struct UF{
  vi sz, p;
  int comps;

  UF(int s) : comps(s) {
    sz.resize(comps + 1);
    p.resize(comps + 1);
    init();
  }

  void init(){
    for(int i = 0; i <= comps; i++){
      sz[i] = 1;
      p[i] = i;
    }
  }

  int fset(int u){
    return u == p[u] ? u : p[u] = fset(p[u]);
  }

  bool connect(int u, int v){
    u = fset(u);
    v = fset(v);
    if(u != v){
      if(sz[v] > sz[u]){
        swap(u, v);
      }
      sz[u] += sz[v];
      p[v] = u;
      comps--;
      return true;
    }
    return false;
  }
};

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

  int n;
  cin >> n;
  vector <tuple<int, int, int>> v(n);
  for(int i = 0; i < n; i++){
    int a, b;
    cin >> a >> b;
    v[i] = make_tuple(a, b, i);
  }
  vector <tuple<int, int, int>> edg;
  sort(all(v));
  for(int i = 0; i < n - 1; i++){
    int w = abs(get<0>(v[i]) - get<0>(v[i + 1]));
    edg.emplace_back(w, get<2>(v[i]), get<2>(v[i + 1]));
  }
  sort(all(v), [](tuple<int, int, int> a, tuple<int, int, int> b){
    return (get<1>(a)) < (get<1>(b)); 
  });
  for(int i = 0; i < n - 1; i++){
    int w = abs(get<1>(v[i]) - get<1>(v[i + 1]));
    edg.emplace_back(w, get<2>(v[i]), get<2>(v[i + 1]));
  }
  sort(all(edg));
  UF uf(n);
  int res = 0;
  for(int i = 0; i < int(edg.size()); i++){
    if(uf.connect(get<1>(edg[i]), get<2>(edg[i]))){
      res += get<0>(edg[i]);
    } 
  }
  cout << res;
}

Measured memory_bytes: 6132
n = int(input())
s = input()
head = ""
depth = 0
for i in s:
    if i == "(":
        depth += 1
    else:
        if depth == 0:
            head += "("
        else:
            depth -= 1
tail = "".join([")" for _ in range(depth)])
print(head + s + tail)

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


void solve(long long N, long long M, long long X, std::vector<long long> A){
    vector<long long> masu(N+1, 0);
    for(auto i = 0; i < M; i++){
        masu[A[i]] = 1;
    }
    /*
    for(auto i : masu){
        cout << i << " ";
    }
    cout << endl;
    */
    int left = accumulate(masu.begin(), masu.begin()+X, 0);
    int right = accumulate(masu.begin()+X, masu.end(), 0);
    //cout << left << " " << right << endl;
    cout << min(left, right) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long X;
    scanf("%lld",&X);
    std::vector<long long> A(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, X, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int get_uint() {
  int n = 0;
  int c = getchar_unlocked();
  if(c < 48 || 57 < c) return c;
  while(47 < c && c < 58) {
    n = 10 * n + (c & 0xf);
    c = getchar_unlocked();
  }
  return n;
}
typedef struct Point {
  double x;
  double y;
} Point;
void koch(int n, Point left, Point right) {
  if(!n) return;
  Point s, u, t;
  const double THETA = M_PI / 3;
  s.x = (2 * left.x + right.x) / 3;
  s.y = (2 * left.y + right.y) / 3;
  t.x = (2 * right.x + left.x) / 3;
  t.y = (2 * right.y + left.y) / 3;
  u.x = (t.x - s.x) * cos(THETA) - (t.y - s.y) * sin(THETA) + s.x;
  u.y = (t.x - s.x) * sin(THETA) + (t.y - s.y) * cos(THETA) + s.y;
  koch(n-1, left, s);
  printf("%.5lf %.5lf\n", s.x, s.y);
  koch(n-1, s, u);
  printf("%.5lf %.5lf\n", u.x, u.y);
  koch(n-1, u, t);
  printf("%.5lf %.5lf\n", t.x, t.y);
  koch(n-1, t, right);
}
int main(int argc, char **argv) {
  int n = get_uint();
  printf("%.5lf %.5lf\n", 0.0, 0.0);
  koch(n, (Point){0, 0}, (Point){100, 0});
  printf("%.5lf %.5lf\n", 100.0, 0.0);
  return 0;
}



Measured memory_bytes: 2084
# coding: utf-8


def solve(*args: str) -> str:
    n, k, c = map(int, args[0].split())
    S = args[1]

    work = [s == 'o' for s in S]
    L = []
    R = []

    i = 0
    while i < n and len(L) < k:
        if work[i]:
            L.append(i+1)
            i += c+1
        else:
            i += 1

    i = n-1
    while 0 <= i and len(R) < k:
        if work[i]:
            R.append(i+1)
            i -= c+1
        else:
            i -= 1

    return '\n'.join(str(l) for l, r in zip(L, R[::-1]) if l == r)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 35180
loop do
    num=[]
    x=[]
    y=[]
    z=0
    s=gets.to_i
    break if (s==0)
    s.times do |i|
        x[i]=0
        num<<gets.chomp.split(nil).map(&:to_i)
        x[i]=num[i].inject(:+)
        z+=x[i]
    end
    s.times do |i|
        y[i]=0
        s.times do |j|
            y[i]+=num[j][i]
        end
    end
    s.times do |i|
        s.times do |j|
            printf("%5d",num[i][j])
        end
        printf("%5d\n",x[i])
    end
    s.times do |i|
        printf("%5d",y[i])
    end
    printf("%5d\n",z)
end

Measured memory_bytes: 6132
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
  string s, t;
  cin >> s >> t;

  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());

  string ans = "No";
  if (s < t) {
    ans = "Yes";
  }

  cout << ans << endl;

  return 0;
}


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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;
    vector<i64> a(n);
    for (auto& e : a) cin >> e;
    sort(begin(a), end(a));

    i64 h = n / 2;
    if (n % 2) {
        i64 can0 = 0;
        can0 -= 2 * accumulate(begin(a), begin(a) + h, 0l);
        can0 += 2 * accumulate(begin(a) + h, end(a), 0l) - a[h] - a[h + 1];
        i64 can1 = 0;
        can1 -= 2 * accumulate(begin(a), begin(a) + n - h, 0l) - a[h] - a[h - 1];
        can1 += 2 * accumulate(begin(a) + n - h, end(a), 0l);
        cout << max(can0, can1) << endl;
    } else {
        i64 ans = 0;
        ans -= 2 * accumulate(begin(a), begin(a) + h, 0l) - a[h - 1];
        ans += 2 * accumulate(begin(a) + h, end(a), 0l) - a[h];
        cout << ans << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


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

int main() {
  int h,w;
  cin>>h>>w;
  vector<vector<char>>image(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>image.at(i).at(j);
    }
  }
  vector<vector<char>>ans(h+2,vector<char>(w+2,'#'));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      ans.at(i+1).at(j+1)=image.at(i).at(j);
    }
  }
  for(int i=0;i<h+2;i++){
    for(int j=0;j<w+2;j++){
      cout<<ans.at(i).at(j);
      if(j==w+1){
        cout<<endl;
      }
    }
  }
}

Measured memory_bytes: 256
import numpy as np
N = input()
N = int(N)
V = input().split()
V = [int(V[i]) for i in range(N)]

V = np.array(V)

while len(V) >= 2:
  V = np.sort(V)
  new = (V[0] + V[1]) / 2
  V = np.hstack([V[2:], new])

print(V[0])

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;

ll divceil(ll x, ll y) {
    assert(y);
    return (x+y-1)/y;
}

void print(vector<ll> a) {
    for (ll x: a) cout<<x<<" ";
    cout<<endl;
}

ll n;
vector<ll> a;

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

    cin>>n;
    a.resize(n);
    for (int i=0; i<n; i++) {
	cin>>a[i];
    }

    ll iter = 0;

    while (*max_element(a.begin(),a.end()) > n-1) {
	for (int i=0; i<n; i++) {
	    if (a[i] >= n) {
		ll go = a[i]/n;
		a[i] %= n;
		iter += go;
		for (int j=0; j<n; j++) {
		    if (i==j) continue;
		    a[j] += go;
		}
	    }
	}
    }

    cout<<iter<<endl;    
    
    return 0;
}


Measured memory_bytes: 3664
//=====================================================================================================================================//
//Al_Qatil 
#include <bits/stdc++.h>
//g++ code.cpp -o /x
using namespace std;
#define ll long long
using ii=tuple<ll, ll>;
#define pb push_back
#define For(i,n) for(ll  i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(a,b,c) for(ll a=b;a<c;a++)
#define M 1000000007
#define vi vector<ll> 
#define vvi vector<vi>
#define int long long
#define rl(t) ll t;cin>>t;
#define rs(t) string t;cin>>t;

//=====================================================================================================================================//
//set <ll> :: iterator itr;
// if (b.find(a[i]) != b.end())
//Multiset
//multiset<int, greater<int>> h;
//auto it = h.lower_bound(x);
//if (it == h.end()) cout << "-1\n";
// priority queue .. queue in des order  :-> priority_queue<tuple<int, bool>> q;
const int N = 2e5 + 10, inf = 1e9 + 42;
//=====================================================================================================================================//
bool areEqual(int arr1[], int arr2[], int n, int m) 
{ 
    // If lengths of array are not equal means 
    // array are not equal 
    if (n != m) 
        return false; 
  
    // Sort both arrays 
    sort(arr1, arr1 + n); 
    sort(arr2, arr2 + m); 
  
    // Linearly compare elements 
    for (int i = 0; i < n; i++) 
        if (arr1[i] != arr2[i]) 
            return false; 
  
    // If all elements were same. 
    return true; 
} 
signed main() 
{   
    fast;
    ll n;
    cin>>n;
    ll a[n];
    For(i,n)cin>>a[i];
    ll val[n];
    val[0]=0;
    val[1]=abs(a[1]-a[0]);
    f(i,2,n)
    {
        val[i]=min(val[i-1]+abs(a[i]-a[i-1]),val[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<val[n-1]<<endl;
}

//======================================================================================================================================//

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

using namespace std;

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

    int N;
    cin >> N;
    int cand = ceil(N / 1.08);
    if ((int)(cand * 1.08) != N) {
        cout << ":(\n";
    } else {
        cout << cand << "\n";
    }

    return 0;
}

Measured memory_bytes: 256