akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int n;cin>>n;
	vi a(n);
	int sum=0;
	rep(i,n){
		cin>>a[i];
		sum+=a[i];
	}
	cout<<sum-n<<endl;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b, c;
  	cin >> a >> b >> c;
  	cout << (a + b >= c ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include <stdio.h>
int Min(int a,int b){
    return a<=b?a:b;
}
int main()
{   int ans,a,b,c;
    char s[10000];
    scanf("%d%d%d",&a,&b,&c);
    if(a+b+1>=c){
        ans=c+b;
       // printf("t");
    }else{
        ans=b+a+1+b;
        //printf("f");
    }
    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 128
// while( !(succeed == try()) );

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

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


#define int long long int
#define loop(i,s,e) for(int i=s; i<e; i++)
#define endl '\n'
#define vii vector<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX

void INP();

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


void alpha()
{	
	int k, n;
	cin>>k>>n;

	int arr[n];
	loop(i,0,n) cin>>arr[i];

	int dis = -inf;
	loop(i,1,n){
		if(arr[i]-arr[i-1] > dis) dis = arr[i] - arr[i-1];
	}
	if(k-arr[n-1]+arr[0] > dis) dis = k-arr[n-1]+arr[0];

	cout<<k-dis<<endl;
}

int32_t main(){

	ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//INP();
    int t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}






















inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}
 
 

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 2e5 + 10;
vector<int> a[N];
int sz[N];
deque<int> d[N], e[N];
int inv2;

int64 power_mod(int64 a, int n) {
  int64 ret = 1;
  for (; n; n >>= 1) {
    if (n & 1) ret = ret * a % MOD;
    a = a * a % MOD;
  }
  return ret;
}

int64 inv_mod(int64 a) {
  return power_mod(a, MOD - 2);
}

int merge(int u, int v) {
  if (d[u].size() < d[v].size()) swap(u, v);
  for (int i = 0; i < d[v].size(); ++i) {
    d[u][i] = ((int64)d[u][i] * e[v][i] +
               (int64)e[u][i] * d[v][i]) % MOD;
    e[u][i] = (int64)e[u][i] * e[v][i] % MOD;
  }
  return u;
}

void DFS(int u) {
  int w = -1;
  sz[u] = 1;
  for (auto& v : a[u]) {
    DFS(v);
    sz[u] += sz[v];
    if (w < 0) {
      w = v;
    } else {
      w = merge(w, v);
    }
  }
  if (w < 0) {
    d[u] = e[u] = {inv2};
    return;
  }
  int len = 0;
  for (auto& v : a[u]) {
    if (v != w) len = max(len, (int)d[v].size());
  }
  for (int i = 0; i < len; ++i) {
    e[w][i] = (1 + MOD - d[w][i]) % MOD;
  }
  d[u] = std::move(d[w]);
  e[u] = std::move(e[w]);
  d[u].push_front(inv2);
  e[u].push_front(inv2);
}

int main() {
  inv2 = inv_mod(2LL);
  int n;
  scanf("%d", &n);
  ++n;
  for (int i = 1; i < n; ++i) {
    int j;
    scanf("%d", &j);
    a[j].push_back(i);
  }
  DFS(0);
  int ret = 0;
  for (int i = 0; i < d[0].size(); ++i) {
    ret = (ret + d[0][i]) % MOD;
  }
  printf("%d\n", (int64)ret * power_mod(2, sz[0]) % MOD);
  return 0;
}


Measured memory_bytes: 481528
n,a,b = map(int,input().split())
if n%2 == 0:
	if (b-a)%2 == 1:
		print('Borys')
	else:
		print('Alice')
else:
	if (b-a)%2 == 1:
		print('Borys')
	else:
		print('Alice')

Measured memory_bytes: 2940
#include<algorithm>
#include<climits>
#include<functional>
#include<vector>
template<typename T = int, T  LOWEST = INT_MAX, typename F = std::function<T(T, T)>>
class SegmentTree {
public:
  explicit SegmentTree(int n, const F& op = (const int&(*)(const int&, const int&))std::min) : NIL(-1) {initialize(n, op);}
  explicit SegmentTree(const std::vector<T>& list, const F& op = (const int&(*)(const int&, const int&))std::min) : NIL(-1) {
    initialize(list.size(), op);
    for(int i = 0; i < list.size(); ++i) update(i, list.at(i));
  }
  const T find(int left, int right) const {return query(left, right + 1, 0, 0, size_);}
  void update(int index, const T& value) {
    int i = index + size_ - 1;
    node_.at(i) = value;
    while((i = parent(i)) != NIL) node_.at(i) = op_(node_.at(left_child(i)), node_.at(right_child(i)));
  }
private:
  void initialize(int n, const F& op) {
    op_ = op;
    size_ = 1;
    while(size_ < n) size_ <<= 1;
    node_.assign((size_ << 1) - 1, LOWEST);
  }
  int parent(int node) const {return node == 0 ? NIL : (node - 1) >> 1;}
  int left_child(int node) const {return (node << 1) + 1;}
  int right_child(int node) const {return (node << 1) + 2;}
  const T query(int a, int b, int k, int l, int r) const {
    if(b <= l || r <= a) return  LOWEST;
    if(a <= l && r <= b) return node_.at(k);
    auto vl = query(a, b, left_child(k), l, (l + r) / 2);
    auto vr = query(a, b, right_child(k), (l + r) / 2, r);
    return op_(vl, vr);
  }
  const int NIL;
  int size_;
  std::vector<T> node_;
  F op_;
};

#include<iostream>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  SegmentTree<int, 0> RSQ(n, plus<int>());
  for(int i = 0; i < q; ++i) {
    int com, x, y;
    cin >> com >> x >> y;
    if(com) cout << RSQ.find(x-1, y-1) << endl;
    else    RSQ.update(x-1, RSQ.find(x-1,x-1)+y);
  }
}

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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

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

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long
#define mp make_pair

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    int x, y, z, num = 0, i = 1;
    cin >> x >> y >> z;
    cout << (x - z) / (y + z) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int N, a, b, Q, K, x, y;
	cin >> N;
	vector<vector<pair<int, long>>> d(N);
	for (int i = 0; i < N - 1; i++) {
		long c;
		cin >> a >> b >> c;
		d[a - 1].emplace_back(b - 1, c);
		d[b - 1].emplace_back(a - 1, c);
	}
	cin >> Q >> K;
	priority_queue<pair<int, long>, vector<pair<int, long>>, greater<pair<int, long>>> e;
	e.emplace(K - 1, 0);
	vector<bool> f(N);
	vector<long> g(N, LONG_MAX);
	g[K - 1] = 0;
	while (!e.empty()) {
		pair<int, long> h = e.top();
		e.pop();
		f[h.first] = true;
		for (pair<int, long>& i : d[h.first]) {
			if (!f[i.first]) {
				if (g[h.first] + i.second < g[i.first]) {
					g[i.first] = g[h.first] + i.second;
					e.emplace(i.first, g[i.first]);
				}
			}
		}
	}
	for (int i = 0; i < Q; i++) {
		cin >> x >> y;
		cout << g[x - 1] + g[y - 1] << endl;
	}
}

Measured memory_bytes: 11120
import scala.io.Source.stdin

object Main {
  def main(args: Array[String]) = {
    val list = stdin.getLines().buffered.map { _.toInt }
    val n = list.next()
    val r0 = list.next()
    val r1 = list.next()
    var max = r1 - r0
    var min = if(r0 > r1) r1 else r0
    for( m <- list ) {
      if( max < m - min) {
        max = m - min
        if( min -m > 0 )
          min = m
      }
      else if( min - m > 0 ) {
        min = m
      }
    }
    println(max)
  }
}

Measured memory_bytes: 65044
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

const int p = 150;

struct St{
  int t, x, y;
  St() {}
  St(int _x, int _y, int _t): x(_x), y(_y), t(_t) {}
};

int xdir[6] = {0, 1, 1, -1, 0, -1}, ydir[6] = {1, 1, 0, -1, -1, 0};
int bfs(bool a[301][301], int t, int sx, int sy)
{
  int cnt = 1;
  queue<St> que;
  a[sy+p][sx+p] = false;
  que.push(St(sx, sy, t));

  while(!que.empty()){
    St st = que.front();
    que.pop();
    
    if(st.t == 0) continue;

    for(int i = 0; i < 6; i++){
      int dx = st.x+xdir[i], dy = st.y+ydir[i];
      if(a[dy+p][dx+p]){
	a[dy+p][dx+p] = false;
	cnt++;
	que.push(St(dx, dy, st.t-1));
      }
    }
  }

  return cnt;
}

int main()
{
  int t, n, u, v;
  bool a[301][301];

  while(cin>>t>>n && (t+n)){
    fill(&a[0][0], &a[300][300], true);    
    while(n--){
      cin >> u >> v;
      a[v+p][u+p] = false;
    }
    cin >> u >> v;

    cout << bfs(a, t, u, v) << endl;
  }

  return 0;
}

Measured memory_bytes: 1008
import numpy as np

N = int(input())
A = [0] + list(map(int, input().split()))

cumsum = np.cumsum(A)

ans = float("inf")
for i in range(1, N):
    left = cumsum[i]
    right = cumsum[-1] - cumsum[i]
    tmp = abs(right - left)
    if tmp < ans:
        ans = tmp

print(ans)


Measured memory_bytes: 34188
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(ll i=0;i<(n);++i)
#define Fr(i,n) for(long long i=1;i<=(n);++i)
#define ifr(i,n) for(long long i=(n)-1;i>=0;--i)
#define iFr(i,n) for(long long i=(n);i>0;--i)

int main() {
  cin.tie(nullptr);
  ll n,a,b,c,ans;
  cin>>a>>b>>c;
  if(a==b){
    cout<<c;
  }
    if(a==c){
      cout<<b;
    }
  if(b==c){
    cout<<a;
  }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef  unsigned int uint;
typedef  long double ld;


int main()
{

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

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	ll t;
	ld ans = 1;
	for (int i = 0; i < n; i++)
	{
		cin >> t;
		if (ans != -1)
			ans *= t;
		if (ans > 1000000000000000000 || ans < 0)
			ans = -1;
		if (t == 0)
			ans = 0;
	}

	cout << (ll)ans;


	return 0;
}

Measured memory_bytes: 3656
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n;
  rep(i, n) cin >> a[i];
  rrrep(i, n - 1, 0) {
    ans += a[i] * sum;
    sum += a[i];
    sum %= MOD;
    ans %= MOD;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 5184
#include <iostream>
#include <fstream>

#include <cmath>

using namespace std;

int profit(int *R, int n);
int main(){

    int n, R[200000];
    cin >> n;
    for(int i=0;i<n;i++) cin >> R[i];
    cout << profit(R,n) << endl;

    return 0;
}

int profit(int *R, int n){
    int maxV = R[1] - R[0];
    int minV = R[0];
    for(int i=1;i<n;i++){
        maxV = max(maxV, R[i] - minV);
        minV = min(minV,R[i]);
    }

    return maxV;
}



Measured memory_bytes: 3872
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll p2[200005];
int main() {
    init();
    ll N;
    cin >> N;
    p2[0] = 1;
    rep(i, N + 1) p2[i + 1] = p2[i] * 2 % MOD;

    ll AB = 0, A = 0, B = 0;
    map<pair<ll, ll>, ll> mp;
    rep(i,N){
        ll a, b;
        cin >> a >> b;
        if(a==0 and b==0)
            AB++;
        else if(a==0)
            A++;
        else if(b==0)
            B++;
        else{
            if (b < 0) a *= -1, b *= -1;
            ll g = gcd(abs(a), abs(b));
            a /= g, b /= g;
            mp[{a, b}]++;
            mp[{-b, a}];
        }
    }

    ll ans = AB;
    ll mul = p2[A] + p2[B] - 1;
    repa(p,mp){
        ll a = p.first.first, b = p.first.second, cnt = p.second;
        if (cnt == 0) continue;
        if (a < 0) a *= -1, b *= -1;

        (mul *= p2[cnt] + p2[mp[{-b, a}]] - 1) %= MOD;
        mp[{-b, a}] = 0;
    }

    (ans += mul + MOD - 1) %= MOD;

    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

int main(void){
   int n, q;
   cin >> n >> q;

   string s;
   cin >> s;

   
   //累積和を求める
   int cnt = 0;
   vector<int> sums(n,0);//2文字を探すので、n-1+1=n
   for (int i = 0; i < n - 1; i++){
      if(s.at(i)=='A'&&s.at(i+1)=='C')
         cnt++;
      sums.at(i + 1) = cnt;
   }

   for (int i = 0; i < q;i++){
      int b, e;
      cin >> b >> e;
      int ans = sums.at(e-1) - sums.at(b - 1);
      cout << ans << endl;
   }
}

Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)










int main(){
    ll m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    cout << (m1 != m2) << endl;
}

Measured memory_bytes: 256
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<string>
using namespace std;

int main()
{
    string s, t;

    cin >> s >> t;

    cout << t + s << endl;

    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python
#-*- coding:utf-8 -*-

N = int(raw_input())

R = [int(raw_input()) for _ in range(N)]

minR = R[0]
maxVal = -2000000000

for i in R[1::]:
    maxVal = max(maxVal,i - minR)
    minR = min(minR, i)

print maxVal

Measured memory_bytes: 18940
#include <iostream>
using namespace std;
int main()
{
    int t=0, b=0;
    string a;
    cin >> a;
    for(int k=0; k<a.size(); k++)
    {
        if(a[k]=='A'||a[k]=='T'||a[k]=='C'||a[k]=='G')
        {
            t++;
            if(b<t)
            b=t;
        }
        else t=0;
    }
    cout << b;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N + 1];
		long[] B = new long[N];
		for(int i = 0; i < N + 1; i++) {
			A[i] = sc.nextLong();
		}
		for(int i = 0; i < N; i++) {
			B[i] = sc.nextLong();
		}
		long sum = 0;
		for(int i = 0; i < N; i++) {
			if(A[i] > B[i]) {
				sum += B[i];
			}
			else {
				sum += A[i];
				long temp = A[i + 1];
				A[i + 1] -= B[i] - A[i];
				A[i + 1] = Math.max(A[i + 1], 0);
				sum += temp - A[i + 1];

			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 64608
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int a,b,h;
	cin >> a >> b >> h;
	cout << (a+b)*h/2 << endl;
  return 0;
}


Measured memory_bytes: 256
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();

        if (a + b <= b + c) {
            if (a + b <= c + a) {
                System.out.println(a + b);
            } else {
                System.out.println(c + a);
            }
        } else if (b + c <= c + a) {
            System.out.println(b + c);
        } else {
            System.out.println(c + a);
        }
    }
}


Measured memory_bytes: 21204
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	a := make([]int, n)
	
	cnt := 0
	for i := range a {
		fmt.Scan(&a[i])
		
		if i % 2 == 0 && a[i] % 2 != 0 {
			cnt++
		}
	}
	fmt.Println(cnt)
}

Measured memory_bytes: 1772
#include <algorithm>
#include<bits/stdc++.h>
#include <ios>
#include <iterator>
using namespace std;
#define ll long long 
#define f(n)  for(ll int i=0;i<n;i++) 
#define pb push_back
#define mp make_pair
#define vi vector<ll int>
#define all(v)   v.begin(),v.end()  
#define take(n)   ll int n;cin>>n;
#define IOS        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
  int s,w;
    cin>>s>>w;
    if(s<=w){cout<<"unsafe";}
    else {cout<<"safe";}
    return 0;
}


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

bool even(int a, int b) {
    return (a%2 == 0) && (b%2 == 0);
}

bool odd(int a, int b) {
    return (a%2 != 0) && (b%2 != 0);
}

int main() {

    int n, k, cont = 0;
    cin >> n;

    vector<int> arr(n);
    map<int, int> idx;

    for(int i=0; i<n; i++) {
        cin >> k;
        idx[k] = i;
        arr[i] = k;
    }

    sort(arr.begin(), arr.end());
    /*for(int i=0; i<n; i++)cout << arr[i] << ' ';
    cout << endl;*/

    for(int i=0; i<n; i++) {

        if(even(i, idx[arr[i]]) || odd(i, idx[arr[i]])) {
            //cont++;
            //cout << "here\n";
        } else {
            cont++;
        }


    }

    cout << (int)cont/2 << '\n';
    return 0;
}



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

int main() {
	int N;
	cin >> N;
	int (*coord)[100] = new int[100][100];
	int xs[100];
	int ys[100];
	int x, y, h;
	int k = 0;
	while (cin >> x >> y >> h)
	{
		xs[k] = x;
		ys[k++] = y;
		coord[x][y] = h;
	}
	
	long long int pre_H;
	long long int H = 1;
	long long int max_H = 100000000000000;
	int i = 0;
	int Cx = 0;
	int Cy = 0;
	for (Cx = 0; i < N && Cx <= 100; Cx++)
		for (Cy = 0; i < N && Cy <= 100; Cy++)
		{
			long long int temp_H = 0;
			for (i = 0; i < N; i++)
			{
				if (coord[xs[i]][ys[i]] > 0)
				{
					H = abs(xs[i] - Cx) + abs(ys[i] - Cy) + coord[xs[i]][ys[i]];
					if (temp_H == 0)
						temp_H = H;
					if (H != temp_H || H > max_H) 
						break;
				}
				else
				{
					max_H = abs(xs[i] - Cx) + abs(ys[i] - Cy) + coord[xs[i]][ys[i]];
					if (temp_H != 0 && temp_H > max_H)
						break;
				}
			}
				
		}
	delete[] coord;
	cout << Cx - 1 << ' ' << Cy - 1 << ' ' << H;
}

Measured memory_bytes: 3236
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

const ll MOD = 1e9 + 7;

ll dfs(Vvec<int>& edge, int from, int tmp, ll K, ll rcol, int depth)
{
    if(depth != 0 && edge[tmp].size() == 1) return rcol;

    ll ans = 1;
    ll ccol = (depth == 0) ? K-1 : K-2;

    for(int& to: edge[tmp]){
        if(to == from) continue;
        if(ccol <= 0) return 0;
        ans *= dfs(edge, tmp, to, K, ccol, depth+1);
        ccol--;
        ans %= MOD;
    }

    return ans * rcol % MOD;
}

int main()
{
    int N; ll K;
    cin >> N >> K;
    Vvec<int> edge(N);
    for(int i=0; i<N-1; i++){
        int u, v;
        scanf(" %d %d", &u, &v);
        u--; v--;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }

    ll ans = dfs(edge, -1, 0, K, K, 0);
    cout << ans << endl;
}

Measured memory_bytes: 12800
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		String B = sc.next();
		sc.close();
		if(A.length() > B.length()) {
			System.out.println("GREATER");
		}else if(A.length() < B.length()) {
			System.out.println("LESS");
		}else {
			int l = A.length();
			for(int i = 0; i < l; i++) {
				if(A.charAt(i) > B.charAt(i)) {
					System.out.println("GREATER");
					System.exit(0);
				}else if(A.charAt(i) < B.charAt(i)) {
					System.out.println("LESS");
					System.exit(0);
				}
			}
			System.out.println("EQUAL");
		}
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

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

    vector<int> a(N);
    bool all_even = true;
    for(auto& e : a){
        cin >> e;
        if(e % 2 == 1){
            all_even = false;
        }
    }
    if(all_even) cout << "second" << endl;
    else cout << "first" << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <cassert>
#include <random>
#include <cstring>
#include <numeric>
#define ll long long
#define ld long double
#define null NULL
#define all(a) a.begin(), a.end()
#define forn(i, n) for (int i = 0; i < n; ++i)
#define sz(a) (int)a.size()
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
template<class T> int gmax(T &a, T b) { if (b > a) { a = b; return 1; } return 0; }
template<class T> int gmin(T &a, T b) { if (b < a) { a = b; return 1; } return 0; }
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

char seq[15];
int main() {
    int n;
    while(~scanf("%d", &n)) {
        map<ll, int> mp;
        for(int i = 0; i < n; ++i) {
            scanf("%s", seq);
            sort(seq, seq + 10);
            ll tmp = 0;
            for(int j = 0, len = strlen(seq); j < len; ++j) {
                tmp = tmp * 26 + (seq[j] - 'a');
            }
            mp[tmp] ++;
        }
        ll ans = 0;
        for(auto it = mp.begin(); it != mp.end(); ++it) {
            ans += 1ll * it->second * (it->second - 1) / 2;
        }
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 6528
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    int mul2 = 0, mul4 = 0, non = 0;
    rep(i, N) {
        int a;
        cin >> a;
        if(a % 4 == 0) {
            mul4++;
        } else if(a % 2 == 0) {
            mul2++;
        } else {
            non++;
        }
    }
    if((mul2 == 0 && non <= mul4 + 1) || (mul2 != 0 && non <= mul4)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define optimize() ios_base::sync_with_stdio(0);
int n,k;
int arr[100001];
int cost[100001];

int func(int index)
{
    if(index>=n-1)
        return 0;
    if(cost[index]!=-1)
        return cost[index];

    int step=INT_MAX;

    for(int jump=1; jump<=k; jump++)
    {
        if(index+jump<=n-1)
        {
            step=min(step,abs(arr[index]-arr[index+jump])+func(index+jump));
        }

    }

    return cost[index]=step;


}
int main()
{
    optimize();

    cin>>n>>k;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }

    memset(cost,-1,sizeof(cost));

    int res=func(0);
    cout<<res<<endl;
}



Measured memory_bytes: 12236
#include<stdio.h>

int main(void) {
	int a, b, c;
	scanf("%d %d %d",&a,&b,&c);
	int s;
	if (c - (a - b) < 0) {
		s = 0;
	}
	else {
		s = c - (a - b);
	}
	printf("%d", s);
	return 0;
}

Measured memory_bytes: 128
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict(list)
#import bisect
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    V = readInts()
    C = readInts()
    ans = -1
    for bit in range(1 << n):
        # bit 全探索
        cost = 0
        value = 0
        for i in range(n):
            if bit & (1 << i):
                # もしフラグが立っていたら、
                cost += C[i]
                value += V[i]
        ans = max(ans,value - cost)
    print(ans)
if __name__ == '__main__':
  main()


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

#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()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	int mnr = MD, mxl = 0;
	rep(i, m){
		int l, r;
		cin >>l >>r;
		mxl = max(mxl, l);
		mnr = min(mnr, r);
	}
	cout << max(0, mnr +1 -mxl) <<"\n";
	return 0;
}


Measured memory_bytes: 256
while gets do
  arr = $_.split(',').map(&:to_i)
  cards = [0]*13
  arr.each do |i|
    cards[i - 1] += 1
  end

  sc = cards.select{ |i| i >= 1 }.sort
  str = cards.join('')

  case sc
    when [1, 4]
      puts 'four card'
    when [2, 3]
      puts 'full house'
    when [1, 1, 3]
      puts 'three card'
    when [1, 2, 2]
      puts 'two pair'
    when [1, 1, 1, 2]
      puts 'one pair'
    when [1, 1, 1, 1, 1]
      if str =~ /1{5}|10{8}1{4}/
        puts 'straight'
      else
        puts 'null'
      end
    else
      puts 'null'
  end
end

Measured memory_bytes: 6104
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inS = Console.ReadLine().Split(' ');
            int in0 = int.Parse(inS[0]);
            int in1 = int.Parse(inS[1]);

            if ( in0 <= 5)
            {
                Console.WriteLine("0");
            }
            else if ( in0 <= 12 )
            {
                Console.WriteLine(in1 / 2);
            }
            else
            {
                Console.WriteLine(in1);
            }
        }
    }
}


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

int main() {
  std::string S, T;
  std::cin >> S >> T;

  bool restorable = false;
  for (int i=0; i<S.size()-T.size()+1; i++) {
    bool match = true;
    for (int j=0; j<T.size(); j++) {
      char s = S[S.size()-T.size()-i+j];
      if (s == '?') continue;
      if (s != T[j]) {
        match = false;
        break;
      }
    }
    if (match) {
      for (int j=0; j<T.size(); j++) {
        S[S.size()-T.size()-i+j] = T[j];
      }
      restorable = true;
      break;
    }
  }

  if (restorable) {
    for (int i=0; i<S.size(); i++) {
      if (S[i]=='?') S[i] = 'a';
    }
    std::cout << S << std::endl;
  } else {
    std::cout << "UNRESTORABLE" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
cnt=0
for i in range(N-1):
  if i+1==A[i]:
    a=A[i]
    b=A[i+1]
    A[i]=b
    A[i+1]=a
    cnt+=1
if A[-1]==N:
  cnt+=1
print(cnt)

Measured memory_bytes: 14008
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int A;
  int B;
  int C;
  cin >>A>>B>>C;
  int a1=abs(B-A)+abs(C-B);
  int a2=abs(C-A)+abs(B-C);
  int a3=abs(A-B)+abs(C-A);
  int a4=abs(A-C)+abs(B-A);
  int a5=abs(B-C)+abs(A-B);
  int a6=abs(C-B)+abs(A-C);
  int x=min(min(a1,a2),a3);
  int y=min(min(a4,a5),a6);
  int z=min(x,y);
  cout << z<< endl;
}
  

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.util.Calendar.Builder;



public class Main {
	static int INF = 2 << 27;
	public static void main(String[] args) {	
		//FastScanner sc = new FastScanner();
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		while(true) {
			int n = sc.nextInt();
			if(n == 0) break;
			ArrayList<ArrayList<Calendar>> list = new ArrayList<ArrayList<Calendar>>();
			for(int i = 0; i < 1000; i++) list.add(new ArrayList<Calendar>());
			for(int i = 0; i < n; i++) {
				String MMDD = sc.next();
				int M = Integer.parseInt(MMDD.substring(0, 2));
				int D = Integer.parseInt(MMDD.substring(3, 5));
			
				String HHMM = sc.next();
				int H = Integer.parseInt(HHMM.substring(0, 2));
				int Min = Integer.parseInt(HHMM.substring(3, 5));
			
				sc.next();
			
				int ID = Integer.parseInt(sc.next());
				
				Builder c = new Calendar.Builder();
				Calendar cc = c.build();
				cc.set(1980, M, D, H, Min, 0);
				
				
				list.get(ID).add(cc);
			}
			int[] sum = new int[1000];
			ArrayList<Calendar> lg = list.get(0);
			for(int i = 1; i < list.size(); i++) {
				ArrayList<Calendar> lng = list.get(i);
				for(int j = 0; j < lg.size(); j += 2) {
					for(int k = 0; k < lng.size(); k += 2) {
						 long gA = lg.get(j).getTimeInMillis();
						 long gB = lg.get(j+1).getTimeInMillis();
						
						 long ngA = lng.get(k).getTimeInMillis();
						 long ngB = lng.get(k+1).getTimeInMillis();
						 
						 long gb = Math.max(gA, ngA);
						 long ngb = Math.min(gB,ngB);
						 
						 sum[i] += Math.max(0, ngb - gb);
					}
				}
			}
			
			
			int MAX = 0;
			for(int i = 1; i < 1000; i++) {
				MAX = Math.max(MAX, sum[i]);
			}
			System.out.println(MAX / 60000);
		}
	}
	static class Data implements Comparable<Data> {
		int ID;
		long In;
		long Out;
		Data(int id, long a, long b) {
			ID = id;
			In = a;
			Out = b;
		}
		@Override
		public int compareTo(Data o) {
			if(this.In == o.In) {
				if(this.Out == o.Out) return this.ID - o.ID;
				return (int)(this.Out - o.Out);
			}
			return (int)(this.In - o.In);
			
		}
	}
}

Measured memory_bytes: 65288
def main():
    sx, sy, tx, ty = map(int, raw_input().split())

    dy = ty-sy
    dx = tx-sx
    result = ''
    for i in range(dy):
        result += 'U'
    for i in range(dx):
        result += 'R'
    for i in range(dy):
        result += 'D'
    for i in range(dx):
        result += 'L'
    result += 'L'
    for i in range(dy+1):
        result += 'U'
    for i in range(dx+1):
        result += 'R'
    result += 'D'
    result += 'R'
    for i in range(dy+1):
        result += 'D'
    for i in range(dx+1):
        result += 'L'
    result += 'U'
    print result

main()

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

using namespace std;
typedef long long ll;
#define sz(x) (ll)((x).size())
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
const ll MOD=1000000007;

int main(){
	ll N; cin>>N;
	string s1,s2; cin>>s1>>s2;
	vector<ll>X;
	ll i=0;
	while(i<sz(s1)){
		if(s1[i]==s2[i]){
			X.pb(1);
			i++;
		}
		else{
			X.pb(2);
			i+=2;
		}
	}

	ll ans,rem=X[0];
	if(X[0]==1) ans=3;
	else ans=6;

	rep1(i,sz(X)-1){
		if(X[i]==2){
			if(rem==1){
				ans*=2;
				ans%MOD;
			}
			else{
				ans*=3;
				ans%=MOD;
			}
		}
		else if(rem==1){
			ans*=2;
			ans%=MOD;
		}

		rem=X[i];
	}
	cout<<ans;
}

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

int A[100000];

int Partition(int p, int r){
    int x,i,j;
    x=A[r];
    i=p-1;
    for(j=p;j<r;j++){
        if(A[j]<=x){
            i++;
            swap(A[i],A[j]);
        }
    }
    swap(A[i+1],A[r]);
    return i+1;
}

int main(void){
    int i,n,cen;
    cin >> n;
    for(i=0;i<n;i++) cin >> A[i];
    cen=Partition(0,n-1);
    for(i=0;i<n;i++){
    if(i==0) cout << A[i];
    else if(i==cen) cout << " [" << A[i] << "]";
    else cout << " " << A[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3380
import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str

isdelim(x::UInt8, xs::Set{UInt8}) = x in xs

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        if !isdelim(c, delims)
            break
        end
    end
    push!(out, c)
    if eof(s)
        return out
    end
    while !eof(s)
        c = read(s, UInt8)
        if isdelim(c, delims)
            break
        end
        push!(out, c)
    end
    return out
end

delimset = Set([0x0a, 0x20])

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

readvec(tys::Tuple , len::Signed)::Vector{Tuple{tys...}} = @inbounds Tuple{tys...}[reads(tys...) for i in 1:len]

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i = 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

function othernum(i,j)
    ij = i+j
    3 - ij%3
end

function main()
    N, S = reads(Int, String)
    SI = map(x -> begin x == 'R' && return 1; x == 'G' && return 2; x == 'B' && return 3 end, collect(S))
    d = zeros(Int, 3, N)

    for j in 1:3
        d[j,1] = 0
    end
    d[SI[begin],1] = 1

    for i in 2:length(SI)
        for j in 1:3
            d[j,i] = d[j,i-1]
        end
        d[SI[i],i] += 1
    end

    if N <= 3
        println(0)
        return
    end

    c = 0
    for i in 1:length(SI)-2, j in i+1:length(SI)-1
        if SI[i] != SI[j]
            k = othernum(SI[i],SI[j])
            c += d[k,N] - d[k,j]
            c -= (2j-i<=N && SI[2j-i]==k) ? 1 : 0
        end
    end
    println(c)
end

main()


Measured memory_bytes: 253656
// 2011/02/26 Tazoe

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
	while(true){
		string str;
		getline(cin, str);
		istringstream ist(str);

		int crd;
		int sum = 0;
		int flg = false;
		while(ist >> crd){
			if(crd==0){
				return 0;
			}
			else if(crd==1){
				sum += 1;
				flg = true;
			}
			else if(crd>=2&&crd<=9){
				sum += crd;
			}
			else if(crd>=10&&crd<=13){
				sum += 10;
			}

			if(sum>21)
				break;
		}

		if(sum<=11&&flg)
			sum += 10;

		if(sum>21)
			sum = 0;

		cout << sum << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>

int main(){
  int n,k,x,r = 0;
  std::vector<int> h;

  std::cin >> n >> k;

  for(int i = 0; i < n; i++){
    std::cin >> x;
    h.push_back(x);

  }

  for(int i = 0; i < h.size();i++){
    if(h[i] >= k) r++;
  }

  std::cout << r << std::endl;

  return 0;
}

Measured memory_bytes: 892
#include <stdio.h>
#define TRUE 1
#define FALSE 0

struct tramp
{
	int S[13];
	int H[13];
	int C[13];
	int D[13];
};

//????????¨??¢??°
int hantei(struct tramp *judge,char *c,int *n);

int main(){
	//?????????
	struct tramp judge;
	int t;
	for(t=0;t<13;t++){
		judge.S[t]=0;
		judge.H[t]=0;
		judge.C[t]=0;
		judge.D[t]=0;
	}
	//??\?????¨?????°
	char c;
	int n;
	int x;
	//??\???
	do{
		printf("");
		scanf("%d",&n);
	}while(!(n>=0 && n<=52));
	
	for(t=0;t<n;t++){
		do{
			printf("");
			scanf("%c %d",&c,&x);
		}while(!hantei(&judge,&c,&x));
	}
	//??????
	for(t=0;t<13;t++){
		if(judge.S[t]==0)printf("S %d\n",t+1);
	}
	for(t=0;t<13;t++){
		if(judge.H[t]==0)printf("H %d\n",t+1);
	}
	for(t=0;t<13;t++){
		if(judge.C[t]==0)printf("C %d\n",t+1);
	}
	for(t=0;t<13;t++){
		if(judge.D[t]==0)printf("D %d\n",t+1);
	}	
	return 0;
}


int hantei(struct tramp *judge,char *c,int *n){
	if(!(*n>=0 && *n<=13)){
		return FALSE;
	}else if(*c=='S'){
		if(judge->S[*n-1]==0){
			judge->S[*n-1]=1;
			return TRUE;
		}else return FALSE;
	}else if(*c=='H'){
		if(judge->H[*n-1]==0){
			judge->H[*n-1]=1;
			return TRUE;
		}else return FALSE;	
	}else if(*c=='C'){		
		if(judge->C[*n-1]==0){
			judge->C[*n-1]=1;
			return TRUE;
		}else return FALSE;
	}else if(*c=='D'){
		if(judge->D[*n-1]==0){
			judge->D[*n-1]=1;
			return TRUE;
		}else return FALSE;
	}else {
		return FALSE;
	}
	return FALSE;
}

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

int main()
{
    int k;
    string s;
    cin >> k >> s;
    int len = s.size();

    if(len <= k)
    {
        cout << s << endl;
    }
    else
    {
        int i;
        for (i = 0; i < k; i++)
        {
            cout << s[i];
        }
        cout << "..." << endl;
        
    }
    
}


Measured memory_bytes: 3596
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMaximum(Node x){
  while(x->right != NIL)x = x->right;
  return x;

}

Node treeMinimum(Node x){
  while(x->left != NIL)x = x->left;
  return x;
}

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  if(x->right != NIL) return treeMinimum(x->right);
  Node y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; 
  Node x; 

  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL){
    x = y->left;
  }
  else{
    x = y->right;
  }

  if(x != NIL){
    x->parent = y->parent;
  }

  if(y->parent == NIL){
    root = x;
  }
  else{
    if(y == y->parent->left){
      y->parent->left = x;
    }
    else{
      y->parent->right = x;
    }
  }

  if(y != z){
    z->key = y->key;
  }

  free(y);
}

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

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

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

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

void inorder(Node u){
  if(u == NIL) return ;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u == NIL) return ;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25176
package main

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

func parse() (int, int) {

	stdin := bufio.NewScanner(os.Stdin)
	stdin.Split(bufio.ScanWords)

	stdin.Scan()
	n, _ := strconv.Atoi(stdin.Text())

	stdin.Scan()
	i, _ := strconv.Atoi(stdin.Text())

	return n, i
}

func main() {

	n, i := parse()
	fmt.Println(n - i + 1)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
typedef long long int ll;
using namespace std;

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

int main(){
  cin >> n;
  int ans = 0;
  for(int i=0;i<n;i++) {cin >> a[i]; a[i]--;}
  for(int i=0;i<n;i++) {cin >> b[i]; ans += b[i];}
  for(int i=0;i+1<n;i++) cin >> c[i];
  
  for(int i=1;i<n;i++){
    if (a[i-1] + 1 == a[i]) ans += c[a[i-1]];
  }
  
  cout << ans << endl;  
  return 0;
}
  

Measured memory_bytes: 256