akhauriyash/Code-Regression huggingface dataset:
class Dice():
    def __init__(self,rot,Face):
        self.rot= rot
        self.Face = Face
    def Rotate(rot,Face):
        r=len(rot)
        intFace=[int(Face[i]) for i in range(6)]

        for i in range(r):
            Temp=[intFace[i] for i in range(6)]

            if rot[i]== "E":
                intFace[0]=Temp[3]
                intFace[1]=Temp[1]
                intFace[2]=Temp[0]
                intFace[3]=Temp[5]
                intFace[4]=Temp[4]
                intFace[5]=Temp[2]

            elif rot[i]== "W":
                intFace[0]=Temp[2]
                intFace[1]=Temp[1]
                intFace[2]=Temp[5]
                intFace[3]=Temp[0]
                intFace[4]=Temp[4]
                intFace[5]=Temp[3]

            elif rot[i]== "N":
                intFace[0]=Temp[1]
                intFace[1]=Temp[5]
                intFace[2]=Temp[2]
                intFace[3]=Temp[3]
                intFace[4]=Temp[0]
                intFace[5]=Temp[4]

            elif rot[i]== "S":
                intFace[0]=Temp[4]
                intFace[1]=Temp[0]
                intFace[2]=Temp[2]
                intFace[3]=Temp[3]
                intFace[4]=Temp[5]
                intFace[5]=Temp[1]

        return intFace
#returnしてなかったわ インデント幅も注意
n=int(input())
Face=[[] for i in range(n)]
i=0
while i<n:
    Face[i] = input().split()
    i+=1

###################
#同じ整数があるので前のは使えず。ごっそり修正
####################3
D1=["","N","W","E","S","NN"]
D2= ["","NWS","NWSNWS","NWSNWSNWS",]
same=False
for l in range(n):
    for m in range(n):
        if m==l:
            pass
        else:
            for k in range(6):
                for i in range(4):
                    rot = D1[k]+D2[i]
                    tempFace= Dice.Rotate(rot,Face[l])
                    j=0
                    while j<6:
                        if tempFace[j]!=int(Face[m][j]):
                            break
                        else:
                            if j==5:
                                same=True
                            j+=1

if same:
    print("No")
else:
    print("Yes")



Measured memory_bytes: 5628
main= getLine >>= putStrLn.(\[a,b,c]->a++":"++b++":"++c).compute
	where
        string2Int str = read str ::Integer
	aa=(\s->[s,s`div`3600])
	bb=(\[s,h]->[h,s-h*3600])
	cc=(\[h,m]->[h,m`div`60,m-(m`div`60)*60])
	compute=map show .cc.bb.aa.string2Int

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

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

  int N;
  cin >> N;
  vector<int> d(N);
  REP(i,N) cin >> d[i];
  SORT(d);
  int a = d[N/2-1], b = d[N/2];
  if (a == b) {
    cout << 0 << endl;
    return 0;
  }
  cout << b-a << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cctype>
#define reg register
#define int long long
using namespace std;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
signed main(void)
{
	int r,d,x;
	rd(r);rd(d);rd(x);
	for(int i=1;i<=10;++i)
		x=r*x-d,printf("%lld\n",x);
	return 0;
}


Measured memory_bytes: 128
from collections import deque
board = [int(s) for _ in range(3) for s in input().split()]
end = [1, 2, 3, 4, 5, 6, 7, 8, 0]
table = set()
def print_board(board):
    for i in range(0, 9, 3):
        print(*board[i:i + 3])

def swap(q, step_q, step, board):
    key = tuple(board)
    if key in table:
        return
    else:
        table.add(key)

    empty = board.index(0)
    def _swap(q, step_q, step, board, k, s):
        b = board.copy()
        b[k], b[s] = b[s], b[k]
        q.append(b)
        step_q.append(step + 1)

    if empty % 3 != 2:
        _swap(q, step_q, step, board, empty, empty + 1)
    if empty % 3 != 0:
        _swap(q, step_q, step, board, empty, empty - 1)
    if empty // 3 < 2:
        _swap(q, step_q, step, board, empty, empty + 3)
    if empty // 3 > 0:
        _swap(q, step_q, step, board, empty, empty - 3)


q = deque([board])
step_q = deque([0])
# print_board(board)
while q[0] != end:
    b = q.popleft()
    step = step_q.popleft()
    swap(q, step_q, step, b)
# print_board(q.popleft())
print(step_q.popleft())


Measured memory_bytes: 47080
# coding: utf-8

import sys

def coding(s):
    t = ''
    flag = True
    for i in s:
        if flag:
            t += i
            flag = False
        if i == 'a' or i == 'i' or i == 'u' or i == 'e' or i == 'o':
            flag = True;
    return t

def pre_possible(ls):
    flag = False
    for i in range(len(ls)):
        for j in range(i+1,len(ls)):
            if ls[i] == ls[j]:
                flag = True
    return flag

def possible(ls,k):
    flag = True
    for i in range(len(ls)):
        for j in range(i+1,len(ls)):
            if len(ls[i]) < k or len(ls[j]) < k:
                if ls[i] == ls[j]:
                    flag = False
                    break
                else:
                    continue

            if ls[i][0:k] == ls[j][0:k]:
                flag = False
                break
        if not(flag):
            break
    return flag

if __name__ == '__main__':
    while(1):
        n = int(input());
        if n == 0:
            break
        l = []
        for i in range(n):
            l.append(input())
        nl = []
        for i in l:
            nl.append(coding(i))
        sz = min([len(i) for i in l])
        ll = 0
        hh = 50
        if pre_possible(nl):
            print(-1)
            continue
        while True:
            mid = (ll + hh) // 2
            if ll == mid:
                print(hh)
                break
            if possible(nl,mid):
                hh = mid
            else:
                ll = mid

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

#define left first
#define value second

using namespace std;

typedef long long ll;
typedef pair < int, int > pii;

const int MAXN = 2e5 + 500;
const int OFF = 1 << 18;

vector <pii> intervals[MAXN];
ll dp[MAXN], tree[2 * OFF], prop[2 * OFF];

void update(int i, int l, int r, int ql, int qr, ll val) {
    if(ql <= l && r <= qr) {
        tree[i] += val;
        prop[i] += val;
        return;
    }

    if(r < ql || qr < l)
        return;

    update(2 * i, l, (l + r) / 2, ql, qr, val);
    update(2 * i + 1, (l + r) / 2 + 1, r, ql, qr, val);
    tree[i] = max(tree[2 * i], tree[2 * i + 1]) + prop[i];
}

int main() {
    int N, M, l, r, val;

    scanf("%d%d", &N, &M);
    for(int i = 0; i < M; i++) {
        scanf("%d%d%d", &l, &r, &val);
        intervals[r - 1].push_back({l - 1, val});
    }

    for(int i = 0; i < N; i++) {
        dp[i] = tree[1];
        update(1, 0, OFF - 1, i, i, dp[i]);
        for(auto interval : intervals[i])
            update(1, 0, OFF - 1, interval.left, i, interval.value);
    }

    printf("%lld\n", tree[1]);

    return 0;
}


Measured memory_bytes: 18944
from collections import defaultdict
n,m=map(int,input().split())
a=list(map(int,input().split()))
d=defaultdict(int)
a.sort()

for i in range(m):
    b,c=map(int,input().split())
    d[c]+=b

d_sorted=sorted(d.items(),reverse=True, key=lambda x:x[0])
l=[]

for i,j in d_sorted:
    for k in range(j):
        l.append(i)
        if len(l)>n:
            break
    else:
        continue
    break
for i in range(min(n, len(l))):
    a[i]=max(a[i],l[i])

print(sum(a))

Measured memory_bytes: 33632
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); 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 (b < a) {
    a = b;
    return true;
  }
  return false;
}
#define INF 1e9
using ll = int64_t;
#define waru 1000000007

std::int64_t gcd(std::int64_t a, std::int64_t b) {
  // a >= b && b != 0
  std::int64_t c;
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb) {
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0) {
    return -1;
  }
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
void rle(std::vector<std::pair<char, std::int64_t>> &data, std::string str) {
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++) {
    if (i == str.size()) {
      data.push_back(make_pair(str[i - 1], count));
      break;
    } else if (now != str[i]) {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return;
}

void Main() {
  //自動整形防止用コメント
  int x,a,b;
  std::cin >> x >> a >> b;
  std::cout << (abs(x - a) > abs(x - b) ? 'B' : 'A') << '\n';

  return;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define modn 1000000007
#define hell 1000000009
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF INT_MAX
using namespace std;

int main()
{
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a, a+3);
    cout<<a[2]*10+a[1] + a[0]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a==b||(a+b)%2==1)
	{
		printf("IMPOSSIBLE\n");
	}
	else if((a+b)%2==0)
	{
		printf("%d\n",(a+b)/2);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
string change(string S, int n) {
	char tmp = S[0];
	for (int i = 0; i < n; i++)
	{
		S[i] = S[i + 1];
	}
	S[n - 1] = tmp;

	return S;
}

int main() {
	string S, T;
	bool flg = false;
	cin >> S >> T;
	for (int i = 0; i < (int)S.length(); i++)
	{
		if (S == T) {
			flg = true;
			break;
		}
		S = change(S, S.length());
	}
	
	cout << ((flg) ? "Yes" : "No") << endl;
	
	return 0;
}

Measured memory_bytes: 888
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;


template <class T>
T gcd(T a, T b) {
    if (a < b) {
        swap(a, b);
    }

    T r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

template <class T>
T lcm(const T& a, const T& b) {
    return (a * b) / gcd<T>(a, b);
}

int main() {
    long long A, B;
    cin >> A >> B;

    cout << lcm(A, B) << endl;

    return 0;
}


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

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

	a--; b--; c--; d--;

	auto f = [&](int start, int end) {
		for (int i = start; i < end; i++) {
			if (s[i] == '#' && s[i + 1] == '#') {
				return true;
			}
		}
		return false;
	};

	if (f(a, c) || f(b, d)) {
		cout << "No" << endl;
		return 0;
	}

	if (c < d) {
		cout << "Yes" << endl;
		return 0;
	}

	if (s[b + 1] != '#' && s[b - 1] != '#') {
		cout << "Yes" << endl;
		return 0;
	}

	s = s + "#";


	int cnt = 0;
	for (int i = b; i <= d; i++) {
		if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
			cout << "Yes" << endl;
			return 0;
		}	
	}
	
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3908
#include <iostream>
using namespace std;
int main(void){
    int n, l, s, b = 1e9;
    cin >> n >> l;
    s = l * n + (n - 1) * n / 2;
    if(s < 0) b = -1e9;
    for(int i=0;i<n;i++){
        int a = l + i;
        if(s >= 0 && a >= 0){
            b = min(b, a);
        }else if(s <= 0 && a <= 0){
            b = max(b, a);
        }
    }
    cout << s - b << endl;
}


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

int main() {
  char c;
  cin >> c;
  if (c == 'a'|| c == 'i'|| c == 'u'|| c == 'e'|| c == 'o'){
    cout << "vowel" << endl;
  }
  else cout << "consonant" << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  ll x,y;
  cin>>x>>y;
  if(x<y)swap(x,y);
  x -= y;
  if(x<=1)puts("Brown");
  else puts("Alice");
  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++)
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, ll>;  // vertex, length

int main() {
  int N;
  cin >> N;
  vector<vector<P>> G(N);
  rep(i,N-1) {
    int a, b; ll c;
    cin >> a >> b >> c;
    --a; --b;  // 0-indexed
    G[a].push_back(P(b,c));
    G[b].push_back(P(a,c));
  }
  
  int Q, K;
  cin >> Q >> K;
  --K;  // 0-indexed
  Graph query(Q, vector<int>(2));
  rep(i,Q) {
    int x, y;
    cin >> x >> y;
    --x; --y;  // 0-indexed
    query[i][0] = x; query[i][1] = y;
  }

  vector<ll> dist(N);  // distance from K
  queue<P> search;
  vector<bool> visited(N, false);
  dist[K] = 0;
  search.push(P(K,0));
  visited[K] = true;

  while(!search.empty()) {
    P v = search.front();
    search.pop();

    for (auto nv : G[v.first]) {
      if (visited[nv.first]) continue;  // obstruct backflow

      dist[nv.first] = dist[v.first] + nv.second;
      search.push(nv);
      visited[nv.first] = true;
    }
  }

  rep(i,Q) {
    int &x = query[i][0], &y = query[i][1];
    ll ans = dist[x] + dist[y];
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 16240
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)

int main(){
	int h,a;
    cin >> h >> a;
    if(h%a==0) cout << h/a << endl;
    else cout << h/a+1 ;


    return 0;

}

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int MOD = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n,m,x;
        cin>>n>>m>>x;
        int c[n],a[n][m];
        for(int i=0;i<n;i++)
        {
            cin>>c[i];
            for(int j=0;j<m;j++)cin>>a[i][j];
        }
        int ans = 1e15;
        for(int mask = 0;mask < (1LL<<n);mask++)
        {
            int cost = 0;
            int now[m] = {};
            for(int i=0;i<n;i++)
            {
                if((1LL<<i) & mask)
                {
                    cost+=c[i];
                    for(int j=0;j<m;j++)now[j]+=a[i][j];
                }
            }
            int ok = 1;
            for(int i=0;i<m;i++)if(now[i]<x)ok=0;
            if(ok)ans = min(ans,cost);
        }
        if(ans == 1e15)ans=-1;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    cout << ((N + 1)/ 2) / (double)N << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
while True:
    a,op,b = map(str, input().split())
    a = int(a)
    b = int(b)
    if op == '?':
        break
    if op == '+':
        print(a+b)
    if op == '-':
        print(a-b)
    if op == '*':
        print(a*b)
    if op == '/':
        print(a//b)


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

#define int long long
#define inf 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)

vector<int> v[334334];
int d[2][334334];

void dfs(int o, int p, int b, int x) {
    d[b][p] = x;
    for(auto i : v[p]) {
        if(i != o) {
            dfs(p, i, b, x + 1);
        }
    }
}

signed main() {
    int n;
    cin >> n;
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dfs(-1, 0, 0, 0);
    dfs(-1, n - 1, 1, 0);
    int f = 0;
    rep(i, n) {
        if(d[0][i] <= d[1][i]) {
            f++;
        }
    }
    if(f * 2 > n) {
        cout << "Fennec" << endl;
    }
    else {
        cout << "Snuke" << endl;
    }
}

Measured memory_bytes: 21504
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);

	rep(i,n) {
		cin >> a[i];
	}

	ll m0 = 0;
	int cur = 0;
	int sign = 1;
	while (true) {
		int left = n - 1 - cur;
		//cout << "cur:" << cur << " left:" << left << endl;
		if (left == cur) {
			m0 += a[cur] * sign;
			break;

		} 

		m0 += a[cur] * sign;
		m0 += a[left] * sign;
		cur++;
		sign *= -1;
	}

	cout << m0;

	ll prev = m0;
	for (int i = 0; i < n - 1; i++) {
		prev = 	a[i] * 2 - prev;
		cout << " " << prev;
	}
	cout  << endl;

	
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using tiii = tuple<int,int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const ll DIV =1e9+7;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
#define chmax(a,b) a=max(a,b)

/*Coding Space*/
int main(){
  int n; cin >> n;
  map<int,int> t;
  rep(i,n){
    int in; cin >> in;
    t[in] = i + 1;
  }
  for(int i = 1; i <= n; ++i){
    cout << t[i] << (i == n?'\n':' ');
  }
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (ll i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
    string s;   cin>>s;
    FOR(i,0,s.size())   if(s[i]=='?')   s[i]='D';
  	cout<<s<<endl;

    return 0;
}




Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, m, s, t;
  cin >> n >> m;
  vector<vl> g(n);
  vector<vl> d(n, vl(3, -1));
  rep(i, m) {
    ll u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
  }
  cin >> s >> t;
  s--;
  t--;
  queue<P> q;
  d[s][0] = 0;
  q.push({s, 0});
  while(!q.empty()) {
    ll i = q.front().first;
    ll k = q.front().second;
    ll nk = (k + 1) % 3;
    q.pop();
    for(auto v : g[i]) {
      if(d[v][nk] != -1) continue;
      d[v][nk] = d[i][k] + 1;
      q.push({v, nk});
    }
  }
  cout << (d[t][0] < 0 ? -1 : d[t][0] / 3) << endl;
}

Measured memory_bytes: 14348
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n, a, b;
const llong mod = (llong)(1e9) + 7;

long long pow_mod(long long n, long long m) {
    //n ** m;
    long long ret = 1;

    while (m) {
        if (m & 1) {
            ret = ret * n % mod;
        }

        n = n * n % mod;
        m = m >> 1;
    }

    return ret;
}

long long combination(long long n, long long k) {
    llong a = 1;
    llong b = 1;

    for (llong i = n; i > (n - k); i--) {
        a *= i;
        a %= mod;
    }

    for (llong i = 1; i <= k; i++) {
        b *= i;
        b %= mod;
    }

    b = pow_mod(b, mod - 2);

    return a * b % mod;
}

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

    llong x = pow_mod(2, n) - 1;
    x -= combination(n, a);
    x -= combination(n, b);
    while (x < 0) x += mod;

    cout << x << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	int cnt=0;
		for(int i=1;i<n-1;i++){
		if(   ((arr[i-1]>arr[i])&&(arr[i+1]<arr[i]))||((arr[i-1]<arr[i])&&(arr[i+1]>arr[i]))  )
		cnt++;
	}
	cout<<cnt<<endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
ii0 = lambda: ii() - 1
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    a,b,x = mis()
    import math
    if a**2*b/2 <= x:
        print(math.degrees(math.atan(2*(a**-3)*(a*a*b-x))))
    else:
        print(90-math.degrees(math.atan(2*x/a/b/b)))



main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int h,w;cin>>h>>w;
  	char temp;
  	int count=0;
  	for(int i=0;i<h;i++){
    	for(int j=0;j<w;j++){
        	cin>>temp;
          	if(temp=='#') count++;
        }
    }
  	if(count==(h+w-1)) cout<<"Possible"<<endl;
  	else  cout<<"Impossible"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "

const int MXN = 2e5+5;
int ans[MXN];
int plu[MXN];


void add(int n)
  {
  debug(n);
  FOR(i, 1, n)ans[i] += n-i;
  }
void kolo(int n)
  {
  FOR(i, 1, (n+1)/2-1)ans[i] += n;
  if(n % 2 == 0)ans[n/2] += n / 2;
  }

void add2(int offset, int n)
  {
//  plu[offset]++;
//  plu[offset+1]--;
  debug(offset, n);
  plu[offset+1] += 2;
  plu[offset+(n+1)/2] -= 2;
  if(n % 2 == 0){plu[offset + n/2] += 1; plu[offset+n/2+1] -= 1;}
  }

void add3(int offset, int n)
  {
//  plu[offset]++;
//  plu[offset+1]--;
  debug(offset, n);
  plu[offset+1] += 4;
  plu[offset+(n+1)/2] -= 4;
  if(n % 2 == 0){plu[offset + n/2] += 2; plu[offset+n/2+1] -= 2;}
  }


int main()
{
  int n, x, y;
  cin >> n >> x >> y;
  //add(x);
  //add(n-y+1);
  add(x+(n-y+1));
  

  FOR(i, 1, x-1)ans[x-i+1]--;
  FOR(i, y, n)ans[i-y+1]--;

// //  kolo(y-x+1);
//   ans[1]--;// wyrzucam x - y
   FOR(i, 1, n)ans[i] *= 2;


  FOR(i, 1, x-1){add3(x-i, y-x+1);}
  FOR(i, y+1, n)add3(i-y, y-x+1);
  FOR(i, x, y)add2(0, y-x+1);

  FOR(i, 1, n)plu[i] += plu[i-1];


  FOR(i, 1, n-1)printf("%d\n", (ans[i] + plu[i])/2);
}

Measured memory_bytes: 256
//NEVER GIVE UP I AM GOING TO IMPROVE ONE DAY.
//PRACTICE,PRACTICE,PRACTICE!!!
#include<bits/stdc++.h>
#define int long long int
// #define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 1e18
#define endl "\n"
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); 
#define dbg(x)  cerr << #x << " = " << x << endl;
const int M=100005;
const int mod=1000000007;
const double pi = acos(-1.0);
using namespace std;
bool possible(int mid,int k,int a[],int n){
    int cut=0;
  if(mid==0){
    return false;
  }
    for(int i=0;i<n;i++){
        cut+=((a[i]-1)/mid);
    }
    if(cut<=k){
        return true;
    }
    return false;
}
int32_t main(){
 
    // #ifndef ONLINE_JUDGE 
    //     freopen("in.txt", "r", stdin); 
    //     freopen("out.txt", "w", stdout); 
    // #endif 
 
    fast;
    int t;
    t=1;
    // cin>>t;
    // int test=t;
    while(t--){
        int n,k;
        cin>>n>>k;
        int a[n],maxi=-1;
        for(int i=0;i<n;i++){
            cin>>a[i];
            maxi=max(maxi,a[i]);
        }
        int low=0,high=maxi,mid,ans=maxi;
        while(high>=low){
            mid=low+((high-low)/2);
            if(possible(mid,k,a,n)){
                ans=min(ans,mid);
                high=mid-1;
            }
            else{
                low=mid+1;
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 5208
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf = 999999999;
const double pi = acos(-1);

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) (i%(ll)(1e9 + 7))

int main(){
	int n,k,x,y;
    cin >> n >> k >> x >> y;
    if(n <= k)cout << n * x << endl;
    else cout << k*x + (n-k)*y << endl;
    
	return 0;
}

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


int b[3000] = {0};

int cur[3000], inv[3000];

int iv(int a, int p) {
  int ans = 1;
  for (int cur = a, b = p - 2; b; b >>= 1, cur = cur * cur % p) {
    if (b&1) ans = cur * ans % p;
  }
  return ans;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int p; cin >> p;
  for (int i = 1; i < p; ++i) inv[i] = iv(i, p);
  for (int i = 0; i < p; ++i) {
    int a; cin >> a;
    if (a) {
      memset(cur, 0, sizeof(cur));
      int fac = 1;
      for (int j = 0; j < p; ++j) if (j != i) {
        fac = fac * (j - i + p) % p;
      }
      if (i) {
        cur[1] = p - 1, cur[p] = 1;
        for (int j = 1; j < p; ++j) {
          cur[j] = cur[j] * inv[p - i] % p;
          cur[j + 1] = (cur[j + 1] - cur[j] + p) % p;
        }
        assert(cur[p] == 0);
      }
      else {
        cur[0] = p - 1, cur[p - 1] = 1;
      }
      for (int i = 0; i < p; ++i) b[i] = (b[i] + cur[i] * inv[fac]) % p;
    }
  }
  for (int i = 0; i < p; ++i) cout << b[i] << " \n"[i == p - 1];
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <map>
#include <algorithm>
#include <functional>
#include <queue>

int main()
{
	std::string S, ans = "No";
	std::cin >> S;

	if ((S == "AAA") || (S == "BBB"))
	{
		ans = "No";
	}
	else{
		ans = "Yes";
	}

	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
   int a,b,c;
   cin >> a >> b >> c;
   cout << max(c-a+b,0) << endl;
}

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

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vi;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nl cout<<'\n'
#define pb push_back
#define all(s) s.begin(),s.end()
#define bs binary_search

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a)*(b)/(__gcd((a),(b)))

const int Mod=1e9+7;
#define sum(a,b) (((a)%Mod)+((b)%Mod))%Mod
#define sub(a,b) (((a)%Mod)-((b)%Mod))%Mod
#define mul(a,b) (((a)%Mod)*((b)%Mod))%Mod
#define digit(x) floor((log10(x))+1)


#define count1(x) __builtin_popcount(x)

#define dbg(x) cout << #x <<":"<<x<<endl;

bool isPowerOfTwo (int x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
} 

ll pow(ll x, ll y, ll mod)
{
	int ans=1;
	while(y)
	{
		if(y&1)
			ans=(ans*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}
	return ans;
}

int main()
{
	fast;
	ull n,x,temp,count=0;
	cin >> x;
	n=100;
	while(n<x)
	{
		temp=n/100;
		n+=temp;
		count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 3652
// vim: shiftwidth=2 expandtab foldmethod=marker

// include {{{
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <utility>
#include <cstdlib>
#include <random>
#include <chrono>
// }}}

// debug(...) {{{
#ifdef LOCAL_DEBUG
#include "./debug.h"
#else
#define debug(...)
#define debugn(...)
#define debug_reset()
#endif

#include <cstdio>

template<class T>
std::string bin(int bits, const T& x) {
  char buf[bits + 1];
  buf[bits] = '\0';
  for(int i = 0; i < bits; i++) {
    if((x >> i) & 1) {
      buf[bits - i - 1] = '1';
    } else {
      buf[bits - i - 1] = '0';
    }
  }
  return std::string(buf);
}
std::string bin(int x) {
  if(x < 0) return bin(32, x);
  for(int i = 4; i < 31; i++) {
    int y = 1 << i;
    if(x < y) return bin(i, x);
  }
  return bin(32, x);
}
// }}}

// misc {{{
using namespace std;
template<class T, class U>

using umap = unordered_map<T, U>;
template<class T>
using uset = unordered_set<T>;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

template<class T>
void sort(T& arr) {
  std::sort(arr.begin(), arr.end());
}
template<class T, class By>
void sort_by(T& arr, By by) {
  std::sort(arr.begin(), arr.end(), [by](auto l, auto r){return  by(l) < by(r); });
}

template<class T>
void reverse(T& arr) {
  std::reverse(arr.begin(), arr.end());
}

class Random {
  public:
  std::uniform_int_distribution<> uniform_int;
  std::mt19937 rnd;
  std::bernoulli_distribution bern_dist;
  int uniform(int l, int r) {
    return uniform_int(rnd, std::uniform_int_distribution<>::param_type(l, r));
  }
  int next(int N) {
    return uniform(0, N - 1);
  }
  int bern(double p) {
    return bern_dist(rnd, std::bernoulli_distribution::param_type(p));
  }
};
// }}}

// main {{{
void solve();
int main() {
  solve();
}
// }}}

void solve() {
  int N;
  cin >> N;
  vector<int> B(N - 1);
  rep(i, N - 1) cin >> B[i];

  int ans = 0;
  rep(i, N) {
    if(i == 0) ans += B[i];
    else if(i == N - 1) ans += B[i - 1];
    else {
      ans += min(B[i - 1], B[i]);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}

int main(){
    string s, t;
    cin >> s >> t;

    cout << t + s << endl;
    

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    vector<int> pos, neg;
    rep(i, n)
    {
        if (a[i] > 0)
            pos.push_back(a[i]);
        else
            neg.push_back(a[i]);
    }
    reverse(all(neg));
    int l, r;
    if (neg.size() == 0)
    {
        r = pos[0], l = pos[1];
        pos.erase(pos.begin()), pos.erase(pos.begin());
    }
    else if (pos.size() == 0)
    {
        r = neg[1], l = neg[0];
        neg.erase(neg.begin()), neg.erase(neg.begin());
    }
    else
    {
        l = pos[0], r = neg[0];
        pos.erase(pos.begin()), neg.erase(neg.begin());
    }
    int ans = 0;
    ans += l, ans -= r;
    rep(i, pos.size()) ans += pos[i];
    rep(i, neg.size()) ans -= neg[i];
    cout << ans << endl;
    rep(i, pos.size())
    {
        cout << r << " " << pos[i] << endl;
        r -= pos[i];
    }
    rep(i, neg.size())
    {
        cout << l << " " << neg[i] << endl;
        l -= neg[i];
    }
    cout << l << " " << r << endl;
}

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

using namespace std;

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

    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    string s;
    cin >> s;
    int ig = 0;
    if (c > d) {
        for (int i = a; i <= d; i++) {
            if (s[i] == '.') {
                int r = i;
                while (r + 1 <= n && s[r + 1] == '.') r++;
                int len = (r - i + 1);
                if (len >= 3 && r > b && i < d) {
                    ig = 1;
                }
                r = i;
            }
        }
    }
    for (int i = min(a, b); i + 1 <= max(c, d); i++) {
        if (s[i] == '#' && s[i + 1] == '#') {
            cout << "No\n";
            return 0;
        }
    }
    if (c < d || ig) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}   


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

using Int = long long;
const int BINOM_MAX = 5100000;
const int MOD = 1000000007;

long long fac[BINOM_MAX], finv[BINOM_MAX], inv[BINOM_MAX];

// テーブルを作る前処理
void initBinom() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < BINOM_MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long binom(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    Int X, Y;
    cin >> X >> Y;
    auto x = -X + 2 * Y;
    auto y = 2 * X - Y;
    if (x % 3 != 0 || y % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    x /= 3;
    y /= 3;
    initBinom();
    cout << binom(x + y, x) << endl;
}


Measured memory_bytes: 119808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int n ; cin  >> n;
    vector<string> s(n);
    rep(i,n){
        cin >> s[i];
    } 
    vector<ll> ans(4,0);
    rep(i,n){
        if(s[i]=="AC") ans[0]++;
        else if(s[i]=="WA") ans[1]++;
        else if(s[i]=="TLE") ans[2]++;
        else if(s[i]=="RE") ans[3]++;
    }
    cout << "AC x " << ans[0] << endl;
    cout << "WA x " << ans[1] << endl;
    cout << "TLE x " << ans[2] << endl;
    cout << "RE x " << ans[3] << endl;
    return 0;
}

Measured memory_bytes: 6352
#include<bits/stdc++.h>
using namespace std;
static const int INF = 1 << 30;
int main(){
	int N, L;
	int a[100001];

	scanf("%d %d", &N, &L);
	for(int i = 0; i < N; i++){
		scanf("%d", &a[i]);
		a[i] = L - a[i];
	}

	int max_incr = 0;;
	a[N] = 0;
	for(int i = 0; i < N; i++){
		int incr = a[i];
		while(a[i] < a[i + 1]){
			incr += a[i + 1];
			i++;
		}
		if(incr > max_incr) max_incr = incr;
	}
	int max_decr = 0;;
	a[N] = INF;
	for(int i = 0; i < N; i++){
		int decr = a[i];
		while(a[i] > a[i + 1]){
			decr += a[i + 1];
			i++;
		}
		if(decr > max_decr) max_decr = decr;
	}

	printf("%d\n", max(max_incr, max_decr));

	return 0;
}

Measured memory_bytes: 3580
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nab = Input.ar;
        WriteLine((nab[2] - nab[1]) % 2 == 0 ? "Alice" : "Borys");
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  
static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int n,d[100010],par[100010];
bool used[100010],flag[100010];
vector<int>v[100010];
void dfs(int x){
    used[x]=true;
    for(int i:v[x]){
        if(!used[i]){
            d[i]=d[x]+1;
            par[i]=x;
            dfs(i);
        }
    }
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--,b--;
        v[a].pb(b);
        v[b].pb(a);
    }
    fill(par,par+n,-1);
    dfs(0);
    priority_queue<P>q;
    rep(i,n)q.push({d[i],i});
    while(!q.empty()){
        P p=q.top();
        q.pop();
        if(flag[p.se])continue;
        if(p.se==0){
            puts("First");
            return 0;
        }
        if(flag[par[p.se]]){
            puts("First");
            return 0;
        }
        flag[par[p.se]]=true;
        flag[p.se]=true;
    }
    puts("Second");
    return 0;
}

Measured memory_bytes: 10232
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using std::endl;
using std::cin;
using std::cout;
using std::vector;
using std::pair;
using std::string;
using std::map;
using std::multimap;

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

    vector<uint32_t> len(N);
    for (uint32_t i = 0; i < N; i++){
        cin >> len[i];
    }

    std::sort(len.begin(), len.end());
    std::reverse(len.begin(), len.end());

    uint32_t l = 0;
    for (uint32_t i = 1; i < N; i++) {
        l += len[i];
    }

    if (l > len[0]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}



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

int main(){
     int a,b,sum,sub,mult;
     cin>>a>>b;
     sum= a + b;
     sub= a - b;
     mult= a * b;
     if(sum>=sub && sum>=mult) cout<<sum;
     else if(sub>=sum && sub>=mult) cout<<sub;
     else{
          cout<<mult;
}
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    int h[n], a, b;
    bool g[n];
    for (int i=0; i<n; i++) {
        cin >> h[i];
        g[i] = true;
    }
    for (int i=0; i<m; i++) {
        cin >> a >> b;
        if (h[a-1] < h[b-1]) {
            g[a-1] = false;
        } else if (h[a-1] > h[b-1]) {
            g[b-1] = false;
        } else {
            g[a-1] = g[b-1] = false;
        }
    }
    int count = 0;
    for (int i=0; i<n; i++) {
        if (g[i]) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 4068
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] str = new String[n];
        for (int i = 0; i < n; i++) {
            str[i] = sc.next();
        }
        long[] march = new long[5];
        for (int i = 0; i < n; i++) {
            switch (str[i].charAt(0)) {
            case 'M':
                march[0]++;
                break;
            case 'A':
                march[1]++;
                break;
            case 'R':
                march[2]++;
                break;
            case 'C':
                march[3]++;
                break;
            case 'H':
                march[4]++;
                break;
            }
        }
        long ans = 0;
        for (int i = 0; i < 3; i++) {
            for (int j = i + 1; j < 4; j++) {
                for (int k = j + 1; k < 5; k++) {
                    ans += march[i] * march[j] * march[k];
                }
            }
        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 51148
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n, m, x, c[100009];
int main() {
	while (scanf("%d%d", &n, &m), n) {
		fill(c, c + n, 1);
		int cnt = 0;
		for (int i = 0; i < m; i++) {
			scanf("%d", &x);
			if (x == 0) cnt++;
			else c[--x] = 0;
		}
		int r = 0, sum = 0, ret = 0;
		for (int i = 0; i < n; i++) {
			if (r > i) r = i, sum = 0;
			while (r < n && sum + c[r] <= cnt) sum += c[r++];
			ret = max(ret, r - i);
			sum -= c[i];
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 2968