akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = 0;
        int lower = sc.nextInt();
        int upper = sc.nextInt();
        for (int num = lower; num <= upper; num++) {
            if (String.valueOf(num).equals(new StringBuilder(String.valueOf(num)).reverse().toString())) {
                count++;
            }
        }
        System.out.println(count);
    }
    
}


Measured memory_bytes: 38484
// Basic module set for Programming Contest
import std.array, std.conv;
import std.stdio, std.string;
import std.range, std.random;
import std.algorithm;

void main()
{
	short[] mountHeight;
	foreach(i; 0 .. 10)
	{
		mountHeight ~= to!short(readln().chomp());
	}
	sort!("a > b")(mountHeight);
	writeln(to!(string[])(mountHeight[0..3]).join("\n"));
}

Measured memory_bytes: 1088
/********** BiSmIlLaHiR rAhMaNiR rAhIm ***********\
*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*
*$*                                             *$*
*$*    ||||||||  ||||||||  ||||||||  ||||||||   *$*
*$*    ||    ||  ||           ||     ||         *$*
*$*    ||||||||  ||||||||     ||     ||||||     *$*
*$*    ||    ||        ||     ||     ||         *$*
*$*    ||    ||  ||||||||  ||||||||  ||         *$*
*$*                                             *$*
*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*
\*************** DIIT(17th batch) ****************/
 
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define pf printf
#define sf scanf
#define fs first
#define ss second
#define endl "\n"
#define pb push_back
#define makep make_pair
#define MOD 1000000007
#define PI acos(-1.0)
#define PII pair<ll , ll>
#define ki_ase(x,y) cout<<x<<" "<<y<<endl;
#define SIZE 200000000
#define fio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
ll fx[]={1,0,-1,0,-1,-1,1,1};
ll fy[]={0,1,0,-1,-1,1,-1,1};

ll dp[1000006],a[1000006],n;
ll sol(ll i){
    //if(i == 0 or i == 1) return (ll)0;

    if(dp[i] != -1) return dp[i];

    ll p = abs(a[i]-a[i-1])+sol(i-1);
    ll q = abs(a[i]-a[i-2])+sol(i-2);
    dp[i] = min(p,q);
    return dp[i];
}

int main()
{
    fio();
    
    ll i,ans=0;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>a[i];
    }
    memset(dp,-1,sizeof(dp));
    dp[1]=0;
    dp[2]=abs(a[1]-a[2]);
    cout<<sol(n)<<endl;
    return 0;
}

Measured memory_bytes: 16924
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()
#define INF 1010101010

signed main() {
  int n,k;
  std::cin >> n >> k;
  std::vector<int> height(n);
  std::vector<int> dp(n+k,INF);
  rep(i,n) std::cin >> height[i];
  dp[0] = 0;
  rep(i,n) {
    rep(j,k) dp[i+j+1] = std::min(dp[i+j+1],dp[i] + std::abs(height[i]-height[i+j+1]));
  }
  print(dp[n-1]);
  return 0;
}

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

struct UnionFind{
    vector<int> par;
    UnionFind(int n): par(n, -1){}
    int root(int x){
        if(par[x]<0) return x;
        return par[x] = root(par[x]);
    }
    bool same(int a, int b){
        return root(a) == root(b);
    }

    bool unite(int a, int b){
        int x = root(a), y = root(b);
        if(x==y) return false;
        if(y<x) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    bool size(int x){
        return -par[root(x)];
    }

};


int main(){
    int n, m;   cin >> n >> m;
    vector<int> p(n);   UnionFind tree(n);
    for(int i=0; i<n; i++){
        int x;  cin >> x;
        p.at(i) = x-1;
    }
    for(int i=0; i<m; i++){
        int a, b;   cin >> a >> b;
        a--; b--;
        tree.unite(a, b);
    }
    int cnt=0;
    for(int i=0; i<n; i++){
        if(i==p.at(i)) cnt += 1;
        else if(tree.same(i, p.at(i))) cnt += 1;
    }
    cout << cnt << endl;

}




Measured memory_bytes: 1024
#include<stdio.h>
 
int main(){
   int x,y;
   scanf("%d%d",&x,&y);
  
   if(y % 2 == 0 && y >= 2 * x && y <= 4 * x) {
      printf("Yes\n");
   } else{
      printf("No\n");
   }
  return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(abs(a-c)<=d){
        printf("Yes");
    }else if(abs(a-b)<=d&&abs(b-c)<=d){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
// Date: 2020-03-30

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define D(x) cout << #x << " = " << x << endl;
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

VI g[4];
int sz[4];
LL suf[4][N], w[N];
int main() {
    FIO;
    int n;
    LL W;
    cin >> n >> W;
    rep(i, 1, n) {
        int v; cin >> w[i] >> v;
        g[w[i]-w[1]].pb(v);
    }
    rep(i, 0, 3) sort(all(g[i]));
    rep(i, 0, 3) sz[i] = g[i].size();
    rep(i, 0, 3) per(j, sz[i]-1, 0) suf[i][j] = suf[i][j+1] + g[i][j];
    LL ans = 0;
    rep(i, 0, sz[0]) rep(j, 0, sz[1]) rep(k, 0, sz[2]) rep(u, 0, sz[3]) {
        LL we = w[1]*i+(w[1]+1)*j+(w[1]+2)*k+(w[1]+3)*u;
        if(we <= W) chkmax(ans, suf[0][sz[0]-i]+suf[1][sz[1]-j]+suf[2][sz[2]-k]+suf[3][sz[3]-u]);
    }
    cout << ans;


    return 0;
}

Measured memory_bytes: 4352
n,m = map(int,input().split())
C = list(map(int,input().split()))
dp = [float('inf') for _ in range(n+1)]

for i in range(n+1):
    for c in C:
        if i + c  <= n:
            dp[i+c] = min(dp[i+c],dp[i]+1) if dp[i] != float('inf') else 1
print(dp[n])


Measured memory_bytes: 7392
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

ll L, R;

int main() {
    cin >> L >> R;

    int ans = 2019;

    if ((R-L)>2019) {
        cout << 0 << endl;
        return 0;
    }

    for(ll i = L; i < R; i++) {
        for(int j = i+1; j <= R; j++) {
            int t = (i * j) % 2019;
            ans = min(ans, t);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int INF=(int)1e9;
const int MOD=(int)1e9+7;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};



int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  int fy=ty-sy,fx=tx-sx;

  for(int t=0;t<fy;t++)cout<<'U';
  for(int t=0;t<fx;t++)cout<<'R';
  for(int t=0;t<fy;t++)cout<<'D';
  for(int t=0;t<fx;t++)cout<<'L';
  cout<<'L';
  for(int t=0;t<fy+1;t++)cout<<'U';
  for(int t=0;t<fx+1;t++)cout<<'R';
  cout<<'D'<<'R';
  for(int t=0;t<fy+1;t++)cout<<'D';
  for(int t=0;t<fx+1;t++)cout<<'L';
  cout<<'U'<<endl;

  return 0;
}


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

int main() {
  int N,K;cin>>N>>K;
  vector<long int> A(200000);
  for(int i=0;i<N;i++) cin>>A.at(i);
  for(int i=K;i<N;i++) {
    if(A.at(i-K)<A.at(i)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}


Measured memory_bytes: 4840
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
//#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
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;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e16;
typedef array<int, 3>arr3;
int readInt() {
	bool minus = false;
	int result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch - '0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result * 10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

bool dp[4005000];
int cum[2020];
int A[2020];
void solve() {
	int N; cin >> N;
	vector<int>A(N);
	REP(i, N) {
		A[i] = readInt();
		cum[i + 1] = cum[i] + A[i];
	}
	int mid = (cum[N] + 1) / 2;
	dp[0] = true;

	REP(i, N) {
		int mn = min(mid, cum[i]+1);
		REPR(j, mn) {
			dp[j + A[i]] |= dp[j];
		}
	}
	FOR(i, mid, cum[N] + 1) {
		if (dp[i]) {
			print(i); return;
		}
	}
}

signed main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
		solve();
}



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

int main() {
    int N;
    long long K;
    cin >> N >> K;
    long long num[100001] = {0};
    for(int i=0; i<N; ++i) {
        int a,b;
        cin >> a >> b;
        num[a] += b;
    }
    for(int i=1; i<=100000; ++i) {
        K -= num[i];
        if(K <= 0) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
N = gets.to_i

dp = []

for i in 0..N

    if i == 0

        dp[i] = 0

    elsif i < 6

        dp[i] = dp[i-1] + 1

    elsif 6 <= i && i < 9

        dp[i] = [dp[i-1]+1,dp[i-6]+1].min

    elsif 9 <= i && i < 36

        dp[i] = [dp[i-1]+1,dp[i-6]+1,dp[i-9]+1].min

    elsif 36 <= i && i < 81

        dp[i] = [dp[i-1]+1,dp[i-6]+1,dp[i-9]+1,dp[i-36]+1].min 

    elsif 81 <= i && i < 216

        dp[i] = [dp[i-1]+1,dp[i-6]+1,dp[i-9]+1,dp[i-36]+1,dp[i-81]+1].min
        
    elsif 216 <= i && i < 729

        dp[i] = [dp[i-1]+1,dp[i-6]+1,dp[i-9]+1,dp[i-36]+1,dp[i-81]+1,dp[i-216]+1].min

    elsif 729 <= i && i < 1296

        dp[i] = [dp[i-1]+1,dp[i-6]+1,dp[i-9]+1,dp[i-36]+1,dp[i-81]+1,dp[i-216]+1,dp[i-729]+1].min

    elsif 1296 <= i && i < 6561

        dp[i] = [dp[i-1]+1,dp[i-6]+1,dp[i-9]+1,dp[i-36]+1,dp[i-81]+1,dp[i-216]+1,dp[i-729]+1,dp[i-1296]+1].min

    elsif 6561 <= i && i < 7776

        dp[i] = [dp[i-1]+1,dp[i-6]+1,dp[i-9]+1,dp[i-36]+1,dp[i-81]+1,dp[i-216]+1,dp[i-729]+1,dp[i-1296]+1,dp[i-6561]+1].min

    elsif 7776 <= i && i < 46656

        dp[i] = [dp[i-1]+1,dp[i-6]+1,dp[i-9]+1,dp[i-36]+1,dp[i-81]+1,dp[i-216]+1,dp[i-729]+1,dp[i-1296]+1,dp[i-6561]+1,dp[i-7776]+1].min

    elsif 46656 <= i && i < 59049

        dp[i] = [dp[i-1]+1,dp[i-6]+1,dp[i-9]+1,dp[i-36]+1,dp[i-81]+1,dp[i-216]+1,dp[i-729]+1,dp[i-1296]+1,dp[i-6561]+1,dp[i-7776]+1,dp[i-46656]+1].min

    else

        dp[i] = [dp[i-1]+1,dp[i-6]+1,dp[i-9]+1,dp[i-36]+1,dp[i-81]+1,dp[i-216]+1,dp[i-729]+1,dp[i-1296]+1,dp[i-6561]+1,dp[i-7776]+1,dp[i-46656]+1,dp[i-59049]+1].min

    end

end

puts dp[N]

Measured memory_bytes: 3964
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
int n = 200005;
vector<int> a(n);
vector<vector<int>> tree(n,vector<int>());
vector<int> ans(n);
vector<int> dp(n,INF);
stack<int> stk;

void dfs(int i,int p=-1){
    auto itr = lower_bound(dp.begin(),dp.end(),a[i]);
    int before = *itr;
    *itr = a[i];
    ans[i] = lower_bound(dp.begin(),dp.end(),INF) - dp.begin();
    for(int c:tree[i]){
        if(c==p) continue;
        dfs(c,i);
    }
    *itr = before;
    return;
}

int main(){
    cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,n-1){
        int u,v;
        cin >> u >> v;
        --u;--v;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }
    dfs(0);
    rep(i,n){
        cout << ans[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 28008
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    vector<int> e;
    for(auto&i:a) cin>>i;
    fr(_,k){
        bool f=false;
        e.assign(n+1,0);
        fr(i,n){
            ++e[max(0,i-a[i])];
            --e[min(n,i+a[i]+1)];
        }
        a[0]=e[0];
        if(a[0]<n) f=true;
        Fr(i,n-1){
            a[i]=a[i-1]+e[i];
            if(a[i]<n) f=true;
        }
        if(!f) break;
    }
    for(auto&i:a) cout<<i<<" ";
    cout<<'\n';
}

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

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
//#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int n;
string x;

ll power(ll a, int b, ll mod){
    if(b == 0)return 1;
    ll pola = power(a,b / 2, mod);
    pola = pola * pola;
    pola %= mod;
    if(b%2 == 1)pola *= a;
    pola %= mod;
    return pola;
}

ll nadji(ll mod){
    ll st = 1;
    ll res = 0;
    fb(i,n - 1,0){
        res += (st * (x[i] - '0'));
        res %= mod;
        st *= 2;
        st %= mod;
    }
    return res;
}

int res[200005];
int resi(int a){
    if(a == 0)return 0;
    int st = 0;
    int pom = 0;
    while((1<<st) <= a){
        if((1<<st) & a)pom++;
        st++;
    }
    return 1 + resi(a%pom);
}

int main()
{

    //ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> x;
    int kol = 0;
    ff(i,0,n - 1){
        if(x[i] == '1')kol++;
    }
    int ost0 = 0;
    int ost1 = 0;
    int ost2 = 0;
    if(kol){
       ost0 = nadji(kol);
    }
    else ost0 = -1;
    if(kol - 1){
        ost1 = nadji(kol - 1);
    }
    else ost1 = -1;

    ost2 = nadji(kol + 1);

    ll st1 = 1;
    ll st2 = 1;
    if(kol == 1)st1 = 0;
    fb(i,n - 1,0){
        if(x[i] == '1'){
            if(kol == 1){
                st1 *= 2;
                st2 *= 2;
                st2 %= (kol + 1);
                if(kol-1)st1 %= (kol - 1);
                continue;
            }
            int ost = ost1 - st1;
            ost %= (kol - 1);
            if(ost < 0)ost += (kol - 1);
            res[i] = 1 + resi(ost);
        }
        else{
            int ost = ost2 + st2;
            ost %= (kol + 1);
            res[i] = 1 + resi(ost);
        }
        st1 *= 2;
        st2 *= 2;
        st2 %= (kol + 1);
        if(kol-1)st1 %= (kol - 1);

    }
    ff(i,0,n - 1){
        cout << res[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 4548
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <string.h>

void inserionSort(int A[], int N) {
	int i = 0;
	for (i = 1; i < N; i++) {
		int print_i = 0;
		for (; print_i < N; print_i++)
		{
			printf("%d", A[print_i]);
			if (print_i != N - 1) {
				printf(" ");
			}
		}
		printf("\n");

		int v = A[i];
		int j = i-1;
		while ( j>= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
	}
}

int main(void) {

	//int result[1001] = { 0 };

	int n = 0;

	scanf("%d", &n);

	int A[1001] = { 0 };

	int i = 0;
	for (i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	

	inserionSort(A, n);
	
	for (i = 0; i < n; i++)
	{
		printf("%d", A[i]);
		if (i != n - 1) {
			printf(" ");
		}
		
	}
	printf("\n");
	

	return 0;
}






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

int main()
{
    int scoreW[10];
    int scoreK[10];

    for (int i = 0; i < 10; i++){
        cin >> scoreW[i];
    }

    for (int i = 0; i < 10; i++){
        cin >> scoreK[i];
    }

    sort(scoreW, scoreW + 10);
    sort(scoreK, scoreK + 10);

    int Ksum = 0;
    int Wsum = 0;

    Wsum = scoreW[7] + scoreW[8] + scoreW[9];
    Ksum = scoreK[7] + scoreK[8] + scoreK[9];
    cout << Wsum << " " << Ksum << endl;

    return (0);
}

Measured memory_bytes: 3064
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main=do
    [n,x]<-map read.words<$>getLine
    print =<< f x 0.unfoldr (B.readInt.B.dropWhile(==' '))<$>B.getLine

f x !i [a,b] = max 0 (i+(a+b)-x)
f x !i (a:b:as)
    | a+b <= x = f x i (b:as)
    | a > x    = f x (i+a-x+b) (0:as)
    | True     = f x (i+a+b-x) ((x-a):as)


Measured memory_bytes: 4092
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  vector<string> S(N);
  cin >> S;

  string ans;
  rep(i, 0, N) {
    if (S[i] == "AB") {
      if (A == 0 && B == 0) {
        cout << "No" << endl;
        return 0;
      }
      bool take_a = A >= B;
      if (A == B && i < N - 1 && S[i + 1] == "AC") {
        take_a = false;
      }
      if (take_a) {
        A--;
        B++;
        ans += 'B';
      } else {
        B--;
        A++;
        ans += 'A';
      }
    } else if (S[i] == "BC") {
      if (B == 0 && C == 0) {
        cout << "No" << endl;
        return 0;
      }
      bool take_b = B >= C;
      if (B == C && i < N - 1 && S[i + 1] == "AB") {
        take_b = false;
      }
      if (take_b) {
        B--;
        C++;
        ans += 'C';
      } else {
        C--;
        B++;
        ans += 'B';
      }
    } else if (S[i] == "AC") {
      if (A == 0 && C == 0) {
        cout << "No" << endl;
        return 0;
      }
      bool take_a = A >= C;
      if (A == C && i < N - 1 && S[i + 1] == "AB") {
        take_a = false;
      }
      if (take_a) {
        A--;
        C++;
        ans += 'C';
      } else {
        C--;
        A++;
        ans += 'A';
      }
    }
  }

  cout << "Yes" << endl;
  for (char x : ans) cout << x << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 6672
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    int a[n+1];
    rep(i,n+1)cin >> a[i];
    ll ans = 0;
    ll s[n+1];
    s[n]=a[n];
    for(int i = n-1;i>=0;i--){
        s[i]=s[i+1]+a[i];
    }
    ll prev = 0;
    if(a[0]>1){
        cout << -1 << endl;
        return 0;
    }
    prev = 1;
    ll tot = 1;
    for(int i=1;i<=n;i++){
        if((prev-a[i-1])*2<a[i]){
            cout << -1 << endl;
            return 0;
        }
        ll now = min((prev-a[i-1])*2,s[i]);
        tot += now;
        prev = now;
        //cout << now << endl;
    }
    cout << tot << endl;
}

Measured memory_bytes: 4804
#include<iostream>
using namespace std;
int main()
{
int a,b,c,flag=0;
  cin>>a>>b>>c;
  
  if(a==b && b==c)
    flag=1;
  
  if((a==b || b==c ||c==a)&& flag==0)
    printf("Yes");
  else
    printf("No");
return 0;
}

Measured memory_bytes: 256
N = int(input())
a = [(s[0], int(s[1])) for s in input().split()]

def bubble(a):
    n = len(a)
    for i in range(n):
        for j in range(n-1, i, -1):
            if a[j][1] < a[j-1][1]:
                a[j], a[j-1] = a[j-1], a[j]
    return a

def selection(a):
    n = len(a)
    for i in range(n):
        minj = i
        for j in range(i+1, n):
            if a[j][1] < a[minj][1]:
                minj = j
        a[i], a[minj] = a[minj], a[i]

    return a

b_a = bubble(a[:])
s_a = selection(a[:])

print(" ".join([p[0]+str(p[1]) for p in b_a]))
print("Stable")
print(" ".join([p[0]+str(p[1]) for p in s_a]))
print("Stable" if b_a==s_a else "Not stable")

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

int main(void)
{
  int a, b;
  cin >> a >> b;
  int gap = abs(a - b);
  if(gap % 2 == 1)
    cout << "IMPOSSIBLE" << endl;
  else
    cout << abs((gap / 2) + min(a, b)) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)


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

Measured memory_bytes: 256
fun main(args: Array<String>) = println(run {
    val (a, b, c, d) = readLine()!!.split(" ").map { it.toInt() }
    val x = (c downTo 1 step b).count()
    val y = (a downTo 1 step d).count()
    if (x <= y) "Yes" else "No"

})


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

using namespace std;

typedef pair<int, int> ii;
#define x first
#define y second
ii con(char a){
	if(a == 'D') return {1, 0};
	if(a == 'U') return {-1, 0};
	if(a == 'R') return {0, 1};
	if(a == 'L') return {0, -1};
}
int h, w , n; 
ii sp;
string s, t;

void sub(int& a){
	a--; if(a < 0) a = 0;
} 
int main(){
	cin>>h>>w>>n;
	cin>>sp.x>>sp.y; 
	cin>>s>>t;
	bool won = false;
	//possible to reach top
	int vu = 0, vd = 0, hl = 0, hr = 0;
	for(int i = n-1; i >= 0; i--){
		//start with t[i]
		if(t[i] == 'L'){
			sub(hr);
		}else if(t[i] == 'R'){
			sub(hl);
		}else if(t[i] == 'U'){
			//down
			sub(vd);
		}else if(t[i] == 'D'){
			sub(vu);
		}
		
		if(s[i] == 'L')	{
			hl++;
		}else if(s[i] == 'R'){
			hr++;
		}else if(s[i] == 'U'){
			vu++;
		}else{
			vd++;
		}
		
		if(hl + hr == w){
			won = true;
			break;
		}
		if(vu + vd == h){
			won = true;
			break;
		}
	}
	if(won){
		cout<<"NO"<<endl;
	}else{
		if((sp.x <= vu || (h - sp.x+1) <= vd) || (sp.y <= hl || (w - sp.y+1) <= hr)){
			cout<<"NO"<<endl;
		}else{
			cout<<"YES"<<endl;
		}
	}
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	vi a(n);
	rep(i,0,n)cin >> a[i];
	sort(all(a));
	ll ans = 0;
	int lp = n - 1;
	int k = 1;
	--n;
	while(n){
		if(k){
			--n;	
			--k;
			ans += a[lp];
		}
		if(k == 0){
			--lp;
			k = 2;
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 4004
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A, B = get_ints

x = A + B
if x % 2 == 0
  puts x / 2
else
  puts 'IMPOSSIBLE'
end


Measured memory_bytes: 14428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

struct katana{ ll a,b,flag;};
bool comp(katana A,katana B){
    return A.b>B.b;
}

int main(){
    ll n,h;cin>>n>>h;
    katana k[n];
    ll maxi=-1;
    ll fa=-1;
    rep(i,0,n-1){
        cin>>k[i].a>>k[i].b;
        k[i].flag=i;
        if(maxi<k[i].a){
            maxi=k[i].a;
            fa=i;
        }else if(maxi==k[i].a){
            if(k[fa].b>k[i].b){
                fa=i;
            }
        }
    }
    ll ka,kb;
    ka=k[fa].a;
    kb=k[fa].b;
    k[fa].a=0;
    k[fa].b=0;
    sort(k,k+n,comp);
    /*rep(i,0,n-1){
        cout<<k[i].a<<' '<<k[i].b<<' '<<k[i].flag<<endl;
    }
    cout<<ka<<' '<<kb<<endl;*/
    
    ll i=0;
    ll ans=0;
    while(true){
        if(k[i].b<=ka){
            break;
        }
        if(h<=kb){
            ans++;
            h=0;
            break;
        }
        ans++;
        h-=k[i].b;
        i++;
        if(h<=0){
            break;
        }
    }
    if(h<=0){
        cout<<ans<<endl;
    }else{
        if(h<=kb){
            ans++;
            cout<<ans<<endl;
        }else{
            ans=ans+((h-kb-1)/ka)+2;
            cout<<ans<<endl;
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;

  vector<vector<Int> > ans(N, vector<Int>(N));
  for(Int i=0;i<N;i++)
    for(Int j=0;j<N;j++){
      if(i == j) continue;
      for(Int k=0;k<20;k++){
        Int x = i >> k & 1;
        Int y = j >> k & 1;
        pr(x, y, i, j);
        if(x != y) ans[i][j] = k + 1;
      }
    }

  for(Int i=0;i<N;i++){
    for(Int j=i+1;j<N;j++) cout<<ans[i][j]<<" ";
    cout<<endl;
  }


  return 0;
}


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

const int N = 2010;
char C[N][N];

int h, w;

struct UnionFind{
    vector<int> par;
    UnionFind(int N) : par(N){
        for(int i = 0; i < N; i++){
            par[i] = -1;
        }
    }
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        else{
            if(par[rx] > par[ry]) swap(rx, ry);
            par[rx] += par[ry];
            par[ry] = rx;
       }
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    void check(){
        for(auto x : par){
            cout << x << " ";
        }
        cout << endl;
    }
};

void dfs_h(UnionFind &uf){
    for(int i = 0; i < w; i++){
        for(int j = 0; j < h - 1; j++){
            if(C[j][i] == '#') continue;
            if(C[j + 1][i] == '#') continue;
            uf.unite(j * w + i, (j + 1) * w + i);
        }
    }
}

void dfs_w(UnionFind &uf){
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w - 1; j++){
            if(C[i][j] == '.' && C[i][j + 1] == '.'){
                uf.unite(i * w + j, i * w + j + 1);
            }
        }
    }
}

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

    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> C[i][j];
        }
    }

    UnionFind uf_h(h * w), uf_w(h * w);

    dfs_h(uf_h);
    dfs_w(uf_w);

    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(C[i][j] == '#') continue;
            int hs = -uf_h.par[uf_h.root(i * w + j)];
            int ws = -uf_w.par[uf_w.root(i * w + j)];
            ans = max(ans, hs + ws - 1);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 35456
#include<iostream>
#include<vector>
#include<string>
#include<cmath>

using namespace std;

int toInt(string S){
  int n=0;
  for(int i=0;i<S.length();i++){
    n+=(pow(10,S.length()-1-i))*(S[i]-'0');
  }
  return n;
}

int main(){
  int n;
  string S;
  vector<int> v;
  while(cin>>S){
    if(S[0]=='?'){
      break;
    }else if(S[0]=='+'||S[0]=='-'||S[0]=='*'){
      int sizeOfS=v.size(),x=0;
      //cout<<v[sizeOfS-2]<<" "<<v[sizeOfS]<<endl;
      if(S[0]=='+'){
        x=0;
      }else if(S[0]=='-'){
        x=1;
      }else{
        x=2;
      }
      switch (x){
        case 0:
          v[sizeOfS-2]=v[sizeOfS-2]+v[sizeOfS-1];
          v.pop_back();
          break;
        case 1:
          v[sizeOfS-2]=v[sizeOfS-2]-v[sizeOfS-1];
          v.pop_back();
          break;
        case 2:
          v[sizeOfS-2]=v[sizeOfS-2]*v[sizeOfS-1];
          v.pop_back();
          break;
      }
    }else{
      n=toInt(S);
      v.push_back(n);
    }
  }
  cout<<v[0]<<endl;
  return 0;
}



Measured memory_bytes: 3372
n, a, b = map(int,input().split())
s = input()

border = a + b
i, j = 1, 1
for p in s:
    flag = False
    if p == "a":
        if i <= a + b:
            flag = True
            i += 1
    elif p == "b":
        if i <= a + b and j <= b:
            flag = True
            i += 1
            j += 1
    if flag:
        print("Yes")
    else:
        print("No")

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

int main() {
  int n, a, y, z;
  cin >> n;
    y = 0;
  z = 30;// 10^9のため
  while (n > 0 ){
    cin >> a;
    y = 0;    
    while( a % 2 == 0){
          a = a / 2;
          y++;}
     if ( z > y){z = y;} 
    n = n - 1;
  }
  cout << z << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define ld long double
#define si(x) (ll)((x).size())
#define pb push_back
#define F first
#define S second
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>=1;i--)
#define all(x) (x).begin(), (x).end()
#define make_unique(x) (x).resize(unique(all(x))-(x).begin())
#define pr_vec(v) for(ll _=0;_<v.size();_++) cout << v[_] << " " ;
const int N = 1e6 + 7;
ll M = 1e9 + 7;
ll inf = 1e18;
void solve()
{
    ll n, m;
    cin >> n >> m;
    ll dp[n + 1][m + 1];
    memset(dp, 0, sizeof dp);
    dp[1][1] = 1;
    string s;
    for(ll i = 1; i <= n; i++)
    {
        cin >> s;
        for(ll j = 1; j <= m; j++)
            if(s[j - 1] != '#')
            {
                dp[i][j] = (dp[i][j] + dp[i - 1][j] + dp[i][j - 1]) % M;
                // cout << dp[i][j] << " ";
            }
            
    }
    cout << dp[n][m] % M;
}




int main()
{


    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t = 1;
    // cin >> t;


    rep1(i, t)
    {
        // cout << "Case #" << i << ": ";
        solve();
        cout << endl;
    }


}

Measured memory_bytes: 8064
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
        return len(self.roots())
 
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
 
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M, K = map(int, input().split())
G = UnionFind(N)

friends = {i:0 for i in range(N)}
for i in range(M):
    a, b = map(int, input().split())
    friends[a-1] += 1
    friends[b-1] += 1
    G.union(a-1, b-1)

# ブロック関係にあったら友達と考える
for i in range(K):
    c, d = map(int, input().split())
    if G.same(c-1, d-1):
        friends[c-1] += 1
        friends[d-1] += 1

for i in range(N):
    print(G.size(i) - friends[i] - 1, end=' ')


Measured memory_bytes: 104548
import math
N = int(input())
x = list(map(int, input().split()))
y = []
if N%2 == 0:
    for i in range(N//2):
        y.append(x[N-1-2*i])
    for i in range(N//2):
        y.append(x[2*i])
if N%2 == 1:
    for i in range(math.ceil(N/2)):
        y.append(x[N-1-2*i])
    for i in range(math.floor(N/2)):
        y.append(x[2*i+1])
print(*y)

Measured memory_bytes: 25156
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
#define int long long
signed main()
{
    int n;cin >>n ;
    if(n%2) cout << 2*n << endl;
    else cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>


#define ll long long
//#define int ll
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 2e5 + 1;

main(){
	string s;
	cin >> s;
	if(s == "Sunny")
		ret("Cloudy");
	if(s == "Cloudy")
		ret("Rainy");
	ret("Sunny");
		
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void)
{
    char S[3];
    scanf("%s", S);
    if (strstr(S, "RRR"))
    {
        printf("3\n");
    }
    else if (strstr(S, "RR"))
    {
        printf("2\n");
    }
    else if (strstr(S, "R"))
    {
        printf("1\n");
    }
    else
    {
        printf("0\n");
    }
    return 0;
}

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

int main()
{
    ll A, B; cin >> A >> B;
    cout << A*B - (A+B) + 1 << endl;

}


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N, D, Q;
int d[550000], q[550000];
int def[550000], con[550000];
bool ans[550000];

signed main() {
    cin >> N >> D;
    for (int i = 1; i <= N; i++)cin >> d[i];
    def[1] = D;
    for (int i = 2; i <= N; i++) {
        if (d[i - 1] <= 2 * def[i - 1])def[i] = abs(d[i - 1] - def[i - 1]);
        else def[i] = def[i - 1];
    }
    con[N] = 1;
    for (int i = N - 1; i > 0; i--) {
        if (2 * con[i + 1] > d[i + 1])con[i] = con[i + 1] + d[i + 1];
        else con[i] = con[i + 1];
    }

    cin >> Q;
    for (int i = 0; i < Q; i++)cin >> q[i];
    for (int i = 0; i < Q; i++) {
        if (con[q[i]] <= def[q[i]])cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

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

#define FOR(i,a,b) for(int (i) = (a);(i) < (int) (b);(i)++)
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
typedef long long LL;

int N,K;
bool num [10];

int main()
{
	scanf("%d%d",&N,&K);
	FOR(i,0,K){
		int D;
		scanf("%d",&D);
		num [D] = true;
	}

	FOR(i,N,100000){
		string s = to_string(i);
		bool flag = true;
		FOR(j,0,s.size()){
			if(num [s [j] - '0'] == true){
				flag = false;
				break;
			}
		}
		if(flag == true){
			printf("%d\n",i);
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>
#include <cmath>
#include <iomanip>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////
int N, M, Q;
vector<int> A, B, C, D;

int buf[12];

int bst;

void Rec (int pos, int l) {
    if (pos == N) {
        int cur = 0;
        for (int i = 0; i < Q; i++) {
            if (buf[ B[i] ] - buf[ A[i] ] == C[i]) {
                cur += D[i];
            }
        }
        
        bst = max(cur, bst);
        return;
    }
    for (int i = l; i <= M; i++) {
        buf[pos] = i;
        Rec(pos + 1, i);
    }
}

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

    cin >> N >> M >> Q;
    A.resize(Q);
    B.resize(Q);
    C.resize(Q);
    D.resize(Q);

    for (int i = 0; i < Q; i++) {
        cin >> A[i] >> B[i] >> C[i] >> D[i];
        A[i]--, B[i]--;
    }

    Rec(0, 1);

    cout << bst << "\n";

    return 0;
}


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

using namespace std;
long long int dp[3005][3005];
string s,t;
long long int LCS(long long int m, long long int n){
  if(m==0 || n==0){
    return 0;
  }
  if(dp[m][n]==-1){
    if(s[m-1]==t[n-1]){
      dp[m][n] = 1 + LCS(m-1,n-1);
    }
    else{
      dp[m][n] = max(LCS(m,n-1),LCS(m-1,n));
    }
  }
  return dp[m][n];
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int i,j,m,n;
  cin>>s>>t;
  for(i=0;i<3005;i++){
    for(j=0;j<3005;j++){
      if(i==0 || j==0){
        dp[i][j] = 0;
      }
      else{
        dp[i][j] = -1;
      }
    }
  }
  m = s.size();
  n = t.size();
  dp[m][n] = LCS(m,n);
  // cout<<dp[m][n]<<endl;
  long long int index = dp[m][n];
  string ans;
  i = m,j = n;
  while(i > 0 && j > 0){
    if(s[i-1]==t[j-1]){
      ans.push_back(s[i-1]);
      i--;
      j--;
      index--;
    }
    else if(dp[i-1][j] > dp[i][j-1]){
      i--;
    }
    else{
      j--;
    }
  }
  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 71040
#include<stdio.h>
int a[1000000], b[1000000], n, j;

int  solve(int i, int m){
    if( m == b[j]){
        return 1;
    }
    else if(i >= n){
        return 0;
    }
    return solve(i + 1, m) || solve(i + 1, m + a[i]) ;
}

int main(){
   int d, i, count;
   count = 0;
   
   scanf("%d", &n);
   for (i = 0; i < n; i++){
      scanf("%d", &a[i]);
   }
   scanf("%d", &d);
   for(j = 0; j < d; j++){
      scanf("%d", &b[j]);
      if(solve(0,0))
          printf("yes\n");
      else
          printf("no\n");
   }

        
    
    return 0;
}



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

int main() {
        int s[101][101], r, c, i, j;
        cin >> r >> c;
        for (i = 0; i < r + 1; i++) {
                for (j = 0; j < c + 1; j++) {
                        s[i][j] = 0;
                }
        }
        for (i = 0; i < r; i++) {
                for (j = 0; j < c; j++) {
                        cin >> s[i][j];
                }
        }
        for (i = 0; i < r; i++) {
                for (j = 0; j < c; j++) {
                        s[i][c] += s[i][j];
                }
        }
        for (i = 0; i < r; i++) {
                for (j = 0; j < c; j++) {
                        s[r][j] += s[i][j];
                }
        }
        for (i = 0; i < r; i++) {
                s[r][c] += s[i][c];
        }
        for (i = 0; i < r + 1; i++) {
                for (j = 0; j < c + 1; j++) {
                        cout << s[i][j];
                        if (j != c) cout << " ";
                        else cout << endl;
                }
        }
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=305,mod=998244353;
int n,p[2][N];
char s[N];
int dp[N][N][N];
bool f[N][N][N];
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=1;i<=n;i++) p[0][i]=p[0][i-1]+(s[i]=='0'),p[1][i]=p[1][i-1]+(s[i]=='1');
    f[0][0][0]=true;
    for(int k=0;k<=n;k++)
        for(int i=0;i<=p[0][k];i++)
            for(int j=0;j<=p[1][k];j++)
    {
        if(!f[k][i][j]) continue;
        f[k+1][i][j]=true;
        if(i&&s[k+1]=='1')
            f[k+1][i-1][j+1]=true;
        if(j&&s[k+1]=='0')
            f[k+1][i+1][j-1]=true;
        if(k+2<=n&&(s[k+1]=='1'||s[k+2]=='1'))
            f[k+2][i][j+1]=true;
        if(k+2<=n&&(s[k+1]=='0'||s[k+2]=='0'))
            f[k+2][i+1][j]=true;
    }
    dp[n+1][0][0]=1;
    ll ans=0;
    for(int k=n+1;k>=1;k--)
        for(int i=0;i<=n;i++)
        for(int j=0;j<=n;j++)
    {
        if(dp[k][i][j]==0) continue;
        if(f[k-1][i][j])
            ans=(ans+dp[k][i][j])%mod;
        if(k>1)
        {
            dp[k-1][i][j]=(dp[k-1][i][j]+dp[k][i][j])%mod;
            if(s[k-1]=='1')
                dp[k][i+1][j]=(dp[k][i+1][j]+dp[k][i][j])%mod;
            else dp[k][i][j+1]=(dp[k][i][j+1]+dp[k][i][j])%mod;
        }
    }
    ans=(ans+mod-1)%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 120812