akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long sx, long long sy, long long tx, long long ty) {
  // go
  REP(y, (ty - sy)) cout << "U";
  REP(x, (tx - sx)) cout << "R";

  // back
  REP(y, (ty - sy)) cout << "D";
  REP(x, (tx - sx)) cout << "L";

  // go
  cout << "L";
  REP(y, (ty - sy) + 1) cout << "U";
  REP(x, (tx - sx) + 1) cout << "R";
  cout << "D";

  // back
  cout << "R";
  REP(y, (ty - sy) + 1) cout << "D";
  REP(x, (tx - sx) + 1) cout << "L";
  cout << "U" << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long sy;
  long long tx;
  long long sx;
  long long ty;
  cin >> sx;
  cin >> sy;
  cin >> tx;
  cin >> ty;
  solve(sx, sy, tx, ty);
  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
using namespace std;
using ll = long long;
const ll INF = 100100100100100;

int main()
{
	ll N, K;
	cin >> N >> K;
	vector<ll> num(N);
	for (int i = 0; i < N; i++) cin >> num[i];
	sort(num.begin(), num.end());
	ll ans = 0;
	for (int i = 0; i < K; i++) ans += num[N - 1 - i];
	cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(6);
	cout << fixed;

	int a, b, c;
	cin >> a >> b >> c;
	cout << (a + b + c >= 22 ? "bust" : "win") << '\n';
	return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

#define MAX_N 1000000007
#define INF 100000000000000

int main(){
  int h,w;
  cin >> h >> w;
  int a[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> a[i][j];
    }
  }
  vector<pair<int,int> > route;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(i%2 == 0) route.push_back(make_pair(i,j));
      else route.push_back(make_pair(i,w-1-j));
    }
  }

  vector<pair<pair<int,int>, pair<int,int> > > ans;
  for(int i=0;i<h*w-1;i++){
    int y,x,y1,x1;
    y = route[i].first;
    x = route[i].second;
    y1 = route[i+1].first;
    x1 = route[i+1].second;
    if(a[y][x]%2 != 0){
      a[y1][x1] += 1;
      ans.push_back(make_pair(make_pair(y,x),make_pair(y1,x1)));
    }
  }
  cout << ans.size() << endl;
  for(int i=0;i<ans.size();i++){
    int y,x,y1,x1;
    y = ans[i].first.first;
    x = ans[i].first.second;
    y1 = ans[i].second.first;
    x1 = ans[i].second.second;
    cout << y+1 << " " << x+1 << " " << y1+1 << " " << x1+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 7152
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;

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

  int x = 1;
  int y = 1;
  int z = 1;
  int num;
  int max;
  int ans;
  for (int i = 1; i <= n; ++i) {
    max = (int)sqrtf(n - 5) + 2;
    num = 0;

    for (x = 1;x <= max; ++x) {
      for (y = 1; y <= x; ++y) {
        for (z = 1; z <= y; ++z) {
          ans = x * x + y * y + z * z + x * y + y * z + z * x;
          if (ans == i) {
            if (x == y && y == z) {
              ++num;
            } else if (x == y && y != z) {
              num += 3;
            } else if (x != y && y == z) {
              num += 3;
            } else {
              num += 6;
            }
          } else if (ans > i) {
            break;
          }
        }
      }
    }
    printf("%d\n", num);
  }
  return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
using namespace std;
const int MAX = 1e5 + 10;
const ll MOD = 1e9 + 7;
int N, M, K, Q;
bool bs[55], vis[55];
int A[55], B[55], maxi;

bool check() {
	// check if all A[i] are reachable to B[i] for every i without using number m
	for (int i = 0; i < N; ++i) {
		queue<int> q;
		memset(vis, 0, sizeof(vis));
		q.push(A[i]);
		vis[A[i]] = true;
		bool flag = false;
		while (!q.empty()) {
			int u = q.front();
			q.pop();
			for (int j = 1; j <= A[i]; ++j) {
				if (!bs[j]) continue;
				int v = u % j;
				if (vis[v]) continue;
				vis[v] = true;
				if (v != 0) q.push(v);

			}
		}
		if (!vis[B[i]]) return false;
	}
	return true;
}


int main()
{
	int i, j, k, x;
	scanf("%d", &N);
	for (i = 0; i < N; ++i) {
		scanf("%d", &A[i]);
	}

	for (i = 0; i < N; ++i) {
		scanf("%d", &B[i]);
	}
	for (i = 1; i <= 50; ++i) bs[i] = true;
	for (i = 0; i < N; ++i) {
		if (A[i] != B[i]) break;
	}
	if (i == N) {
		printf("0");
		return 0;
	}
	if (!check()) {
		printf("-1");
		return 0;
	}
	ll sum = 0LL;
	for (i = 50; i >= 1; --i) {
		bs[i] = false;
		if (!check()) {
			bs[i] = true;
			sum += (1LL << i);
		}
	}
	printf("%lld", sum);
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

int main()
{
  string n;
  cin >> n;
  bool b = true;
  for(int i=0; i < n.size(); i++){
    if(n[i] != n[n.size()-1-i]){
      b = false;
      break;
    }
  }
  if(b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a = 0;
	int b = 0;

	scanf("%d %d", &a, &b);

	if (a < b) printf("a < b\n");
	else if (a > b) printf("a > b\n");
	else if (a == b)printf("a == b\n");



	return 0;

}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define ll long long


using namespace std;

string str;

int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    int i;
    ios::sync_with_stdio(false);
    cin >> str;
    for(i = 0; i < str.size() - 8; i++)
        cout << str[i];
    //cin.close();
    //cout.close();
    return 0;
}


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

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

  //左からi個、右からj個取って調べる
  //max(0,K-(i+j))個外せる
  int64_t ans=0;
  for(int i=0;i<N;++i){
    for(int j=0;j<=N-i;++j){
      if(i+j>K) continue;
      vector<int64_t> w;
      for(int s=0;s<i;++s) w.push_back(v[s]);
      for(int s=0;s<j;++s) w.push_back(v[N-1-s]);
      sort(w.begin(),w.end());
      int cnt=0;
      int64_t sum=0;
      for(int s=0;s<w.size();++s){
        if(w[s]<0 && cnt<K-(i+j)) ++cnt;
        else sum += w[s];
      }
      ans = max(sum,ans);
    }
  }

  cout<<ans<<endl;
}

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

int main(){
    string a,b;
    int A,B;
    cin >> A;
    cin >>a;
    B = a.length();
    if(B <= A){
        cout << a <<endl;
    }else{
        A;
        cout << a.substr(0,A) << "..."<<endl;
    }

}

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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

int main()
{

	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, res=0;
	string s;
	cin >> s;
	
	if(s.substr(0,4)=="YAKI") puts("Yes");
	else puts("No");
	//cout << res << endl;
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n;
	cin >> n;
	vector<int> a(n);
	bool flag = false;
	REP(i, n) {
		cin >> a[i];
		if (a[i] == 1) {
			flag = true;
		}
	}
	if (!flag) {
		put(-1);
		return 0;
	}
	int cnt = 1;
	REP(i, n) {
		if (a[i] == cnt) {
			cnt++;
		}
	}
	put(n - cnt + 1);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
using namespace std;
#define LL long long

map <pair<int, int>, int> mp;
int n, ans;
LL int x[50], y[50];

int main(){


	cin >> n;
	for (int i = 0; i < n; i++)cin >> x[i] >> y[i];

	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			if (i == j)continue;
			mp[{x[i] - x[j], y[i] - y[j]}]++;
		}
	}
	for (auto p : mp){
		ans = max(ans, p.second);
	}
	cout << n - ans << endl;

	return 0;
}

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

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

    if (a == b) {
        if (a == c) cout << 1 <<endl;
        else cout << 2 << endl;
    }

    else {
        if ((b == c) || (a == c)) cout << 2 << endl;
        else cout << 3 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//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 SQ(a) ((a)*(a))
#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,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

//ここから編集

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(5);
  
  string s,t; cin >> s >> t;
  int a, b; cin >> a >> b;
    string aa;
    cin >> aa;
    if(s == aa) a--;
    else b--;
    cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	string tmp;
	int64 nn, ac = 0, wa = 0, tl = 0, re = 0;
	cin >> nn;
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> tmp;
		if(tmp[0] == 'A')
		{
			ac++;
		}
		if(tmp[0] == 'W')
		{
			wa++;
		}
		if(tmp[0] == 'T')
		{
			tl++;
		}
		if(tmp[0] == 'R')
		{
			re++;
		}
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tl << endl;
	cout << "RE x " << re << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-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; }
// ---------------------------------------------------------------------------

// snukeさんのmodint
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

// mint N;

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(2000500);

// combination c(N);
// mint ans = c(N,n);
// cout << ans.x << endl;
// Nとnはll型(mintではない)
// -------------------------------------------------------------


mint suzuken(int r,int c){
    return comb(r+c+2,r+1) - 1;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int r1,c1,r2,c2;
    cin >> r1 >> c1 >> r2 >> c2;
    r1--;
    c1--;
    mint ans = suzuken(r2,c2);
    ans -= suzuken(r1,c2);
    ans -= suzuken(r2,c1);
    ans += suzuken(r1,c1);
    cout << ans.x << enld;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i=0;i<N;i++)
    cin >> vec[i];
  
  sort(vec.begin(),vec.end());
  int Alice=0;
  int Bob = 0;
  
  for (int i=0;i<N;i++){
    if (i%2==0)
      Alice += vec[N-i-1];
    else
      Bob += vec[N-i-1];
  }
  cout << Alice - Bob << endl;
}

  


Measured memory_bytes: 256
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int a,b,c,k;
    scanf("%d %d %d",&a, &b, &c);
    scanf("%d", &k);
    int i = 0;
    while(b <= a){
        b *= 2;
        i++;
    }
    while(c <= b){
        c *= 2;
        i++;
    }
  
    if(i <= k){
        printf("Yes");
    }
    else {
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 3224
s = input()
K = int(input())

n = len(s)

ex = [s[:min(K, n)]]
for i in range(n):
    if i + K - 1 < n:
        if ex[0] > s[i:i+K]:
            ex[0] = s[i:i+K]
    else:
        if ex[0][:n-i] > s[i:]:
            ex.insert(0, s[i:])


for n in range(len(ex)):
    for i in range(len(ex[n])):
        for j in range(i+1, len(ex[n])+1):
            ex.append(ex[n][i:j])

ex = set(ex)
ex = sorted(list(ex))

print(ex[K-1])


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


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a[5];
    for(int i=0;i<5;++i) cin>>a[i];
    for(int i=0;i<5;++i) if(a[i]==0) return cout<<i+1,0;
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] sumup = new int[n + 1];
		int[] sumdown = new int[n + 1];
		sumup[0] = 0;
		sumdown[0] = 0;
		for(int i = 1; i < n + 1; i++) {
			sumup[i] = sc.nextInt() + sumup[i - 1];
		}
		for(int i = 1; i < n + 1; i++) {
			sumdown[i] = sc.nextInt() + sumdown[i - 1];
		}
		int ans = 0;
		for(int i = 1; i < n + 1; i++) {
			int tmp = sumup[i] + sumdown[n] - sumdown[i - 1];
			ans = Math.max(ans, tmp);
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21972
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
#define ll long long

int main(void){
  string c;
  cin >> c;
  if(c[0] == 'a' || c[0] == 'i' || c[0] == 'u' || c[0] == 'e' || c[0] == 'o'){
    cout << "vowel\r\n";
  }else{
    cout << "consonant\r\n";
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, c) for(int i = 0; i < (int)c; i++)
using namespace std;
int main()
{
    int N; cin >> N;
    vector<int> X(N);
    rep(i, N) cin >> X[i];
    sort(X.begin(), X.end(), greater<int>());
    int alice, bob; alice = 0; bob = 0;
    for (int i = 0; i < N; i++)
        if (i % 2 == 0) alice += X[i];
        else bob += X[i];
    cout << abs(alice - bob) << endl;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	string S;
	cin >> N >> S;

	string ts = S;
	rep(k, 0, 100)
	{
		string ns;
		rep(i, 0, SZ(ts))
		{
			if (i < SZ(ts) - 1 && ts[i] == '('&&ts[i + 1] == ')')
			{
				i++;
			}
			else
			{
				ns += ts[i];
			}
		}
		ts = ns;
	}

	int l = 0, r = 0;
	rep(i, 0, SZ(ts))
	{
		if (ts[i] == ')')l++;
		else r++;
	}

	string ans;
	rep(i, 0, l)ans += '(';
	ans += S;
	rep(i, 0, r)ans += ')';

	cout << ans << endl;

	return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int N, M;
set<string> st;
vector<string> dic;
vector<string> rdic;

char ex = 'z'+1;

int match_count(string s, const vector<string>& d) {
  int l = lower_bound(all(d), s) - begin(d);
  int u = upper_bound(all(d), s+ex) - begin(d);
  return u-l;
}

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

  scanf("%lld %lld", &N, &M);
  rep(i, N) {
    char buf[256];
    scanf("%s", buf);
    string word(buf);
    st.insert(buf);
    dic.push_back(word);
    reverse(all(word));
    rdic.push_back(word);
  }
  sort(all(dic));
  sort(all(rdic));

  rep(i, M) {
    char buf[256];
    scanf("%s", buf);
    string slate(buf);
    if(count(all(slate), '*') == 0) {
      if(count(all(slate), '?') == 0) {
	cout << st.count(slate) << endl;
      } else {
	int idx = slate.find('?');
	int ans = 0;
	for(char c = 'a'; c <= 'z'; c++) {
	  slate[idx] = c;
	  ans += st.count(slate);
	}
	cout << ans << endl;
      }
    } else {
      if(slate[0] == '*') {
	reverse(all(slate));
	slate.pop_back();
	if(count(all(slate), '?') == 0) {
	  cout << match_count(slate, rdic) << endl;
	} else {
	  int idx = slate.find('?');
	  int ans = 0;
	  for(char c = 'a'; c <= 'z'; c++) {
	    slate[idx] = c;
	    ans += match_count(slate, rdic);
	  }
	  cout << ans << endl;
	}
      } else {
	slate.pop_back();
	if(count(all(slate), '?') == 0) {
	  cout << match_count(slate, dic) << endl;
	} else {
	  int idx = slate.find('?');
	  int ans = 0;
	  for(char c = 'a'; c <= 'z'; c++) {
	    slate[idx] = c;
	    ans += match_count(slate, dic);
	  }
	  cout << ans << endl;
	}
      }
    }
  }

  return 0;
}

Measured memory_bytes: 16624
my $s = <>;chomp $s;
my ($a,$b,$c,$d)=split(/ /,$s);

my $max = $b*$d;
$max = $a*$c if($max < $a*$c);
$max = $b*$c if($max < $b*$c);
$max = $a*$d if($max < $a*$d);

print "$max";


Measured memory_bytes: 4776
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------
class RollingHash {
#define int long long
#define H pair<int, int>
	int b1, b2;
	int m1, m2;
	vector<int>h1, h2, p1, p2;
public:
	RollingHash() :b1(1007), b2(1009), m1(1e9 + 7), m2(1e9 + 9) {}
	void init(const string& s) {
		int n = s.size();
		h1.assign(n + 1, 0);
		h2.assign(n + 1, 0);
		p1.assign(n + 1, 1);
		p2.assign(n + 1, 1);
		for (int i = 0; i < n; i++) {
			h1[i + 1] = (h1[i] + s[i]) * b1 % m1;
			h2[i + 1] = (h2[i] + s[i]) * b2 % m2;
			p1[i + 1] = p1[i] * b1 % m1;
			p2[i + 1] = p2[i] * b2 % m2;
		}
	}
	H get(int l, int r) {
		int t1 = ((h1[r] - h1[l] * p1[r - l]) % m1 + m1) % m1;
		int t2 = ((h2[r] - h2[l] * p2[r - l]) % m2 + m2) % m2;
		return H{ t1,t2 };
	}//[l,r)
};
int n; string s;
RollingHash rh;
signed main() {
	cin >> n >> s;
	rh.init(s);
	int ok = 0, ng = n;
	while (ng - ok > 1) {
		int t = (ok + ng) / 2;
		set<H>se;
		se.insert(rh.get(0, t));
		for (int i = t; i <= n - t; i++) {
			H k = rh.get(i, i + t);
			if (se.find(k) != se.end()) {
				ok = t;
				goto loop;
			}
			se.insert(rh.get(i - t + 1, i + 1));
		}
		ng = t;
	loop:;
	}
	cout << ok << endl;
}

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

int main() {

	int n; cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	ll ans = 0;
	int posiCnt;
	int negaCnt;
	int index = 0;
	if (n % 2 == 0) {
		posiCnt = n / 2 - 1;
		negaCnt = n / 2 - 1;		
		while (posiCnt--) {
			ans += 2 * a[index];
			index++;
		}
		ans += a[index];
		index++;
		ans += (-1) * a[index];
		index++;
		while (negaCnt--) {
			ans += (-2) * a[index];
			index++;
		}
	}
	else { // n % 2 != 0
		ll ans1 = 0;
		posiCnt = (n - 1) / 2;
		negaCnt = (n - 3) / 2;
		while (posiCnt--) {
			ans1 += 2 * a[index];
			index++;
		}
		ans1 += (-1) * a[index];
		index++;
		ans1 += (-1) * a[index];
		index++;
		while (negaCnt--) {
			ans1 += (-2) * a[index];
			index++;
		}
		ll ans2 = 0;
		index = 0;
		posiCnt = (n - 3) / 2;
		negaCnt = (n - 1) / 2;
		while (posiCnt--) {
			ans2 += 2 * a[index];
			index++;
		}
		ans2 += a[index];
		index++;
		ans2 += a[index];
		index++;
		while (negaCnt--) {
			ans2 += (-2) * a[index];
			index++;
		}
		ans = max(ans1, ans2);
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4052
fn read_split<T : std::str::FromStr>() -> Vec<T> {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}

fn read_split_multi<T : std::str::FromStr>(count : i32) -> Vec<Vec<T>> {
    (0..count).map(|_| read_split()).collect()
}

fn main() {
    let inputs1 : Vec<i32> = read_split();
    let num_d = inputs1[0];
    let num_n = inputs1[1];
    let points : Vec<Vec<f32>> = read_split_multi(num_d);
    let mut result = 0;
    for point_a in 0..num_d {
        for point_b in (point_a + 1)..num_d {
            let mut total_distance = 0f32;
            let a_p = &points[point_a as usize];
            let b_p = &points[point_b as usize];
            for i in 0..num_n {
                let total = &a_p[i as usize] - &b_p[i as usize];
                total_distance += total * total;
            }
            let a = total_distance.sqrt();
            let b = *&a as i32;
            if a == b as f32 {
                result += 1;
            }
        }
        
    }

    println!("{}", result);
}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
   ll n,k;
   cin>>n>>k;

   if(n<=k){
        cout<<min(k-n,n)<<endl;
   }
   else{

      ll diff = n-k;
      ll rem = diff%k;
      cout<<min(rem,abs(rem-k))<<endl;
   }


}


Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

bool ispremeiji(int y,int m,int d){
	if(y<1868)return true;
	else if(y==1868 &&m<9)return true;
	else if(y==1868 &&m==9&&d<8)return true;
	else return false;
}

bool ismeiji(int y,int m,int d){
	if(y<1868||y>1912)return false;
	else{
		if(y==1868 && m<9)return false;
		else{
			if(y==1868&&m==9&&d<8)return false;
			else{
				if(y==1912&&m>8)return false;
				else{
					if(y==1912&&m==7&&d>29)return false;
					else return true;
				}
			}
		}
	}
}

bool istaisho(int y,int m,int d){
	if(y<1912||y>1926)return false;
	else{
		if(y==1912 && m<7)return false;
		else{
			if(y==1912&&m==7&&d<30)return false;
			else{
				if(y==1926&&m>12)return false;
				else{
					if(y==1926&&m==12&&d>24)return false;
					else return true;
				}
			}
		}
	}
}

bool isshowa(int y,int m,int d){
	if(y<1926||y>1989)return false;
	else{
		if(y==1926 && m<12)return false;
		else{
			if(y==1926&&m==12&&d<25)return false;
			else{
				if(y==1989&&m>1)return false;
				else{
					if(y==1989&&m==1&&d>7)return false;
					else return true;
				}
			}
		}
	}
}

int main(){
	int nen,getu,hi;
	while(cin>>nen){
		cin>>getu>>hi;
		if(ispremeiji(nen,getu,hi)){
			cout<<"pre-meiji"<<endl;
		}
		else if(ismeiji(nen,getu,hi)){
			cout<<"meiji "<<nen-1868+1<<" "<<getu<<" "<<hi<<endl;
		}else if(istaisho(nen,getu,hi)){
			cout<<"taisho "<<nen-1912+1<<" "<<getu<<" "<<hi<<endl;
		}else if(isshowa(nen,getu,hi)){
			cout<<"showa "<<nen-1926+1<<" "<<getu<<" "<<hi<<endl;
		}else{
			cout<<"heisei "<<nen-1989+1<<" "<<getu<<" "<<hi<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1172
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-9;
const int inf=1e8;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	vi co(100100);
	rep(i,n){
		int a;cin>>a;
		co[a]++;
	}
	rep(i,100100)if(co[i]>2)co[i]=(co[i]-1)%2+1;
	int t=0,out=0;
	rep(i,100100)if(co[i])out++;
	rep(i,100100){
		if(co[i]==2){
			if(t)t--;
			else t++;
		}
	}
	cout<<out-t<<endl;
}










Measured memory_bytes: 1152
import java.util.ArrayList;
import java.util.Scanner;

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String s  = sc.nextLine();
		char[] sChars = s.toCharArray();
		String t  = sc.nextLine();
		char[] tChars = t.toCharArray();
		int max = 0;
		
		for(int i = 0; i <= s.length() - t.length(); i++) {
			
			int matchChar = 0;
			for(int j = 0; j < t.length(); j++) {
				if(tChars[j] == sChars[i+j]) {
						matchChar++;
				}
			}

			if(max < matchChar) {
				max = matchChar;
			}
			
		}


		System.out.println(t.length() - max);
		sc.close();
	}
}




Measured memory_bytes: 35616
s = input()
flag = -1
k = -1
for i in range(len(s)):
  flag += 1
  k += 1
  a = s[0:(len(s)-k)//2]
  b = s[(len(s)-k)//2:(len(s)-k)]
  if a == b:
    if flag != 0:
      print(len(a)+len(b))
      break

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>

#include <algorithm>
#include <functional>

using namespace std;

typedef long long i64;

#define NMAX 100000

static int n, M, V, P;
static int a[NMAX + 10];

int main() {
    scanf("%d%d%d%d", &n, &M, &V, &P);
    for (int i = 1; i <= n; i++)
        scanf("%d", a + i);
    sort(a + 1, a + n + 1, greater<int>());

    int ans = P;
    i64 sum = 0;
    for (int i = P + 1; i <= n; i++) {
        i64 k = i - P;
        ans += a[P] + (max(0LL, sum) + k - 1) / k <= a[i] + M;
        sum -= a[P] - a[i];
        if (P + n - i <= V)
            sum += M;
    }

    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

long long w[100],v[100];

long long func(long long n,long long tar){
  
  long long dp[100010],ans=0;
  for(int i=0;i<100000;i++)dp[i]=1e10;
  dp[0]=0;
  
  for(int i=0;i<n;i++)
    for(long long int j=100000;j>=v[i];j--){
      
      dp[j]=min(dp[j],w[i]+dp[j-v[i]]);
      if(dp[j]<=tar){
        //cout<<dp[j]<<endl;
        ans=max(ans,j);
      }
      
    }
  
  return ans;
  
}

int main(){
  
   cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
  long long n,tar;
  cin>>n>>tar;
  
  for(int i=0;i<n;i++)cin>>w[i]>>v[i];
  
  cout<<func(n,tar)<<endl;
  
  return 0;
}

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

int main()
{
    int N, M;
    cin >> N >> M;
    int student[N][2];
    int checkpt[M][2];
    for (int i = 0; i < N; i++)
    {
        cin >> student[i][0] >> student[i][1];
    }
    for (int i = 0; i < M; i++)
    {
        cin >> checkpt[i][0] >> checkpt[i][1];
    }
    for (int i = 0; i < N; i++)
    {
        int dist = 2 * 1e9;
        int jcheck;
        for (int j = M - 1; j >= 0; j--)
        {
            int disttmp = abs(student[i][0] - checkpt[j][0]) + abs(student[i][1] - checkpt[j][1]);
            if (dist >= disttmp)
            {
                dist = disttmp;
                jcheck = j;
            }
        }
        cout << jcheck + 1 << endl;
    }
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

type card struct {
	suit string
	number int
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func partition(A []card, p, r int) int {
	std := A[r].number
	i := p - 1
	for j := p; j < r; j++ {
		if A[j].number <= std {
			i++
			A[i], A[j] = A[j], A[i]
		}
	}
	i++
	A[i], A[r] = A[r], A[i]
	return i
}

func isStable(A, S []card) bool {
	for i := 0; i < len(A); i++ {
		if A[i] != S[i] {
			return false
		}
	}	
	return true
}

func mergeSort(A []card, left, right int) {
	if left + 1 < right {
		mid := (left + right) / 2
		mergeSort(A, left, mid)
		mergeSort(A, mid, right)
		merge(A, left, mid, right)
	}
}

func merge(A [] card, left, mid, right int) {
	n1 := mid - left
	n2 := right - mid
	L := make([]card, n1+1)
	R := make([]card, n2+1)

	infCard := card{"Z", 1 << 32}

	for i := 0; i < n1; i++ {
		L[i] = A[left+i]
	}
	L[n1] = infCard

	for i := 0; i < n2; i++ {
		R[i] = A[mid+i]
	}
	R[n2] = infCard

	i := 0 // Left array index
	j := 0 // Right array index
	for k := left; k < right; k++ {
		if L[i].number <= R[j].number {
			A[k] = L[i]
			i++
		} else {
			A[k] = R[j]
			j++
		}
	}
}

func quickSort(A []card, p, r int) {
	if p < r {
		q := partition(A, p, r)
		quickSort(A, p, q-1)
		quickSort(A, q+1, r)
	}
}

func main() {
	input := nextString()
	n, _ := strconv.Atoi(input)

	A := make([]card, n)
	S := make([]card, n)
	for i := 0; i < n; i++ {
		cardInfo := strings.Fields(nextString())
		number, _ := strconv.Atoi(cardInfo[1])
		c := card{cardInfo[0], number}
		A[i] = c
		S[i] = c
	}

	mergeSort(A, 0, n)
	quickSort(S, 0, len(S)-1)
	if stable := isStable(A, S); stable {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}

	for _, c := range S {
		fmt.Printf("%s %d\n", c.suit, c.number)
	}
}


Measured memory_bytes: 16620
def main():
    n=int(input())
    A=list(map(int,input().split()))
    if n==3 or n==2:
        return max(A)
    DP=[[None]*3 for _ in range(n)]
    DP[0][0]=A[0]
    DP[1][1]=A[1]
    DP[2][0]=A[0]+A[2]
    DP[2][2]=A[2]
    DP[3][1]=max(A[0],A[1])+A[3]
    #print(DP)
    for i in range(4,n):
        a=A[i]
        if i%2==0:
            DP[i][0]=DP[i-2][0]+a
            DP[i][2]=max(DP[i-2][2]+a,DP[i-3][1]+a,DP[i-4][0]+a)
        if i%2!=0:
            DP[i][1]=max(DP[i-2][1]+a,DP[i-3][0]+a)
    if n%2==1:
        ans=max(DP[-1][2],DP[-2][1],DP[-3][0])
        return ans
    ans=max(DP[-1][1],DP[-2][0])
    return ans
    
if __name__=='__main__':
    print(main())

Measured memory_bytes: 114432
//#include <StdAfx.h>
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
	int N,M,L;
	cin>>L>>M>>N;
	for(int i=0;i<10;i++){
		N=L*N-M;
		printf("%d\n",N);
	 }
	return 0;
}

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

using namespace std;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
typedef long long ll;
typedef unsigned long long ull;
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)

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

#define fil0(i,n) cout<<swet(n)<<setfill('0')<<i<<resetiosflags(ios_base::floatfield)
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define possible(n) cout<<((n)?"possible":"impossible")<<endl
#define Possible(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    int n;
    cin>>n;
    vi a(n);
    REP(i,n){
        cin>>a[i];
    }
    int normal=0;
    REP(i,n-1){
        normal+=abs(a[i]-a[i+1]);
    }
    normal+=abs(a[0]);
    normal+=abs(a[n-1]);

    REP(i,n){
        if(i==0)cout<<normal-abs(a[0])-abs(a[0]-a[1])+abs(a[1])<<endl;
        else if(i==n-1)cout<<normal-abs(a[n-1])-abs(a[n-1]-a[n-2])+abs(a[n-2])<<endl;
        else cout<<normal-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])<<endl;
    }

    return 0;
}


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

int main(){
    int tanka,suu,sum=0,ssum=0,cnt=0;
    while(scanf("%d,%d",&tanka,&suu)!=EOF){
        sum+=tanka*suu;
        ssum+=suu;
        cnt++;
    }
    ssum=(ssum*10)/cnt;
    if(ssum%10!=0){
        ssum=ssum+5;
    }
    ssum=ssum/10;
    printf("%d\n",sum);
    printf("%d\n",ssum);
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC omodtimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long ,long> ii; 	
typedef complex<long double> com;
 
const ll mod = 998244353;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	vector <ll> red(a);
	vector <ll> green(b);
	vector <ll> color(c);
	for (int z=0;z<a;z++){
		cin >> red[z];
	}
	for (int z=0;z<b;z++){
		cin >> green[z];
	}
	for (int z=0;z<c;z++){
		cin >> color[z];
	}
	sort(red.begin(),red.end());
	sort(green.begin(),green.end());
	sort(color.rbegin(),color.rend());
	ll ans = 0;
	ll i = a-x;
	ll j = b-y;
	for (int z=i;z<a;z++){
		ans += red[z];
	}
	for (int z=j;z<b;z++){
		ans += green[z];
	}
	for (int z=0;z<c;z++){
		if(i == a && j == b) break;
		if (i == a){
			if(green[j] < color[z]){
			ans += color[z];
			ans -= green[j];
			j++;
			}
		}
		else if (j == b){
			if(red[i] < color[z]){
			ans += color[z];
			ans -= red[i];
			i++;
			}
		}
		else if (red[i] <= green[j] && red[i] < color[z]){
			ans += color[z];
			ans -= red[i];
			i++;
		}
		else if (red[i] >= green[j] && green[j] < color[z]){
			ans += color[z];
			ans -= green[j];
			j++;
		}
	}	
	cout << ans << endl;
}


Measured memory_bytes: 2560
using System;
using System.Linq;

class C
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var x = read().OrderBy(t => t).ToArray();
		int n = h[0], m = h[1];
		Console.WriteLine(x[m - 1] - x[0] - Enumerable.Range(0, m - 1).Select(i => x[i + 1] - x[i]).OrderByDescending(t => t).Take(n - 1).Sum());
	}
}


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

int main() {
    ll n, m;
    int r = 0;
    cin >> n;
    m = n;
    for (ll p = 2; m > 1 && p * p <= n; ++p) {
        if (m % p) continue;
        ll q  = p;
        int c = 0;
        while (m % q == 0) m /= q, ++c, q *= p;
        while (m % p == 0) m /= p;
        r += c;
    }
    if (m > 1) ++r;
    cout << r;
    return 0;
}


Measured memory_bytes: 3632
program main
  implicit none
  integer(8) :: n, k, i, i1, i2, j1, j2, x1, x2, y1, y2, res, cnt
  integer(8), allocatable :: x(:), y(:), xs(:), ys(:)
  read *, n, k
  allocate (x(n), y(n))
  do i = 1, n
    read *, x(i), y(i)
  end do
  xs = x
  ys = y
  call quicksort(xs)
  call quicksort(ys)
  res = 4 * 10_8 ** 18
  do i1 = 1, n
    do i2 = i1 + 1, n
      do j1 = 1, n
        do j2 = j1 + 1, n
          x1 = xs(i1)
          x2 = xs(i2)
          y1 = ys(j1)
          y2 = ys(j2)
          cnt = 0
          do i = 1, n
            if ((x1 <= x(i) .and. x(i) <= x2) .and. (y1 <= y(i) .and. y(i) <= y2)) cnt = cnt + 1
          end do
          if (cnt >= k) then
            res = min(res, (x2 - x1) * (y2 - y1))
          end if
        end do
      end do
    end do
  end do
  print "(i0)", res

  contains

  recursive subroutine quicksort(a)
    integer(8), intent(inout) :: a(:)
    integer(8) :: pivot, i, j, k, tmp, n
    real(4) :: r
    n = size(a)
    if (n <= 1) return
    i = 1
    j = n
    call random_number(r)
    k = 1 + floor(r * n)
    k = max(1, min(k, n))
    pivot = a(k)
    do
      do while (.not. pivot <= a(i))
        i = i + 1
      end do
      do while (.not. a(j) <= pivot)
        j = j - 1
      end do
      if (i >= j) exit
      tmp = a(i)
      a(i) = a(j)
      a(j) = tmp
      i = i + 1
      j = j - 1
    end do
    call quicksort(a(1:i - 1))
    call quicksort(a(j + 1:n))
  end subroutine quicksort
end program main


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
 
int main(){
  int n,m;
  cin >> n >>m;
  VI p(m);
  vector<string> s(m);
  rep(i,m){
    cin >> p.at(i) >> s.at(i);
  }
  
 
  ll wasum=0;
  int acsum=0;
  VI wa(100001);
  vector<bool> ac(100001);
  for(int i=1;i<=n;i++){
    wa.at(i)=0;
    ac.at(i)=false;
  }
  rep(i,m){
    if(ac.at(p.at(i)))continue;
    else{
      if(s.at(i)=="AC"){
		ac.at(p.at(i))=true;
        wasum+=wa.at(p.at(i));
        acsum++;
      }
      else if(s.at(i)=="WA"){
        wa.at(p.at(i))++;
      }
    }
  }
  cout << acsum << " " << wasum << endl;
        
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  string res;
  for(int i = 0;i < s.size();i++){
    if(i % 2 == 0)res = res + s[i];
  }
  cout << res << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll ans = 0;
    ll last = N - 1;
    rep(i, N) {
        if (S[i] == 'W') {
            rrep(j, last, i + 1) {
                if (S[j] == 'R') {
                    ans++;
                    char tmp = S[i];
                    S[i] = S[j];
                    S[j] = tmp;
                    last = j;
                    break;
                }
            }
            if (S[i] == 'W') {
                break;
            }
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3720
#include<stdio.h>
int D;
int main(){
	scanf("%d",&D);
	switch (D){
		case 22:printf("Christmas Eve Eve Eve\n");break;
		case 23:printf("Christmas Eve Eve\n");break;
		case 24:printf("Christmas Eve\n");break;
		case 25:printf("Christmas\n");break;
	}
	return 0;
}

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

using namespace std;

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

  for (auto &s: S) {
    s += N;
    if (s > 'Z') {
      s -= 'Z' - 'A' + 1;
    }
  }

  cout << S << endl;
}


Measured memory_bytes: 256