akhauriyash/Code-Regression huggingface dataset:
using System;
public class simple {
    public static void Main() {
        while (true) {
            string[] read = new string[2];
            read = Console.ReadLine().Split(' ');
            int x = int.Parse(read[0]);
            int y = int.Parse(read[1]);
            int button = 0;
            bool same = false;
            if (x > 0) {
                if (y > 0) {
                    same = true;
                } else if (y < 0) {
                    same = false;
                }
            } else if (x < 0) {
                if (y > 0) {
                    same = false;
                } else if (y < 0) {
                    same = true;
                }
            }
            if (same==true) {//x,yが同じ符号
                if (x == y) {
                    button = 0;
                } else if (x < y) {
                    button = y - x;
                } else if (x > y) {
                    button = 1 + x - y + 1;
                }
            } else if (same==false) {//x,yが異なる符号
                if (x < 0) {
                    if (x == -1 * y) {
                        button = 1;
                    } else {
                        if (-1 * x > y) {
                            button = -(x + y) + 1;
                        } else {
                            button = 1 + y + x;
                        }
                    }
                } else if (x > 0) {
                    if (x == -1 * y) {
                        button = 1;
                    } else {
                        if (x > -1 * y) {
                            button = 1 + x + y;
                        } else {
                            button = -(x + y) + 1;
                        }
                    }
                }

            } 
            if(x*y==0) {//x,yのどちらかが0
                if (x == 0) {
                    if (y >= 0) {
                        button = y - x;
                    } else {
                        button = 1 - y;
                    }
                }
                if (y == 0) {
                    if (x >= 0) {
                        button = x + 1;
                    } else {
                        button = 0 - x;
                    }
                }
            }
            /*int button2 = 9999999;
            if (x * y < 0) {
                if (x < 0) {
                    if (-1 * x > y) {
                        button2 = -(x + y) + 1;
                    } else {
                        button2 = 1 + y + x;
                    }
                } else {


                }
            }
            if (button <= button2) {
                Console.WriteLine(button);
            } else {
                Console.WriteLine(button2);
            }*/
            Console.WriteLine(button);
            break;
        }
    }
}

Measured memory_bytes: 2648
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
 
using namespace std;
 
#define INF (1 << 30)
 
struct Route
{
    int x, y, z;
};
 
struct Path
{
    int mask;
    int city;
    vector<int> pathCost;
};
 
bool solve()
{
    int n, m, p, a, b;
    cin >> n >> m >> p >> a >> b;
 
    if( (n | m | p | a | b) == 0 )return false;
 
    //?????????????????????????????????
    a--;
    b--;
 
    vector<int> t(n);
 
    for(auto& _t : t)
    {
        cin >> _t;
    }
 
    //dummy data
    t.push_back(-10);
 
    sort(t.begin(), t.end(), std::greater<int>());
 
    vector<Route> route(p);
    vector<Route> bin[30];
 
    for(auto& r : route)
    {
        cin >> r.x;
        cin >> r.y;
        cin >> r.z;
 
        //?????????????????????????????????
        r.x--;
        r.y--;
 
        bin[r.x].push_back(r);
        bin[r.y].push_back(Route{ r.y, r.x, r.z }); 
    }
  
    //a???start
    //b???goal
    queue<Path> que;
    queue<Path> ansPath;
 
    Path tmp{ 1 << a, a };
    tmp.pathCost.push_back(0);
 
    que.push(tmp);
 
    double minCost[30] = {};
    for(auto &mc : minCost)
    {
        mc = INF;
    }
    minCost[a] = 0.0;
 
    //??¬???????????°
    for(int i = 0; i < n; i++)
    {
        while(que.front().pathCost.size() == (i + 1))
        {
            //que.front???????????????
            int nowCity = que.front().city;
            //cout << "now : " << nowCity << " loops " << bin[nowCity].size() << "times\n";
            for(int j = 0; j < bin[nowCity].size(); j++)
            {
                //?????§?????\????????¨????????£??????
                if(que.front().mask & 1 << bin[nowCity][j].y)        
                {
                    //cout << bin[nowCity][j].y << " skip\n";
                    continue;
                }

                //?¬????????????????
                Path next = que.front();
                next.mask |= 1 << bin[nowCity][j].y;
                next.city = bin[nowCity][j].y;
                next.pathCost.push_back(bin[nowCity][j].z);
 
                //??????????????§?????????????????????
                sort(next.pathCost.begin(), next.pathCost.end(), std::greater<int>());
 
                double cost_tmp = 0.0;
                for(int i = 0; i < next.pathCost.size(); i++)
                {
                    //cout << cost[i] << " " << t[i] << endl;
                    cost_tmp += (double)next.pathCost[i] / (double)t[i];
                }
 
                if(cost_tmp < minCost[next.city]) minCost[next.city] = cost_tmp;
                else continue;
             
 
                //cout << " next : " << next.city << endl;
 
                //????????°??????????????????????????????push
                if(next.city == b) ansPath.push(next);
                else que.push(next);
            }
 
            que.pop();
            //cout << " : " << que.size() << " " << ansPath.size() << endl;
        }
    }
 
 
    if(minCost[b] >= INF - 1){
        cout << "Impossible\n";
        return true;
    }
 
    cout << minCost[b] << endl;
 
    return true;
 
}
 
int main()
{   
    while( solve() );
 
    return 0;
}

Measured memory_bytes: 3092
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	map<string, int>mp;
	for (int n = 0; n < N; ++n) {
		string S;
		cin >> S;
		sort(S.begin(),S.end());
		mp[S]++;
	}
	long long ans = 0;
	auto begin = mp.begin(), end = mp.end();
	for (auto iter = begin; iter != end; iter++) {
		ans += (long long)iter->second*(iter->second-1)/2;
	}
	cout << ans <<endl;
	return 0;
}


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

using namespace std;

int main()
{
  int a, b, c;
  scanf("%d %d", &a, &b);
  if ((a==1 && b==2) || (a==2 && b==1))c = 3;
  if ((a==2 && b==3) || (a==3 && b==2))c = 1;
  if ((a==3 && b==1) || (a==1 && b==3))c = 2;
  printf("%d\n", c);
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]
dist = 10**9


for i, j in ab:
    for k in range(m):
        dist1 = abs(i - cd[k][0]) + abs(j - cd[k][1])
        if dist1 < dist:
            dist = dist1
            ch = k + 1
    print(ch)
    dist = 10**9

Measured memory_bytes: 3064
// ░▒▓█████▓▒▒                       ▒▓█████████▓▒
// ▒▓██▒▒▓███▒░                      ▓█▓▓▓▓▓▓▓███▒
// ▒▓██   ▒▓██▒░                     ▒▓▓▒▒▒░  ███▒
// ▒▓██  █████▒░            ░░░░░░    ▒▒▒░  ████▒░           ░░▒▒░░
// ▒▓█████▓▓▓▒░          ░▒▒██████░    ▒▒  ███▒▒           ░▒██████▒░
// ▒▓██░███░░░          ░▒▒██▒▒░██░     ░ ███▒░            ▒▓█▓   ██░
// ▒▓██ ▒▓███       ░░  ░▒██ ░░ ██░░    ░███▒▒             ▒▓██████▓░
// ▒▓▓█  ▒▒▓███░  ░▒██▒ ░▒██ ░░ ██▒▒░ ░▓███▒▒▒▒▒▒▒░  ▒██▒░ ▒▓█▓
// ░▓▓█▒  ▒▒▒▓██░ ░▓██▓ ░▒██████████░ ▒███████████▒  ▓██▓░ ░▒▓█████▓▓░░
// ░▒▓▓▒   ░░▒▓▓▓ ░▒▓▓▒  ░▒▓▓▓▓▓▓▒▒▒░  ░▓▓▓▓▓▓▓▓▓▒   ▒▓▓▒░  ░▒▒▒▒▒▒░░░
//  ░░░░     ░░▓▓  ░▒▒░   ░▒▒▒▒▒▒▒       ░░▒▒▒▒▒     ░▒▒░    ░▒▒▒▒░░
//  ░░░░     ░░░░   ░░      ░░▒░           ░░░░       ░░      ░░░░░
//   ░░       ░░     ░       ░░             ░░         ░        ░░
//   ░       ░░     ░        ░              ░         ░         ░
//   ░        ░     ░        ░              ░   ░     ░         ░
//   ░        ░     ░        ░              ░         ░         ░
#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i, x, y)   for (__typeof(x) i = x; i < y; ++i)
#define repr(i, x, y)   for (__typeof(x) i = x; i > y; i --)
#define endl "\n"
#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define rSort(x)                     sort((x).rbegin(),(x).rend())
#define X                           first
#define Y                           second
#define sep                         ' '
#define SZ(x)                       ll(x.size())
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define pb                          push_back
#define mp                          make_pair
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define first X
#define second Y

const ll N = 1e6 + 7;
const ll NN = 1e7 + 7;

int32_t main()
{
   IOS;
   ll n,m,p,pen=0,AC=0;
   string s;
   cin >> n >> m;
   ll A[n+1],B[n+1];
   rep(i,0,n+1){
       B[i]=0;
       A[i]=0;
   }
   rep(i,0,m){
    cin >> p >> s;
    if(B[p]==1)continue;
    else{
      if(s=="WA") A[p]++;
      else{
        B[p]=1;
        AC++;
      }
    }
   }
   rep(i,0,n+1){
       if(B[i]==1) pen+=A[i];
   }
   cout << AC << sep << pen << endl;


   
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define all(a)  (a).begin(), (a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i = 0; i < n; i++)
#define repR(i,n) for(int i = n-1; i >= 0; i--)
#define FOR(i,m,n) for(int i = m; i < n; i++)
#define PB push_back
#define MP make_pair
#define EPS (1e-7)
#define INF (1e12)
#define PI (acos(-1))

int main(){
    ll n,sum = 0;
    cin >> n;
    vector<ll> A(n+2);
    A[0] = A[n+1] = 0;
    rep(i,n) cin >> A[i+1];
    rep(i,n+1) sum += abs(A[i+1] - A[i]);
    rep(i,n+1){
        if(!i)continue;
        cout << sum + abs(A[i+1]-A[i-1]) - abs(A[i+1] - A[i])
                    - abs(A[i] - A[i-1]) << endl;
    }
    return 0;
}


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

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

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

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

	if(x>=30)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	


    return 0;
}

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

using pii = pair<int, int>;
constexpr int inf = 1e9;

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

int main() {
    int h, w; cin >> h >> w;
    vector<string> a(h);
    vector<vector<int>> dist(h, vector<int>(w, inf));
    queue<pii> que;
    for(int i = 0; i < h; ++i) {
        cin >> a[i];
        for(int j = 0; j < w; ++j) {
            if(a[i][j] == '#') {
                que.emplace(i, j);
                dist[i][j] = 0;
            }
        }
    }

    auto in_range = [&] (int y, int x) {
        return 0 <= y && y < h && 0 <= x && x < w;
    };
    int ans = 0;
    while(!que.empty()) {
        const int y = que.front().first, x = que.front().second;
        que.pop();
        for(int i = 0; i < 4; ++i) {
            const int ny = y + dy[i], nx = x + dx[i];
            if(!in_range(ny, nx) || dist[ny][nx] != inf) continue;
            dist[ny][nx] = dist[y][x] + 1;
            que.emplace(ny, nx);
            ans = max(ans, dist[ny][nx]);
        }
    }

    cout << ans << endl;
}

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

int main() {
  long long n, m, inf = 100000000000000;
  cin >> n >> m;
  vector<long long> a(m), f(n+1, inf);
  for(int i = 0; i < m; i++) {
    cin >> a.at(i);
    f.at(a.at(i)) = 0;
  }
  f.at(0) = 1;
  if(f.at(1) != 0) f.at(1) = 1;
  for(int i = 2; i <= n; i++) {
    if(f.at(i) == inf) {
      f.at(i) = f.at(i-1) + f.at(i-2);
      f.at(i) %= 1000000007;
    }
  }
  cout << f.at(n);
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 1000005
#define MOD 1000000007

using namespace std;
typedef long long int ll;

ll dp[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	dp[n-1]=n;
	ll sum=0;
	int to=n-1;
	for(int i=n-2;i>=0;i--)
	{
		dp[i]=dp[i+1];
		dp[i]+=(ll) (n-1)*(ll) (n-1)%MOD;
		if(dp[i]>=MOD) dp[i]-=MOD;
		while(to>=i+3)
		{
			sum+=dp[to];
			if(sum>=MOD) sum-=MOD;
			to--;
		}
		dp[i]+=sum;
		if(dp[i]>=MOD) dp[i]-=MOD;
		if(i==n-2) dp[i]+=n-1;
		else dp[i]+=i+2;
		if(dp[i]>=MOD) dp[i]-=MOD;
	}
	printf("%lld\n",dp[0]);
	return 0;
}


Measured memory_bytes: 7936
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll n,a;
  cin>>n>>a;
  a = 2*a+1;
  ll ans = n/a;
  if(n%a!=0)ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]

a_sum = abs(a[0])
a_min = abs(a[0])
cnt = 0
if a[0] < 0:
    cnt += 1
for i in range(n - 1):
    a_min = min(a_min, abs(a[i+1]))
    a_sum += abs(a[i+1])
    if a[i + 1] < 0:
        cnt += 1
if cnt % 2 == 0:
    print(a_sum)
else:
    print(a_sum-a_min*2)


Measured memory_bytes: 64752
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <functional>

#include <sstream>
#include <iostream>

using namespace std;
typedef long long llint;
const llint inf = 1000000000000000000LL;

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

#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<

const int MAXN = 2005;
int N, K;

int f[MAXN];
int dep[MAXN];
int wei[MAXN];
vector< int > T[MAXN];

int idx[MAXN];
set< pair< int, int > > S[MAXN];

void calc(int i, int dad = -1, int d = 0) {
  dep[i] = d;
  wei[i] = 1;

  int best = -1;

  for (int j : T[i]) {
    if (j != dad) {
      calc(j, i, d + 1);
      wei[i] += wei[j];
      if (best == -1 || wei[j] > wei[best])
	best = j;
    }
  }

  if (best == -1)
    idx[i] = i;
  else
    idx[i] = idx[best];

  int id = idx[i];

  S[id].insert({-dep[i], i});

  for (int j : T[i]) 
    if (j != dad && j != best) 
      for (auto k : S[idx[j]])
	S[id].insert(k);

  while (!S[id].empty() && -(S[id].begin()->first) > min(K, 2 * dep[i] - 2))
    S[id].erase(S[id].begin());

  f[i] = S[id].size();
}

int kill[MAXN];

void dfs(int i, int dad = -1, int killed = 0) {
  kill[i] = killed + wei[i] - 1;

  int sum = 0;
  
  for (int j : T[i]) 
    if (j != dad)
      sum += wei[j] - f[j];

  for (int j : T[i])
    if (j != dad)
      dfs(j, i, killed + sum - wei[j] + f[j]);
}

int solve(int i) {
  FOR(j, 1, N + 1) S[j].clear();

  calc(i);
  dfs(i);

  int sol = 1e9;
  FOR(j, 1, N + 1)
    if (dep[j] <= K)
      sol = min(sol, kill[j]);

  return sol;
}

int main(void) 
{
  scanf("%d%d", &N, &K);

  REP(i, N - 1) {
    int a, b;
    scanf("%d%d", &a, &b);
    T[a].push_back(b);
    T[b].push_back(a);
  }

  // solve(1);
  
  int sol = 1e9;
  FOR(i, 1, N + 1) 
    if (T[i].size() == 1)
      sol = min(sol, solve(i));
    
  printf("%d\n", sol);

  return 0;
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
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;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N, A, B; cin >> N >> A >> B;
  ll ans = 0;
  ll vmax = A + (N - 1) * B;
  ll vmin = A * (N - 1) + B;
  ans = vmax - vmin + 1;
  if(ans < 0) ans = 0;
  

  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


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

using namespace std;
	
const int maxn = 1e5 + 20;
int ar[maxn];

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	if((c-b)%2 == 0)
		cout << "Alice";
	else 
		cout << "Borys";
}		

 



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_169b
{
    class Program
    {
        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());
            long[] num = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            long res = 1;

            if (num.Contains(0))
            {
                Console.WriteLine("0");
                Console.Read();
                return;
            }

            try
            {
                checked
                {
                    foreach (long item in num)
                    {
                        res *= item;

                        if (res > (long)Math.Pow(10, 18))
                        {
                            res = long.Parse("-1");
                        }
                    }
                }
            }
            catch
            {
                res = long.Parse("-1");
            }
            
            Console.WriteLine(res);
            Console.Read();

        }
    }
}

Measured memory_bytes: 42316
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i,a,b) for(int i=(a);i<=(b);++i)
#define FD(i,b,a) for(int i=(b);i>=(a);--i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;
constexpr int inv(LL x, int m) { return x > m ? inv(x % m, m) : x > 1 ? inv(m % x, m) * (m - m / x) % m : x; }
constexpr int mpow(LL a, LL k, int m) { int r(1); for (a %= m; k; k >>= 1, a = a * a % m) if (k & 1)r = r * a % m; return r; }

struct DSU {
    vector<int> F;
    DSU(int n): F(n, -1) {}
    int root(int x) { return F[x] < 0 ? x : F[x] = root(F[x]); }
    int size(int x) { return -F[root(x)]; }
    bool same(int x, int y) { return root(x) == root(y); }
    bool unite(int x, int y) {
        x = root(x), y = root(y);
        if (x != y) { if (F[y] < F[x]) swap(x, y); F[x] += F[y], F[y] = x; }
        return x != y;
    }
};

const int N = 2e5 + 5;
LL n, d, A[N];
DSU uf(N);
using PLI = pair<LL, int>;
vector<tuple<LL, int, int>> E;

void dac(int l, int r) {
    if (l + 1 >= r) return;
    int m = (l + r) >> 1;
    dac(l, m), dac(m, r);
    PLI left = {1LL << 60, 0}, right = {1LL << 60, 0};
    for (int i = l; i < m; i++) left = min(left, PLI{A[i] - i * d, i});
    for (int i = m; i < r; i++) right = min(right, PLI{A[i] + i * d, i});
    for (int i = l; i < m; i++) E.emplace_back(right.first + A[i] - i * d, i, right.second);
    for (int i = m; i < r; i++) E.emplace_back(left.first + A[i] + i * d, i, left.second);
}
int main() {
    cin >> n >> d;
    FI(i, 1, n) scanf("%lld", &A[i]);
    dac(1, n + 1);
    sort(E.begin(), E.end());
    LL ans = 0;
    for (auto e : E) {
        LL len;
        int i, j;
        tie(len, i, j) = e;
        if (!uf.same(i, j)) ans += len, uf.unite(i, j);
    }
    cout << ans << endl;
}


Measured memory_bytes: 70240
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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 T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    string s;
    cin>>s;
    ll cnt=0;
    if(s.size()==1) {
        cout<<0<<endl;
        return 0;
    }
    for(int i=1;i<s.size();i++){
        if(i%2==0){
            if(s[i]!=s[0]) cnt++;
        }
        else{
            if(s[i]==s[0]) cnt++;
        }
    }
    cout<<cnt<<endl;

    return 0;
}

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

#define S(num)			((num) * (num))

typedef struct {
	float vertical;
	float horizontal;
	float height;
} DATA;

int main(void)
{
	DATA cheese;
	float min_line;
	float in_circle;
	int n;
	int i;
	
	while (1){
		scanf("%f %f %f", &cheese.vertical, &cheese.horizontal, &cheese.height);
		
		if (cheese.vertical == 0){
			break;
		}
		
		scanf("%d", &n);
		
		min_line = sqrt(S(cheese.vertical) + S(cheese.horizontal));
		
		if (sqrt(S(cheese.vertical) + S(cheese.height)) < min_line){
			min_line = sqrt(S(cheese.vertical) + S(cheese.height));
		}
		
		if (sqrt(S(cheese.horizontal) + S(cheese.height)) < min_line){
			min_line = sqrt(S(cheese.horizontal) + S(cheese.height));
		}
		
		for (i = 0; i < n; i++){
			scanf("%f", &in_circle);
			if (in_circle * 2 > min_line){
				printf("OK\n");
			}
			
			else {
				printf("NA\n");
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <stdio.h>
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

using ll = long long;
using ull = unsigned long long;
//constexpr ll N = 2e5;
//ll a[N];

//constexpr int max = 2147483647;


bool sunuke[100 + 1] = { false };

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

	for (int i = 0; i < k; i++)
	{
		int tmp;
		cin >> tmp;
		for (int i = 0; i < tmp; i++)
		{
			int t;
			cin >> t;
			sunuke[t] = true;
		}
	}

	int c = 0;
	for (int i = 1; i <= n; i++)
	{
		if (!sunuke[i])
			c++;
	}

	cout << c;
	
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N);
  vector<int> B(N-1);
  for( int i = 0; i < N-1; i++ ) cin >> B.at(i);
  
  A.at(0) = B.at(0);
  for( int i = 1; i < N-1; i++ ) A.at(i) = min( B.at(i), B.at(i-1) );
  A.at(N-1) = B.at(N-2);
  
  int sum = 0;
  for( int i = 0; i < N; i++ ) sum += A.at(i);
  
  cout << sum;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 10;
int num[N];
bool dfs(int i,int a,int b){
	if(i == N)	return true;
	if(num[i] > a)	if(dfs(i+1,num[i],b))	return true;
	if(num[i] > b)	if(dfs(i+1,a,num[i]))	return true;
	return false;
}
bool solve(){ return dfs(0,-1,-1); }
int main(){
	int T;	scanf("%d",&T);
	while(T--){
		for (int i = 0; i < N; ++i)	scanf("%d",num+i);
		if(solve())	puts("YES");
		else		puts("NO");
	}
}


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

ifstream in("test.in");
ofstream out("test.out");

int main(void) {
    srand(unsigned(time(0)));
    
    long long x, y, z, t, n, ans = 0;
    cin >> x >> y >> z >> t >> n;
    
    y = min(y, 2 * x);
    z = min(z, 2 * y);
    t = min(t, 2 * z);
    
    n *= 4;
    ans += (n / 8) * t;
    n %= 8;
    
    ans += (n / 4) * z;
    n %= 4;
    
    ans += (n / 2) * y;
    n %= 2;
    
    ans += n * x;
    cout << ans;
    
    return 0;
}


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

int main() {
    string S;
    cin >>S;
    int N;
    cin >>N;
    for (int i=0; i<N; i++) {
        string C;
        int x, y;
        cin >>C >>x >>y;
        if ("print" == C)
            cout <<S.substr(x, y-x+1) <<endl;
        else if ("reverse" == C)
            reverse(S.begin()+x, S.begin()+y+1);
        else {
            string R;
            cin >>R;
            S = S.substr(0, x)+R+S.substr(y+1);
        }
    }
    return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a; cin>>a;
	cout<<a*a;
	
	return 0;
}

Measured memory_bytes: 3600
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class C
{
	public static void Main()	
	{
		int N = GetInt();
		int[] a = new int[N];
		for(int i = 0; i < N; i++)
			a[i] = GetInt();

		int minCost = int.MaxValue;
		for(int i = -100; i <= 100; i++)
		{
			int cost = 0;
			for(int j = 0; j < N; j++)
				cost += (i - a[j]) * (i - a[j]);
			minCost = Math.Min(minCost, cost);
		}

		Console.WriteLine(minCost);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 13140
#include<cstdlib>
#include<iostream>
#include<string>

using namespace std;

struct Node {
  int key;
  Node* right;
  Node* left;
  Node* parent;
};

Node* root;
Node* NIL;

void insert(int k) {
  Node* y = NIL;
  Node* x = root;
  Node* z;

  z = (Node*) malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;
  if (y == NIL) {
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void preOrder(Node* u) {
  if (u == NIL) {
    return;
  }
  cout << " " << u->key;
  preOrder(u->left);
  preOrder(u->right);
}

void inOrder(Node* u) {
  if (u == NIL) {
    return;
  }
  inOrder(u->left);
  cout << " " << u->key;
  inOrder(u->right);
}

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

  int x;
  string com;
  for (int i = 0; i < N; i++) {
    cin >> com;
    if (com == "insert") {
      cin >> x;
      insert(x);
    } else if (com == "print") {
      inOrder(root);
      cout << endl;
      preOrder(root);
      cout << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 26644
#include<stdio.h>
#include<stdlib.h>
#define MAX 101

int top;
int S[MAX];

void initialize()
{
  top = 0;
}

int isEmpty()
{
  return top == 0;
}

int isFull()
{  
  return top >= MAX - 1;
}

void push(int x)
{
  if (isFull()) {
    exit(1);
  }
             
  top++;
  S[top] = x;
}

int pop() {
  if (isEmpty()) {
    exit(1);
  }

  top--;
  return S[top+1];
}

int main(void)
{
  int x, a, b;
  char s[MAX];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a = pop();
      b = pop();
      push(a+b);
    } else if ( s[0] == '-' ){
      a = pop();
      b = pop();
      push(b-a);
    } else if ( s[0] == '*' ){
      a = pop();
      b = pop();
      push(a*b);
    } else {
      x = atoi(s);
      push(x);
    }
  }
  
  printf("%d\n", pop());
  return 0;
}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL L,R;
int main(){
	scanf("%lld%lld",&L,&R);
	LL mi=2e9;
	for(LL i=L;i<=min(R,L+2019);i++){
		for(LL j=i+1;j<=min(R,L+2019);j++){
			mi=min(mi,i*j%2019);	
		}
	}
	printf("%lld\n",mi);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, ans = 0;
    cin >> n;
    cout << (n - 2) * 180 << endl;
    return 0;
}


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

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.rbegin(), A.rend());

    int alice = 0;
    int bob = 0;
    for (int i = 0; i < N;i++){
        if(i%2==0){
            alice += A[i];
        }else{
            bob += A[i];
        }
    }
    cout << alice - bob;
}

Measured memory_bytes: 256
n,m,k = map(int, input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
def ruiseki(n, A):
    "長さnの数列Aの累積和を返す　ただし[0] = 0"
    res = [0]*(n+1)
    for i in range(n):
        res[i+1] = res[i] + A[i]
    return res
sa = ruiseki(n,A)
sb = ruiseki(m,B)

ans = 0
j = m
for i,a in enumerate(sa):
    
    while j >= 0 and a+sb[j] > k:
        j -= 1
    if j < 0:break
    ans = max(ans,i+j)
print(ans)


Measured memory_bytes: 117796
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
// #define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

int w, h;
char c[51][51];
int dy[4] = {1, -1, 0, 0};
int dx[4] = {0, 0, 1, -1};
bool contain(int y, int x){
    return (0 <= y && y < h && 0 <= x && x < w);
}

signed main(){
    while(1){
        cin >> w >> h;
        if(w + h == 0) break;
        int wsum = 0, bsum = 0;
        rep(i, 0, h){
            rep(j, 0, w){
                cin >> c[i][j];
                if(c[i][j] == 'W') wsum++;
                if(c[i][j] == 'B') bsum++;
            }
        }
        int data[51][51] = {};
        rep(i, 0, h){
            rep(j, 0, w){
                if(c[i][j] != '.'){
                    int id = (c[i][j] == 'W' ? 1 : 2);
                    string str = "?BW";
                    if(data[i][j] & id) continue;
                    queue<P> q;
                    q.push(P(i, j));
                    data[i][j] |= id;
                    while(!q.empty()){
                        P p = q.front(); q.pop();
                        int y = p.first;
                        int x = p.second;
                        rep(k, 0, 4){
                            int ny = y + dy[k];
                            int nx = x + dx[k];
                            if(!contain(ny, nx)) continue;
                            if(c[ny][nx] == str[id]) continue;
                            if(data[ny][nx] & id) continue;
                            data[ny][nx] |= id;
                            q.push(P(ny, nx));
                        }
                    }
                }
            }
        }
        int wc = 0, bc = 0;
        rep(i, 0, h){
            rep(j, 0, w){
                if(data[i][j] == 1) wc++;
                if(data[i][j] == 2) bc++;
                // cout << data[i][j];
            }
            // cout << endl;
        }
        cout << bc - bsum << " " << wc - wsum << endl;
    }
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 1e6 + 10;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
  int n;cin >> n;
  vector<int>x(n),y(n),h(n);
  for(int i = 0;i<n;i++){
    cin >> x[i] >> y[i] >> h[i];
  }
  for(int nx = 0;nx<=100;nx++){
    for(int ny = 0;ny<=100;ny++){
    bool ok = 1;int now = 0;int lim = 2e9;
        for(int i = 0;i<n;i++){
            int a = abs(x[i]-nx)+abs(y[i]-ny);
            int dh = h[i]+a;
            if(h[i]==0){
                lim = min(dh,lim);
                continue;
            }
            if(now == 0){
                now = dh;
            }
            else{
                if(dh!=now) ok = 0;
            }
        }
        now = max(now,1);
        if(now>lim) ok = 0;
        if(ok){
            cout << nx <<' '<< ny <<' '<< now;
            return;
        }
    }
  }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}


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

using namespace std;

int main(){

    int n, m;
    cin >> n >> m;
    vector<vector<int>> top(n, vector<int>(m, 0)), bottom(n, vector<int>(m, 0)), left(n, vector<int>(m, 0)), right(n, vector<int>(m, 0));
    vector<vector<int>> org(n, vector<int>(m, 0));
    string s;
    for(int i = 0; i < n; i++){
        cin >> s;
        for(int j = 0; j < s.size(); j++)
            if( s[j] == '.' )
                org[i][j] = 1;
    }

    // filling the top
    for(int i = 1; i < n; i++)
        for(int j = 0; j < m; j++)
            if( org[i][j] && org[i-1][j] )
                top[i][j] = top[i-1][j]+1;

    // filling the bottom
    for(int i = n-2; i >= 0; i--)
        for(int j = 0; j < m; j++)
            if( org[i][j] && org[i+1][j] )
                bottom[i][j] = bottom[i+1][j] + 1;

    // filling the left
    for(int j = 1; j < m; j++)
        for(int i = 0; i < n; i++)
            if( org[i][j] && org[i][j-1] )
                left[i][j] = left[i][j-1] + 1;

    // filling right
    for(int j = m-2; j >= 0; j--)
        for(int i = 0; i < n; i++)
            if( org[i][j] && org[i][j+1] )
                right[i][j] = right[i][j+1] + 1;

    int res = 0;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            if( org[i][j] )
                res = max(res, top[i][j] + bottom[i][j] + left[i][j] + right[i][j] + 1);

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 78720
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;	
 
signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int a, b;
	cin >> a >> b;
	if(a >= 1 && a <= 9 && b >= 1 && b <= 9)
		cout << a*b;
	else
		cout << -1;	
	return 0;
}

Measured memory_bytes: 256
/*
 * 2592.cc: Flowers
 */

#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 = 100000;

/* typedef */

typedef long double ld;

/* global variables */

ld vws[MAX_N], pfs[MAX_N], vfs[MAX_N], ths[MAX_N];

/* subroutines */

ld cost(int n, ld w, ld pw) {
  ld sum = w * pw;
  for (int i = 0; i < n; i++) {
    ld fi = (ths[i] - w * vws[i]) / vfs[i];
    if (fi > 0.0) sum += fi * pfs[i];
  }
  return sum;
}

/* main */

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (n == 0) break;

    ld pw;
    cin >> pw;

    for (int i = 0; i < n; i++)
      cin >> vws[i] >> pfs[i] >> vfs[i] >> ths[i];

    ld wl = 0.0, wr = 100.0;
    for (int i = 0; i < 150; i++) {
      ld w0 = (wl * 2 + wr) / 3;
      ld w1 = (wl + wr * 2) / 3;
      ld c0 = cost(n, w0, pw);
      ld c1 = cost(n, w1, pw);
      if (c0 > c1) wl = w0;
      else wr = w1;
    }

    ld c = cost(n, wl, pw);
    printf("%.10Lf\n", c);
  }
  return 0;
}

Measured memory_bytes: 7496
#include<iostream>
#include<map>
#include<cmath>
using namespace std;

int main() {
	int n; cin >> n;
	map<int, int>a;
	for (int i = 0; i < n; i++) {
		int tmp; cin >> tmp;
		a[tmp]++;
	}

	int ans = 1;
	for (auto x : a) {
		if (x.first == 0) {
			if (n % 2 == 0) {
				if (x.second > 0) {
					cout << 0 << endl;
					return 0;
				}
			}
			else {
				if (x.second != 1) {
					cout << 0 << endl;
					return 0;
				}
			}
		}
		else {
			if (x.second != 2) {
				cout << 0 << endl;
				return 0;
			}
			else (ans *= 2) %= 1000000007;
		}
	}
	cout << ans << endl;

	return 0;
}

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

typedef long long ll;

const long long MOD = 1000000007;
long long modpow(long long a, long long n, long long m)
{
    long long ans = 1;
    while (n)
    {
        if (n & 1)
        {
            ans = (ans * a) % m;
        }
        a = (a * a) % m;
        n >>= 1;
    }
    return ans;
}
long long combi(long long n, long long a)
{
    long long ans = 1, ans1 = 1;
    for (long long i = n - a + 1; i <= n; i++)
    {
        ans *= i % MOD;
        ans %= MOD;
    }

    for (long long i = 2; i <= a; i++)
        ans1 = (ans1 * i) % MOD;
    ans1 = modpow(ans1, MOD - 2, MOD);
    return ((ans % MOD) * ans1) % MOD;
}

void dfs(string s, char mx, ll N)
{
    if (s.length() == (size_t)N)
    {
        cout << s.c_str() << endl;
    }
    else
    {
        for (char c = 'a'; c <= mx; c++)
        {
            dfs(s + c, ((c == mx) ? (char)(mx) : mx), N);
        }
    }
}

int bfs(int a, int b, int h, int w, char tmp[][101])
{
    int ans[101][101] = {0};
    char c[101][101] = {0};
    queue<pair<int, int>> s;

    for (int i = 0; i <= h; i++)
    {
        for (int j = 0; j <= w; j++)
        {
            c[i][j] = tmp[i][j];
        }
    }

    s.push(make_pair(a, b));

    while (s.size() > 0)
    {

        pair<int, int> tmp = s.front();
        s.pop();
        c[tmp.first][tmp.second] = '#';
        for (int i = -1; i <= 1; i++)
        {
            for (int j = -1; j <= 1; j++)
            {
                if (tmp.first + i < 1 || tmp.first + i > h)
                {
                    continue;
                }
                if (tmp.second + j < 1 || tmp.second + j > w)
                {
                    continue;
                }
                if (i != 0 && j != 0)
                {
                    continue;
                }
                if (i == 0 && j == 0)
                {
                    continue;
                }
                if (c[tmp.first + i][tmp.second + j] == '#')
                {
                    continue;
                }
                c[tmp.first + i][tmp.second + j] = '#';
                if (ans[tmp.first + i][tmp.second + j] == 0)
                {
                    ans[tmp.first + i][tmp.second + j] = ans[tmp.first][tmp.second] + 1;
                }
                else
                {
                    ans[tmp.first + i][tmp.second + j] = min(ans[tmp.first + i][tmp.second + j], ans[tmp.first][tmp.second] + 1);
                }
                s.push(make_pair(tmp.first + i, tmp.second + j));
            }
        }
    }

    int asd = 0;

    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            asd = max(a, ans[i][j]);
        }
    }

    return asd;
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

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

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

    ll ans = modpow(2, n, MOD) - combi(n, a) - combi(n, b) - 1;
    while(ans < 0){
        ans += MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fi first
#define sec second
#define pr priority_queue
#define ump  unordered_map
#define prg priority_queue<ll, vec<ll> ,greater<ll> >
#define pb  push_back;
//parent finding
ll find(vector<ll> &v, ll n)
{
  if (v[n] == n)
    return n;
  return v[n] = find(v, v[n]);
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n, x, t; cin >> n >> x >> t;
  ll v = (n % x == 0) ? (n / x) : (n / x + 1);
  cout << (v * t) << "\n";
  return 0;
}

Measured memory_bytes: 3632
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = l[0], B = l[1], C = l[2], X = l[3], Y = l[4];

            var priorityC = A + B > 2 * C ? true : false;
            var min = Math.Min(X, Y);
            var max = Math.Max(X, Y);
            var maxA = false;

            if (X > Y)
                maxA = true;

            var total = 0L;
            if (priorityC)
            {
                total = C * 2 * min;
                if (maxA)
                    total += A * (max - min);
                else
                    total += B * (max - min);

                total = Math.Min(C * 2 * max, total);
            }
            else
                total = A * X + B * Y;

            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int main(){
  string raw;
  string datastr[3];
  int cnt=0;
  cin >> raw;
  for(int i=0;i<raw.length();i++){
    if(raw[i]=='/'){
      cnt++;
    }else{
      datastr[cnt]=datastr[cnt]+raw[i];
    }
  }
  if(stoi(datastr[0])>2019 || (stoi(datastr[0])==2019 && stoi(datastr[1])>4 )){
    cout << "TBD";
  }else{
    cout << "Heisei";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e1 + 5, INF = 0x3f3f3f3f, mod = 1e9 + 7;
const ll LNF = 0x3f3f3f3f3f3f3f3f;
typedef pair<int, int> pii;
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, r, l) for (int i = r; i >= l; i--)
#define repe(i, u) for (int i = head[u]; i; i = nxt[i])

int n, a[N], b[N], c[N];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 1, n) cin >> a[i];
  rep(i, 1, n) cin >> b[i];
  rep(i, 1, n - 1) cin >> c[i];
  int sum = b[a[1]];
  rep(i, 2, n) {
    if (a[i] == a[i - 1] + 1) sum += b[a[i]] + c[a[i - 1]];
    else sum += b[a[i]];
  }
  cout << sum << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		String[] b = sc.next().split("[^0-9]");
		long bunshi = 100 * Long.parseLong(b[0]) + Long.parseLong(b[1]);
		long ans = a * bunshi / 100;
		System.out.println(ans);
	}

}


Measured memory_bytes: 35636
using System;

public class Potchari {
    public static void Main() {
        while(true) {
            int n = int.Parse(Console.ReadLine());
            int ans = 0;
            if (n < 1) return;
            string[] step = Console.ReadLine().Split();
            for (int i = 0; i < n-1; i++) {
                if (step[i][1] == step[i+1][1]) ans++;
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 9240
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		Set<Integer> setA = new TreeSet<>();
		Set<Integer> setB = new TreeSet<>();
		Set<Integer> setC = new TreeSet<>();

		int n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			setA.add(sc.nextInt());
		}

		int m = sc.nextInt();
		for(int i = 0; i < m; i++) {
			setB.add(sc.nextInt());
		}

		setC.addAll(setA);
		setA.addAll(setB);
		setB.retainAll(setC);
		setA.removeAll(setB);

		for(int value : setA) {
			System.out.println(value);
		}
	}

}


Measured memory_bytes: 205172