akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

long long power(long long m, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n % 2 == 1) res = res * m % mod;
        m = m * m % mod;
        n /= 2;
    }
    return res;
}

int main() {
    int m, n;
    cin >> m >> n;
    cout << power(m, n, 1000000007) << endl;
    return 0;
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

int n, m, a[1005][1005];
int mx[] = {1, -1, 0, 0};
int my[] = {0, 0, 1, -1};
queue<int> qx, qy;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> m;
	memset(a, -1, sizeof(a));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++) {
			char c;
			cin >> c;
			if (c == '#') {
				a[i][j] = 0;
				qx.push(i), qy.push(j);
			}
		}

	int res = 0;
	while (qx.size()) {
		int i = qx.front(); qx.pop();
		int j = qy.front(); qy.pop();
		res = a[i][j];

		for (int l = 0; l < 4; l++) {
			int x = i + mx[l];
			int y = j + my[l];
			if (0 <= x && x < n && 0 <= y && y < m && a[x][y] == -1) {
				a[x][y] = a[i][j] + 1;
				qx.push(x), qy.push(y);
			}
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
#define sp fixed<<setprecision
#define sz sizeof
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod2=998244353;
ll fpow(ll x,ll y){x=x%MOD;ll sum=1;while(y){if(y&1)sum=sum*x;sum%=MOD;y=y>>1;x=x*x;x%=MOD;}return sum;}
ll inv(ll a,ll m=MOD){ll c=m;ll y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=c;return x;}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
      cin>>a[i];


    ll pre[n][n]; // to store sums from i..j
    for(int i=0;i<n;i++)
    for(int j=i;j<n;j++)
    {
      if(i==j)
      pre[i][j]=a[i];
      else
      pre[i][j]=pre[i][j-1]+a[j];
    }

    ll dp[n][n]; // dp[i][j] denotes the minimum cost to combine subarray i to j {i and j inclusive}
    // initialize the dp array with infinity
    for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      dp[i][j]=LLONG_MAX;

    for(int i=0;i<n;i++)
      dp[i][i]=0;
    // cost of merging single element is 0 as nothing to merge with

    for(int i=n-1;i>=0;i--)// filling backwards
    for(int j=i;j<n;j++)
    {
      // we are trying to find mincost of array i..j
      // now consider an example:
      // lets say 3....6 it can be formed by merging 3..4 and 5..6 or 3..5 and 6 or 3 and 4...6  and so on
      // we'll try all such possible split points
      // lets call a split point as k so we'll iterate over k
      // so for i,...j we are using results for i...k and k+1...j & try all possible k
      if(j==i)continue; // we have already computed the result as 0
      else if(j==i+1) dp[i][j]=min(dp[i][j],a[i]+a[j]); // cost of combining two slimes is a[i]+a[j]
      else
      {
        for(int k=i;k<j;k++)
        dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+pre[i][k]+pre[k+1][j]);// now since we are combining slimes i..k and and k+1...j, we need to add their weights as well
      }
    }

    cout<<dp[0][n-1]<<"\n"; // this should contain the minimum cost for complete array 0....n-1;
    // lets test
/*
    for(int i=n-1;i>=0;i--)
    {
      for(int j=i;j<n;j++)
      cout<<dp[i][j]<<" ";

      cout<<"\n";
    }*/

    // ok so we forgot to add the weights of the individual slimes
    // now obviously weight of slime from i to j will be a[i]+a[i+1]+......a[j]
    // we can precompute this using prefix sums & lets store it in 2d array


    // done
    // ill mail you the code
    // go through it , any doubts then call
}

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

#define lli long long
#define vi vector<int>
#define vli vector<li>
#define vlli vector<lli>
#define pi pair<int,int>
#define pli pair<li, li>
#define vpi vector<pi>

using namespace std;

int main() {

    ios_base::sync_with_stdio(false);

    int n;

    cin >> n;

    pi pts[n];

    for(int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        pts[i].F = x;
        pts[i].S = y;
    }

    map<pi, int> freq;

    int ans = 0;

    for(auto p1 : pts) {
        for(auto p2: pts) {
            if(p1.F == p2.F && p1.S == p2.S) continue;
            int d_x = p1.F - p2.F;
            int d_y = p1.S - p2.S;

            pi par = MP(d_x, d_y);
            freq[par]++;
        }
    }

    for(auto fr : freq) {
        //cout << fr.F.F << " " << fr.F.S << " freq " << fr.S << endl;
        ans =  max(ans, fr.S);
    }


    cout << n - ans << endl;

}


Measured memory_bytes: 384
#include <stdio.h>

int main()
{
    int A,B,K;
    int num[100];
    int i,tmp = 0;

    scanf("%d%d%d",&A,&B,&K);

    int ban;
    if(A<B){
        ban = A;
    }else{
        ban = B;
    }

    for(i=1;i<=ban;i++){
        if(A%i == 0 && B%i == 0){
            num[tmp] = i;
            tmp++;
        }
    }

    printf("%d",num[tmp - K]);
    return 0;
}

Measured memory_bytes: 128
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

ll calc(ll l, ll r){
	ll lv = abs(l) + abs(l) + r;
	ll rv = r + r + abs(l);
	return  min(lv, rv);
}

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	ll n, k;
	cin >> n >> k;
	vector<ll> x(n);
	rep(i, n) cin >> x[i];
	vector<ll> v, rv;
	v.push_back(0);
	rrep(i, n){
		if(x[i] < 0) v.push_back(x[i]);
		else rv.push_back(x[i]);
	}
	rv.push_back(0);
	reverse(ALL(rv));
	ll ans = LLINF;
	rep(i, v.size()){
		if(k - i >= rv.size() || k - i < 0) continue;
		ll res = calc(v[i], rv[k - i]);
		chmin(ans, res);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5264
#include <bits/stdc++.h>
using namespace std;
constexpr long long gcd(long long a, long long b){return b ? gcd(b, a % b) : a;}
constexpr long long lcm(long long a, long long b){return a / gcd(a, b) * b;}
constexpr int INF = 1e9, MOD = INF + 7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
constexpr int mod_pow(long long x, long long n, const int mod){long long ret=1;while(n){if(n&1)(ret*=x)%=mod;(x*=x)%=mod;n>>=1;}return ret;}
template<int n> struct Factorial{long long arr[n+1],ary[n+1];constexpr Factorial():arr(),ary(){arr[0]=1;ary[0]=1;for(int i=0;i<n;i++){arr[i+1]=arr[i]*(i+1)%MOD;ary[i+1]=mod_pow(arr[i+1],MOD-2,MOD);}}}; constexpr Factorial<1010> fact;
constexpr long long comb(int a, int b){if(a < b) return 0LL;if(!a or !b) return 1LL; long long pos = fact.arr[a], pot = fact.ary[a - b], por = fact.ary[b]; return pos * pot % MOD * por % MOD;}
constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
constexpr long double PI = abs(acos(-1));
constexpr int sqrtN = 512, logN = 32;
constexpr long long LINF=1e18;

struct SegmentTree{
	vector<long long> seg;
	int sz = 1;
	
	SegmentTree(int n){
		while(sz < n) sz *= 2;
		seg.assign(sz * 2, -LINF);
	}
	
	void update(int k, long long x){
		k += sz - 1;
		seg[k] = x;
		
		while(k){
			k = (k - 1) / 2;
			seg[k] = max(seg[2 * k + 1], seg[2 * k + 2]);
		}
	}
	
	long long get(int a, int b){
		return get(a, b, 0, 0, sz);
	}
	
	long long get(int a, int b, int k, int l, int r){
		if(b<=l||r<=a) return 0;
		if(a<=l&&r<=b) return seg[k];
		
		return max(get(a, b, 2 * k + 1, l, (l + r) / 2), get(a, b, 2 * k + 2, (l + r) / 2, r));
	}
};

int main(){
	long long n, l; cin >> n >> l; vector<long long> a(n + 10, 0), b(n + 10, 0);
	for(int i = 1; i <= n; i++) cin >> a[i] >> b[i]; a[n + 1] = l; a[0] = 0;
	
	vector<long long> A(n + 10, 0), B(n + 10, 0);
	for(int i = 1; i <= n; i++)	A[i] = A[i - 1] + b[i];
	for(int i = n; i >= 1; i--)	B[i - 1] = B[i] + b[i];
	
	long long ma = 0;
	for(int i = 0; i <= n; i++) A[i] -= a[i];
	for(int i = 0; i <= n; i++) B[i] -= l - a[i + 1];
	for(int i = 0; i <= n; i++) ma = max(ma, A[i]);
	for(int i = 0; i <= n; i++) ma = max(ma, B[i]);
	for(int i = 0; i <= n; i++) A[i] -= a[i];
	
	SegmentTree seg(n + 10);
	for(int i = 0; i <= n; i++) seg.update(i, B[i]);
	for(int i = 0; i <= n; i++) ma = max(ma, A[i] + seg.get(i, n + 1));
	SegmentTree seg2(n + 10);
	for(int i = 0; i <= n; i++) seg2.update(i, A[i] + a[i]);
	for(int i = 0; i <= n; i++) ma = max(ma, B[i] - (l - a[i + 1]) + seg2.get(0, i + 1));
	
	cout << ma << endl;
	return 0;
}


Measured memory_bytes: 7552
class Node
  attr_reader :id
  attr_accessor :parent

  def initialize(id)
    @id = id
    @children = []
  end

  def <<(child)
    child.parent = self
    @children << child
  end

  def depth
    ret = 0
    p = self.parent
    while p
      ret += 1
      p = p.parent
    end
    ret
  end

  def type
    if parent.nil?
      'root'
    elsif @children.any?
      'internal node'
    else
      'leaf'
    end
  end

  def to_s
    "node #{id}: parent = #{parent ? parent.id : -1}, depth = #{depth}, #{type}, [#{child_ids.join(', ')}]"
  end

  private

  def child_ids
    @children.map(&:id)
  end
end

if $PROGRAM_NAME == __FILE__
  n = gets.to_i

  nodes = Array.new(n) {|id| Node.new(id) }

  n.times do
    id, _, *child_ids = gets.chomp.split.map(&:to_i)

    parent = nodes[id]

    child_ids.each do |child_id|
      child = nodes[child_id]
      parent << child
    end
  end

  nodes.each do |node|
    puts node
  end
end

Measured memory_bytes: 25284
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            while((n = int.Parse(Console.ReadLine())) != 0)
            {
                var ene = Console.ReadLine().Split(' ').Select(double.Parse);
                var avg = ene.Average();
                var a2 = ene.Select(e => Math.Pow(e - avg, 2)).Sum() / ene.Count();
                Console.WriteLine($"{Math.Sqrt(a2):0.000000000}");
            }
        }
    }
}


Measured memory_bytes: 18476
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<MOD>;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,X; cin >> N >> X;
    vector<int> S(N);
    rep(i,N) cin >> S[i];

    sort(all(S));
    reverse(all(S));
    vector<vector<mint>> dp(N+1, vector<mint>(X+1));
    mint b = 1;
    rep(i,N-1) b *= (i+1);
    dp[0][X] = 1;
    rep(i,N) {
        rep(j,X+1) {
            dp[i+1][j] += dp[i][j]*(N-1-i);
            dp[i+1][j%S[i]] += dp[i][j];
        }
    }
    mint ans = 0;
    rep(i,X+1) ans += dp[N][i]*i;

    cout << ans.a << ln;
}

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

ll gcd(ll a, ll b){
    if(a < b) return gcd(b, a);
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

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

int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> a(N);
    rep(i, 0, N) cin >> a[i];
    ll gc;
    rep(i, 0, N){
        ll tmp = a[i], cnt = 0;
        while(tmp % 2 == 0){
            tmp /= 2;
            cnt++;
        }
        if(i == 0){
            gc = cnt;
        }else{
            if(gc != cnt){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    ll LCM = a[0];
    if(a[0] > 2*M){
        cout << 0 << endl;
        return 0;
    }
    rep(i, 1, N){
        LCM = lcm(LCM, a[i]);
        if(LCM > 2*M){
            cout << 0 << endl;
            return 0;
        }
    }
    LCM /= 2;
    //cerr << LCM << endl;
    ll ans = M / LCM;
    if(ans % 2 == 0) ans /= 2;
    else ans -= (ans-1)/2;
    cout << ans << endl;
    return 0;
}

/*
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

ll gcd(ll a, ll b){
    if(a < b) return gcd(b, a);
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

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

vector<pair<ll,ll>> prime_factorize(ll N){
    vector<pair<ll,ll>> ret;
    for(ll a = 2; a * a <= N; a++){
        if(N % a != 0) continue;
        ll ex = 0;
        while(N % a == 0){
            ex++;
            N /= a;
        }
        ret.push_back({a, ex});
    }
    if(N != 1) ret.push_back({N, 1});
    return ret;
}

int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> a(N);
    rep(i, 0, N) cin >> a[i];
    map<ll, ll> primes;
    rep(i, 0, N){
        auto p = prime_factorize(a[i]);
        for(auto r : p){
            if(primes.count(r.first) > 0){
                primes[r.first] = max(r.second, primes[r.first]);
            }else{
                primes[r.first] = r.second;
            }
        }
    }
    ll ans = M;
    for(auto p : primes){
        rep(i, 0, p.second){
            ans /= p.first;
        }
    }
    if(ans % 2 == 0) ans /= 2;
    else ans -= (ans-1)/2;
    cout << ans << endl;
    return 0;
}
*/

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

int main() {
	
	int n;
	int ca = 0;
	while (cin >> n) {
		for (int a = 0; a < 10;a++) {
			for (int b = 0; b < 10;b++) {
				for (int c = 0; c < 10; c++) {
					for (int d = 0; d < 10;d++) {
						if (n == a + b + c + d) {
							ca++;
						}
					}
				}
			}
		}
		cout << ca<<endl;
		ca = 0;
	}
	return 0;
}

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

public class Program
{
  static List<Node> graphList = new List<Node>();
  static Queue<Node> queue = new Queue<Node>();
  public static void Main(string[] args)
  {
    int n = int.Parse(Console.ReadLine());

    for(int i = 0; i < n; i++)
    {
      var inputLine = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
      var children = new List<int>();
      var childCount = inputLine[1];
      for(int j = 0; j < childCount; j++)
      {
        children.Add(inputLine[j + 2]);
      }
      var node = new Node
      {
          Id = inputLine[0],
          ChildrenIds = children,
          Depth = -1,
      };

      graphList.Add(node);
    }

    Bfs(graphList[0]);

    foreach(var node in graphList)
    {
      Console.WriteLine("{0} {1}", node.Id, node.Depth);
    }
  }

  private static void Bfs(Node start)
  {
    queue.Enqueue(start);
    start.Depth = 0;
    while(queue.Count > 0)
    {
      var node = queue.Dequeue();
      foreach(var childId in node.ChildrenIds)
      {
        if(graphList[childId - 1].Depth == -1)
        {
          graphList[childId - 1].Depth = node.Depth + 1;
          queue.Enqueue(graphList[childId - 1]);
        }
      }
    }
  }
}

public class Node
{
  public int Id { get; set; }
  public List<int> ChildrenIds { get; set;}
  public int Depth { get; set;}
}



Measured memory_bytes: 10636
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
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;
}
//

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

  int n;
  cin >> n;
  vector<lint> A(n), disA(n);
  lint total = 0;
  rep(i, n) cin >> A[i], total += A[i];

  for (int i = 1; i < n - 1; i += 2) total -= 2 * A[i];

  vector<lint> ans;
  ans.push_back(total);
  rep(i, n) {
    lint xi = 2 * A[i] - ans[i];
    ans.push_back(xi);
  }

  rep(i, n) cout << ans[i] << (i != n - 1 ? " " : "");
  cout << endl;

  return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
//#include "debug.cpp"


int32_t main()
{
	boost;
	
	int n;
	cin>>n;
	vector<PI>a;
	for(int i=0;i<n;i++){
		int l,r;
		cin>>l>>r;
		a.push_back({l+r,l-r});
	}
	sort(a.begin(),a.end());
	//print(a);
	int tmp=a[0].ff;
	int ans=1;
	for(int i=1;i<n;i++){
		if(a[i].ss < tmp)
			continue;
		else{
			tmp=max(tmp,a[i].ff);
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2420
# -*- coding: utf-8 -*-
import numpy as np

if __name__ == '__main__':
    S = input()
    T = input()

    count = 0
    if S[0] == T [0]:
        count += 1
    if S[1] == T [1]:
        count += 1
    if S[2] == T [2]:
        count += 1

    print(count)


Measured memory_bytes: 12420
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  for (int i = 0;; i++) {
    if (i % 2 == 1) {
      a -= d;
      if (a <= 0) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      c -= b;
      if (c <= 0) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3632
N=int(input())
P=[int(i) for i in input().split()]
Q=[0]*N
for i in range(N):
    Q[P[i]-1]=i
L=30000
A=[L*(i) for i in range(1,N+1)]
B=[L*(N+1-i) + Q[i-1] for i in range(1,N+1)]
print(' '.join(map(str,A)))
print(' '.join(map(str,B)))

Measured memory_bytes: 48176
#include<stdio.h>

int main(){
    int h,m;
    int H,M;
    while(1){
        scanf("%d %d",&h, &m);
        if((h==0)&&(m==0))break;
        for(H=h;H>0;H--){
            for(M=m;M>0;M--){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int arr[m];
    for(int i=0;i<m;i++) cin>>arr[i];
    
    int sum=0;
    for(int i=0;i<m;i++)
    {
	sum+=arr[i];
    }
    int ans=n-sum;
    if(ans>=0)
     cout<<ans;
     else
     cout<<-1;
}


Measured memory_bytes: 3660
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

a = list(map(int,input().split()))
k = int(input())
for i in range(k):
    a.sort()
    a[-1]*=2
print(sum(a))

Measured memory_bytes: 3316
object Main {
  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readInt()
    for(q <- 0 until n) {
      val nk = io.StdIn.readLine().split(" ").map(_.toInt)
      val x = io.StdIn.readLine().split(" ").map(_.toInt)

      if (nk(0) <= nk(1)) {
        println(0)
      } else if (nk(1) == 1) {
        println(x(x.length-1) - x(0))
      } else {
        val x_len = for(i <- 0 until x.length - 1) yield x(i+1) - x(i)
        val sort_x_len = x_len.sorted
        val res = for(i <- 0 to x_len.length - nk(1)) yield sort_x_len(i)
        println(res.sum)
      }
    }
  }
}

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

string change(string s){
    int n = s.size();
    string cp=s;
    for(int i=1;i<n;i++){
        cp[i] = s[i-1];
    }
    cp[0] = s[n-1];
    return cp; 
}

int main(){
    string s,t;
    cin >> s;
    cin >> t;
    int n = s.size();
    if(s==t){
        cout << "Yes" << endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        s = change(s);
        if(s == t){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
public static void main(String[]agrs) {
Scanner input=new Scanner(System.in);
 int n1= input.nextInt();
 	 int sum=0;
 	 for (int i = 0; i <= n1; i++) {
 		 sum+=i;
		
	}
 System.out.println(sum); 
 	
}
	
}


Measured memory_bytes: 26848
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stdio.h>
#include<deque>
#include<map>
#include<queue>

typedef long long ll;

#define debug(x) cout << #x << "=" << x << endl;
#define debug_arr(a, n) for(ll i = 0; i < n; i++)cout << a[i] << " "
#define inf 1000000000000000000
#define loop(i,n) for(ll i = 0; i < n; i++)

using namespace std;

int main(){
    ll n,k;
    cin >>n >>k;
    vector<ll> a(n);
    loop(i,n) cin >> a[i];
    sort(a.begin(),a.end());

    ll l = -inf, r = inf;
    
    // ある数x未満の積の数がk-1になるような最小のxを求める
    while(l+1 < r){
        ll mid = (r + l)/2;
        bool ok = [&]{
            ll total = 0;
            loop(i,n){
                ll l = -1,r = n;
                if(a[i] < 0){
                    while(l+1 < r){
                        ll aNum = (r+l)/2;
                        if(a[i] * a[aNum] < mid) r = aNum;
                        else l = aNum;
                    }
                    total += (n-r);
                }else{
                    while(l+1 < r){
                        ll aNum = (r+l)/2;
                        if(a[i] * a[aNum] < mid) l = aNum;
                        else r = aNum;
                    }
                    total += r;
                }
                if(a[i]* a[i] < mid) total --;
            }
            total /= 2;
            return total < k;
        }();

        if(ok) l = mid;
        else r = mid;
    }

    cout << l << endl;
    return 0;
}




Measured memory_bytes: 1920
n, m = map(int, input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]
for k in range(n-m+1):
  for j in range(n-m+1):
    h="true"
    for i in range(m):
      if a[k+i][j:j+m]!=b[i]:
        h="false"    
    if h=="true":
      print("Yes")
      exit()
else:
  print("No")


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

ll x[100010], mod=1000000007;

ll modpow(ll a, ll b, ll m){
    ll res=1, p=0, now=a%m;
    b %= (m-1);
    for(int i=0; b>p; ++i){
        if(b&((ll) 1<<i)){
            res=(res*now)%m;
            p |= ((ll) 1<<i);
        }
        now=(now*now)%m;
    }
    return res;
}
ll modinv(ll a, ll m){
    return modpow(a, m-2, m);
}
ll moddiv(ll a, ll b, ll m){
    return (a*modinv(b, m))%m;
}

int main() {
	int N;
	cin >> N;
	for(int i=0; i<N; ++i) cin >> x[i];
	ll frac=1;
	for(int i=1; i<N; ++i) frac=(frac*i)%mod;
	ll ans=0, now=frac;
	for(int i=0; i+1<N; ++i){
		ans=(ans+(now*(x[i+1]-x[i]))%mod)%mod;
		now=(now+moddiv(frac, i+2, mod))%mod;
	}
	cout << ans << endl;
	return 0;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int gcd(int a, int b) {
    while (b != 0) {
        int r = a % b;
        a = b;
        b = r;
    }
    return a;
}

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

    int N;
    cin >> N;
    vector<int> x(N), y(N);
    set<pii> s;
    REP(i, N) {
        cin >> x[i] >> y[i];
        s.insert(pii(x[i], y[i]));
    }
    int result = N;
    REP(i, N) FOR(j, i + 1, N) {
        int p = x[j] - x[i];
        int q = y[j] - y[i];
        /*
        vector<bool> used(N, false);
        used[i] = true;
        used[j] = true;
        int count = 1;
        */
        int count = 0;
        REP(k, N) {
            int X = x[k] + p;
            int Y = y[k] + q;
            if (s.count(pii(X, Y))) {
                count++;
            }
        }
        int cost = N - count;
        amin(result, cost);
    }
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 256
from scipy.optimize import fmin
N = int(input())

INF = 10 ** 18
# x 方向に動かない点、右移動の点、左移動の点の最小・最大値
fixed_x = [INF, -INF]
R = [INF, -INF]
L = [INF, -INF]
# y 方向に動かない点、右移動の点、左移動の点の最小・最大値
fixed_y = [INF, -INF]
U = [INF, -INF]
D = [INF, -INF]

def update(fixed, li, x, y):
  li[0], li[1] = min(li[0], x), max(li[1], x)
  fixed[0], fixed[1] = min(fixed[0], y), max(fixed[1], y)
  
for _ in range(N):
  x,y,d = input().split()
  x,y = int(x), int(y)
  if d == 'L':
    update(fixed_y, L, x, y)
  elif d == 'R':
    update(fixed_y, R, x, y)
  elif d == 'U':
    update(fixed_x, U, y, x)
  else:
    update(fixed_x, D, y, x)

def calc_x(t, fixed, dec, inc):
  left = INF
  right = -INF
  for li, speed in [(fixed, 0), (dec, -1), (inc, 1)]:
    left = min(left, li[0] + speed * t)
    right = max(right, li[1] + speed * t)
  return right - left

def area(t):
  if t < 0:
    return INF
  return calc_x(t, fixed_x, L, R) * calc_x(t, fixed_y, D, U)

xopt = fmin(area, x0 = 10**8, ftol = 10**-9, disp = False)
answer = area(xopt[0])
print(answer)


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n + 1);
    vector<int> f(n + 1);
    for (int i = 0; i < n; i++) cin >> a[i];
    f[1] = abs(a[1] - a[0]);
    for (int i = 2; i < n; i++){
        f[i] = min(f[i - 1] + abs(a[i] - a[i - 1]), f[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << f[n - 1];
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int ar[]=new int[n+1];
        Map<Integer,Po>po=new HashMap<>();
        for(int i=0;i<n;i++){
             Po p=new Po();
             po.put(i+1,p);
        }
        for(int i=0;i<n-1;i++){
            int a=sc.nextInt();
            int b=sc.nextInt();
            int c=sc.nextInt()%2;
            po.get(a).put(b,c);
            po.get(b).put(a,c);
            
        }
        Queue<Integer> queue = new ArrayDeque<>();
        queue.add(1);
        while(queue.size()!=0){
            int ll=queue.poll();
            po.get(ll).dis=false;
            for(int j=0;j<po.get(ll).a.size();j++){
                int xx=po.get(ll).a.get(j);
                int yy=po.get(ll).b.get(j);
                
                //System.out.println(xx+" "+yy+" "+po.get(xx).dis);
                if(po.get(xx).dis){
                    queue.add(xx);
                    ar[xx]+=ar[ll]+yy;
                }
                
            }
        }
        for(int i=1;i<=n;i++){
            System.out.println((ar[i])%2);
        }
    }
    static class Po{
        ArrayList<Integer>a=new ArrayList<>();
        ArrayList<Integer>b=new ArrayList<>();
        public boolean dis=false;
        public Po(){
        a=new ArrayList<>();
        b=new ArrayList<>();
            
            dis=true;
        }
        public Po(int y,int z){
            dis=true;
            a.add(y);
            b.add(z);
        }
        public void put(int a,int b){
            this.a.add(a);
            this.b.add(b);
        }
        public void print(){
            //System.out.println(a+" "+b+" "+value);
        }
    }
    
}


Measured memory_bytes: 118752
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int indx1 = 0 ;
	int indx2 = 0 ;
	string s;
	cin>>s;
	int l=s.length();
	for(int i = 0 ; i<l ; i++ )
	{
	    if(s[i]=='A')
        {
            indx1=i;
            break;
        }
	}
		for(int J = l-1 ; J>=0 ; J-- )
	{
	    if(s[J]=='Z')
        {
            indx2=J;
            break;
        }
	}
	cout<<indx2-indx1+1<<"\n";

}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
ri = lambda: int(input())
#rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

N,K=rl()
""" M=[0]*(max(N,K)+2)
k = K
M[k] = 1
while k > 1:
    k = k / 2.0
    ind = int(k//1)
    if k%1 == 0:
        ind -= 1
    M[ind] = 1
for i in range(K,0,-1):
    M[i] += M[i+1]
ans = 0
for i in range(1,N+1):
    ans += (1/2)**(M[i])/N
print(ans)
 """
ans = 0
for i in range(1,N+1):
    ex = 0
    point = i
    while point < K:
        ex += 1
        point *= 2
    ans += (1/2)**ex/N
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 500009
#define MOD 1000000007
#define INF 1000000000

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> S(N),T(M);
  for(int i=0;i<N;i++){
    cin>>S.at(i);
  }
  for(int j=0;j<M;j++){
    cin>>T.at(j);
  }

  vector<vector<ll>> dp(N+1,vector<ll>(M+1,0));
  vector<vector<ll>> sum(N+1,vector<ll>(M+1,0));
  /*
  dp[0][0]=1;
  sum[0][0]=1;
  for(int i=0;i<N;i++){
    sum[i+1][0]=1;
  }
  for(int j=0;j<M;j++){
    sum[0][j+1]=1;
  }
  */
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      if(S.at(i)==T.at(j)){
        dp[i+1][j+1]=sum[i][j]+1;
        dp[i+1][j+1]%=MOD;
      }
      sum[i+1][j+1]=sum[i][j+1]+sum[i+1][j]-sum[i][j]+dp[i+1][j+1]+MOD;
      sum[i+1][j+1]%=MOD;
    }
  }
  cout<<(sum[N][M]+1)%MOD<<endl;
}


Measured memory_bytes: 62976
#include <stdio.h>

int getBlock(int rating)
{
    if (rating < 400) return 1;
    else if (rating < 800) return 2;
    else if (rating < 1200) return 3;
    else if (rating < 1600) return 4;
    else if (rating < 2000) return 5;
    else if (rating < 2400) return 6;
    else if (rating < 2800) return 7;
    else if (rating < 3200) return 8;
    else return 0;
}

int min(int a, int b)
{
    if (a < b)
        return a;
    return b;
}

int max(int a, int b)
{
    if (a > b)
        return a;
    return b;
}

int main()
{
    int n, t, block[9] = {0};
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &t);
        block[getBlock(t)]++;
    }
    int res = 0;
    for (int i = 1; i <= 8; i++) {
        if (block[i] != 0) res++;
    }
    printf("%d %d", max(res, (bool)block[0]), res + block[0]);
}


Measured memory_bytes: 128
#include <iostream>
#define NUM 4
using namespace std;
int main(){
  int a;
  cin>>a;
  
  int b[NUM];
  for(int i=0;i<NUM;i++){
    b[i]=a%10;
    a=a/10;
  }
  
  for(int i=0;i<NUM;i++){
    if(i==3){
      cout<<"Good";
      break;
    }
    
    else if(b[i]==b[i+1]){
      cout<<"Bad";
      break;
    }
  }
    return 0;
}


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

int main() {
  string S; cin>>S;
  bool ok=true;
  if (S[2]!=S[3]) ok=false;
  if (S[5]!=S[4]) ok=false;
  if (ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main {



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

            for(int i=0;i<k;i++)
            {
                int x = sc.nextInt();
                for(int j=0;j<x;j++)
                {
                    int l =sc.nextInt();
                    arr[l-1]=arr[l-1]+1;
                }
            }

            int count =0;
            for(int i=0;i<n;i++)
            {
                if(arr[i]==0)
                {
                    count=count+1;
                }
            }
            System.out.println(count);




    }


}

Measured memory_bytes: 46424
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    
    ll n,m;
    cin>>n>>m;
    cout<<n+1-m<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main () {
  int n;
  std::cin >> n;
  float a = (n - 1) / 2;
  if(n % 2 == 0) std::cout << 0.5 << std::endl;
  else std::cout << (a + 1) / n << std::endl;
  return 0;
}

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

int res;
int H, W; // H?????????W????¨?
char HW[102][102], htm;

void zahyo(int x, int y) {
	if (HW[x][y] == HW[x + 1][y] && x > -1 && x < H - 1 && y > -1 && y < W) {
		htm = HW[x][y];
		HW[x][y] = '.';
		zahyo(x + 1, y);
		HW[x][y] = htm;
	}
	if (HW[x][y] == HW[x - 1][y] && x > 0 && x < H && y > -1 && y < W) {
		htm = HW[x][y];
		HW[x][y] = '.';
		zahyo(x - 1, y);
		HW[x][y] = htm;
	}
	if (HW[x][y] == HW[x][y - 1] && x > -1 && x < H && y > 0 && y < W) {
		htm = HW[x][y];
		HW[x][y] = '.';
		zahyo(x, y - 1);
		HW[x][y] = htm;
	}
	if (HW[x][y] == HW[x][y + 1] && x > -1 && x < H && y > -1 && y < W - 1) {
		htm = HW[x][y];
		HW[x][y] = '.';
		zahyo(x, y + 1);
	}
	HW[x][y] = '.';
}

int main() {
	for (int i = 0; i < 21; i++) {
		cin >> H >> W;
		if (H == 0 && W == 0) {
			return 0;
		}
		for (int j = 0; j < H; j++) {
			for (int k = 0; k < W; k++) {
				cin >> HW[j][k];
			}
		} 
		//?????°??????????????????
		for (int j = 0; j < H; j++) {
			for (int k = 0; k < W ; k++) {
				if (HW[j][k] != '.') {
					zahyo(j, k);
					res++;
				}
			}
		}
		cout << res << "\n";
                res = 0;
	}
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define reverse(x) reverse(x.begin(), x.end())
#define sort(x) sort(x.begin(), x.end())
#define pb push_back
#define pii pair<int, int>
#define pll pair<long long,long long>
#define f first
#define s second
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
ll  n, m;

int main(){
	ll x;
	cin >> n >> m >> x;
	ll ans = floor((long double)(m/x));
	ans -= floor((long double)(n-1LL)/x);
	cout << ans;
}


Measured memory_bytes: 256
a,b=map(int,input().split())
l=[]
e=b-a
k=0
for i in range(1000):
    k+=i
    l.append(k)

for j in range(999):
   o=l[j+1]-l[j]
   if(o==e):
       print(l[j]-a)
   else:
       continue

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

int main()
{
	int A,B;
	cin>>A>>B;
	int ans=0;
	ans=max(ans,A+A-1);
	ans=max(ans,A+B);
	ans=max(ans,B+B-1);
	
	cout << ans <<endl;
}

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

const int mxn = 2010;

pair<ll,ll> a[mxn];
ll dp[mxn][mxn];

int main(){
  int n;
  cin >> n;
  for(int i = 0;i < n; ++i){
    cin >> a[i].first;
    a[i].second = i;
  }  
  
  // dp[l][r] -> l elements in left and r elements in right
  ll ans = 0;
  sort(a,a+n,greater<pair<ll,ll>>());
  for(int l = 0;l < n; ++l){
    for(int r = 0;r < n; ++r){
      int i = l + r;
      if(i >= n) continue;
      dp[l + 1][r] = max(dp[l + 1][r],dp[l][r] + a[i].first*(abs(l - a[i].second)));
      dp[l][r + 1] = max(dp[l][r + 1],dp[l][r] + a[i].first*(abs(n - 1 - r - a[i].second)));

      ans = max({ans,dp[l + 1][r],dp[l][r + 1]});
    }
  }
  cout << ans;
}

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


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

    int E = 0;
    for (char c : s) E += c=='E';

    int W = 0;
    int ans = n;
    for (char c : s) {
        E -= c=='E';
        ans = min(ans, W+E);
        W += c=='W';
    }

    cout << ans << endl;


    return 0;
}


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

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

const LL mod = 1e9 + 7;


double noudo(int mizu, int sato) {
	return 100.0*(double)sato / (double)(mizu + sato);
}

int main() {
	
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	int numA = F / (A*100);
	int numB = F / (B*100);

	double maxnode = -1;
	int Mmizu = 0, Msato = 0;
	REP(a, numA+1)REP(b, numB+1) {
		if (a == 0 && b == 0) { continue; }
		int mizu = 100 * A*a + 100 * B*b;

		if (mizu > F) { continue; }

		int maxsato = F - mizu;

		int numC = maxsato / C;
		int numD = maxsato / D;

		/*if (mizu == 1700) {
			debug(maxsato);
		}*/

		REP(c, numC + 1)REP(d, numD + 1) {
			int sato = C * c + D * d;
			if (sato > maxsato) { continue; }
			if (sato > E*(a*A + b*B)) { continue; }
			double node = noudo(mizu, sato);
			
			if (node >= maxnode) {
				maxnode = node;
				Mmizu = mizu;
				Msato = sato;
			}
		}

	}
	//debug(maxnode);
	cout << Mmizu+Msato << " " << Msato << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int INF = 1001001001;

int main(){
  int n, m;
  cin >> n >> m;
  ll ans = (n - m) * 100 + 1900 * m;
  ans *= 1LL << m;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod=37;
int ans,a[37];
int main(){
  int N;
  cin>>N;
  int v;
  for(int i=0;i<N;i++){
    cin>>v;
    a[(v&-v)%mod]++;
  }
  for(int i=0;i<30;i++)
    ans+=i*a[(1<<i)%mod];
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n;
    scanf("%d", &n);
    int v[n];
    int c[n];
    int sum = 0;
    for(int i=0; i<n; i++)scanf("%d", &v[i]);
    for(int i=0; i<n; i++)scanf("%d", &c[i]);
    for(int i=0; i<n; i++){
        if(v[i] > c[i]){
            sum += v[i] - c[i];
        }
    }
    printf("%d", sum);
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<ll> V(N);
    for (int i = 0; i < N; i++) cin >> V[i];

    ll res = 0;
    for (int p = 0; p <= min(K, N); ++p) {
        for (int q = 0; p + q <= min(K, N); ++q) {
            vector<ll> v;
            ll cur = 0;
            for (int i = 0; i < p; ++i) v.push_back(V[i]), cur += V[i];
            for (int i = 0; i < q; ++i) v.push_back(V[N-1-i]), cur += V[N-1-i];

            sort(v.begin(), v.end());
            for (int i = 0; i < min(K - p - q, (int)v.size()); ++i) {
                if (v[i] < 0) cur -= v[i];
            }
            res = max(res, cur);
        }
    }
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256