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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}
struct Edge{
  int to;
  long long cost;
};
struct NODE{
  int pos;
  long long cost;
};
bool operator < (const NODE &a,const NODE &b){
  return a.cost > b.cost;
}
class dijkstra{
  public:
  const int MAX_V = 1000000;
  vector<Edge> g[100000],rg[100000];
  bool visit[100000];

  int N;
  const ll INF = 1e15;
  dijkstra(){};
  dijkstra(int n):N(n){};
  vector<ll> shorter_path(int s){
    priority_queue<NODE> Q;
    Q.push({s,0});
    vector<ll> res(N,INF);
    while(Q.size()){
      NODE q= Q.top();Q.pop();
      if(res[q.pos] == INF){
        res[q.pos] = q.cost;
      }
      else{
        continue;
      }
      for(auto n : g[q.pos]){
        Q.push({n.to,q.cost+n.cost});
      }
    }
    return res;
  }
  void push(int p,int to,int c){
    g[p].push_back({to,c});
    rg[to].push_back({p,c});
  }
  deque<ll> Topological_sort(){
    deque<ll> res;
    rep(i,N){
      dfs(res,i);
    }
    return res;
  }
  void dfs(deque<ll> &res,int k){
    if(!visit[k]){
      visit[k] = true;
      for (auto&& nxt : g[k]) {
        dfs(res,nxt.to);
      }
      res.emplace_front(k);
    }
  }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll v,e,a,b;
  cin >> v >> e;
  dijkstra d(v);
  rep(i,e){
    cin >> a >> b;
    d.push(a,b,0);
  }
  auto res = d.Topological_sort();
  for (auto&& n : res) {
    std::cout << n << std::endl;
  }
  return 0;
}

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

using namespace std;

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

#define INF INT_MAX / 2 - 1
#define PI 2*acos(0.0)
#define ll long long

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

int main() {
	int n;
	cin >> n;
	cout << (int)(n * 800 - (n / 15) * 200) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <vector>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  if(b/a>=c){
    cout<<c<<"\n";
  }
  else{
    cout<<b/a<<"\n";
  }
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <vector>
#include <climits>
#include <algorithm>
 
using namespace std;
 
class RMQ
{
    int n;
    vector<int> dat;
public:
    RMQ(int n_)
    {
        n = 1;
        while (n < n_)
        {
            n *= 2;
        }
        dat.resize(2 * n - 1);
        for (int i = 0; i < 2 * n - 1; ++i)
        {
            dat[i] = INT_MAX;
        }
    }
    void update(int k, int a)
    {
        k += n - 1;
        dat[k] = a;
        while (k > 0)
        {
            k = (k - 1) / 2;
            dat[k] = min(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }
    int query(int a, int b, int k = 0, int l = 0, int r = 0)
    {
        if (r <= l)
        {
            r = n;
        }
        if (r <= a || b <= l)
        {
            return(INT_MAX);
        }
        if (a <= l && r <= b)
        {
            return(dat[k]);
        }
        int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return(min(vl, vr));
    }
};
 
void solve()
{
    int n, q;
    cin >> n >> q;
    RMQ r(n);
    for (int i = 0; i < q; ++i)
    {
        int com, x, y;
        scanf("%d%d%d", &com, &x, &y);
//      cin >> com >> x >> y;
        if (com == 0)
        {
            r.update(x, y);
        }
        else
        {
            printf("%d\n", r.query(x, y + 1));
//          cout << r.query(x, y + 1) << endl;
        }
    }
}
 
int main()
{
    solve();
    return(0);
}


Measured memory_bytes: 3796
// #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <numeric>
#include <cmath>
#include <map>
#include <set> 

#define rep(i,n) for (int i = 0; i < n; ++i)
#define repr(i,n) for (int i = n; i > 0; --i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MAX = 100;
const int INF = (1<<12);

int main() {
  ll H;
  cin >> H;
  ll sum = 0;
  ll cur_monsters = 1;

  while (H > 0)
  {
    H /= 2;
    sum += cur_monsters;
    cur_monsters *= 2;
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3160
#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 <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n), sum(n + 1);
    rep (i, n) {
        cin >> a[i];
        sum[i + 1] = sum[i] + a[i];
    }
    ll ans = (ll)1e18;
    rep (i, 2, n - 1) {
        ll m, M;
        int ok = 0, ng = i;
        while (ng - ok > 1) {
            int med = (ng + ok) / 2;
            (sum[med] <= sum[i] / 2 ? ok : ng) = med; 
        }
        ll lo = sum[ok], ro = sum[i] - sum[ok];
        ll ln = sum[ng], rn = sum[i] - sum[ng];
        m = max(lo, rn);
        M = min(ro, ln);
        // eprintf("%d : %d %d -> %lld %lld, ", i, ok, ng, M, m);
        eprintf("(%lld,%lld) (%lld,%lld) => %lld,%lld : ", lo, ro, ln, rn, m, M);

        ok = i, ng = n;
        while (ng - ok > 1) {
            int med = (ng + ok) / 2;
            (sum[med] <= (sum[i] + sum[n]) / 2 ? ok : ng) = med; 
        }
        lo = sum[ok] - sum[i], ro = sum[n] - sum[ok];
        ln = sum[ng] - sum[i], rn = sum[n] - sum[ng];
        chmin(m, max(lo, rn));
        chmax(M, min(ro, ln));
        // eprintf("%d %d -> %lld %lld\n", ok, ng, M, m);
        eprintf("(%lld,%lld) (%lld,%lld) => %lld,%lld\n", lo, ro, ln, rn, m, M);

        chmin(ans, M - m);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 6336
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
const int MAXN=5e5+10;
const double eps=1e-8;
const int MOD=1000000007;
using namespace std;
typedef  long long ll;
string str[100005];
int main()
{
    ll n,sum=1,ans=0;;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>str[i];
        sort(str[i].begin(),str[i].end());
    }
    sort(str,str+n);
    for(int i=1;i<n;i++)
    {
        //cout<<str[i]<<endl;
        if(str[i]==str[i-1])
            sum++;
        else
        {
            ans+=sum*(sum-1)/2;
            sum=1;
        }
    }
    ans+=sum*(sum-1)/2;
    cout<<ans<<endl;
    return 0;
}



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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/01/06  Problem: EDU_DP R / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

template<typename T>
vector<vector<T>> mul(vector<vector<T>> &A, vector<vector<T>> &B) {
	vector<vector<T>> C(A.size(), vector<T>(B[0].size()));
	FOR(i, 0, (int)A.size()) {
		FOR(k, 0, (int)B.size()) {
			if (A[i][k]) {
				FOR(j, 0, (int)B[0].size()) {
					C[i][j] = (C[i][j] + (A[i][k]) * (B[k][j])) % MOD;
				}
			}
		}
	}
	return C;
}

//a^N べき乗法 logN
template<typename T>
vector<vector<T>> pow(vector<vector<T>> A, long long n) {
	vector<vector<T>> B((int)A.size(), vector<T>((int)A.size()));
	FOR(i, 0, (int)A.size()) {
		B[i][i] = 1;
	}
	while (n > 0) {
		if (n & 1) B = mul(B, A);
		A = mul(A, A);
		n >>= 1;
	}
	return B;
}

LL ans = 0LL;

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


	LL N, K; cin >> N >> K;
	VVL a(N, VL(N));
	FOR(i, 0, N) {
		FOR(j, 0, N) {
			cin >> a[i][j];
		}
	}
	auto res = pow(a, K);
	FOR(i, 0, N) {
		FOR(j, 0, N) {
			ans += res[i][j];
			ans %= MOD;
		}
	}
	
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#define int long long
using namespace std;
int n,L,R,a[100100],ans1,ans2,cnt1,cnt2;
bool cmp(int a,int b){return a>b;}
int C[55][55];
void init(){
	C[0][0]=1;
	for(int i=1;i<=50;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++)
		C[i][j]=C[i-1][j]+C[i-1][j-1];
	}
//	for(int i=0;i<=10;i++,puts(""))
//	for(int j=0;j<=i;j++) cout<<C[i][j]<<" ";
}
signed main(){
	init();
	cin>>n>>L>>R;
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=L;i++) ans1+=a[i];
	for(int i=1;i<=n;i++) if(a[i]==a[L]) cnt1++;
	for(int i=1;i<=L;i++) if(a[i]==a[L]) cnt2++;
	if(a[1]==a[L])
		for(int i=L;i<=R;i++) ans2+=C[cnt1][i];
	else ans2=C[cnt1][cnt2];
	printf("%lf\n%lld",(double)ans1/L,ans2);
}
/*
5 2 2
1 2 3 4 5
4.500000
1

4 2 3
10 20 10 10
15.000000
3

5 1 5
1000000000000000 999999999999999 999999999999998 999999999999997 999999999999996
1000000000000000.000000
1

50 1 50
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1.000000
1125899906842623
*/

Measured memory_bytes: 256
#include <stdio.h>
   
int main()
{
    int a, b, d, r;
    double f;
   
    scanf("%d %d\n", &a, &b);
   
    d = a / b;
    r = a % b;
    f = (double) a / b;
   
    printf("%d %d %.8lf\n", d, r, f);
   
    return 0 ;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

void solve() {
    int n, k;
    cin >> n >> k;

    vector<int> v(n);
    map<int, int> mp;
    for (int i = 0; i < n; i++)
        cin >> v[i];
    int ct = 0, ans = n + 10;
    for (int j = 0, i = 0; i < n and j < n; i++) {
        mp[v[i]]++;
        if (mp[v[i]] == 1 and v[i] <= k)
            ct++;
        while (ct >= k and j < n and (mp[v[j]] - 1 >= 1 or v[j] > k) and j < i) {
            mp[v[j]]--;
            j++;
        }
        if (ct >= k)
            ans = min(ans, i - j + 1);
    }
    if (ans == n + 10)
        ans = 0;
    cout << ans << endl;
}

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

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 9960
#include <stdio.h>

int main(void){
	int kin;
	int mai;
	int otsu;
	
	while(1){
		scanf("%d",&kin);
		if(kin == 0) break;
		otsu = 1000 - kin;
		if(otsu / 100 > 4){
			mai = 1 + otsu / 100 - 5;
			otsu -= otsu / 100 * 100;
		}else{
			mai = otsu / 100;
			otsu -= otsu / 100 * 100;
		}
		if(otsu / 10 > 4){
			mai += 1 + otsu / 10 - 5;
			otsu -= otsu/ 10 * 10;
		}else{
			mai += otsu / 10;
			otsu -= otsu/10 * 10;
		}
		if(otsu > 4){
			mai += 1 + otsu - 5;
		}else{
			mai += otsu;
		}
		printf("%d\n",mai);
		mai = 0;
	}
	return 0;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n;cin >> n;

    cout << "Christmas";
    REP(i,25-n)
    cout <<" "<<"Eve";
    cout <<"\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int att(ll H) {
	if (H == 1) {
		return 1;
	}
	else {
		return (2 * att(H / 2) + 1);
	}
}



int main() {

	ll H, min ,an=1;
	cin >> H;
	cin >> min;
	rep(i, H - 1) {
		ll p;
		cin >> p;
		if (p <= min) {
			an++;
			min = p;
		}

	}
	cout <<an << endl;
}





Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int N=sc.nextInt(), K=sc.nextInt();
    int h[] = new int[N];
    for(int j=0; j<N; j++) {
      h[j] = sc.nextInt();
    }
    Arrays.sort(h);
    int min = h[N-1] - h[0];
    for(int i=0; i<N-K+1; i++) {
      int s = h[i+K-1] - h[i];
      if(min>s) {
        min = s;
      }
    }
    System.out.println(min);
  }
}

Measured memory_bytes: 50800
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	s, _ := r.ReadString('\n')
	s = strings.TrimRight(s, " \t\n")
	slice := strings.Split(s, " ")
	a := string(slice[0])
	b := string(slice[1])
	A, _ := strconv.Atoi(a)
	B, _ := strconv.Atoi(b)

	for i := 1; i <= 3; i++ {
		if A*B*i%2 == 1 {
			fmt.Println("Yes")
			os.Exit(0)
		}
	}
	fmt.Println("No")
	os.Exit(0)

}


Measured memory_bytes: 1772
<?php
$n = (int)trim(fgets(STDIN));
$a = explode(' ', trim(fgets(STDIN)));

$max = 0;
$min = 1000000001;
for ($i = 0; $i < $n; $i++) {
    if ((int)$a[$i] > $max) {
        $max = (int)$a[$i];
    }

    if ((int)$a[$i] < $min) {
        $min = (int)$a[$i];
    }
}

echo abs($max - $min) . PHP_EOL;

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

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

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        string s;
        cin >> s;
        int ans = 0;
        for (int i = 0; i < 3; i++) {
                int cnt = 0;
                while (s[i] == 'R') {
                        ++cnt;
                        ++i;
                }
                ans = max(ans, cnt);
//                --i;
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3520
// #define CPP_IO

#pragma region

#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
template <typename T>
using minheap = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using maxheap = priority_queue<T>;

#define f first
#define s second

#ifdef LOCAL
#define debug cout
#define debugf(format, ...) printf(format, ##__VA_ARGS__)
#else
#define debug \
    if (0) cout
#define debugf(format, ...) 42
#endif

#define DUMP(a) debug << #a " = " << (a) << "\n";
#define DUMP2(a, b) debug << #a " = " << (a) << " " #b " = " << (b) << "\n";
#define DUMP3(a, b, c) debug << #a " = " << (a) << " " #b " = " << (b) << " " #c " = " << (c) << "\n";
#define DUMP4(a, b, c, d) debug << #a " = " << (a) << " " #b " = " << (b) << " " #c " = " << (c) << " " #d " = " << (d) << "\n";

template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[ ";
    for (auto e : v) os << e << " ";
    return os << "]";
}

template <typename T, typename V>
ostream& operator<<(ostream& os, set<T, V> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V, typename S>
ostream& operator<<(ostream& os, map<T, V, S> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V>
ostream& operator<<(ostream& os, pair<T, V> x) {
    return os << "( " << x.first << ", " << x.second << " )";
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& e : v) is >> e;
    return is;
}

template <typename T, typename V>
istream& operator>>(istream& is, pair<T, V>& x) {
    return is >> x.first >> x.second;
}

void solve();

int main() {
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#else
#ifdef CPP_IO
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
#endif
    solve();
}

#pragma endregion

void solve() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int numcomps = 0;
    for (int i = 0; i < n; ++i) {
        if (i + 1 < n) {
            if (s[i + 1] != s[i]) {
                ++numcomps;
            }
        } else {
            ++numcomps;
        }
    }

    if (numcomps <= 2) {
        cout << n - 1 << "\n";
        return;
    }

    cout << n - max(numcomps - 2 * k, 1) << "\n";
}

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  string ans = "No";
  if ((a == b && a != c) || (a == c && a != b) || (b == c && b != a))
    ans = "Yes";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#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()
#define ll long long
#define INF 1000000000000000000

int N, Q;
vector<vector<int>> G(N, vector<int>());

void dfs(int s, vector<int> &counter, vector<bool> &seen) {
    seen[s] = true;
    for (auto ns : G[s]) {
        if (seen[ns])
            continue;
        counter[ns] += counter[s];
        dfs(ns, counter, seen);
    }
}

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

    cin >> N >> Q;
    G.resize(N, vector<int>());

    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> counter(N, 0);
    vector<bool> seen(N, false);
    rep(i, Q) {
        int a, b;
        cin >> a >> b;
        a--;
        counter[a] += b;
    }

    dfs(0, counter, seen);

    rep(i, N) { cout << counter[i] << " "; }
    cout << endl;
}

Measured memory_bytes: 26624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio() ios_base::sync_with_stdio(false);
#define rmod(x, y) ((((x)%(y))+(y))%(y))
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
template<typename T, typename R = null_type, typename C = less<T>>
tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update> ordered_set(){
	return tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update>();
}

const int maxn = 1e5+5;
int n, x, a[maxn];

int main(){
	scanf("%d %d", &n, &x);
	ll ans = 0;
	for(int i = 0; i<n; i++)
		scanf("%d", &a[i]), ans+=ll(max(0,a[i]-x)), a[i] = min(a[i], x);
	for(int i = 1; i<n; i++){
		int aux = a[i-1]+a[i];
		if(aux>x) ans+= ll (aux-x), a[i]-= aux-x;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
 
int main() {
  std::string s, a, b;
  std::cin >> s;
  
  int N = s.length();
  a = s.substr(0, (N-1)/2);
  b = s.substr((N+3)/2-1);
  
  int A = a.length();
  int B = b.length();
  bool k = true;
  
  for (int i = 0; i < a.length(); i++) {
    if (a[i] != a[A-i-1]) k = false;
  }
  for (int i = 0; i < b.length(); i++) {
    if (b[i] != b[B-i-1]) k = false;
  }
  
  if (a != b) k = false;
  
  if (k) {
  	std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

int main()
{
    int n;
    cin >> n;

    vector<int> a(n);

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

    for (int i = 0; i < n; i++)
    {
        cout << (res ^ a[i]);
        if (i == n - 1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

Measured memory_bytes: 4048
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

0.upto(n-1) do |i|
    a[i] -= (i+1)
end
a.sort!

m = a[n/2]

ans = 0
0.upto(n-1) do |i|
    ans += (a[i] - m).abs
end

puts ans

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

int main(){
    int a[5];

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

    if (a[0] >= (a[2] + a[4]) && a[2] >= a[4] && a[3] >= a[4] && a[1] >= (a[3] + a[4])) {
        cout << "Yes" << endl;
    }

    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
// https://atcoder.jp/contests/abc155/tasks/abc155_e

#include <bits/stdc++.h>
using namespace std;
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n' 
#define int long long

const int maxl = 1000500;
const int INF = LLONG_MAX-500;

int pre[2];
int dp[2];

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

    string s;
    cin >> s;

    reverse(s.begin(), s.end());
    s += "0";

    pre[1] = INF;

    for(int i = 0; i < s.size(); i++) {
        int need = s[i]-'0';
        dp[0] = min(pre[0]+need, pre[1]+need+1);
        dp[1] = min(pre[0]+(10-need), pre[1]+(9-need));

        for(int i = 0; i <= 1; i++) {
            pre[i] = dp[i];
        }
    }

    cout << dp[0] << endl;
}


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

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int n,k;
V<bool> d;
V<int> dd;

int main(){
    INIT;
    cin >> n; cin >> k;
    d.resize(10, true);
    REP(i,k) {
        int x; cin >> x; d[x] = false;
    }

    for(int i = n; to_string(i).size() <= to_string(n).size(); i++) {
        string s = to_string(i);
        bool ok = true;
        REP(j,s.size()) {
            int x = s[j] - '0';
            if(!d[x]) ok = false;
        }
        if(ok) {
            cout << s << "\n";
            return 0;
        }
    }

    REP(i,10) if(d[i]) dd.push_back(i);

    string s = to_string((dd[0] == 0) ? dd[1] : dd[0]);
    REP(i,to_string(n).size()) s += to_string(dd[0]);
    cout << s << "\n";

}

Measured memory_bytes: 256
import itertools, collections
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
C = list(itertools.accumulate([0] + A))
D = [(v - i) % K for i, v in enumerate(C)]
#D[i]==D[j] and i-j<K
dp = collections.Counter(D[:K])
ans = 0
for i in range(N):
    dp[D[i]] -= 1
    ans += dp[D[i]]
    if i + K < len(D):
        dp[D[i + K]] += 1
print(ans)


Measured memory_bytes: 119580
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		long sum = 0;
		for (int i = 0; i < n; i++) {
			a[i]=sc.nextInt();
			sum += a[i];
		}
		int max = a[0];
		int min = a[0];
		for (int i = 1; i < n; i++) {
			if (max > a[i])
				max = a[i];
			if (min < a[i])
				min = a[i];
		}
		System.out.println(max+" "+min+" "+sum);

		sc.close();
	}
}



Measured memory_bytes: 42028
N = gets.to_i
hs = gets.split.map(&:to_i)

dp = Array.new(N)
dp[0] = 0
dp[1] = (hs[0] - hs[1]).abs

for i in 2..(N-1) do
  dp[i] = [dp[i-2] + (hs[i-2] - hs[i]).abs, dp[i-1] + (hs[i-1] - hs[i]).abs].min
end

puts dp[N-1]

Measured memory_bytes: 11396
import queue

N, M = list(map(int, input().split()))
uv = [list(map(int, input().split())) for _ in range(M)]
S, T = list(map(int, input().split()))

V = [[0, 0, 0] for _ in range(N + 1)]
R = {}

for u, v in uv:
  if u not in R:
    R[u] = [v]
  else:
    R[u].append(v)
q = queue.Queue()
put = q.put
get = q.get

put([S, 0, 2])
ans = -1
while not q.empty():
  t = get()
  if t[0] == T and t[2] == 2:
    ans = t[1]
    break
  k = (t[2] + 1) % 3
  m = t[1]
  if t[2] == 2:
    m += 1
  if t[0] not in R: continue
  for i in R[t[0]]:
    if V[i][k] == 0:
      V[i][k] = 1
      put([i, m, k])

print(ans)

Measured memory_bytes: 101588
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
h,w = LI()
y,x = LI()
print(h*w-h*x-w*y+y*x)
"""

#B
"""
n,m,c = LI()
b = LI()
a = LIR(n)
ans = 0
for i in range(n):
    d = c
    for k in range(m):
        d += b[k]*a[i][k]
    if d > 0:
        ans += 1
print(ans)
"""


#C

"""
n,m = LI()
v = LIR(n)
v.sort(key = lambda x:x[0])
ans = 0
k = 0
for a,b in v:
    if k+b >= m:
        ans += (m-k)*a
        print(ans)
        quit()
    ans += b*a
    k += b
"""

#D
def f(n):
    if n%4 == 3:
        return 0
    if n%4 == 0:
        return n
    if n%4 == 1:
        return 1
    return n+1
a,b = LI()
print(f(b)^f(a-1))

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 39152
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int count = 0;
  for (int r = 0; r * R <= N; r++)
  {
    for (int g = 0; r * R + g * G <= N; g++)
    {
      int rest = N - r * R - g * G;
      // cout << r << " " << g << " " << rest << endl;
      if (rest % B == 0)
      {
        count++;
        // cout << "count" << endl;
      }
    }
  }

  cout << count << endl;
  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ


int main(){
    int n;
    cin>>n;
    vector<int> s(n);
    rep(i,n){
        cin>>s[i];
    }
    all(s);
    int sum=0;
    rep(i,n){
        sum += s[i];
    }
    int j=0;
    while(sum%10==0&&j<n){
        if(s[j]%10!=0){
        sum -= s[j];
        }
        j++;
    }
    if(sum%10==0){
        cout<<0<<endl;
    }
    else{
    cout<<sum<<endl;
    }
}

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

signed main(void){ 
  int n,m; cin >> n >> m;
  int cnt = 0;
  if(n%2){ 
    for(int l = 1,r = n-1; l < r ; l++,r--){ 
      cout << l << " " << r << endl;
      cnt++;
      if( cnt >= m ){ break;}
    }
  }
    else{ 
      bool flag = false;
      for(int l = 1,r = n-1; l < r; l++,r--){
        if( !flag && r-l <= n/2 ){ r--; flag = true;}
        cout << l << " " << r << endl;
        cnt++;
        if(cnt >= m ){ break;
                     }
      }
    }

  return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

int main() {
	cin.sync_with_stdio(false);
	string s;
	cin >> s;
	int K;
	cin >> K;
	vector<string>word;
	rep(i, s.size()) {
		string tmp;
		rep(j, 5) {
			tmp = s[i];
			rep(k, j) {
				if (i + k + 1 >= s.size())break;
				tmp.push_back(s[i + k + 1]);
			}
			while (tmp.size() < 5)tmp.push_back('A');
			word.push_back(tmp);
			//cout << tmp << endl;
		}
	}
	//rep(i, word.size())cout << word[i] << endl;
	sort(word.begin(), word.end());
	word.erase(unique(word.begin(), word.end()), word.end());
	//rep(i, word.size())cout << word[i] << endl;
	string ans = word[K - 1];
	rep(i, ans.size()) {
		if (ans[i] != 'A')cout << ans[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1660
from sys import exit, stdin
S = stdin.readline().rstrip()
N = len(S)
if S == S[::-1] and S[0:(N-1)//2] == S[0:(N-1)//2][::-1] and S[(N+3)//2-1:N] == S[(N+3)//2-1:N][::-1]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
class ABC109Solver():
    def __init__(self):
        self.a = int()
        self.b = int()
    def input(self, a, b):
        self.a = a
        self.b = b
    def solve(self):
        # return 'Yes'
        # return 'No' if self.b%2 == 0 else 'Yes'
        return 'No' if self.a%2 == 0 or self.b%2 == 0 else 'Yes'

vals = input().split(' ')
a, b = int(vals[0]), int(vals[1])
solver = ABC109Solver()
solver.input(a,b)
 
print( solver.solve() )

Measured memory_bytes: 3060
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_C
 */
#include <iostream>
#include <string>

using namespace std;

int
main()
{
  ios::sync_with_stdio(false);

  int n;
  cin >> n; cin.ignore();

  int st = 0;
  int sh = 0;
  for (int i = 0; i < n; i++) {
    string t, h;
    cin >> t >> h; cin.ignore();

    int r = t.compare(h);
    if (r < 0) {
      sh += 3;
    } else if (r > 0) {
      st += 3;
    } else {
      st++;
      sh++;
    }
  }
  cout << st << ' ' << sh << endl;

  return 0;
}

Measured memory_bytes: 3204
"use strict";

const main = arg => {
    const inputList = arg.trim().split("\n");
    // 回答を記述
    const N = parseInt(inputList[0].split(" ")[0]);
    const AC = "AC"
    const WA = "WA"
    const TLE = "TLE"
    const RE = "RE"
    let rst = new Array(4).fill(0);
    for (let i = 1; i <= N; i++) {
        if (inputList[i] === AC) {
            rst[0]++
        } else if (inputList[i] === WA) {
            rst[1]++
        } else if (inputList[i] === TLE) {
            rst[2]++
        } else {
            rst[3]++
        }
    }

    console.log("AC x " + rst[0] + "\nWA x " + rst[1] + "\nTLE x " + rst[2] + "\nRE x " + rst[3])

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 37380
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main()
{
  ll i,  n, x, ans = 0;
  cin >> n;
  
  for(i=0; i<n; i++)
  {
    cin >> x;
    ans += x-1;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>

using namespace std;

int main(void) {

	int a;
	vector<int> vb;

	cin >> a;
	int sum = 0;

	for (int i = 0; i < a; i++) {
		int tmp;
		cin >> tmp;
		vb.push_back(tmp);
	}
	for (int i = 0; i < a; i++) {
		int tmp;
		cin >> tmp;
		if (vb[i] > tmp) {
			sum += vb[i] - tmp;
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
import bisect
A,B,Q=map(int,input().split())
INF=10**18
S=[-INF]+[int(input()) for i in range(A)]+[INF]
T=[-INF]+[int(input()) for i in range(B)]+[INF]
for q in range(Q):
    x=int(input())
    i=bisect.bisect_right(S,x)
    j=bisect.bisect_right(T,x)
    d=INF
    for s in [S[i-1],S[i]]:
        for t in [T[j-1],T[j]]:
            d1=abs(s-x)+abs(s-t)
            d2=abs(t-x)+abs(s-t)
            d=min(d,d1,d2)
    print(d)

Measured memory_bytes: 77800
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int r,g,b,n;
	int ans=0;
	cin >>r>>g>>b>>n;
	for(int i1=0;i1<=n/r;i1++){
		for(int i2=0;i2<=(n-i1*r)/g;i2++){
			if((n-i1*r-i2*g)%b==0){
				ans++;
			}	
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int n = Integer.parseInt(scanner.nextLine());
		String[] temp = scanner.nextLine().split(" ");
		int[] list = new int[temp.length];
		for(int i  = 0; i < temp.length; i++) {
			list[i] = Integer.parseInt(temp[i]);
		}
		int guu = 0;
		for(int i = 0; i < list.length; i++) {
			if(list[i] % 2 == 0) {
				while(list[i] % 2 == 0) {
				list[i] /= 2;
				guu++;
				}
			}
		}
		System.out.println(guu);
	}
}


Measured memory_bytes: 26384
def gcd(a, b):
  while b:
    a, b = b, a % b
  return a
def lcm(a,b):
  return a*b//gcd(a,b)

N=int(input())
T=[int(input()) for i in range(N)]
T.sort()
G=T[0]
for i in range(N):
  G=lcm(G,T[i])
print(G)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=10000000007;

int main(){
  int a,b,c;cin>>a>>b>>c;
  cout<<c<<" "<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
import math

def calc(a, b, h, m):
    A = (h/12*360) + (m/60*30)
    B = m/60*360
    angle = abs(A-B)
    res = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(angle)))
    return res

a, b, h, m = map(int, input().split())
ans = calc(a, b, h, m)
print(ans)

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

int input(vector<vector<char>> vecX , int i){
  int sum = 0;
  for(int j = 0 ; j < vecX.at(0).size()-1 ; j++){
    if(vecX.at(i).at(j) == vecX.at(i).at(j+1)){
      sum++;
    }
  }
  return sum;
}

int main() {
  int H, W;
  cin >> H >>W;
  
  vector<vector<char>> data(H, vector<char>(W));
  
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      cin >> data.at(i).at(j);
    }
  }
  
  for(int i = 0 ; i < H ; i++){
    
    for(int j = 0 ; j < W-1 ; j++){
      
      if(data.at(i).at(j) == data.at(i).at(j+1) && data.at(i).at(j) == '.'){
        
        if(j == W-2){
          
          for(int k = 0 ; k < W ; k++){
            data.at(i).at(k) = 'a';
          }
        }else{
          continue;
        }
      }else{
        break;
      }
    }
  }

   for(int j = 0 ; j < W ; j++){
    
    for(int i = 0 ; i < H-1 ; i++){
      
      if( data.at(i).at(j) == 'a' || data.at(i).at(j) == '.' ){
        if( data.at(i+1).at(j) == 'a' || data.at(i+1).at(j) == '.' ){
          
          if(i == H-2){
          
            for(int k = 0 ; k < H ; k++){
              data.at(k).at(j) = 'a';
            }
          }else{
            continue;
          }
        }else{
          break;
        }
      }else{
        break;
      }
    }
   }
  int sum = 0;
  
    for(int i = 0 ; i < H ; i++){
    
      for(int j = 0 ; j < W ; j++){
      
        if(data.at(i).at(j) != 'a'){
        
          cout << data.at(i).at(j);
        }
        if(j == W-1 && input(data,i) != 5){
          cout << endl;
        }
      }
    }
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    ll x[n+4];
    ll s[n+4];
    FOR(i,1,n+1) {
      cin >> x[i];
      s[i] = x[i];
    }
    sort(s+1,s+n+1);
    map<int,int> m;
    FOR(i,1,n+1) {
      m[s[i]] = i;
    }
    FOR(i,1,n+1){
      if(m[x[i]] < n+1-n/2) cout << s[n+1-n/2]<<endl;
      else cout << s[n-n/2]<<endl;
    }
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 14464
#include<iostream>
#include<cmath>
#include<cstdio>
using  namespace std;

const double PI=acos(-1);

pair<double,double> point;

void  koch(int n,pair<double,double> a,pair<double,double> b)
{
    if(n==0) return;
    pair<double,double> s,t,u;
    double th=PI*60.0/180.0;
    s.first=(2.0*a.first+1.0*b.first)/3.0;
    s.second=(2.0*a.second+1.0*b.second)/3.0;
    t.first=(1.0*a.first+2.0*b.first)/3.0;
    t.second=(1.0*a.second+2.0*b.second)/3.0;
    u.first=(t.first-s.first)*cos(th)-(t.second-s.second)*sin(th)+s.first;
    u.second=(t.first-s.first)*sin(th)+(t.second-s.second)*cos(th)+s.second;

    koch(n-1,a,s);
    printf("%.8f %.8f\n",s.first,s.second);
    koch(n-1,s,u);
    printf("%.8f %.8f\n",u.first,u.second);
    koch(n-1,u,t);
    printf("%.8f  %.8f\n",t.first,t.second);
    koch(n-1,t,b);
}

int read()
{
    char  c=getchar();
    int n=0;
    while(c<'0'||c>'9') c=getchar();
    while(c>='0'&&c<='9')
    {
        n=(n<<1)+(n<<3)+(c&15);
        c=getchar();
    }
    return n;
}

int main(void)
{
    pair<double,double> a,b;
    int n;
    n=read();
    a.first=0;
    a.second=0;
    b.first=100;
    b.second=0;

    printf("%.8f %.8f\n",a.first,a.second);
    koch(n,a,b);
    printf("%.8f %.8f\n",b.first,b.second);

    return 0;
}




Measured memory_bytes: 3344
package main

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

func main() {
	fsc := NewFastScanner()
	a, b, c := fsc.NextInt(), fsc.NextInt(), fsc.NextInt()
	res := 100*a + 10*b + c
	if res%4 != 0 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
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; }

ll div2(vector<ll> a) {
    ll cnt = 0;
    for (int i = 0; i < len(a);) {
        if (a[i] % 2 == 0) {
            a[i] /= 2; cnt++;
            continue;
        } else i++;
    }
    return cnt;
}

int main() {
   ll N; cin >> N;
   vector<ll> a(N);
   rep(i, N) cin >> a[i];
   cout << div2(a) << endl;
}

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

int main(){

  while(1){
    int x, y;
    cin>>x>>y;

    if(x == 0 && y == 0) break;

    if(x > y) swap(x, y);
    cout<<x<<" "<<y<<endl;
  }

  return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

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

  ll n;
  cin >> n;

  pll p(n);
  for(ll i = 0; i < n; i++){
    cin >> p[i].second >> p[i].first;
  }
  sort(all(p));

  ll t = 0;
  for(ll i = 0; i < n; i++){
    t += p[i].second;
    if(t > p[i].first){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3456