akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
int main(){
    ll n, ans1=0, ans2=0, sum=0;
    bool plus = true;
    cin >> n;
    ll A[n];
    for(ll i=0;i<n;i++){
        cin >> A[i];
    }
    for(ll i=0;i<n;i++){
        sum += A[i];
        if(sum==0){
            if(plus){
                sum = 1;
            }else{
                sum =-1;
            }
            ans1++;
        }else if(sum<0 && plus){
            ans1 += abs(sum)+1;
            sum = 1;
        }else if(sum>0 && !plus){
            ans1 += abs(sum)+1;
            sum = -1;
        }
        plus = !plus;
    }
    plus = false;
    sum = 0;
    for(ll i=0;i<n;i++){
        sum += A[i];
        if(sum==0){
            if(plus){
                sum = 1;
            }else{
                sum =-1;
            }
            ans2++;
        }else if(sum<0 && plus){
            ans2 += abs(sum)+1;
            sum = 1;
        }else if(sum>0 && !plus){
            ans2 += abs(sum)+1;
            sum = -1;
        }
        plus = !plus;
    }
    cout << min(ans1, ans2) << endl;
    return 0;
 
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
  int A, B;
  cin >> A >> B;
  int res = 0;
  for(int i=0; i<2; i++){
    if(A>=B){
      res = res + A;
      --A;
    }
    else{
      res = res + B;
      --B;
    }
  }
  cout << res;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int main(void)
{
    int K,i;
    string S;

    cin >> K;
    cin >> S;

    if(K < S.size()){
        for(i=0;i<K;i++){
            cout << S[i];
        }
        cout << "..." << endl;
    }else{
        cout << S << endl;
    }

    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
using namespace std;
typedef long long ll;
const int maxn = 200005;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n, h, w;
  cin>>n>>h>>w;
  cout<<(n-h+1)*(n-w+1)<<endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np

N,M=map(int,input().split())
length=np.ones(N+1)
aka=np.ones(N+1)
aka[1]=-1

for _ in range(M):
  x,y=map(int,input().split())
  if aka[x]==-1:
    aka[y]=-1
  if length[x]-1==0:
    aka[x]=1
  length[x]-=1
  length[y]+=1

print(len(aka[aka<0]))

Measured memory_bytes: 29168
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <iomanip>
#include <tuple>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;


int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	cout << (n-1)*n/2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    ll n, m;
    cin >> n >> m;
    set<ll> d;
    string s;
    cin >> s;
    rep(i, n + 1)
    {
        if (s[i] == '1')
        {
            d.insert(i);
        }
    }
    ll now = 0;
    rep(i, n + 1)
    {
        if (s[i] == '0')
        {
            if (i - now > m)
            {
                cout << -1 << endl;
                return 0;
            }
            now = i;
        }
    }
    now = n;
    vector<ll> ans;
    while (now - m > 0)
    {
        rep2(i, now - m, now)
        {
            if (!d.count(i))
            {
                ans.push_back(now - i);
                now = i;
            }
        }
    }
    ans.push_back(now);
    for (ll i = ans.size() - 1; i >= 0; i--)
    {
        cout << ans[i] << " ";
    }
    cout << endl;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n; cin >> n;
    vl a(n);
    rep(i,n)cin>>a[i];
    sort(rall(a));
    if(n % 2){
        ll ans1 = 0;
        rep(i,n/2)ans1 += a[i]*2;
        ans1 -= (a[n/2] + a[n/2 + 1]);
        for(int i=n/2 + 2;i<n;i++)ans1 -= a[i]*2;

        ll ans2 = 0;
        rep(i,n/2 -1)ans2 += a[i]*2;
        ans2 += (a[n/2-1] + a[n/2]);
        for(int i=n/2+1;i<n;i++)ans2 -= a[i]*2;
        out(max(ans1,ans2));
    }
    else{
        ll ans3 = 0;
        rep(i,n/2-1)ans3+=a[i]*2;
        ans3+=a[n/2-1];
        ans3-=a[n/2];
        for(int i=n/2+1;i<n;i++)ans3-=a[i]*2;
        out(ans3);
    }
}


Measured memory_bytes: 1024
/*en3_3
    takafumi_ueki*/
#include <stdio.h>
int main(void){
    //n(:ある整数)がk進法で表したときdigit桁になる
    int n,k;
    int digit = 0;
    //nが0になるまで引き続け、その引いた回数が桁数になる
    scanf("%d %d",&n,&k);
    while(n != 0){
        n = n/k;
        digit++;
    }
    printf("%d\n",digit);
    return 0;
}


Measured memory_bytes: 128
import itertools
n,m = map(int, input().split())
ks = []
c = 0
for i in range(m):
  ks.append(list(map(int, input().split())))
p = list(map(int, input().split()))
for i in list(itertools.product((0,1), repeat=n)):
  count = 0
  for j in ks:
    if sum([i[j[k+1]-1] for k in range(len(j)-1)]) % 2 == p[ks.index(j)]:
      count += 1
  if count == m:
    c += 1
print(c)

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


int main(int argc, char *argv[]){
  int n;
  cin >> n;
  for (int r = 0; r < n; r++) {

    string x, y;
    cin >> x >> y;
    int dp[y.length() + 1][x.length() + 1];
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < y.length(); i++) {
      for (int j = 0; j < x.length(); j++) {
        if(y[i] == x[j]){
          dp[i + 1][j + 1] = dp[i][j] + 1;
        }else{
          dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
        }
      }
    }
    std::cout << dp[y.length()][x.length()] << std::endl;
  }
  return 0;
}

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

#define vi vector<int>
#define vii vector<int, int>
#define ll long long
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...) 42
#endif
const int MOD=1e9+7;

//////////////////////// code starts ///////////////////////

int main(){
    IOS;
    #ifdef LOCAL
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif
    int n;
    string s;
    cin >> n;
    cin >> s;
    vi red(n, 0), green(n, 0), blue(n, 0);

    for (int i = 0; i < n; i++){
        if (s[i] == 'R') red[i]++;
        if (s[i] == 'G') green[i]++;
        if (s[i] == 'B') blue[i]++;

        if (i != 0){
            red[i] += red[i-1];
            green[i] += green[i-1];
            blue[i] += blue[i-1];
        }
    }

    //for (int i = 0; i< n; i++){
        //trace(red[i], green[i], blue[i]);
    //}

    ll ans = 0;
    for (int i = 0; i < n; i++){
        for (int k = i + 2; k < n; k++){
            if (s[i] != s[k]){
                 if ((s[i] == 'R' && s[k] == 'G') || (s[i] == 'G' && s[k] == 'R')){
                     ans += blue[k-1] - blue[i];
                 }
                 if ((s[i] == 'R' && s[k] == 'B') || (s[i] == 'B' && s[k] == 'R')){
                     ans += green[k-1] - green[i];
                 }
                 if ((s[i] == 'B' && s[k] == 'G') || (s[i] == 'G' && s[k] == 'B')){
                     ans += red[k-1] - red[i];
                 }

                 int j = (i + k) / 2;
                 //trace(i, j, k, s[i], s[j], s[k], ans);

                 if ((2 * j == i + k) && (s[i] != s[j]) && (s[k] != s[j])){
                     ans--;
                 }
            }
        }
    }

    cout << ans << endl;

    #ifdef LOCAL
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif

    return 0;
}




Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <cctype>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    ll n,m; cin >>n>>m;
    ll hm = m/2;

    ll res = min(n, hm);
    hm -= res;

    if (hm > 0) {
        res += hm/2;
    } 

    cout << res << endl;

    return 0;
}




Measured memory_bytes: 256
function Main(input) {
  var od = ['R', 'U', 'D'];
  var ev = ['L', 'U', 'D'];
  input = input.split('');

  var results = 'Yes';
  for (var i = 0; i < input.length; i++) {
    if (input[i] == 'U' || input[i] == 'D') {
      continue;
    }
    if (input[i] == 'R') {
      if ((i + 1) % 2 == 0) {
        results = 'No';
        break;
      }
    } else if (input[i] == 'L') {
      if ((i + 1) % 2 != 0) {
        results = 'No';
        break;
      }
      
    }
  }
  console.log(results);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

template<ll MOD = 1000000007>
class ModInt {
    ll n;
    ModInt constexpr inverse() const {
        return ModInt::pow(*this, MOD - 2);
    }

public:
    ModInt()
        : n(0) {}
    ModInt(ll _n)
        : n(((_n % MOD) + MOD) % MOD) {}
    ModInt operator+=(const ModInt &m) {
        n += m.n;
        if (n >= MOD) n -= MOD;
        return *this;
    }
    ModInt operator-=(const ModInt &m) {
        n -= m.n;
        if (n < 0) n += MOD;
        return *this;
    }
    ModInt operator*=(const ModInt &m) {
        n *= m.n;
        if (n >= MOD) n %= MOD;
        return *this;
    }
    ModInt operator/=(const ModInt &m) {
        (*this) *= m.inverse();
        return *this;
    }
    friend ModInt operator+(ModInt t, const ModInt &m) {
        return t += m;
    }
    friend ModInt operator-(ModInt t, const ModInt &m) {
        return t -= m;
    }
    friend ModInt operator*(ModInt t, const ModInt &m) {
        return t *= m;
    }
    friend ModInt operator/(ModInt t, const ModInt &m) {
        return t /= m;
    }
    ModInt operator=(const ll l) {
        n = l % MOD;
        if (n < 0) n += MOD;
        return *this;
    }
    friend ostream &operator<<(ostream &out, const ModInt &m) {
        out << m.n;
        return out;
    }
    friend istream &operator>>(istream &in, ModInt &m) {
        ll l;
        in >> l;
        m = l;
        return in;
    }
    static constexpr ModInt pow(const ModInt x, ll p) {
        ModInt<MOD> ans = 1;
        for (ModInt<MOD> m = x; p > 0; p /= 2, m *= m) {
            if (p % 2) ans *= m;
        }
        return ans;
    }
};
using mint = ModInt<>;
mint operator"" _m(unsigned long long m) {
    return mint(m);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    cin, n, k;
    cout << mint::pow(k, n) << endl;
    return 0;
}



Measured memory_bytes: 3212
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    cnt = 0
    for i in range(1, n - 1):
        for j in range(i + 1, n):
            for k in range(j + 1, n + 1):
                if (i + j + k) == x:
                    cnt += 1
    print(cnt)

Measured memory_bytes: 7644
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define PRIM 3
#define INF (1 << 29)
#define LINF (1LL << 60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

int main()
{
    int h, w;
    cin >> h >> w;
    map<int, int> dist;
    multiset<int> values;
    for (int i = 0; i < w; i++) {
        dist[i] = 0;
        values.insert(0);
    }

    for (int i = 0; i < h; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;

        auto fn = [&](int x) {
            if (auto to = dist.upper_bound(x);
                to != dist.begin() && x < w && dist.count(x) == 0) {
                auto prev_to = prev(to);
                dist[x] = prev_to->second + (x - prev_to->first);
                values.insert(dist[x]);
            }
        };
        fn(b + 1);
        fn(a - 1);

        for (auto to = dist.lower_bound(a);
             to != dist.end() && to->first <= b;) {
            int value = to->second;
            auto pos = values.lower_bound(value);
            values.erase(pos);
            dist.erase(to++);
        }

        /*        for (auto p : dist) {
                    cout << p.first << ":" << p.second << " ";
                }
                cout << endl;
                for (auto v : values) {
                    cout << v << " ";
                }
                cout << endl;*/

        if (values.empty())
            cout << -1 << endl;
        else
            cout << *values.begin() + i + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 21880
// B - ∵∴∵
#include <bits/stdc++.h>
using namespace std;

int main(){
	string O,E; cin>>O>>E;
	for(int i=0; i<O.size()+E.size(); i++) cout<<(i%2?E[i/2]:O[i/2]);
	cout<<"\n";
}

Measured memory_bytes: 256
//b.c B-Palace
#include<stdio.h>

double iabs(double x){
    if(x<0){
        return -x;
    }
    return x;
}

int main(void){
    int n,t,a;
    scanf("%d",&n);
    scanf("%d %d",&t,&a);
    int h[n];
    for(int i=0;i<n;++i){
        scanf("%d",&h[i]);
    }

    double ans;
    int num = 0;
    ans = (double)t - (double)h[0]*0.006;
    for(int i=0;i<n;++i){
        double diff = iabs(ans-a);
        double _ans = (double)t - (double)h[i]*0.006;
        if(diff>iabs(_ans-a)){
            num = i;
            ans = _ans;
        }
    }
    printf("%d\n",num+1);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
 
using namespace std;
 
int main()
{
	int n,m;
	int arr [100];
	cin>>n>>m;
	long long tol=0;
	for(int i=0;i<n;i++){cin>>arr[i];tol+=arr[i];}
	sort(arr,arr+n);
	//for(int i=0;i<n;i++)cout<<arr[i]<<" ";
	//cout<<endl;
	if(arr[n-m]<(tol+4*m-1)/(4*m))cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	//cout<<arr[n-m]<<(tol+4*m-1)/(4*m)<<endl;
	return 0;
}



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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 1 << 18;
const int   mod = 998244353;

void add(int &a,int b)  {
    a += b;
    if (a >= mod)
        a -= mod;
}
void sub(int &a,int b)  {
    a -= b;
    if (a <  0)
        a += mod;
}
int mul(int a,int b)    {
    return  1ll * a * b % mod;
}
int Pow(int a,int b)    {
    int ans = 1;
    while (b)   {
        if(b & 1)   ans = mul(ans,a);
        a = mul(a,a);   b >>= 1;
    }
    return  ans;
}
int inv(int a,int p)    {
    return  a == 1 ? 1 : p - 1ll * p * inv(p % a,a) / a;
}

typedef pair<int,int>   ii;

int a[N];
int b[N];

void fft(int n,int *f)  {
    for(int k = 1 ; k < n ; k <<= 1)
    for(int i = 0 ; i < n ; i += 2 * k)
    for(int j = 0 ; j < k ; ++j)    {
        int x = f[i + j];
        int y = f[i + j + k];

        f[i + j]     = (x + y) % mod;
        f[i + j + k] = (x - y + mod) % mod;
    }
}

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

    int n;  cin >> n;
    int S = 0;

    n = (1 << n);

    for(int i = 0 ; i < n ; ++i)    {
        cin >> a[i];
        S +=   a[i];
    }
    for(int i = 0 ; i < n ; ++i)
        a[i] = mul(a[i],inv(S,mod));

    a[0]--;
    b[0] = n;

    for(int i = 0 ; i < n ; ++i)
        sub(b[i],1);

    fft(n,a);
    fft(n,b);

    for(int i = 0 ; i < n ; ++i)    {
        a[i] = mul(b[i],Pow(a[i],mod - 2));
        a[i] = mul(a[i],Pow(n,mod - 2));
    }
    S = 0;

    for(int i = 0 ; i < n ; ++i)
        sub(S,a[i]);

    a[0] = S;

    fft(n,a);

    for(int i = 0 ; i < n ; ++i)
        cout << a[i] << "\n";
}

Measured memory_bytes: 4864
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=-10**18
flag=dict()
for i in range(n):
    if i in flag:
        continue
    cur=i
    accum=[]
    flag[cur]=0
    s=0
    while flag[cur]<2:
        cur=p[cur]-1
        s+=c[cur]
        accum.append(s)
        if cur not in flag:
            flag[cur]=0
        else:
            flag[cur]+=1
    l=len(accum)//2
    accum=[0]+accum
    #print(accum)
    for x in range(1,l+1):
        if accum[x+l-1]-accum[x-1]<=0 or k//l<1:
            ans=max(ans,max(accum[x:x+min(k,l)])-accum[x-1])
        else:
            a=max(accum[x:x+l-1])-accum[x-1]
            d=accum[x+l-1]-accum[x-1]
            if k%l!=0:
                b=max(accum[x:x+k%l])-accum[x-1]
                ans=max(ans,max(k//l*d,k//l*d+b,(k//l-1)*d+a))
            else:
                b=max(accum[x:x+l-1])-accum[x-1]
                ans=max(ans,max(k//l*d,(k//l-1)*d+a))
print(ans)

Measured memory_bytes: 75148
#include <stdio.h>

#define N 100001
#define NIL -1

#define INNER_NODE 1
#define LEAF -1
#define ROOT 0

typedef struct {
	int parent;
	int left;
	int right;
} Node;

Node node[N];

void initNode(int n) {
	int i;

	for (i = 0; i < n; i++) {
		node[i].parent = NIL;
		node[i].left = NIL;
		node[i].right = NIL;
	}
}

void createTree(int n) {
	int nodeId, i;

	initNode(n);

	for (i = 0; i < n; i++) {
		scanf("%d", &nodeId);
		scanf("%d %d", &node[nodeId].left, &node[nodeId].right);
		if (node[nodeId].left != NIL) {
			node[node[nodeId].left].parent = nodeId;
		}
		if (node[nodeId].right != NIL) {
			node[node[nodeId].right].parent = nodeId;
		}
	}
}

int judgeNode(Node node) {

	if (node.parent == NIL) {
		return ROOT;
	} else if (node.left == NIL && node.right == NIL) {
		return LEAF;
	} else {
		return INNER_NODE;
	}

	return 0;
}

void preorderTreeWalk(int id) {

	printf(" %d", id);
	if (node[id].left != NIL) {
		preorderTreeWalk(node[id].left);
	}
	if (node[id].right != NIL) {
		preorderTreeWalk(node[id].right);
	}

}

void inorderTreeWalk(int id) {

	if (node[id].left != NIL) {
		inorderTreeWalk(node[id].left);
	}
	printf(" %d", id);
	if (node[id].right != NIL) {
		inorderTreeWalk(node[id].right);
	}
}

void postorderTreeWalk(int id) {

	if (node[id].left != NIL) {
		postorderTreeWalk(node[id].left);
	}
	if (node[id].right != NIL) {
		postorderTreeWalk(node[id].right);
	}
	printf(" %d", id);
}

int main() {
	int i, n;

	scanf("%d", &n);

	initNode(n);
	createTree(n);

	for (i = 0; i < n; i++) {
		if (judgeNode(node[i]) == ROOT) {
			break;
		}
	}

	puts("Preorder");
	preorderTreeWalk(i);
	puts("");

	puts("Inorder");
	inorderTreeWalk(i);
	puts("");

	puts("Postorder");
	postorderTreeWalk(i);
	puts("");

	return 0;
}

Measured memory_bytes: 612
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

r, d, x = rm()
for _ in range(10):
  x = r*x - d
  print(x)






Measured memory_bytes: 27172
#include<iostream>
using namespace std;
int main(){
  string s, t;
  int a, b;
  string u;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;

  if (u == s) a--;
  else if (u == t) b--;
  cout << a << ' ' << b;

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    long long int n,k;
    cin>>n>>k;
    vector<int> a(n);
    vector<int> b(n);
    REP(i,n) cin>>a[i]>>b[i];
    vector<pair<int,int>> c(n);
    REP(i,n){
        c[i].first=a[i];
        c[i].second=b[i];
    }
    sort(c.begin(),c.end());
    long long int d=0;
    REP(i,n){
        d+=c[i].second;
        if(d>=k){
        cout<<c[i].first;
        return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1792
h, w = gets.split.map(&:to_i)
list = h.times.map{ gets.chomp.split('') }
s = list.flatten.map.with_index{ |c, i| i if c == '#' }.compact
t = (0...h*w).to_a - s
move = [[-1, 0], [0, 1], [1, 0], [0, -1]]
ans = 0
visited = h.times.map{ [false] * w }
s.each do |i|
  x = i % w
  y = i / w
  if !visited[y][x]
    count_w = 0
    count_b = 1
    q = [[x, y, 0]]
    visited[y][x] = true
    until q.empty?
      x, y, color = q.shift
      move.each do |mx, my|
        nx = x + mx
        ny = y + my
        if 0 <= nx && nx < w && 0 <= ny && ny < h && !visited[ny][nx]
          if color == 0 && list[ny][nx] == '.' || color == 1 && list[ny][nx] == '#'
            visited[ny][nx] = true
            q << [nx, ny, 1 - color]
            if color == 0
              count_w += 1
            else
              count_b += 1
            end
          end
        end
      end
    end
    ans += (count_w * count_b) 
  end
end
puts ans
      



Measured memory_bytes: 28484
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;

signed main() 
{
    int x1,y1,x2,y2,x3,y3,x4,y4; 
    cin >> x1 >> y1 >> x2 >> y2; 

    x3 = x2 -(y2-y1); 
    y3 = y2 +(x2-x1); 

    x4 = x1 - (y2-y1);
    y4 = y1 + (x2-x1);

    cout << x3 << " " << y3 <<" " << x4 << " " << y4; 
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<map>
using namespace std;

int main() {
  string w;
  cin >> w;

  map<char, int> m;
  for (char c : w) m[c]++;

  string ans = "Yes";
  for (pair<char, int> a : m)
    if (a.second % 2 == 1) ans = "No";

  cout << ans << endl;
  return 0;
}


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

int main() {
	string c[3];
	string ans = "NO";
	for (int i = 0; i < 3; i++) {
		cin >> c[i];
	}
	if (c[0].at(c[0].size() - 1) == c[1].at(0) && c[1].at(c[1].size() - 1) == c[2].at(0)) {
		ans = "YES";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

using ipair = pair<ll,ll>;

ll INF = 1e16+7;

bool operator>(const ipair a,const ipair b){return a.first > b.first;}

int dp[101][4][2];

int main(){

  string S;
  cin >> S;
  int N = S.size();
  int K;
  cin >> K;

  dp[0][0][0] = 1;

  rep(i, N) rep(j, 4) rep(k, 2){
    int nd = S[i] - '0';
    rep(d, 10){
      // 次の状態
      int ni = i+1, nj = j, nk = k;
      // 次の状態の条件
      if(d != 0) nj++;
      if(K < nj) continue;
      if(k==0){
        if(nd < d) continue;
        if(nd > d) nk = 1;
      }
      // 遷移
      dp[ni][nj][nk] += dp[i][j][k];
    }
  }

  int ans = dp[N][K][0] + dp[N][K][1];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/*
___ is a raging sadist.
*/

//Destroy all WA at test 2

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define siz(a) int((a).size())
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define PI 3.14159265
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MOD1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7; 
using namespace std;

ll power(ll x, ll y) 
{ 
   ll res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  

        y = y>>1; 

        if (x<=100000000)
        x = (long long)(x*x);

        //cout<<x<<'\n'; 
    } 
    return res; 
} 






int main()
{

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

fastio();

    ll n;
    cin>>n;
    ll a[n];

    For(i,0,n)
    cin>>a[i];

    sort(a,a+n);

    ll cnt=1;
    ll ans=a[n-1];

    for(int i=n-2;i>=0;i--)
    {
        for(int j=0;j<2;j++)
        {
            ans+=a[i];
            cnt+=1;

            if (cnt==n-1)
                goto x;
        }
    }

    x:; 


    if (n==2)
        ans=a[n-1];
    cout<<ans;

return 0;
}

Measured memory_bytes: 5216
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int 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; }
// ---------------------------------------------------------------------------

int main(){
  int A,B,M;
  cin >> A >> B >> M;
  vector<int> a(A);
  int min_A = mod;
  for(int i=0; i<A; i++){
    cin >> a[i];
    chmin(min_A,a[i]);
  }
  vector<int> b(B);
  int min_B = mod;
  for(int i=0; i<B; i++){
    cin >> b[i];
    chmin(min_B,b[i]);
  }
  int sum = min_A + min_B;
  for(int i=0; i<M; i++){
    int x,y;
    cin >> x >> y;
    int c;
    cin >> c;
    chmin(sum,a[x-1]+b[y-1]-c);
  }
  cout << sum << endl;
  return 0;
}


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

int main() {
  int s;
  cin >> s;
  int s1 = s % 10;
  int s2 = (s - s1) / 10 % 10;
  int s3 = (s - s1 - s2 * 10) / 100;
  cout << s2 + s3 + s1 << endl;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    int v[n];
    for(int i=0; i<n; i++){
        cin >> v[i];
    }
    int ans = 0;
    int n_max = 100001;
    int s[n_max]; fill(s, s+n_max, 0);
    int t[n_max]; fill(t, t+n_max, 0);
    int s1, s2; s1 = 0; s2 = 0;
    int t1, t2; t1 = 0; t2 = 0;
    for(int i=0; i<n; i++){
        if(i%2 == 0) {
            s[v[i]]++;
        }
        else {
            t[v[i]]++;
        }        
    }
    for(int i=0; i<n_max; i++){
        if(s[i] > s2){
            if(s[i] > s1){
                s2 = s1;
                s1 = s[i];
            }
            else s2 = s[i];
        }
        if(t[i] > t2){
            if(t[i] > t1){
                t2 = t1;
                t1 = t[i];
            }
            else t2 = t[i];
        }
    }
    if(max_element(s, s + n_max) - s == max_element(t, t + n_max) - t) ans += n - max(s1 + t2, s2 + t1);
    else ans += n - (s1 + t1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

const static int N=100;

int main()
{
    int M[N][N];
    int n,u,k,v;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)
            M[i][j]=0;
    }

    for(int i=0;i<n;i++){
        cin>>u>>k;
        u--;
        for(int j=0;j<k;j++){
            cin>>v;
            v--;
            M[u][v]=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j) cout<< " ";
            cout<<M[i][j];
        }
        cout<<endl;
    }
    return 0;
}



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

int main() {
  int n; string s;
  cin>>n>>s;
  int l=0,r;
  r=count(s.begin()+1,s.end(),'E');
  int ans=r;
  rep(i,n-1){
    if(s[i]=='W'){l++;}
    if(s[i+1]=='E'){r--;}
    ans=min(ans, l+r);
  }
  cout<<ans;
}

Measured memory_bytes: 3924
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//  
//

#include <bits/stdc++.h>
using namespace std;

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

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;

//#define __DBG__


void solve(void){
  
  int r;
  
  cin >> r;
  
  cout << r*r << endl;
  
  return;
   
}


int main(int argc, const char * argv[]) {

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

    solve();
 
    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <map>
using namespace std;
const int MAX_N=100001;
long long int H,W,N;
long long int ans[10];
int main(){
  long long int sum=0;
  scanf("%d %d %d",&H,&W,&N);
  int a,b;
  map<pair<int,int> ,int > m;
  for(int i=0;i<N;i++){
    scanf("%d %d",&a,&b);
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
	if(1<=a-j && a-j<=H-2 && 1<=b-k && b-k<=W-2) {
	  //printf("pair(%d %d) insert\n",a-j,b-k);
	  m[make_pair(a-j,b-k)]++;
	}
      }
    }
  }
  for(int j=1;j<=9;j++){
    for(map<pair<int,int>,int>::iterator i=m.begin();i!=m.end();++i){
      if(i->second==j){ans[j]++;sum++;}
    }
  }
  printf("%lld\n",(H-2)*(W-2)-sum);
  for(int j=1;j<=9;j++)printf("%lld\n",ans[j]);
  return 0;
}

Measured memory_bytes: 56448
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long; 
using ld = long double;
#define endl "\n"
//#define int long long
#define all(V) V.begin(),V.end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1 << 25;
constexpr long double pi = 3.141592653589793238462643383279;
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
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 fact_mod(ll n, ll mod) {
    ll f = 1; for (int i = 2; i <= n; i++) f = f * (i % mod) % mod;
    return f;
}
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
ll keta(ll n) {
    if (n == 0) return 1;
    ll count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll mch(ll n) {
    if (n == 1) return 1;
    else return n * mch(n - 1);
}
ll pow_mod(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % mod;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}
ll inv_mod(ll a, ll mod) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
//関数とか

//宣言とか

/*signed*/int main(void) {
    int K;
    cin >> K;
    if (K == 2 || K == 5) {
        cout << -1 << endl;
        return 0;
    }
    int res = -1;
    int t = 0;
    rep(i, 1000000) {
        t += 7;
        if (t % K == 0) {
            res = i + 1;
            break;
        }
        t = (t * 10) % K;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int, int>
#define N 200123
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define pb push_back
#define fs first
#define sc second
#define sz(x) ((int)((x).size()))
#define oo 1000000123
#define mod 1000000007

using namespace std;

int n;
ll A[N];
map<ll, ll> fd, fs;

int main(){
    ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i <= n; ++i){
        cin >> A[i];
        fs[A[i]+i]++;
        fd[i-A[i]]++;
    }
    ll ans = 0;
    for(ll i = 1; i <= n; ++i){
        if(fs.count(i-A[i]))
            ans += (fs[i - A[i]]);
        if(fd.count(A[i] + i))
            ans += (fd[A[i] + i]);
    }
    ans /= 2LL;
    cout << ans << '\n';
    return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;


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

    int N;
    cin >> N;
    int K = N/2;

    vll A(N);
    for (int i=0; i<N; i++) cin >> A[i];

    ll tot = 0;
    for (int i=0; i<N; i++) tot += A[i];
    tot /= 2;

    vll B(N);
    ll not_zero = 0;
    for (int i=0;i<K; i++) not_zero += A[2*i + 1];

    B[0] = tot - not_zero;
    for (int i=1;i<N;i++) {
        B[i] = A[i-1] - B[i-1];
    }

    for (int i=0;i<N; i++) cout << 2*B[i] << " \n"[i+1==N];

    return 0;
}


Measured memory_bytes: 2944
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] str = line.split("");
		String line2 = br.readLine();
		String[] str2 = line2.split("");
		
		for(int i=0;i<=line.length()-line2.length();i++){
			int cnt=0;
			for(int j=0;j<line2.length();j++){
				if(str2[j].equals(str[i+j])){
					cnt++;
				}else continue;
			}
			if(cnt>=line2.length()){
				System.out.println(i);
			}
		}		
	}
}

Measured memory_bytes: 25384
#include<iostream>
using namespace std;
int main(){
  int W,H,x,y,r;
  cin>>W>>H>>x>>y>>r;
  int num=0;
  if(W>0){
    if(x-r<0)
    num++;
    if(x+r>W)
    num++;
  }else{
    if(x+r>0)
    num++;
    if(x-r<W)
    num++;
  }
  if(H>0){
    if(y-r<0)
    num++;
    if(y+r>H)
    num++;
  }else{
    if(y+r>0)
    num++;
    if(y-r<H)
    num++;
  }
  if(num>0){
    cout<<"No\n";
  }else{
    cout<<"Yes\n";
  }
}

Measured memory_bytes: 3076
#include<iostream>
using namespace std;int main(){int n,b[]={1,5,3,3,3,3,3,4,3,4},m,i;string s;char t[20][6]={" ",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};cin>>n;while(cin>>s){for(i=m=0;i<s.size();i++)if(s[i]=='0'){if(m)cout<<t[s[i-1]-'0'][(m-1)%b[s[i-1]-'0']];m=0;}else
m++;cout<<endl;}return 0;}

Measured memory_bytes: 0
#include<iostream>
#include<string>
using namespace std;
int main(){
    string c;
    int n,ac=0,wa=0,tle=0,re=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>c;
        if(c=="AC")ac++;
        if(c=="WA")wa++;
        if(c=="TLE")tle++;
        if(c=="RE")re++;
    }
    cout<<"AC x "<<ac<<endl<<"WA x "<<wa<<endl<<"TLE x "<<tle<<endl<<"RE x "<<re<<endl;
    return 0;
}

Measured memory_bytes: 3620
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt()

	aArray := make([]int, n+1)
	for i := 0; i < n+1; i++ {
		aArray[i] = nextInt()
	}
	bArray := make([]int, n+1)
	for i := 0; i < n; i++ {
		bArray[i] = nextInt()
	}
	// bArray[n] = 0

	ans := 0
	for i := n; i > 0; i-- {
		ans += minInt(aArray[i], bArray[i])
		aArray[i] = maxInt(0, aArray[i]-bArray[i])
		ans += minInt(aArray[i], bArray[i-1])
		// aArray[i] = maxInt(0, aArray[i] - bArray[i - 1])
		bArray[i-1] = maxInt(0, bArray[i-1]-aArray[i])
	}
	ans += minInt(aArray[0], bArray[0])
	// aArray[0] = maxInt(0, aArray[0] - bArray[0])
	fmt.Println(ans)
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> Type igcd(Type x,Type y){if(x==0||y==0)return (x>y)?x:y;return (y%x)?igcd(y%x,x):x;}
template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	vvi d(n,vi(n));
	REP(i,n)REP(j,n) cin>>d[i][j];
	
	llong sum=0;
	REP(i,n)REP(j,n) sum+=d[i][j];
	
	bool jud[n][n]={};
	REP(k,n)REP(i,n)REP(j,n){
		if(k==i or k==j) continue;
		if(d[i][j]>d[i][k]+d[k][j]){
			cout<<-1<<endl;
			return 0;
		}else if(d[i][j]==d[i][k]+d[k][j]){
			if(!jud[i][j]){
				sum-=d[i][j];
				jud[i][j]=true;
			}
		}
	}
	
	cout<<sum/2<<endl;
}

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

int main() {
  int A, B, C, D;
  string op;

  cin >> A >> B >> C;
  D = A;
  A = B;
  B = D;

  D = C;
  C = A;
  A = D;
  
 cout << A << " " << B << " " << C;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 200001
#define maxa 201
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

ll power(ll a, ll b){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}




void solve(){
    ll n;
    cin >> n;
    map<pii, ll> mp;
    for(ll i = 1; i <= n; i++){
        ll l = i%10;
        ll r = i;
        while(r >= 10){
            r/=10;
        }
        mp[{r, l}]++;
    }
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        ll l = i%10;
        ll r = i;
        while(r >= 10){
            r/=10;
        }
        ans += mp[{l, r}];
    }
    cout << ans ;

}

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


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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        String ans = (a + b > c + d)? "Left" : (a + b == c + d)? "Balanced" : "Right";
        System.out.println(ans);
    }
}

Measured memory_bytes: 21460
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#include <stdlib.h>
#include <time.h>
#include <chrono>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll d;
vector<ll> c(26 + 1);
vector<vector<ll>> s(365 + 1, vector<ll>(26 + 1, 0));

ll scoring(vector<int> t)
{
    ll ans = 0;
    vector<ll> last(d + 1, 0);

    for (int i = 1; i <= d; i++)
    {
        ans += s[i][t[i]];
        last[t[i]] = i;

        for (int j = 1; j <= 26; j++)
        {
            ans -= c[j] * (i - last[j]);
        }
    }

    return ans;
}

int main(void)
{
    srand(time(NULL));
    cin >> d;

    for (int i = 1; i <= 26; i++)
    {
        cin >> c[i];
    }

    for (int i = 1; i <= d; i++)
    {
        for (int j = 1; j <= 26; j++)
        {
            cin >> s[i][j];
        }
    }

    vector<int> BestT(d + 1, 1);

    for (int i = 1; i <= d; i++)
    {
        BestT[i] = rand() % 26 + 1;
    }

    // printf("%lld\n", scoring(BestT));

    double BestScore = scoring(BestT);

    auto start = chrono::system_clock::now();
    vector<int> t(d + 1);

    double T0 = 1e6;
    double T1 = 1e2;
    double TL = 1950;

    while (1)
    {
        auto end = chrono::system_clock::now(); // 計測終了時刻を保存
        auto dur = end - start;                 // 要した時間を計算
        auto msec = chrono::duration_cast<chrono::milliseconds>(dur).count();

        if (msec >= 1950)
        {
            break;
        }

        double T = powf(T0, 1 - msec / TL) * powf(T1, msec / TL);

        t = BestT;

        t[rand() % d + 1] = rand() % 26 + 1;

        double score = scoring(t);

        if (exp((score - BestScore) / T) > 0.5)
        {
            BestT = t;
            BestScore = score;
        }
    }

    for (int i = 1; i <= d; i++)
    {
        printf("%d\n", BestT[i]);
    }

    // printf("%lld\n", scoring(BestT));
}


Measured memory_bytes: 4336
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
int main()
{
	int n;
	cin>>n;
	cout<<"Christmas";
	for(int i=0;i<25-n;i++)
		cout<<" Eve";
	cout<<"\n";
	return 0;
}


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

template<typename T> T GCD(T a, T b) { if (a % b == 0) { return b; } return(GCD(b, a % b)); }
template<typename T> T LCM(T a, T b) { return(a / GCD(a, b) * b); }

int main(){
    long long N, M;
    string S, T;
    cin >> N >> M >> S >> T;
    long long L = LCM(N, M);
    bool judge = true;
    map<long long, char> mp;
    for (int i = 0; i < N; i++) {
        long long j = i * L / N;
        mp[j] = S[i];
    }
    
    for (int i = 0; i < M; i++) {
        long long j = i * L / M;
        if (mp.count(j) && mp[j] != T[i]) judge = false;
    }
    
    cout << ((judge) ? L : -1) << endl;
    return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long mod = 1000000007;
long long power(long long m,long long n){
    long long res = 1;
    if(n > 0){
        res = power(m,n / 2);
        if(n % 2 == 0){
            res = (res * res) % mod;
        }
        else{
            res = (((res * res) % mod) * m) % mod;
        }
    }
    return res;
}
int main(){
  int x,y;
  cin >> x >> y;
  long long kotae = 0;
  if((x + y) % 3 == 0){
    long long n = (y * 2 - x) / 3;
    long long m = (x * 2 - y) / 3;
    if(n > 0 && m > 0){
      vector<long long> jyou(n + m + 1);
      jyou[1] = 1;
      for(int i = 2;i <= n + m;i++){
        jyou[i] = (jyou[i - 1] * i) % mod;
      }
      kotae = (((jyou[n + m] * power(jyou[n],mod - 2)) % mod) * power(jyou[m],mod - 2)) % mod;
    }
    else if(n == 0 || m == 0){
      kotae = 1;
    }
  }
  cout << kotae << endl;
}

Measured memory_bytes: 5504
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
int n;
int h[21];
int main(){
  cin>>n;
  rep(i,n) cin>>h[i];
  int res=1,maxh=h[0];
  rep1(i,n-1){
    if(h[i]>=maxh){
      maxh=h[i];
      res++;
    }
  }
  prin(res);
  return 0;
}


Measured memory_bytes: 256