akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var colors = new color[8]
			{
				new color(){c = "black",  r=0,    g=0,    b=0},
				new color(){c = "blue",   r=0,    g=0,    b=255},
				new color(){c = "lime",   r=0,    g=255,  b=0},
				new color(){c = "aqua",   r=0,    g=255,  b=255},
				new color(){c = "red",    r=255,  g=0,    b=0},
				new color(){c = "fuchsia",r=255,  g=0,    b=255},
				new color(){c = "yellow", r=255,  g=255,  b=0},
				new color(){c = "white",  r=255,  g=255,  b=255},
			};

			var s = "";
			while ((s = Console.ReadLine()) != "0")
			{
				int color = Convert.ToInt32(s.TrimStart('#'), 16);
				int red = color >> 16;
				int green = color >> 8 & 0xff;
				int blue = color & 0xff;
				double t = double.MaxValue;
				int r = 0;
				for (int i = 0; i < 8; i++)
				{
					double d = Math.Sqrt(
						(red - colors[i].r) * (red - colors[i].r) +
						(green - colors[i].g) * (green - colors[i].g) +
						(blue - colors[i].b) * (blue - colors[i].b));
					if (t > d)
					{
						r = i;
						t = d;
					}
				}
				Console.WriteLine(colors[r].c);
			}
		}

		struct color
		{
			public string c;
			public int r, g, b;
		}
	}
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  string s;
  cin >> s;
  if(s.length()<3){
    cout << "No" << endl;
    return 0;
  }
  while(1){
    bool ok=false;
    rep(i,s.length()-2){
      if(s.substr(i,3)=="ABC"){
        s[i]=s[i+1]=s[i+2]='?';
        ok=true;
      }
    }
    if(!ok){
      cout << "No" << endl;
      return 0;
    }
    if(s=="???"){
      cout << "Yes" << endl;
      return 0;
    }
    vector<bool> f(3,false);
    rep(i,s.length()){
      if(s[i]!='?') f[s[i]-'A']=true;
    }
    char c='?';
    rep(i,3){
      if(!f[i]){
        if(c=='?'){
          c='A'+i;
        }else{
          cout << "No" << endl;
          return 0;
        }
      }
    }
    string ns="";
    rep(i,s.length()){
      if(s[i]=='?'){
        ns.push_back(c);
        i+=2;
      }else{
        ns.push_back(s[i]);
      }
    }
    s=ns;
  }
  return 0;
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  cin >> a;
  vector<int> b(n + 1);
  b[0] = 0;
  rep3(i, 1, n + 1) b[i] = b[i - 1] + a[i - 1];
  int ans = 0;
  rep(i, n + 1) if (b[i] <= x) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int n, h, w;
    cin >> n >> h >> w;

    cout << (n-h+1) * (n-w+1) << "\n";
    return 0;
}

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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

int N, M, Q;
vector<int> a, b, c, d;
vector<int> A(11);

ll maxscore = 0;

void rec(int i) {
    if (i == N) {
        ll total = 0;
        REP (j, Q) {
            if ((A.at(b.at(j)) - A.at(a.at(j))) == c.at(j)) total += d.at(j);
        }
        chmax(maxscore, total);
        return;
    }

    for (A.at(i) = A.at(i - 1); A.at(i) <= M; A.at(i)++) {
        rec(i + 1);
    }

    return;
}

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

    cin >> N >> M >> Q;

    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);

    REP(i, Q) {
        int aa, bb, cc, dd;
        cin >> aa >> bb >> cc >> dd;
        aa--; bb--;
        a.at(i) = aa; b.at(i) = bb; c.at(i) = cc; d.at(i) = dd;
    }

    A.at(0) = 1;

    rec(1);

    cout << maxscore << endl;

    return 0;
}

Measured memory_bytes: 3664
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};

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

  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  rep(i,h) cin >> grid[i];

  int cnt = 0;
  rep(i,h) rep(j,w) if(grid[i][j] == '#') cnt++;

  queue<pair<int, int>> que;
  vector<vector<int>> dist(h, vector<int> (w, -1));
  dist[0][0] = 0;
  que.push({0, 0});

  while(!que.empty()) {
    int vh = que.front().fi;
    int vw = que.front().se;
    que.pop();

    rep(dir, 4) {
      int nvh = vh + dy[dir];
      int nvw = vw + dx[dir];

      if(nvh < 0) continue;
      if(nvw < 0) continue;
      if(nvh >= h) continue;
      if(nvw >= w) continue;
      if(dist[nvh][nvw] != -1) continue;
      if(grid[nvh][nvw] == '#') continue;

      dist[nvh][nvw] = dist[vh][vw]+1;
      que.push({nvh, nvw});
    }
  }

  if(dist[h-1][w-1] == -1) cout << -1 << endl;
  else cout << h*w-dist[h-1][w-1]-cnt-1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <cassert>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

using namespace std;

LL modcom(const LL n, const LL k, LL mod) {
  LL nfact = 1;
  for(LL i=1; i<=n; i++) {
    nfact = (nfact * i) % mod;
  }

  LL s = max(k,n-k);
  std::vector<LL> inv(s+1);
  inv[1] = 1;
  for(LL i=2; i<= s; i++) {
    inv[i] = mod - inv[mod%i] * (mod / i) % mod;
  }
  LL kinv_fact = 1;
  for(LL i=2; i<=k; i++) {
    kinv_fact = (kinv_fact * inv[i]) % mod;
  }
  LL nkinv_fact = 1;
  for(LL i=2; i<=(n-k); i++) {
    nkinv_fact = (nkinv_fact * inv[i]) % mod;
  }

  if(n<k) { return 0; }
  if(n<0 || k<0) { return 0; }
  return nfact * (kinv_fact * nkinv_fact % mod) % mod;
}

int main() {

  LL N, M, K;
  cin >> N >> M >> K;
  LL mod = 1000000007;

  // consider x-diff
  LL score = 0;
  for(LL dx=1; dx<M; dx++) {
    score += dx * (M-dx) * N * N;
    score %= mod;
  }

  for(LL dy=1; dy<N; dy++) {
    score += dy * (N-dy) * M * M;
    score %= mod;
  }

  LL c = modcom(N*M-2, K-2, mod);
  score = (score * c) % mod;

  cout << score << endl;

  return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,ina,inb,inc;
    vector<int> tl;
    vector<pair<int,int>> lo;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>ina>>inb>>inc;
        tl.push_back(ina);
        lo.push_back({inb,inc});
    }
    int t=0,x=0,y=0,dis;
    for(int i=0;i<n;i++){
        dis=(abs(x-lo[i].first)+abs(y-lo[i].second));
        t=tl[i]-t;
        if(!(t-dis>=0&&(t-dis)%2==0)){
            cout<<"No"<<endl;
            return 0;
        }
        t=tl[i];
        x=lo[i].first;
        y=lo[i].second;
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 1780
n, m = map(int,input().split())
h = list(map(int,input().split()))
good = [True] * n
for _ in range(m):
    a,b = map(lambda x:int(x)-1,input().split())
    if h[a] < h[b]:
        good[a] = False
    elif h[a] > h[b]:
        good[b] = False
    else:
        good[a] = False
        good[b] = False
print(good.count(True))


Measured memory_bytes: 20088
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
//int fie[4003][8][8003];
int main(){

    int N;
    string S;
    cin>>N>>S;
    long long int cou[3]={0,0,0};
    for(int i=0;i<N;i++){
        if(S[i]=='R')cou[0]++;
        if(S[i]=='G')cou[1]++;
        if(S[i]=='B')cou[2]++;
    }
    long long int ans=cou[0]*cou[1]*cou[2];
    //cout<<ans<<endl;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            //if(S[i]==S[j])continue;
            if(j+(j-i)<N){
                if(S[j+(j-i)]!=S[i]&&S[j+(j-i)]!=S[j]&&S[i]!=S[j]){
                    ans--;
                }
            }
        }
    }
    /*
    fie[0][0][0]=1;
    for(int i=0;i<N;i++){
        for(int j=0;j<8;j++){
            for(int k=0;k<8003;k++){
                if(j==0){
                    fie[i+1][0][0]+=fie[i][j][k];
                    if(S[i]=='R'){
                        fie[i+1][4][i]+=fie[i][j][k];
                    }
                    if(S[i]=='G'){
                        fie[i+1][2][i]+=fie[i][j][k];
                    }
                    if(S[i]=='B'){
                        fie[i+1][1][i]+=fie[i][j][k];
                    }
                }
                if(j==1||j==2||j==4){
                    fie[i+1][j][k]+=fie[i][j][k];
                    int bi;
                    if(S[i]=='R')bi=4;
                    if(S[i]=='G')bi=2;
                    if(S[i]=='B')bi=1;
                    if((bi&j)==0){
                        fie[i+1][bi|j][i+(i-k)]+=fie[i][j][k];
                    }
                }
                if(j==3||j==5||j==6){
                    fie[i+1][j][k]+=fie[i][j][k];
                    int bi;
                    if(S[i]=='R')bi=4;
                    if(S[i]=='G')bi=2;
                    if(S[i]=='B')bi=1;

                    if((bi&j)==0&&(i!=k)){
                        fie[i+1][bi|j][0]+=fie[i][j][k];
                    }

                }
                if(j==7){
                    fie[i+1][j][k]+=fie[i][j][k];
                }
            }
        }
    }

    long long int ans=0;
    for(int i=0;i<8003;i++){
        ans+=fie[N][7][i];
    }
    */
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3628
while True:
    H,W = map(int,raw_input().split())
    if (H,W) == (0,0): break
    array = [raw_input() for i in range(H)]
    saw = [[False for i in range(W)] for j in range(H)]
    X = 0
    Y = 0
    while True:
        if array[X][Y] == ">":
            Y += 1
            if saw[X][Y]:
                print 'LOOP'
                break
            saw[X][Y] = True
        elif array[X][Y] == "<":
            Y -= 1
            if saw[X][Y]:
                print 'LOOP'
                break
            saw[X][Y] = True
        elif array[X][Y] == "^":
            X -= 1
            if saw[X][Y]:
                print 'LOOP'
                break
            saw[X][Y] = True
        elif array[X][Y] == "v":
            X += 1
            if saw[X][Y]:
                print 'LOOP'
                break
            saw[X][Y] = True
        elif array[X][Y] ==".":
            print Y,X
            break

Measured memory_bytes: 4412
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N,K;
  cin>>N>>K;
  double ans=0;
  FOR(i,1,N+1){
    double temp=1;
    int score=i;
    while(score<K){
      score*=2;
      temp/=2;
    }
    ans+=temp;
  }
  ans/=N;
  cout<<fixed<<setprecision(12)<<ans<<endl;
  return 0;
}


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

using namespace std;

int N;
int P[200000];
bool used[200002];
int memo[200001];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> P[i];
	}
	int ans = 1;
	used[200001] = true;
	for (int i = 0; i < N; i++) {
		used[P[i]] = true;
		if (used[P[i] - 1]) {
			memo[P[i]] = memo[P[i] - 1] + 1;
			ans = max(ans, memo[P[i]] + 1);
		}
	}
	cout << N - ans << endl;
	return 0;
}

Measured memory_bytes: 2048
// https://atcoder.jp/contests/abc173/tasks/abc173 a
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>

using namespace std;
#define lli long long int
#define numberofdigits(x) floor(log10(x)) + 1

int main()
{
    lli n,var;
    cin>>n;
    var=n%1000;
    while(var<0)   var+=1000;
    if(var==0)  var+=1000;
    cout<<1000-var<<"\n";
    return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<61);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int n,m,i,x,y,nxt,st,ed;
ll dist[nmax],dist1[nmax],c,c1,cs,ans[nmax];
vector<pair<int,pair<ll,ll> > >a[nmax];
set<pair<ll,int> >s;
int main()
{
    //freopen("dijkstra.in","r",stdin);
    //freopen("dijkstra.out","w",stdout);
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n>>m>>st>>ed;
    while(m--)
    {
        cin>>x>>y>>c>>c1;
        a[x].pb(make_pair(y,make_pair(c,c1)));
        a[y].pb(make_pair(x,make_pair(c,c1)));
    }
    for(i=1;i<=n;i++)dist[i]=llinf;
    dist[st]=0;
    s.in(make_pair(0,st));
    while(!s.empty())
    {
        cs=s.begin()->fr;
        nxt=s.begin()->sc;
        s.er(s.begin());
        for(i=0;i<a[nxt].size();i++)
          if(dist[nxt]+a[nxt][i].sc.fr<dist[a[nxt][i].fr])
          {
            if(dist[a[nxt][i].fr]!=llinf)s.er(s.find(make_pair(dist[a[nxt][i].fr],a[nxt][i].fr)));
            dist[a[nxt][i].fr]=dist[nxt]+a[nxt][i].sc.fr;
            s.in(make_pair(dist[a[nxt][i].fr],a[nxt][i].fr));
          }
    }
    s.clear();
    for(i=1;i<=n;i++)dist1[i]=llinf;
    dist1[ed]=0;
    s.in(make_pair(0,ed));
    while(!s.empty())
    {
        cs=s.begin()->fr;
        nxt=s.begin()->sc;
        s.er(s.begin());
        for(i=0;i<a[nxt].size();i++)
          if(dist1[nxt]+a[nxt][i].sc.sc<dist1[a[nxt][i].fr])
          {
            if(dist1[a[nxt][i].fr]!=llinf)s.er(s.find(make_pair(dist1[a[nxt][i].fr],a[nxt][i].fr)));
            dist1[a[nxt][i].fr]=dist1[nxt]+a[nxt][i].sc.sc;
            s.in(make_pair(dist1[a[nxt][i].fr],a[nxt][i].fr));
          }
    }
    for(i=n;i>=1;i--)ans[i-1]=max(ans[i],1000000000000000LL-dist[i]-dist1[i]);
    for(i=0;i<n;i++)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 15232
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

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

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

  sort(all(a));
  sort(rall(b));

  int64 ans1 = 0, ans2 = 0;
  deque<int> dq1, dq2;
  // ・・・小大小・・・
  dq1.push_back(b[0]);
  int pos1 = 1, pos2 = 0;
  while ((int) dq1.size() < n) {
    dq1.push_back(a[pos2]); ++pos2;
    if ((int) dq1.size() < n) {
      dq1.push_front(a[pos2]); ++pos2;
    }
    if ((int) dq1.size() < n) {
      dq1.push_back(b[pos1]); ++pos1;
    }
    if ((int) dq1.size() < n) {
      dq1.push_front(b[pos1]); ++pos1;
    }
  }

  // ・・・大小大・・・
  dq2.push_back(a[0]);
  int pos3 = 0, pos4 = 1;
  while ((int) dq2.size() < n) {
    dq2.push_back(b[pos3]); ++pos3;
    if ((int) dq2.size() < n) {
      dq2.push_front(b[pos3]); ++pos3;
    }
    if ((int) dq2.size() < n) {
      dq2.push_back(a[pos4]); ++pos4;
    }
    if ((int) dq2.size() < n) {
      dq2.push_front(a[pos4]); ++pos4;
    }
  }

  for (int i = 1; i < n; ++i){
    ans1 += (int64) abs(dq1[i] - dq1[i - 1]);
    ans2 += (int64) abs(dq2[i] - dq2[i - 1]);
  }
  print(max(ans1, ans2));

  return 0;
}

Measured memory_bytes: 1920
# AOJ 0003 Is it a Right Triangle?
# Python3 2018.6.7 bal4u

n = int(input())
for i in range(n):
    a = list(map(int, input().split()))
    a.sort()
    if a[0]*a[0] + a[1]*a[1] == a[2]*a[2]:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 5596
def examA():
    N = I(); H = I(); W = I()
    ans = (N-H+1)*(N-W+1)
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examA()


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

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

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

    ///公約数
    ll n = gcd(a,b);
    ///素数の数
    vector<pair<int, int>> v;
    for(ll i=2;i*i<n;i++) {
        if (n%i!=0) continue;
        v.emplace_back(i,0);
        while (n%i==0) {
            n /= i;
            v.back().second++;
        }
    }
    if (n!=1) v.emplace_back(n,1);
    cout << v.size()+1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x%y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;

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

	if (a == b) {
		cout << "EQUAL" << endl;

	}
	else if (a.size() == b.size()) {
		if (a > b) {
			cout << "GREATER" << endl;
		}
		else {
			cout << "LESS" << endl;
		}
	}
	else if (a.size() > b.size()) {
		cout << "GREATER" << endl;
	}
	else {
		cout << "LESS" << endl;

	}





}


Measured memory_bytes: 256
S=input()
N=len(S)

flag=True
for i in range(N//2):
    if S[i]!=S[N-i-1]:
        flag=False
for j in range(N//2//2):
    if S[N-N//2+j]!=S[N-j-1]:
        flag=False             
        
if flag==True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
var input = ""
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
 
process.stdin.on('end', function() {
  input = input.split("\n");
  i = 0
  while (input[i] != 0) {
    arr = input[i].split(" ");
    if (arr[0] != 0 || arr[1] != 0) {
      h = "";
      for (j = 0; j < arr[1]; j++) {
        h = h + "#";
      }
      for (k = 0; k < arr[0]; k++) {
        console.log(h);
      }
      console.log("");
    }
    i++;
  }
});

Measured memory_bytes: 9872
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=200005;
int a[N],b[N],sum1[N],sum2[N];
int l,n,ans;
int gs1(int l,int r){return r<l?0:(sum1[r]-sum1[l-1]);}
int gs2(int l,int r){return r<l?0:(sum2[r]-sum2[l-1]);}
void solve()
{
	for(int i=1;i<=n;i++) 
		sum1[i]=sum1[i-1]+a[i];
	for(int i=1;i<=n;i++) 
		sum2[i]=sum2[i-1]+l-a[i];
	for(int i=1;i<=n/2;i++)
	{
		int y=n-i*2;
		ans=max(ans,gs1(y,y+i-1)*2+a[y+i]+gs2(y+i+1,n)*2);
		ans=max(ans,gs1(y+1,y+i)*2+gs2(y+i+2,n)*2+l-a[y+i+1]);
	}
}
main()
{
	ios::sync_with_stdio(false);
	cin>>l>>n;
	for(int i=1;i<=n;i++) 
		cin>>a[i];
	ans=max(a[n],l-a[1]);
	solve();
	for(int i=1;i<=n;i++) 
		b[i]=l-a[n-i+1];
	for(int i=1;i<=n;i++) 
		a[i]=b[i];
	solve();
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <time.h>
#include <stdlib.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define clr(x) x.clear()
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define hell 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(a) a.begin(),a.end()
#define ign cin.ignore();

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

using namespace std;
using namespace __gnu_pbds;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

ll dp[20010];

ll wt[1010],val[1010];

ll n,W;

void KnapSack(ll n,ll W,ll maxi)
{
    for(ll i=0; i < n; i++)
        for(ll j=0; j<W+maxi ; j++){
                if(j+wt[i]>=W+maxi)
                break;
                dp[j+wt[i]] = min(dp[j+wt[i]] , val[i] + dp[j]);
            }
}

int main()
{
    IOS
    ll maxi=-1;
    for(int i=0;i<20010;i++)
    {
        dp[i]=1e12;
    }
    dp[0]=0;
    ll W,n;
    cin>>W>>n;
    for(int i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
        maxi=max(maxi,wt[i]);
    }
    KnapSack(n,W,maxi);
    ll mini=LLONG_MAX;
    for(ll i=W;i<W+maxi;i++)
    {
        mini=min(mini,dp[i]);
    }
    cout<<mini<<"\n";
    return 0;
}


Measured memory_bytes: 384
#![allow(non_snake_case)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::*;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;
//use petgraph::unionfind::UnionFind;
const MOD: i64 = 1_000_000_000 + 7;
fn main() {
    input! {
        n:i64,a:i64,b:i64
    }
    // n choose r の合計、ただしr=a,bを除く。
    // n choose r = fact[n] * modInv(fact[n-r])*modInv(fact[r])
    // let mut fact = vec![1i64; n + 1];
    //  let mut ifact = vec![1i64; n + 1];
    let mut fact = 1;
    let mut fact_a = 0;
    let mut fact_b = 0;
    let mut fact_na = 0;
    let mut fact_nb = 0;
    for i in 1i64..=b as i64 {
        fact = fact * i % MOD;
        //println!("fact[{}]={}", i, fact);
        match i {
            i if i == a => {
                fact_a = fact;
            }
            i if i == b => {
                fact_b = fact;
            }
            _ => (),
        }
    }
    fact = 1;
    for i in ((n - b) as i64..=n as i64).rev() {
        fact = fact * i % MOD;
        match i {
            i if i == n - a + 1 => {
                fact_na = fact;
            }
            i if i == n - b + 1 => {
                fact_nb = fact;
            }
            _ => (),
        }
    }

    //println!("{},{},{},{}", fact_a, fact_b, fact_na, fact_nb);
    let mut ans = modPow(2, n as i64) - 1;
    let choose_na = fact_na * modInv(fact_a) % MOD;
    let choose_nb = fact_nb * modInv(fact_b) % MOD;
    ans = (ans + MOD + MOD - choose_na - choose_nb) % MOD;
    println!("{}", ans);
}

fn modPow(x: i64, a: i64) -> i64 {
    if a == 0 {
        1
    } else {
        if a % 2 != 0 {
            modPow(x, a - 1) * x % MOD
        } else {
            let y = modPow(x, a / 2);
            y * y % MOD
        }
    }
}
fn modInv(x: i64) -> i64 {
    modPow(x, MOD - 2) % MOD
}


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

using namespace std;

int cnt[100001];

int main () {
	int n, m;
	cin >> n >> m;
	for (int i = 1;i <= m;i ++) {
		int x, y;
		cin >> x >> y;
		cnt[x] ++;
		cnt[y] ++;
	}
	for (int i = 1;i <= n;i ++) {
		if (cnt[i] % 2) {
			cout << "NO";
			return 0;
		} 
	}
	cout << "YES";
	return 0;
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);

    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int maxEle = v[n-1]/2;
    //cout << maxEle << endl;
    int sum = 0;
    for(int i = 0; i < n-1; i++){
        sum += v[i];
    }
    sum += maxEle;
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import os
import math


N = int(input())
s_list = []
for i in range(N):
    s_list.append(input().strip())

alphabets = 'abcdefghijklmnopqrstuvwxyz'

for c in alphabets:
    min_count = float('inf')
    for s in s_list:
        count = s.count(c)

        if count < min_count:
            min_count = count
    print(c * min_count, end='')
print()

Measured memory_bytes: 3060
#include"bits/stdc++.h"
using namespace std;
int main(){
	long long n,k;
	cin>>n>>k;
	long long sum=0,a,b;
	multimap<long long,long long> x;
	for(int i=0;i!=n;++i){
		cin>>a>>b;
		x.insert({a,b});
	}
	for(auto i:x){
		sum+=i.second;
		if(sum>=k){
			cout<<i.first;
			return 0;
		}
	}
}

Measured memory_bytes: 6528
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int A1 = Integer.parseInt(strArr[0]);
		int A2 = Integer.parseInt(strArr[1]);
		int A3 = Integer.parseInt(strArr[2]);
		if (A1 + A2 + A3 >= 22)
			System.out.println("bust");
		else
			System.out.println("win");
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


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

using namespace std;

#define int long long

const int DIM = 107;

main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	
	int k;
	cin >> k;
	
	if(s.size() == 1)
	{
		if(k == 1)
		{
			cout << 0 << '\n';
			return 0;
		}
		
		cout << k / 2 << '\n';
		return 0;
	}
	
	
	s = ' ' + s;
	
	vector <int> v;
	
	int n = s.size() - 1;
	
	int nr = 1;
	
	for(int i = 2; i <= n; i++)
		if(s[i] == s[i - 1])
			nr++;
		else
		{
			v.push_back(nr);
			nr = 1;
		}
	
	v.push_back(nr);
	
	if(v.size() == 1)
	{
		cout << (v[0] * k) / 2;
		return 0;
	}
	
	if(s[1] != s[n])
	{
		int sum = 0;
		
		for(auto i : v)
			sum += i / 2;
		
		cout << sum * k;
		return 0;
	}
	
	int res = v[0] / 2 + v.back() / 2;
	
	for(int i = 1; i < v.size() - 1; i++)
		res += k * (v[i] / 2);
	
	int p = v[0] + v.back();
	
	res += (p / 2) * (k - 1);
	
	cout << res;
}

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

int main(void){
	int b, f, r, v, n;
	int a[5][4][11]={0};
    cin >> n;
    for(int i=1; i<=n;i++){
		cin >>b >>f >>r >>v;
		a[b][f][r]+=v;
    }
    for(int i=1; i<5; i++){
		for(int j=1; j<4; j++){
			for(int k=1; k<11; k++){
				cout <<" " <<a[i][j][k];
			}
			cout <<endl;
		}
		if(i!=4){
			cout <<"####################" <<endl;
		}
    }
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<cstring>
#define repst(p) for(int i=begin[p],q;i;i=next[i])if((q=to[i])!=h)
#define rept(p,t) for(int i=t.begin[p],q;i;i=t.next[i])if((q=t.to[i])!=h)
template<typename T>inline void check_max(T a,T &b){if(a>b)b=a;}
template<typename T>inline void read(T &x)
{
	char c=x=0;
	for(c=getchar();!isdigit(c);c=getchar());
	for(;isdigit(c);c=getchar())x=(x<<3)+(x<<1)+(c^48);
}
namespace wrong
{
	const int N=201000,M=N*2;
	struct tool
	{
		int begin[N],next[M],to[M];
		int fa[N][20],dep[N];
		int e;
		void add(int x,int y,bool k=1)
		{
			to[++e]=y;
			next[e]=begin[x];
			begin[x]=e;
			if(k)add(y,x,0);
		}
		void predfs(int p=1,int h=0)
		{
			dep[p]=dep[h]+1;
			for(int k=1;k<=18;k++)
				fa[p][k]=fa[fa[p][k-1]][k-1];
			repst(p)
			{
				fa[q][0]=p;
				predfs(q,p);
			}
		}
		int get_lca(int u,int v)
		{
			if(dep[u]<dep[v])std::swap(u,v);
			for(int k=18;k>=0;k--)
				while(dep[fa[u][k]]>=dep[v])u=fa[u][k];
			for(int k=18;k>=0;k--)
				while(fa[u][k]!=fa[v][k])
					u=fa[u][k],v=fa[v][k];
			return u==v?u:fa[u][0];
		}
		int dis(int u,int v){return dep[u]+dep[v]-2*dep[get_lca(u,v)];}
		bool check(int u,int v)
		{
			if(dep[u]<dep[v])std::swap(u,v);
			if(fa[u][0]==v || fa[u][1]==v)return 0;
			if(fa[u][0]==fa[v][0])return 0;
			return 1;
		}
		int go(int p,int q)
		{
			if(dep[p]>=dep[q])return fa[p][0];
			for(int k=18;k>=0;k--)
				while(dep[fa[q][k]]>dep[p])q=fa[q][k];
			if(fa[q][0]==p)return q;
			return fa[p][0];
		}
	}s,t;
	int f[N],g[N];
	bool isit[N];
	int n,X,Y;
	void initialize()
	{
		read(n),read(X),read(Y);
		for(int i=1,u,v;i<n;i++)
			read(u),read(v),s.add(u,v);
		for(int i=1,u,v;i<n;i++)
			read(u),read(v),t.add(u,v);
		t.predfs();
		f[X]=Y,g[X]=0;
	}
	void dfs(int p=X,int h=0)
	{

		if(p==f[p])return;
		rept(p,s)
		{
			if(t.check(p,q))isit[p]=isit[q]=1;
			if(q==f[p])continue;
			f[q]=t.go(f[p],q);
			g[q]=g[p]+1;
			dfs(q,p);
		}
	}
	int getans()
	{
		int ret=0;
		for(int i=1;i<=n;i++)
		{
			if(!f[i])continue;
			if(f[i]!=i && isit[i])return -1;
//			printf("%d %d %d\n",i,f[i],g[i]);

			check_max(g[i]+t.dis(i,f[i]),ret);
		}
		return ret*2;
	}
	void solve()
	{
		initialize();
		dfs();
		printf("%d\n",getans());
	}
}
int main()
{
//	freopen("in","r",stdin);
	wrong::solve();
	return 0;
}


Measured memory_bytes: 36736
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  string s;
  cin >> s;
  ll n = s.size();
  ll ans = 0;
  rep(bit, 1 << n) {
    ll t = 0;
    string num = {s[0]};
    rep(j, n - 1) {
      if (bit >> j & 1) {
        t += stol(num);
        num = s[j + 1];
      } else {
        num += s[j + 1];
      }
    }
    if (num == "") {
      num += s[n - 1];
      t += stol(num);
    } else {
      t += stol(num);
    }
    ans += t;
  }
  ans /= 2;
  ANS;
  return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
using namespace std;

int main(){
    int n;
    scanf("%d",&n);
    //printf("%d",n);
    int A[n];
    for(int i = 0; i < n; i++){
        scanf("%d", &A[i]);
    }
    for(int foc = 0; foc < n; foc++){
        int key = A[foc];
        int j = foc-1;
        while( j >= 0 && A[j] > key){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = key;
        //printf("debug\n");
        for(int i=0; i<n; i++){
            printf("%d", A[i]);
            if(i!=n-1)printf(" ");
        }
        printf("\n");
    }
}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> A(N+1), B(N);
  for (ll i = 0; i <= N; i++) cin >> A[i];
  for (ll i = 0; i < N; i++) cin >> B[i];
  ll ans = 0;
  for (ll i = N-1; i >= 0; i--) {
    ll v = min(B[i], A[i+1]);
    ans += v;
    A[i+1] -= v;
    B[i] -= v;
    ll w = min(B[i], A[i]);
    ans += w;
    A[i] -= w;
    B[i] -= w;
  }
  cout << ans << endl;
  

  return 0;
}



Measured memory_bytes: 4776
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

template<typename T>
struct BIT {
	int n;
	vector<T>dat;
	BIT(int n = 0) {
		initialize(n);
	}
	void initialize(int temp) {
		n = temp;
		dat.resize(n);
		rep(i, 0, n)dat[i] = 0;
	}
	T sum(int i) {
		T s = 0;
		while (i >= 0) {
			s += dat[i];
			i = (i & (i + 1)) - 1;
		}
		return s;
	}
	T sum_between(int i, int j) {
		if (i > j)return 0;
		return sum(j) - sum(i - 1);
	}
	void plus(int i, T x) {
		while (i < n) {
			dat[i] += x;
			i |= i + 1;
		}
	}
	int lower_bound(T x) {
		if (sum(n - 1) < x)return -1;
		else if (sum(0) >= x)return 0;
		int ng = 0, ok = n - 1;
		while (ok - ng > 1) {
			int mid = (ok + ng) / 2;
			if (sum(mid) >= x)ok = mid;
			else ng = mid;
		}
		return ok;
	}
};


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

	BIT<ll>bit(2020);
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int L;
		cin >> L;
		bit.plus(L,1);
	}

	ll ans = 0;
	for (int i = 1; i <= 2020; i++) {
		ll p = bit.sum_between(i,i);
		ans += (p*(p - 1)*(p - 2)) / 6LL;
		ans += ((p*(p - 1)) / 2LL)*(bit.sum_between(0,i-1));
		for (int j = 1; j < i; j++) {
			ll q = bit.sum_between(j,j);
			if (2 * j > i)ans += ((q*(q - 1)) / 2LL)*p;
		}
		for (int j = 1; j < i; j++) {
			ll r = bit.sum_between(j, j);
			ll s = bit.sum_between(i-j+1,j-1);
			ans += p*r*s;
		}
	}
	puts(ans);
	

	return 0;
}


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

using namespace std;

const int maxn=2e5+5;

typedef long long ll;

const ll mod=1e9+7;

int num[20][20];

int digit(int num){
	int ans=0;
	while(num){
		ans++;
		num/=10;
	}
	return ans;
}

int qPow(int a,int b){
	int ans=1;
	while(b){
		if(b&1) ans*=a;
		a*=a;
		b>>=1;
	}
	return ans;
}

int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int sec=i%10;
		int tmp=digit(i)-1;
		int fir=i/qPow(10,tmp);
//		printf("%d %d %d\n",i,fir,sec);
		num[fir][sec]++;
	}
	ll ans=0;
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
//			printf("%d %d %d\n",i,j,num[i][j]);
			ans+=num[i][j]*num[j][i];
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  vector<int> v(3);
  rep(snip_i, 3){
    cin >> v.at(snip_i);
  }
  sort(v.begin(), v.end());
  int ans = 0;
  ans += v.at(2) - v.at(1);
  v.at(0) += ans;
  int dif = v.at(2) - v.at(0);
  int add = dif/2;
  ans += add;
  v.at(0) += dif/2*2;
  if(v.at(0) != v.at(2)) ans += 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
using namespace std;
void dfs(vector<int> adj[],int i,bool a[])
{
	a[i]=1;
	for(auto itr=adj[i].begin();itr!=adj[i].end();itr++)
	{
		if(!a[*itr])
		{
			dfs(adj,*itr,a);
		}
	}
}
int main() {
	int n,m,i,j,k,ans=0;
	cin>>n>>m;
	bool a[n+1]={0};
	vector<int> adj[n+1];
	while(m--)
	{
		cin>>i>>j>>k;
		adj[i].push_back(j);
		adj[j].push_back(i);
	}
	for(i=1;i<=n;i++)
	{
		if(a[i]==0)
		{
			ans++;
			dfs(adj,i,a);
		}
	}
	cout<<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 10496
#include <stdio.h>
 
int main()
{
  unsigned long n;
  scanf("%lu",&n);
  unsigned long a[n];
  int i;
  i = 0;
  unsigned long sum = 0;
  unsigned long p = 0;
  while (i < n)
  {
    scanf("%lu",&a[i]);
    if (i != 0)
    {
        p += a[i - 1];
      	p %= 1000000000 + 7;
    	sum += a[i]*p;
      	if(sum >= 1000000000 + 7)
         sum %= 1000000000 + 7;
    }
    i++;
  }
  printf("%lu",sum % (1000000000 + 7));
}

Measured memory_bytes: 3264
n = int(input())
s = str(input())
#n = len(s)

bl = s.count('#')
wh = s.count('.')
cnt = wh
mincnt = cnt
for i in range(n):
    if s[i] == '#':
        cnt += 1
    else:
        cnt -= 1
    mincnt = min(mincnt, cnt)

print(mincnt)
        

Measured memory_bytes: 3500
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

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

	int N;
	cin >> N;
	vector<pair<int, int>> A( N );
	for( auto& v: A ) { cin >> v.first >> v.second; }
	sort( A.begin(), A.end() );

	cout << A.back().first + A.back().second << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}


using namespace std;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(int argc, char *argv[]) {
    ll result = 0;
    ll A, B;
    cin >> A >> B;
    
    result = A + B;
    if(result < A - B){
        result = A-B;
    }
    if(result < A * B){
        result = A*B;
    }
    
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <cmath>
#include <bitset>
#include <queue>
#include <set>
#include <numeric>
#include <unordered_set>

using namespace std;

#define ef emplace_front
#define eb emplace_back
#define mp make_pair
#define MOD 1000000007

typedef long double f80;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef float f32;
typedef double f64;
typedef long double f80;
typedef unordered_set<int> usi;
typedef set<int> si;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
	
	int n;
	string s,t;
	cin>>n>>s>>t;
	for (int i=0;i<n;++i){
		cout<<s[i]<<t[i];
	}
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] a = new int[N];
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}

		int[] dp = new int[N];
		Arrays.fill(dp, (int)Double.POSITIVE_INFINITY);
		dp[0] = 0;

		for (int i = 0; i < N; i++) {
			for (int j = 1; j <= K; j++) {
				if (i + j < N)
					dp[i + j] = Math.min(dp[i + j], dp[i] + Math.abs(a[i] - a[i + j]));
			}
		}

		System.out.println(dp[N - 1]);
	}

}


Measured memory_bytes: 50132