akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class I,class V=typename I::value_type>V sum_up(const I&l,const I&r){V v;for(I i=l;i!=r;i++)v=i==l?*i:v+*i;return v;}
template<class I,class T=iterator_traits<I>>I operator+(I it,int n){for(int i=0;i<n;i++)it++;return it;}
template<class I,class T=iterator_traits<I>>I operator-(I it,int n){for(int i=0;i<n;i++)it--;return it;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

i64 sub(int digit, int prefix) {
    i64 num = 0;
    vector2d<i64> v(digit + 1, vector<i64>(10, 0));
    v[0][prefix] = 1;
    for(int i = 0; i < digit; i++) {
        for(int j = 0; j < 10; j++) {
            v[i + 1][j] += v[i][j];
            if(j < 9) v[i + 1][j] += v[i][j + 1];
            if(j > 0) v[i + 1][j] += v[i][j - 1];
        }
    }
    for(int j = 0; j < 10; j++) {
        num += v[digit][j];
    }
    return num;
}

int main() {
    i64 K;
    int N;
    cin >> K;
    vector<int> array;
    // 概算でprefixを探す
    i64 k = 0;
    bool break_flag = false;
    for(int d = 0; true; d++) {
        for(int p = 1; p < 10; p++) {
            k += sub(d, p);
            if (k >= K) {
                N = d + 1;
                array = vector<int>(N);
                array[N - 1] = p;
                break_flag = true;
                k -= sub(d, p);
            }
            if(break_flag) break;
        }
        if(break_flag) break;
    }
    for(int d = N - 2; d >= 0; d--) {
        int H = min(9, array[d + 1] + 1);
        int L = max(0, array[d + 1] - 1);
        for(int p = L; p <= H; p++) {
            k += sub(d, p);
            if(k >= K) {
                array[d] = p;
                k -= sub(d, p);
                break;
            }
        }
    }
    i64 ans = 0;
    i64 p10 = 1;
    for(int i = 0; i < N; i++) {
        ans += array[i] * p10;
        p10 *= 10;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define pb push_back
#define F first
#define S second
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
const int MOD = 1e9+7;
template <typename A>istream& operator>>(istream& input,vector<A>& x) {for(auto& i:x)input>>i;return input;}
template<typename A>ostream& operator<<(ostream& output,vector<A>& x) {for(auto& i:x)output<<i<<' ';return output;}
signed main()
{
    ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    int T=1;
   // cin>>T;
    while(T--)
    {
        string s;
        cin>>s;
        int ans =0;
        vector<int> cnt(2020,0);
        int x=1;
        int n=s.size();
        cnt[0]=1;
        int num=0;
        for(int i=n-1;i>=0;i--)
        {
          num+=(s[i]-'0')*x;
          num%=2019;
          ans+=cnt[num];
          cnt[num]++;
          x=(x*10)%2019;
        }
        cout<<ans<<"\n";
    }

}


Measured memory_bytes: 3740
s=gets.chomp.split("")
if s.length==26 then
    itr=24
    while itr>=0&&s[itr]>s[itr+1] do
        itr-=1
    end
    if itr==-1 then
        puts "-1"
    else
        while s[itr] > s[-1] do s.pop end
        puts (s[0...itr] + [s[-1]]).join("")
    end
else
    list = Array.new(26, true)
    for i in 0...s.length do
        list[s[i].ord - "a".ord]=false
    end
    for i in 0...26 do
        if list[i] then
            s<<=(i+"a".ord).chr
            break
        end
    end
    puts s.join("")
end

Measured memory_bytes: 1788
#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>;
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; }

struct WeightedUnionFind {
    //各要素が属する集合の代表(根)を管理する
    //もし、要素xが根であればdata[x]は負の値を取り、-data[x]はxが属する集合の大きさに等しい
    vector<int> data;
    vector<int> diff_weight;

    WeightedUnionFind(int sz) : data(sz, -1), diff_weight(sz, 0) {}

    // weight(y) - weight(x) = w となるように merge する
    bool unite(int x, int y, int w) {
        w += weight(x);
        w -= weight(y);
        x = find(x);
        y = find(y);
        bool is_union = (x != y);
        if (is_union) {
            if (data[x] > data[y]) {
                swap(x, y);
                w = -w;
            }
            data[x] += data[y];
            data[y] = x;
            diff_weight[y] = w;
        } else {
            if (diff(x, y) == w) return true;
        }
        return is_union;
    }

    int find(int x) {
        if (data[x] < 0) { //要素xが根である
            return x;
        } else {
            int par = data[x];
            data[x] = find(data[x]); //data[x]がxの属する集合の根でない場合、根になるよう更新される
            diff_weight[x] += diff_weight[par];
            return data[x];
        }
    }

    int weight(int x) {
        find(x);
        return diff_weight[x];
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int diff(int x, int y) {
        return weight(y) - weight(x);
    }

    int size(int x) {
        return -data[find(x)];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    WeightedUnionFind wuf(n);
    for (int i = 0; i < q; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        if (!wuf.unite(x, y, z)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<math.h>

using namespace std;

void solve()
{
	int a = 0,b = 0;
	cin >> a >> b;
	cout << a * b;
}

int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=998244353;
const LL LINF=1LL<<60;
const int INF=1<<20;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


vector<LL> divi(LL K){
    vector<LL> v;
    for(int i=1;i*i<=K;i++){
        if(K%i) continue;
        v.pb(i);
        v.pb(K/i);
    }
    sort(ALL(v));
    v.erase(unique(ALL(v)),v.end());
    return v;
}


int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<vector<LL>> dp(n+1,vector<LL> (2,0));
    dp[0][1] = 1;
    for (int i = 0; i < n; i++) {
        for (int f = 0; f < 2; f++) {
            if(f){
                int x = s[i] - '0';
                for (int j = 0; j <= x; j++) {
                    if(j==x) dp[i+1][1] = (dp[i+1][1] + dp[i][1])%mod;
                    else dp[i+1][0] = (dp[i+1][0] + dp[i][1])%mod;
                }
            }
            else{
                dp[i+1][0] = (dp[i+1][0] + 2 * dp[i][0])%mod;
            }
        }
    }
    LL ans = 0, count = (dp[n][0] + dp[n][1])%mod;
    ans = count * n % mod * 2 % mod;
    auto p = divi(n);
    reverse(ALL(p));
    vector<LL> dp2(n+1,0);
    for(auto a:p){
        LL x = n / a;
        if(n % 2){
            string t = "";
            for (int j = 0; j < n; j++) {
                if(j / x % 2){
                    t += '0' + (s[j % x] ^ '1');
                }
                else{
                    t += s[j % x];
                }
            }
            LL sum = 0;
            if(t <= s){
                dp2[x] = (dp[x][0] + dp[x][1])%mod;
            }
            else{
                dp2[x] = dp[x][0];
            }
            for(auto b:p){
                LL y = n / b;
                if(x % y == 0 && x != y) dp2[x] = (dp2[x] - dp2[y] + mod) %mod;
            }
            ans = (ans - ((2 * (n - x + mod)%mod) * dp2[x] %mod) + mod)%mod;
        }
        else{
            if(x % 2) continue;
            if(n / x % 2 == 0 || x == n) continue;
            string t = "";
            for (int j = 0; j < n; j++) {
                if(j / x % 2){
                    t += '0' + (s[j % x] ^ '1');
                }
                else{
                    t += s[j % x];
                }
            }
            LL sum = 0;
            if(t <= s){
                dp2[x] = dp[x][0] + dp[x][1];
            }
            else{
                dp2[x] = dp[x][0];
            }
            for(auto b:p){
                LL y = n / b;
                if(x % y == 0 && x != y) dp2[x] = (dp2[x] - dp2[y] + mod) %mod;
            }
            ans = (ans - ((2 * (n - x + mod)%mod) * dp2[x] %mod) + mod)%mod;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 13440
N = int(input())
a = list(map(int,input().split()))
a1 = 0
a2 = 0
a4 = 0
for i in a:
    if i % 4 == 0:
        a4 += 1
    elif i % 2 == 0:
        a2 +=1
    else:
        a1 += 1



if (a1 <= (a4+1) and a2 == 0) or a1 <= a4:
    print("Yes")
    
else:
    print("No")

Measured memory_bytes: 14252
from collections import Counter


n = int(input())
lst_v = list(map(int, input().split()))


lst_o = lst_v[::2]
lst_e = lst_v[1::2]
cnt_o = Counter(lst_o).most_common() + [(0, 0)]
cnt_e = Counter(lst_e).most_common() + [(0, 0)]


if cnt_o[0][0] == cnt_e[0][0]:
    rem_number = max(cnt_o[0][1] + cnt_e[1][1], cnt_o[1][1] + cnt_e[0][1])
else:
    rem_number = cnt_o[0][1] + cnt_e[0][1]
ans = n - rem_number


print(ans)

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

using namespace std;
using namespace __gnu_pbds;

#define DIM 100007
#define DIMM 17
#define INF 1000000009.0
#define X 500007
#define epc 0.0000001
#define pi 3.14159265358979323846
#define MAX 25
#define MODULO 10009
const long double gr=(1+sqrt(5))/2;

typedef int I;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<I,I> pII;
typedef pair<ll,ll> pllll;
typedef pair<ld,ld> pldld;

typedef vector<I> vI;
typedef vector<ll> vll;
typedef vector<pllll> vpllll;

typedef char cr;
typedef string str;

typedef tree<
I,
null_type,
less<I>,
rb_tree_tag,
tree_order_statistics_node_update> mset;

ll n,a[DIM],b[DIM],c[DIM],d[DIM][DIMM];

int main()
{
    //freopen("suffarray.in", "r", stdin);
    //freopen("suffarray.out", "w", stdout);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //cout<<"ops"<<endl;

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

    //ll x1,y1,xs,ys,y1,y2,x3,x4,y3,y4;

    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i]>>b[i]>>c[i];
    d[1][1]=a[1];
    d[1][2]=b[1];
    d[1][3]=c[1];

    for(int i=2;i<=n;i++){
     d[i][1]=max(d[i-1][2],d[i-1][3])+a[i];
     d[i][2]=max(d[i-1][1],d[i-1][3])+b[i];
     d[i][3]=max(d[i-1][1],d[i-1][2])+c[i];
    }
    cout<<max(d[n][1],max(d[n][2],d[n][3]))<<endl;
}


Measured memory_bytes: 15872
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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 fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	VP A, B;
	VS S(N);
	int sum = 0;
	REP(i, N) {
		cin >> S[i];
		string s = S[i];
		int cnt = 0;
		int mi = 0;
		REP(j, s.size()) {
			if (s[j] == '(')cnt++;
			else cnt--;
			chmin(mi, cnt);
		}
		sum += cnt;
		if (cnt <= 0)B.push_back(pii(mi - cnt, -cnt));
		else A.push_back(pii(mi, cnt));
	}
	int now = 0;
	rSORT(A);
	rSORT(B);
	REP(i, A.size()) {
		int a = A[i].first, b = A[i].second;
		if (now + a < 0) {
			cout << "No" << endl;
			return 0;
		}
		now += b;
	}
	now = 0;
	REP(i, B.size()) {
		int a = B[i].first, b = B[i].second;
		if (now + a < 0) {
			cout << "No" << endl;
			return 0;
		}
		now += b;
	}
	//cout << now << " " << nnow << endl;
	if (sum == 0)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 50264
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Range Set Query
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 500000;
const int MAX_Q = 500000;

/* typedef */

typedef pair<int,int> pii;
typedef vector<pii> vpii;

template <typename T, const int MAX_N>
struct BIT {
  int n;
  T bits[MAX_N + 1];
  BIT() {}

  void init(int _n) {
    n = _n;
    memset(bits, 0, sizeof(bits));
  }

  T sum(int x) {
    T s = 0;
    while (x > 0) {
      s += bits[x];
      x -= (x & -x);
    }
    return s;
  }

  void add(int x, T v) {
    while (x <= n) {
      bits[x] += v;
      x += (x & -x);
    }
  }
};

/* global variables */

int cs[MAX_N], cps[MAX_N], as[MAX_N];
vpii qs[MAX_N];
BIT<int,MAX_N> bit;

/* subroutines */

/* main */

int main() {
  int n, qn;
  scanf("%d%d", &n, &qn);

  for (int i = 0; i < n; i++) scanf("%d", cs + i), cs[i]--;

  for (int i = 0; i < qn; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    l--, r--;
    qs[r].push_back(pii(l, i));
  }

  bit.init(n);
  memset(cps, -1, sizeof(cps));

  for (int i = 0; i < n; i++) {
    int ci = cs[i];
    if (cps[ci] >= 0) bit.add(cps[ci] + 1, -1);
    cps[ci] = i;
    bit.add(i + 1, 1);

    vpii &qi = qs[i];
    for (vpii::iterator vit = qi.begin(); vit != qi.end(); vit++) {
      int l = vit->first, ai = vit->second;
      as[ai] = bit.sum(i + 1) - bit.sum(l);
    }
  }

  for (int i = 0; i < qn; i++) printf("%d\n", as[i]);
  return 0;
}


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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<ll> vll;
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

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

int const MAX = 1e5 + 41;

int n;
int a[MAX];
int b[MAX];
int c[MAX];

vi per;

bool cmp(int i, int j) {
	return c[i] > c[j];
}

int par[MAX];
ll ans[MAX];
ll add[MAX];
vi ver[MAX];

int find(int x) {
	if (par[x] == x) return x;
	return par[x] = find(par[x]);
}

void solve() {
	fi(1, n - 1) {
		per.pb(i);
	}
	sort(per.begin(), per.end(), cmp);

	fi(1, n) {
		par[i] = i;
		ver[i].pb(i);
	}

	for (int id : per) {
		int x = find(a[id]);
		int y = find(b[id]);
		if (sz(ver[x]) < sz(ver[y])) {
			swap(x, y);
		}
		for (int z : ver[y]) {
			ans[z] += add[y];
			ans[z] += (ll) (sz(ver[x]) - sz(ver[y])) * c[id];
			ans[z] -= add[x];
		}
		add[y] = 0;
		add[x] += (ll) sz(ver[y]) * c[id];
		ver[x].insert(ver[x].end(), ver[y].begin(), ver[y].end());
		par[y] = x;
	}
	fi(1, n) {
		ans[i] += add[find(i)];
		printf("%lld\n", ans[i]);
	}
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

  scanf("%d", &n);
  fi(1, n - 1) {
  	scanf("%d %d %d", &a[i], &b[i], &c[i]);
  }
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 14060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Input in = new Input(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		BJudgeStatusSummary solver = new BJudgeStatusSummary();
		solver.solve(1, in, out);
		out.close();
	}
	static class BJudgeStatusSummary {
		public void solve(int testNumber, Input in, PrintWriter out) {
			int n = in.nextInt();
			int[] arr = new int[4];
			for(int i = 0; i<n; i++) {
				String s = in.next();
				if(s.equals("AC")) {
					arr[0]++;
				}else if(s.equals("WA")) {
					arr[1]++;
				}else if(s.equals("TLE")) {
					arr[2]++;
				}else {
					arr[3]++;
				}
			}
			out.printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", arr[0], arr[1], arr[2], arr[3]);
		}

	}

	static class Input {
		BufferedReader br;
		StringTokenizer st;

		public Input(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
			try {
				st = new StringTokenizer(br.readLine());
			}catch(IOException e) {
				e.printStackTrace();
			}
		}

		public boolean hasNext() {
			try {
				while(!st.hasMoreTokens()) {
					String s = br.readLine();
					if(s==null) {
						return false;
					}
					st = new StringTokenizer(s);
				}
				return true;
			}catch(Exception e) {
				return false;
			}
		}

		public String next() {
			if(!hasNext()) {
				throw new InputMismatchException();
			}
			return st.nextToken("\r\n\t\f ");
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 48456
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int powmod(int a, int b,int p){
	int r=1;
	while(b){
		if(b&1)
		 r=(r*a)%p;
		a=(a*a)%p;
		b=b/2;
	}
	return r;
} 
signed main(){
  int n,p;
  cin>>n>>p;
  string s;
  cin>>s;
  if(p==2 || p==5){
    int cnt=0;
    for(int i=0;i<n;i++){
      if((s[i]-'0')%p==0)
         cnt=cnt+i+1;
    }
    cout<<cnt;
  }
  else{
    map<int,int> m;
    m[0]=1;
    int cnt=0;
    int s1=0;
    for(int i=n-1;i>=0;i--){
      s1=(s1+(s[i]-'0')*powmod(10,n-1-i,p))%p;

      cnt+=m[s1];
      m[s1]+=1;
     
    }
    cout<<cnt;
  }
}


Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  ll h, w; int n; cin >> h >> w >> n;

  vl dp(10, 0);
  dp[0] = (h-2) * (w-2);
  set<P> paint;
  int a, b, x, y;
  Graph G;

  rep(i,n) {
    cin >> a >> b; --a; --b;
    paint.insert(P(a,b));
    G.assign(5, vi(5, 0));

    rep(j,5) {
      x = a-2+j;
      if (x < 0 || x >= h) continue;
      rep(k,5) {
        y = b-2+k;
        if (y < 0 || y >= w) continue;
        if (paint.count(P(x,y))) G[j][k] = 1;
      }
    }

    rep(j,3) {
      x = a-2+j;
      if (x < 0 || x+2 >= h) continue;
      rep(k,3) {
        y = b-2+k;
        if (y < 0 || y+2 >= w) continue;
        int sum = 0;
        rep(p,3) rep(q,3) sum += G[j+p][k+q];
        ++dp[sum]; --dp[sum-1];
      }
    }
  }

  rep(i,10) cout << dp[i] << endl;
  return 0;
}


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

static const int N = 4;
static const int N2 = 16;

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

struct Puzzle {
    int f[N2], space, MD;
    int cost;
    bool operator < (const Puzzle& p) const {
	for(int i=0; i<N2; i++) {
	    if( f[i] == p.f[i] ) continue;
	    return f[i] < p.f[i];
	}
	return false;
    }
};

struct State {
    Puzzle puzzle;
    int estimated;
    bool operator < (const State& s) const  {
	return estimated > s.estimated;
    }
};

int getAllMD(Puzzle pz) {
    int sum=0;
    for(int i=0; i<N2; i++) {
	if( pz.f[i] == N2 ) continue;
	sum += MDT[i][pz.f[i]-1];
    }
    return sum;
}

inline void dump(Puzzle& u) {
    for(int i=0; i<N; i++) {
	for(int j=0; j<N; j++)
	    cout << u.f[i*N+j] << " " ;
	cout << endl;
    }
}
map<Puzzle, bool> V;

int astar(Puzzle s) {
    priority_queue<State> PQ;
    s.MD = getAllMD(s);
    s.cost = 0;
    Puzzle u,v;
    State initial;
    initial.puzzle = s;
    initial.estimated = getAllMD(s);
    PQ.push(initial);

    while( !PQ.empty() ) {
	State st = PQ.top(); PQ.pop();
	u = st.puzzle;
	if( u.MD == 0 ) return u.cost;
	V[u] = true;

	int sx = u.space / N;
	int sy = u.space % N;
	for(int r=0; r<4; r++) {
	    int tx = sx + dx[r];
	    int ty = sy + dy[r];
	    if( tx<0 or ty<0 or tx>=N or ty>=N ) continue;
	    v = u;

	    v.MD -= MDT[tx*N+ty][v.f[tx*N+ty]-1];
	    v.MD += MDT[sx*N+sy][v.f[tx*N+ty]-1];

	    swap(v.f[sx*N+sy], v.f[tx*N+ty]);
	    v.space = tx*N+ty;
	    if( !V[v] ) {
		v.cost++;
		State news;
		news.puzzle = v;
		news.estimated = v.cost + v.MD;
		PQ.push(news);
	    }
	}
    }
    return -1;
}


int main() {
    for(int i=0; i<N2; i++)
	for(int j=0; j<N2; j++)
	    MDT[i][j] = abs(i/N-j/N) + abs(i%N-j%N);

    Puzzle in;

    for(int i=0; i<N2; i++) {
	cin >> in.f[i];
	if(in.f[i] == 0) {
	    in.f[i] = N2;
	    in.space = i;
	}
    }
    cout << astar(in) << endl;
    return 0;
}

Measured memory_bytes: 257652
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                  cerr<<#x<<": "<<x<<endl
#define trace2(x, y)              cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)              cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)          cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}



int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    cout << n*(n+1)/2;
    return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define int long long
#define ll long long
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = 1e-9;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline ll gcd(ll a, ll b) {
	while (b) {
		ll c = a;
		a = b; b = c % b;
	}
	return a;
}
inline ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
bool isprime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
ll mypow(ll a, ll b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	int memo = mypow(a, b >> 1);
	return memo * memo;
}
int n, m, a[110];
signed main() {
	cin >> n >> m;
	int oddcount = 0;
	rep(i, m) {
		cin >> a[i];
		if (a[i] & 1)oddcount++;
	}
	if (m == 1) {
		if (a[0] == 1) {
			cout << 1 << endl << 1 << endl << 1 << endl;
			return 0;
		}
		cout << a[0] << endl;
		cout << 2 << endl;
		cout << a[0] - 1 << " " << 1 << endl;
		return 0;
	}
	if (oddcount >= 3) {
		puts("Impossible");
		return 0;
	}
	if (oddcount == 2 && (n & 1)) {
		puts("Impossible");
		return 0;
	}
	REP(i, m - 1) {
		if (a[i] & 1) {
			if (a[0] & 1) {
				swap(a[i], a[m - 1]);
				break;
			}
			swap(a[0], a[i]);
		}
	}
	rep(i, m - 1)cout << a[i] << " ";
	cout << a[m - 1] << endl;
	if (a[0] != 1) {
		cout << m << endl;
		cout << a[0] - 1 << " ";
	}
	else cout << m - 1 << endl;
	REP(i, m - 2)cout << a[i] << " ";
	cout << a[m - 1] + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
import math
import collections

N = input()
nums = list(map(int, input().split()))
counter = collections.Counter(nums)
patterns = {}
for k, v in counter.items():
    patterns[k] = math.comb(v, 2)

baseline = sum(v for v in patterns.values())

cache = {}
for n in nums:
    if n in cache:
        print(cache[n])
    else:
        val = baseline - patterns[n] + math.comb(counter[n] - 1, 2)
        cache[n] = val
        print(val)


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

int n;
int p[30], l[30], r[30];

void preParse(int i){
  if(i == -1) return ;

  cout << " " << i;
  if(l[i] != -1) preParse(l[i]);
  if(r[i] != -1) preParse(r[i]);
}

void inParse(int i){
  if(i == -1) return ;

  if(l[i] != -1) inParse(l[i]);
  cout << " " << i;
  if(r[i] != -1) inParse(r[i]);
}

void postParse(int i){
  if(i == -1) return ;

  if(l[i] != -1) postParse(l[i]);
  if(r[i] != -1) postParse(r[i]);
  cout << " " << i;
}

int main(){

  cin >> n;
  for(int i = 0;i < n;i++) p[i] = l[i] = r[i] = -1;
  for(int i = 0;i < n;i++){
    int id, left, right;

    cin >> id >> left >> right;
    l[id] = left;
    r[id] = right;
    p[left] = p[right] = id;
  }

  for(int i = 0;i < n;i++){
    if(p[i] == -1){
      cout << "Preorder" << endl;
      preParse(i);
      cout << endl;

      cout << "Inorder" << endl;
      inParse(i);
      cout << endl;

      cout << "Postorder" << endl;
      postParse(i);
      cout << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3088
#include<iostream>
    #include<vector>
    #include<algorithm>
    using namespace std;
     
    int main(){
      int N,A,ans=0,jdg=0;
      vector<int> v;
      cin>>N;
      for(int i=0;i<N;i++){
        cin>>A;
        v.push_back(A);
      }
      sort(v.begin(),v.end());
      for(int i=0;i<N;i++){
        if(v[i]==v[i+1]){
          jdg+=1;
          continue;
        }
        if(jdg%2==0){
          ans+=1;
        }
        jdg=0;
      }
      cout<<ans<<endl;
      return 0;
    }

Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

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

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

    int r = 0, b = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == b) {
            r--;
            b = 0;
        } else {
            r++;
            b = a[i];
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 640
#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() {
  char s[4];
  scanf("%s", s);
  int ans = 0;
  rep(i, 3) if (s[i] == '1') ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
n = int(input())
m = -1
for i in range(1, n+1):
    if i * (i - 1) < 2 * n <= i * (i + 1):
        m = i
top = m * (m + 1) // 2
for i in range(0, m):
    if top - i == n:
        ng = i
        break
for i in range(1, m+1):
    if i == ng:
        continue
    print(i)

Measured memory_bytes: 9172
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

int main() {
	
    int a,b,x ;
    cin >> a >> b >> x ;
  
    if(a>x) cout << "NO" ;
    if(a==x) cout << "YES" ;
    if(a<x){
      if(b>=(x-a)){
        cout << "YES" ;
      }else{
                cout << "NO" ;
      }
    } 
  
  cout << endl ;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
using namespace std;
typedef pair<int, int> P;
typedef long long LL;

#define _CRT_SECURE_NO_WARNINGS
int a,b;
int main() {
	char s[100];
  scanf("%d %d %s",&a,&b,s);
	for(int i=0;i<a+b+1;i++){
		if(i<a){
          if(s[i]<'0' || '9'<s[i] ){
	
			printf("No");
            return 0;
          }
        }else if(i==a){
          if(s[i]!='-'){
            printf("No");
            return 0;
          }
        }else{
          if(s[i]<'0' || '9'<s[i] ){
	
			printf("No");
            return 0;
          }
        }
    }
  printf("Yes");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;



int main(){

    int a, b;
    cin >> a >> b;

    int dif = b - a;
    int k;
    for (int i=1; i <= 999; i++){
        if (b-a == i+1) k = i;
    }

    int s = k*(k+1)/2 - a;

    cout << s << endl;

}





//              g++ -std=c++1z

Measured memory_bytes: 256
/******************************************
 *  Author : Atul Anand   
 *  Created On : Sat Feb 08 2020
 *******************************************/

import java.io.*;
import java.util.*;

public class Main{
    
    public static void main(String[] args) throws IOException {
        int H=in.nextInt();
        int W=in.nextInt();
        int a[][]=new int[H][W];
        for(int i=0;i<H;i++){
            String S=in.next();
            for(int j=0;j<W;j++){
                a[i][j]= S.charAt(j)=='.' ? 0 : 1;
            }
        }
        long dp[][]=new long[H][W];
        int mod=(int)1e9+7;
        for(int i=0;i<W;i++){
            if(a[0][i]==1){
                break;
            }
            dp[0][i]=1;
        }
        for(int i=0;i<H;i++){
            if(a[i][0]==1){
                break;
            }
            dp[i][0]=1;
        }

        for(int i=1;i<H;i++){
            for(int j=1;j<W;j++){
                if(a[i][j]!=1){
                    dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
                }
            }
        }
        println(dp[H-1][W-1]);
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);
    static void read(int arr[], int N) throws IOException{ for(int i=0;i<N;i++){ arr[i]=in.nextInt(); } }
    static void read(long arr[], int N) throws IOException{ for(int i=0;i<N;i++){ arr[i]=in.nextLong(); } }
    static void read(String arr[], int N) throws IOException{ for(int i=0;i<N;i++){ arr[i]=in.next(); } }
    static void print(Object O){ out.print(O); }
    static void println(Object O){ out.println(O); }
    static void print(int arr[]){ for(int i=0;i<arr.length;i++){ print(arr[i]+" "); } println(""); }
    static void print(int arr[][]){ for(int i=0;i<arr.length;i++){ print(arr[i]); } }
    static void debug(Object O){ System.out.println(O); }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { tokenizer=new StringTokenizer(reader.readLine()); }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { return Integer.parseInt(next()); }
    double nextDouble() throws IOException { return Double.parseDouble(next()); }
    long nextLong() throws IOException { return Long.parseLong(next()); }
    String nextLine() throws IOException { return reader.readLine(); }
    void close() throws IOException { reader.close(); }
}

Measured memory_bytes: 39692
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("Yes\n")
#define ptn printf("No\n")
//==========================Code here==========================
LL n, a, b, c, d;
char s[200000 + 5];
int main() {
	cin >> n >> a >> b >> c >> d;
	scanf("%s", s + 1);
	s[++n] = '#';
	
	for (LL i = b; i < d; ++i) {
		if (s[i] == '#' && s[i + 1] == '#') return ptn, 0;
	} 
	for (LL i = a; i < c; ++i) {
		if (s[i] == '#' && s[i + 1] == '#') return ptn, 0;
	}
	
	/*if (c < d) return pty, 0;
	
	for (LL i = b - 2; i <= d; ++i) {
		if (s[i] == s[i + 1] && s[i + 1] == s[i + 2] && s[i] == '.') return pty, 0;
	}
	
	return ptn, 0;*/
	
	LL maxi = 0, cnt=0;
	if(c<d)
	{
		printf("Yes");
		return 0;
	}
	for(int i=b;i<=d+1;i++)
	{
		if(s[i]=='.') cnt++;
		else cnt=0;
		maxi=max(maxi,cnt);
	}
	if(s[b-1]=='.'&&s[b+1]=='.') maxi=3;
	if(maxi<=2)
		printf("No");
	else printf("Yes");
	
	return 0;
}
/*
11 5 9 9 11
..##..#..#.

9 4 6 9 8 
.##...#..
*/

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

#define LL long long
#define RG register

using namespace std;
template<class T> T gi() {
	T x = 0; bool f = 0; char c = getchar();
	while (c != '-' && (c < '0' || c > '9')) c = getchar();
	if (c == '-') f = 1, c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f ? -x : x;
}

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	LL n = gi<LL>(), a = gi<LL>(), b = gi<LL>();
	if ((b - a) % 2 == 0) printf("%lld\n", (b - a) / 2);
	else printf("%lld\n", min((b - a - 1) / 2 + a, n - b + (b - a + 1) / 2));	
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int a,b,h; cin >> a >> b >> h;
    out((a+b)*h/2);

    return 0;
}

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

double x[10],y[10];
double d[10][10];

int main(){
    int n ; cin  >> n;
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i];
    }
    //iとjの距離を計算
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            d[i][j]=sqrt(pow(x[i]-x[j],2.0)+pow(y[i]-y[j],2.0));
        }
    }
    vector<int> v;
    for(int i=0;i<n;i++){
        v.push_back(i);
    }
    double ans=0;
    int cnt=0;
    do{
        for(int i=1;i<n;i++){
            ans+=d[v[i-1]][v[i]];
        }
        cnt++;
    }while(next_permutation(v.begin(),v.end()));
    ans/=double(cnt);
    cout<<fixed<<setprecision(10);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << ' ' << X << ' ' << Y << endl;
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Security.Cryptography;
using System.Text;

namespace Contest
{
    class Program
    {

        public void Solve()
        {
            var sc = new Scanner();
            int N = sc.NextInt();
            string S = sc.Next();
            int red = S.Count(c => c == 'R');
            int blue = S.Count(c => c == 'B');
            Console.WriteLine(red>blue?"Yes":"No");
        }


        static void Main(string[] args) => new Program().Solve();
    }

    class Scanner
    {
        private char _separator = ' ';
        private StreamReader _stream = new StreamReader(Console.OpenStandardInput());
        private int _pos = 0;
        private string[] _line = new string[0];
        public string Next()
        {
            if (_pos >= _line.Length)
            {
                _line = _stream.ReadLine().Split(_separator);
                _pos = 0;
            }
            return _line[_pos++];
        }
        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public string[] Array()
        {
            if (_pos >= _line.Length)
                _line = _stream.ReadLine().Split(_separator);
            _pos = _line.Length;
            return _line;
        }
        public int[] IntArray()
        {
            var arr = Array();
            var res = new int[arr.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                res[i] = int.Parse(arr[i]);
            }
            return res;
        }
        public long[] LongArray()
        {
            var arr = Array();
            var res = new long[arr.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                res[i] = long.Parse(arr[i]);
            }
            return res;
        }
        public double[] DoubleArray()
        {
            var arr = Array();
            var res = new double[arr.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                res[i] = double.Parse(arr[i]);
            }
            return res;
        }
    }
}


Measured memory_bytes: 13268
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;



namespace Test1 {

    class ClassMain {

        public static char[,] moji = new char[,] { 
        {'a','b','c','d','e'},
        {'f','g','h','i','j'},
        {'k','l','m','n','o'},
        {'p','q','r','s','t'},
        {'u','v','w','x','y'},
        {'z','.','?','!',' '}};
       
        public static void Main(String[] args) {
            string line;

            while ((line = Console.ReadLine()) != null) {
                char[] chrs = line.ToCharArray();
                StringBuilder sb = new StringBuilder();
                if(chrs.Length%2==1){Console.WriteLine("NA");continue;}
                for (int i = 0; i < chrs.Length; i+=2) {
                    int x1 = chrs[i]-'0'-1;
                    int x2 = chrs[i+1]-'0'-1;
                    if (x1 < 0 || 5 < x1 || x2 < 0 || 4 < x2) { sb = new StringBuilder(); ; sb.Append("NA"); break; }
                    sb.Append(moji[x1,x2]);
                }

                Console.WriteLine(sb.ToString());

            }
        }


    }

}

Measured memory_bytes: 5312
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();

        int[] hights = new int[n];
        long[] memo = new long[n];
        Arrays.fill(memo, Long.MAX_VALUE);
        memo[0] = 0;
        hights[0] = in.nextInt();
        for (int i = 1; i < n; i++) {
            hights[i] = in.nextInt();
            for (int j = Math.max(i - k, 0); j < i; j++) {
                memo[i] = Math.min(memo[i], (Math.abs(hights[i] - hights[j]) + memo[j]));
            }
        }
        in.close();
        System.out.println(memo[n-1]);
    }
}

Measured memory_bytes: 52296
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a + b < 24) System.out.println(a + b);
        else System.out.println(a + b - 24);
    }
}


Measured memory_bytes: 35600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            String S = in.next();

            int count = 1;
            for (int i = 1; i < N; i++) {
                if (S.charAt(i) != S.charAt(i - 1)) {
                    count++;
                }
            }

            System.out.println(count);
        }
    }
}


Measured memory_bytes: 30232