akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

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

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class D3NNumbers {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<int> a(3*n);
      rep(i, 3*n) {
        cin >> a[i];
      }
      priority_queue<int, vector<int>, greater<>> que1;
      ll sum = 0;
      rep(i, n) {
        que1.push(a[i]);
        sum += a[i];
      }
      vector<ll> ans(n+1);
      int pos = 0;
      ans[pos] += sum;
      debug(sum);
      pos++;
      for(int i=n; i<2*n; i++) {
        que1.push(a[i]);
        int tmp = que1.top(); que1.pop();
        sum += a[i]-tmp;
        ans[pos] += sum;
        debug(sum);
        pos++;
      }

      priority_queue<int> que2;
      sum = 0;
      reverse(all(a));
      rep(i, n) {
        que2.push(a[i]);
        sum += a[i];
      }
      pos = n;
      ans[pos] -= sum; pos--;
      debug(sum);
      for(int i=n; i<2*n; i++) {
        que2.push(a[i]);
        int tmp = que2.top(); que2.pop();
        sum += a[i]-tmp;
        debug(sum);
        ans[pos] -= sum; pos--;
      }

      ll ret = LLONG_MIN;
      for(auto& e: ans) {
        chmax(ret, e);
      }
      cout << ret << endl;

    }
};

signed main() {
  D3NNumbers solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3320
N,A,B=[int(i) for i in input().split()]

count=0
for num in range(1,N+1):
    tmp=num
    #判定
    wa=num%10
    while(num>=10):
        num=int(num/10)
        wa+=num%10
    # print(num,wa)
    if wa>=A and wa<=B:
        count+=tmp
print(count)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
vector<LP> ab;
int main(){
    int n; cin >> n;
    REP(i,n){
        ll a,b;
        cin >> a >> b;
        ab.push_back(make_pair(a,b));
    }
    sort(ab.begin(), ab.end());
    LP e = (*(ab.end()-1));
    cout << e.first + e.second << endl;
}

Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,i,j,dis[100005],x,y,z;
vector<pair<long long,long long>/**/> e[100005];
void dfs(long long x,long long dist)
{
	if (dis[x])
	{
		if (dis[x]!=dist)
		{
			cout<<"No";
			exit(0);
		}
		return;
	}
	dis[x]=dist;
	int i;
	for (i=0;i<e[x].size();i++)
	{
		dfs(e[x][i].first,dist+e[x][i].second);
	}
}
int main()
{
	cin>>n>>m;
	while (m--)
	{
		cin>>x>>y>>z;
		e[x].push_back(make_pair(y,z));
		e[y].push_back(make_pair(x,-z));
	}
	for (i=1;i<=n;i++)
	{
		if (dis[i]) continue;
		dfs(i,1e15);
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 16512
//============================================================================
// Name        : competitive_programing.cpp
// Author      : .Data_Nerd.
// Description : problem solving training
//============================================================================

#include <bits/stdc++.h>
#define Data_Nerd ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define files freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define mod 1000000007
#define OO 0x3f3f3f3f
#define NIL -1
using namespace std;
typedef long long ll;

vector <vector<int>> graph;

int memo[100005];

int DFS(int node){
	int ans = NIL, num_of_nodes = graph[node].size();

	if(!num_of_nodes)
		return 0;

	if(memo[node] != NIL)
		return memo[node];

	for(int i = 0; i < num_of_nodes; ++i)
		ans = max(ans, 1 + DFS(graph[node][i]));

	return memo[node] = ans;
}

int main() {
	Data_Nerd
	memset(memo, NIL, sizeof(memo));

	int n, m; scanf("%d%d", &n, &m);

	graph.resize(n + 5);
	vector <int> degree(n + 5, 0);

	for(int i = 0; i < m; ++i) {
		int u, v; scanf("%d%d", &u, &v);
		graph[u].push_back(v);
		++degree[v];
	}

	int ans = NIL;

	for(int i = 1; i <= n; ++i)
		if(!degree[i])
			ans = max(ans, DFS(i));

	printf("%d", ans);

	return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define MAX_INT 2100000000
#define rep(i,n) for (i=1;i<=(n);++i)
using namespace std;
typedef long long int ll;
#ifdef COMPILE_IN_VCPP
#include <windows.h>
HWND GetConsoleHwnd(void)
{
#define MY_BUFSIZE 1024 // Buffer size for console window titles.
	HWND hwndFound;         // This is what is returned to the caller.
	char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated// WindowTitle.
	char pszOldWindowTitle[MY_BUFSIZE]; // Contains original// WindowTitle.
	ULARGE_INTEGER nt;
	nt.QuadPart = GetTickCount64();
	GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
	wsprintf(pszNewWindowTitle, "%d%d/%d", nt.HighPart, nt.LowPart, GetCurrentProcessId());
	SetConsoleTitle(pszNewWindowTitle);
	Sleep(40);
	hwndFound = FindWindow(NULL, pszNewWindowTitle);
	SetConsoleTitle(pszOldWindowTitle);
	return(hwndFound);
}
#endif
ll mod = 1e9 + 7;
int main()
{
	int m, d, i, j, k,ans=0;
	cin >> m >> d;
	for (i = 1; i <= d; i++)
	{
		for (j = 1; j <= m; j++)
		{
			if ((i / 10) * (i % 10) == j&& i / 10>=2&&i%10>=2)
			{
				ans++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
<?php
$arr1=array();
$arr2=array();
$count=0;
//1行目の空白までのデータをもらって$n1に入れる
fscanf(STDIN,'%d',$n1);
//2行目の文字列をもらう
  $temp_arr1=fgets(STDIN);
//文字列から空白のスペースを取り除く
  $temp_arr1=trim($temp_arr1);
//空白を境目にして、文字列から配列を作る
  $arr1=explode(' ',$temp_arr1);
  //2つめのデータの1行目の空白までのデータをもらって$n2に入れる
  fscanf(STDIN,'%d',$n2);
  //$arr1を作ったのと同じ作業を1行で済ませる
  $arr2=explode(' ',trim(fgets(STDIN)));
//数を記録する変数
$count=0;

  foreach($arr2 as $a){
    //配列1の中に配列2のデータがあるかを検索する
    //左端と右端の最初の位置を設定
    $left=0;
    $right=$n1;
    $a=(int)$a;
    //間に数値がなくなるまで繰り返す
    while($left<$right) {
      //真ん中の地点を調べる。小数点が出ないようにint型にキャスト
      $mid=(int)(($left+$right)/2);
      //真ん中の地点のデータ
      $b=(int)$arr1[$mid];
      if($b===$a){
        $count++;
        break;
    }else if($b<$a){
      //＋1しないと配列の最後の数字だった時に終わらない
      $left=$mid+1;
    }else{
      $right=$mid;
    }
  }
}
  echo $count . PHP_EOL;



Measured memory_bytes: 36228
// C - Sugar Water
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

void solve(int w1,int w2, int s1, int s2, int solute, int volume){
	int WS = w1*100, S = 0;
	int wend = volume/100 + 1;
	double maxper = 0.0;
	rp(iw, 1, wend) rp(jw, 0, wend){
		int w = w1*iw + w2*jw;
		if(w >= wend) break;
		int send = volume - w*100 + 1;
		rp(is, 0, send) rp(js, 0, send){
			int s = s1*is + s2*js;
			if(s >= send) break;
			int ws = w * 100 + s;
			if(ws <= volume && s <= solute*w){
				double per = 100.0*s/ws;
				if(maxper < per){
					maxper = per;
					WS = ws;
					S = s;
				}
			}
		}
	}
	printf("%d %d\n",WS,S);
}

int main(){
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	solve(a,b,c,d,e,f);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int N=300000;
int p[N], lr[N];

int main() {
    int i, j, t, n;
    ll L, R, ans=0;
    scanf("%d", &n);
    for(i=1; i<=n; i++) {
        scanf("%d", &t);
        p[t]=i;
    }
    for(i=n; i>=1; i--) {
        j=p[i];
        L=lr[j-1]; if(!L) L=j;
        R=lr[j+1]; if(!R) R=j;
        ans+=i*(j-L+1)*(R-j+1);
        lr[L]=R;
        lr[R]=L;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
int main(void){
	int n;
	long a;
	long prev_a;
	long x = 0;
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%ld", &a);
		if(i != 0){
			if(a < prev_a){
				x += prev_a - a;
				a = prev_a;
			}
		}
		prev_a = a;
	}
	printf("%ld\n", x);
	return 0;
}


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

int main()
{
    int n,x,y;
    cin >> n;
    int a[n];
    int b[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(a,a+n);
    x = a[n/2-1];
    y = a[n/2];
    for(int i = 0; i < n; i++){
        if(b[i] <= x){
            cout << y << endl;
        }else{
            cout << x << endl;
        }
    }
}

Measured memory_bytes: 3712
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

int n, x, l, d, ans;

int main() {
    scanf("%d %d", &n, &x);
    d = 0;
    ans = 1;

    for ( int i = 0; i < n; i++ ) {
        scanf("%d", &l);
        d += l;

        if (d <= x) {
            ans++;
        }
    }

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


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

ll C[2100][2100];

int main(){
  bool flag=true;
  ll N,A[210000],B[210000];
  pair<ll,ll> task[210000];
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>task[i].second>>task[i].first;
  }
  sort(task,task+N);
  ll now=0;
  for(int i=0;i<N;i++){
    if(now+task[i].second>task[i].first){
      flag=false;
      break;
    }else{
      now+=task[i].second;
    }
  }
  if(flag) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<long long> > vvll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define INF 1000000000LL
#define MOD 1000000007
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define p_q priority_queue
 
#define FOR(i, a, b) for (int i=(a); i<=(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)
 
#define MN 55
int n, k;

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

    cin >> n >> k;
    cout << n-(k-1);

    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>

#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
// #define iter(a) __typeof(a.begin())
#define FOR(it, a) for (auto it = a.begin(); it != a.end(); ++it)
#define F first
#define S second
#define SZ(a) static_cast<int>((a).size())
#define sz(a) SZ(a)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).begin(), (a).end()
using namespace std;

typedef int64_t ll;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
typedef uint64_t ull;

#ifdef ONLINE_JUDGE
#define PR(...) (void(0))
#else
#define PR(...) \
  do { cerr << "line : " << __LINE__ << ", " << endl;  \
    pr(#__VA_ARGS__, __VA_ARGS__); } while (0)

template<class T>
void pr(const string& name, T t) {
  cerr << name << ": " << t << endl;
}
template<typename T, typename ... Types>
void pr(const string& names, T t, Types ... rest) {
  auto p = names.find(',');
  cerr << names.substr(0, p) << ": " << t << ", ";
  pr(string(names, p + 1), rest ...);
}
#endif

template<class T, class U> ostream& operator<<(
    ostream& o, const pair<T, U>& v) {
  return o << "(" << v.F << ", " << v.S << ")";
}
template<class T> ostream& operator<<(
    ostream& o, const vector<T>& v) {
  o << "{"; rep(i, SZ(v)) o << (i?", ":"") << v[i]; return o << "}"; }
template<class T, class U> ostream& operator<<(
    ostream& o, const map<T, U>& v) {
  o << "{"; for (const auto& e : v) o << e << ", "; return o << "}"; }
template<class T, class U> ostream& operator<<(
    ostream& o, const unordered_map<T, U>& v) {
  o << "{"; for (const auto& e : v) o << e << ", "; return o << "}"; }
template<class T> ostream& operator<<(ostream& o, const set<T>& v) {
  o << "{"; for (const auto& e : v) o << e << ", "; return o << "}"; }
template<class T> string to_s(const T& v) {
  ostringstream is; is << v; return is.str(); }

const int dx[]={0, 1,  0, -1,  1, 1, -1, -1, 0};
const int dy[]={1, 0, -1,  0, -1, 1,  1, -1, 0};

#define endl '\n'

int main(int argc, char *argv[])
{
  int n;
  string s, t;
  cin >> n >> s >> t;
  for (int i = n; i >= 1; --i) {
    if (s.substr(n-i) == t.substr(0, i)) {
      cout << n * 2 - i << endl;
      return 0;
    }
  }
  cout << n * 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

const ll inf=1e9+7;

ll mult(ll n,ll m){//n^m%infを求める
    if(m==1){
        return n%inf;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%inf;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%inf;
    }
}

typedef pair<int,int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k,l;
    cin>>n>>k>>l;
    class UnionFind uf1(n+1);//道路
    class UnionFind uf2(n+1);//鉄道
    rep(i,k){
        int p,q;
        cin>>p>>q;
        uf1.unite(p,q);
    }
    rep(i,l){
        int r,s;
        cin>>r>>s;
        uf2.unite(r,s);
    }
    map<P,int> ans;
    FOR(i,1,n+1){
        ans[P(uf1.find(i),uf2.find(i))]++;
    }
    FOR(i,1,n+1){
        cout<<ans[P(uf1.find(i),uf2.find(i))]<<' ';
    }
    cout<<endl;
}

Measured memory_bytes: 15124
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  int *A, *B, C[VMAX];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(int) * n+1);
  B = malloc(sizeof(int) * n+1);

  for (i=0; i<=VMAX; i++)      C[i] = 0;

  for (i=0; i<n; i++){
    scanf("%d", &A[i + 1]);
    C[A[i + 1]]++;
  }
  for (i=1; i<=VMAX; i++) C[i] = C[i] + C[i - 1];

  for (j = 1; j<=n; j++){
    B[ C[ A[j] ] ] = A[j];
    C[ A[j] ]--;
  }
  for (i=1; i<=n; i++){
    if (i>1) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 17380
#include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;

//vector< vector<int> > v (size1, vector<int>(size2) );

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    int a,b;
    vector<int> v(n);
    FOR(i,0,m){
        cin>>a>>b;
        v[a-1]++;
        v[b-1]++;
    }
    FOR(i,0,n){
        cout<<v[i]<<endl;
    }
}

Measured memory_bytes: 256
#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/gcd(a,b)*b;}

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

int main(){
	string s;cin>>s;
	rep(i,s.size()){
		if(s[i]=='7'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}


Measured memory_bytes: 3596
/*
T M Hridoy KUET CSE 15
*/
#include<bits/stdc++.h>

using namespace std;

#define print printf("==================\n");
typedef    long long ll;
typedef pair<ll,ll   > payar;
typedef   unsigned long long ull;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define min3(a,b,c) min(a,min(b,c));
#define max3(a,b,c) max(a,max(b,c));
#define readf                freopen("in.txt", "r", stdin);
#define writef               freopen("out.txt", "w", stdout);

priority_queue<int, vector<int>,  greater<int> > pq; ///accending
vector< pair<int,payar  > > vpp;
vector< pair<int,  pair<int,payar  > > > own;
vector < payar >  vp;
#define pi acos(-1.0);
#define EPS 1e-9
#define  mod   1000000007
#define  mod2  998244353
#define all(x) x.begin(),x.end()
#define endl "\n"
const int N=2e5+5;


int a[N];
const int M = 998244353;

int main()
{
    IOS;
    int t ;
    string s,v ;
    cin>>s;
    v=s;
    reverse(all(s));
    if(s!=v)
    {
        cout<<"No\n";
        return 0;
    }

    t = (s.size()-1)>>1;
    string s1 = s.substr(0,t);
   // cout<<s1<<endl;
    v = s1;
    reverse(all(s1));
    if(s1!=v)
    {
        cout<<"No\n";
        return 0;
    }

    t = (s.size()+3)>>1;
    string s2 =  s.substr(t-1,s.size());

    v = s2;
    reverse(all(s2));
    if(s2!=v)
    {
        cout<<"No\n";
        return 0;
    }
    cout<<"Yes\n";



    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int i,j,x;
    int cnt[101]={};
    int res=1;
    for(i=1;i<n+1;i++){
        x=i;
        for(j=0;j<n+1;j++){
            bool ex_odd=false;
            if(x%2==0){
                x/=2;
                cnt[i]++;
            }
            if(x%2==1)ex_odd=true;
            if(ex_odd)break;
            
        }
        if(cnt[i]>cnt[res])res=i;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n;
	int h[100001];
	int dp[100001];

	cin >> n;

	h[0] = 1 << 30;
	for(int i = 1; i <= n; ++i)
	{
		cin >> h[i];
	}
	
	dp[0] = 0;
	for(int i = 2; i <= n; ++i)
	{
		dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
	}

	cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    char N[4];
    cin >> N;

    ll X[4];
    rep(i, 4){
        X[i] = N[i] - '0';
    }

    ll sum = 0;
    for(ll bits = 0; bits < (1 << 3); bits++){
        sum = X[0];
        for(ll i = 0; i < 3; i++){
            if(((bits >> i) & (ll)1) == 0){
                sum += X[i + 1];
            }else{
                sum -= X[i + 1];
            }
        }
        if(sum == 7){
            cout << X[0];
            rep(i, 3){
                if(((bits >> i) & (ll)1) == 0){
                    cout << "+" << X[i + 1];
                }else{
                    cout << "-" << X[i + 1];
                }
            }
            cout << "=7" << endl;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3632
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

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

	int index = s.length() / 2 - 1;
	bool flags = true;
	int N = s.length();
	for (int i = 0; i < (N - 1) / 2; ++i) {
		if(s[i] == s[i + (N + 3) / 2 - 1]){
			//pass;
		}
		else {
			flags = false;
			break;
		}
	}

	if (flags)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
int HN(int n){
  int a,b,c;
  int count=0;
  do{
    a=n/10;
    b=a*10;
    c=n-b;
    count+=c;
    n=a;
  }while(a>10);
  return count+a;
}
int main(){
  int N;
  scanf("%d",&N);
  int i;
  int num=0;
  int min=50000;
  for(i=1;i<=N/2;i++){
    num=HN(i)+HN(N-i);
    if(num<min){
      min=num;
    }
  }
  printf("%d",min);
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{ int x,y,j,n,i;
  char a[1000][1000];
   scanf("%d%d",&x,&y);
   for(i=0;i<x;i++)
   scanf("%s",&a[i]);
   for(i=0;i<y+2;i++)
   printf("#");
   printf("\n");
    for(i=0;i<x;i++)
    {printf("#");
	  printf("%s",a[i]);
	  printf("#");
	  printf("\n");
	 } 
   for(i=0;i<y+2;i++)
   printf("#");
   printf("\n");
	   return 0;
     
}

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

int main()
{

    int t,i,x,sum=1,counter=0;
    cin>>x;
    int arr[x+1],arr2[x+1];
    for(i=0;i<x;i++)
    {
        cin>>arr[i];
       arr2[i]=arr[i];
    }
    sort(arr,arr+x);
    for(i=0;i<x;i++)
    {

       if(arr2[i]==arr[i])
        counter++;
    }

    //cout<<x-counter<<endl;


    (x-counter>2)?cout<<"NO"<<endl:cout<<"YES"<<endl;


    return 0;

}




Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(sc.hasNext()){
			int n = sc.nextInt();
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int[] d = new int[n];
			int[] e = new int[n+1];
			
			for(int i=0;i<n;i++){
				d[i] = sc.nextInt();
			}
			Arrays.sort(d);
				
			int sum = c;
			for(int i=0;i<n;i++){
				sum += d[n-1-i];
				e[i] = sum/(a+b*(i+1));
			}
			e[n] = c/a;
			Arrays.sort(e);
			
			System.out.println(e[n]);
		}
	}
}

Measured memory_bytes: 18132
// abc163_b
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
  int n,m,a;
  cin>>n>>m;
  rep(i,m){
    cin>>a;
    n-=a;
  }
  if (n<0) cout<<-1<<endl;
  else cout<<n<<endl;
  return 0;
}


Measured memory_bytes: 3640
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-24 16:57:59
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n; cin >> n;
  vector<int64> a(n); cin >> a;
  int64 sum = 0;
  int right = 0;
  int64 ans = 0;

  auto ok = [](int64 x, int64 y) -> bool {
    return x + y == (x ^ y);
  };

    // fix left
  for (int left = 0; left < n; ++left) {

    // increment right while ok
    while (right < n && ok(sum, a[right])) {
      sum += a[right];
      ++right;
    }
    int len = right - left;

    // do something using 'len'(length of section which satisfies condition)

    ans += len;

    // if right do not move at all, increment it
    if (right == left) {
      ++right;
    } else {
      sum -= a[left];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
	int R;
    cin >> R;
    cout << setprecision(15) << R * 2 * M_PI << endl;
}

Measured memory_bytes: 3780
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define int long long

void test_case(){
	int n;
	cin >> n;
	vector<int> v(n);
	for(int i=0;i<n;i++) cin >> v[i];
	sort(v.begin(), v.end());

	int ans=0;
	
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if( (v[i]!=v[j] && v[j]!=v[k]) && v[i] + v[j] > v[k]) ans ++;
			}
		}
	}

	cout << ans << endl;
}

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	int t=1;
	// cin >> t;

	while(t--) test_case();
	
	return 0;
}













//     	 __       _   __  _     _   _______   __
//	    /  \     | | / / | |   | | |__   __| |  |
//	   / /\ \    | |/ /  | |___| |    | |    |  |
//	  / /__\ \   |   <   |  ___  |    | |    |  |
//	 / ______ \  | |\ \  | |   | |  __| |__  |  |_____
//	/_/      \_\ |_| \_\ |_|   |_| |_______| |________|




Measured memory_bytes: 3676
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main
{
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int A = ni(), B = ni();
		out.println((A + B) % 2 == 0 ? (A + B) / 2 : "IMPOSSIBLE");
	}
		
	void run() throws Exception
	{
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
	}
	
	public static void main(String[] args) throws Exception 
	{ new Main().run(); }
	
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;
	
	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf)
		{
			ptrbuf = 0;
			try 
			{ lenbuf = is.read(inbuf); } 
			catch (IOException e) 
			{ throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}
	
	private boolean isSpaceChar(int c)
	{ return !(c >= 33 && c <= 126); }
	private int skip() 
	{ int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
	
	private double nd() 
	{ return Double.parseDouble(ns()); }
	private char nc()
	{ return (char)skip(); }
	
	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b)))
		{ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b)))
		{
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}
	
	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}
	
	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}
	
	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-')
		{
			minus = true;
			b = readByte();
		}
		
		while(true)
		{
			if(b >= '0' && b <= '9')
			{
				num = num * 10 + (b - '0');
			}else
			{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-')
		{
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9')
			{
				num = num * 10 + (b - '0');
			}else
			{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private static void tr(Object... o) 
	{ System.out.println(Arrays.deepToString(o)); }
}


Measured memory_bytes: 23124
#include<stdio.h>
#include<math.h>
double temp[10000][10000];
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	int i,j,k;
	int count = 0;
	double sum = 0;
	double c = 0;
	for(i = 0;i<a;i++)
		for(j = 0;j<b;j++)
			scanf("%lf",&temp[i][j]);
	getchar(); 
	
	for(i = 0;i<a;i++)
	{
		for(j = i+1;j<a;j++)
		{
			for(k = 0;k<b;k++)
				sum += (temp[j][k] - temp[i][k]) * (temp[j][k] - temp[i][k]);
			c = sqrt(sum);
			if(c-(double)(int)c < 1e-6) count++;
			sum=0;
		}
	} 
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int k, n;
	cin >> k >> n;
	int a[2*110000];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	int ma = 0, sum = 0;
	for (int i = 0; i < n-1; ++i)
	{
		sum += a[i+1] - a[i];
		ma = max(a[i+1] - a[i], ma);
	}
	sum += k + a[0] - a[n - 1];
	ma = max(k + a[0] - a[n - 1], ma);
	cout << sum - ma << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    ll n,l,t,cnt=0;
    cin >> n >> l >> t;
    vector<pair<ll,ll>> a(n);
    vector<ll> b(n);
    rep(i,n) cin >> a[i].first >> a[i].second;
    rep(i,n){
        b[i]=(((a[i].first+(a[i].second==1?1:-1)*t)%l)+l)%l;
    }
    ll now=b[0];
    sort(b.begin(),b.end());
    if(a[0].second==1){
        for(int i=1;i<n;i++){
            if(a[i].second==2){
                ll sa=a[i].first-a[0].first;
                ll si=2*t-sa-1;
                if(si>=0){
                    cnt+=si/l+1;
                }
            }
        }
        int su=cnt%n;
        int se=find(b.begin(),b.end(),now)-b.begin();
        rotate(b.begin(),b.begin()+(se-su+n)%n,b.end());
    }else{
        for(int i=1;i<n;i++){
            if(a[i].second==1){
                ll sa=(a[0].first+l)-a[i].first;
                ll si=2*t-sa;
                if(si>=0){
                    cnt+=si/l+1;
                }
            }
        }
        int su=cnt%n;
        int se=find(b.begin(),b.end(),now)-b.begin();
        rotate(b.begin(),b.begin()+(se+su+n)%n,b.end());
    }
    
    for(int i=0;i<n;i++){
        cout << b[i] << endl;
    }
    
    return 0;
}











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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

typedef struct{
    int s;
    int t;
    int c;
}data;

int main(void){
    int N,C;
    scanf("%d%d",&N,&C);

    data* A;
    NEW(A,N);
    for(int i=0;i<N;i++){
        scanf("%d%d%d",&A[i].s,&A[i].t,&A[i].c);
        A[i].s=A[i].s*2-1;
        A[i].t*=2;
        A[i].c--;
    }

    int t_max=0;
    for(int i=0;i<N;i++) t_max=MAX(t_max,A[i].t);

    int M[C][t_max];
    for(int i=0;i<C;i++){
        for(int j=0;j<=t_max;j++) M[i][j]=0;
    }
    for(int i=0;i<N;i++){
        for(int j=A[i].s;j<=A[i].t;j++) M[A[i].c][j]=1;
    }

    int ans=0;
    for(int i=0;i<=t_max;i++){
        int tmp=0;
        for(int j=0;j<C;j++) tmp+=M[j][i];
        ans=MAX(ans,tmp);
    }
    printf("%d\n",ans);

    return 0;
}

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

int f(int x){
    return x * x;
}

int area(int d){
    int x, y, sum, i;
    x = 600;
    y = f(d);
    sum = 0;
    i = 1;
    while(d * i <= 600 - d){
        sum += y * d;
        i++;
        y = f(d * i);
    }
    return sum;
}

int main(void){
    int d;
    while(cin >> d) {
       cout << area(d) << endl;
    }
    return 0;
    
}



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


int main() {
    int N;
    cin >> N;
    int b[N-1];
    int c[N];
    ll ans = 0;
    for(int i=0;i<N-1;i++) cin >> b[i];
    c[0] = b[0]; c[N-1] = b[N-2];
    for(int i=1;i<N-1;i++) {
        c[i]=min(b[i-1],b[i]);
    }
    for(int i=0;i<N;i++) ans += c[i];
    cout << ans << endl;

}

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 t = sc.nextInt();
        int tmp = t / a;
        System.out.println(tmp * b);


    }
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
const int maxn = 100 + 5;
const int mod = 998244353; 

int k;
int a[maxn], p[1000 + 10], q[maxn];
int last[maxn];

bool check(int sz){
	int mnm = *min_element(a+1,a+k+1), mxm = *max_element(a+1,a+k+1);
	if (mxm < 2*mnm+1)
		return true;
	if (mxm > 2*mnm+1)
		return false;
	for (int i = sz; i >= sz-k+1; i--)
		last[p[i]] = i;
	int m1 = sz, m2 = sz-k+1;
	for (int i = 1; i <= k; i++){
		if (a[i] == mnm)
			m1 = min(m1, last[i]);
		if (a[i] == mxm)
			m2 = max(m2, last[i]);
	}
	return m2 < m1;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin >> k;
	int sum = 0;
	for (int i = 1; i <= k; i++){
		cin >> a[i];
		sum += a[i];
	}
	if (*max_element(a+1,a+k+1) > 2 * (*min_element(a+1,a+k+1)))
		return cout << -1 << endl, 0;
	int sz = 0;
	for (int i = 1; i <= k; i++)
		p[++sz] = i;
	if (*max_element(a+1,a+k+1) == 2 * (*min_element(a+1,a+k+1))){
		sz = 0;
		int idx = 0;
		for (int i = 1; i <= k; i++)
			if (a[i] == *max_element(a+1,a+k+1))
				idx = i;
		for (int i = 1; i <= idx; i++)
			if (a[i] != *min_element(a+1,a+k+1))
				p[++sz] = i;
		for (int i = 1; i <= k; i++)
			if (i > idx or a[i] == *min_element(a+1,a+k+1))
				p[++sz] = i;
	}
	for (int i = 1; i <= k; i++)
		a[i] --;
	while (sz < sum){
		for (int i = sz-k+1; i <= sz; i++)
			q[i-(sz-k)] = p[i];
		vector<int> then;
		for (int i = 1; i <= k; i++){
			vector<int> A;
			for (int j = 1; j <= i; j++){
				a[q[j]] --;
				A.push_back(q[j]);
			}
			sort(A.begin(), A.end());
			int now = sz;
			int mnm = *min_element(a+1,a+k+1), mxm = *max_element(a+1,a+k+1);
			vector<int> me;
			if (2*mnm+1 == mxm){
				int idx = -1;
				for (int j = 0; j < i; j++)
					if (a[A[j]] == mxm)
						idx = j;
				for (int j = 0; j <= idx; j++){
					if (a[A[j]] == mnm)
						continue;
					p[++now] = A[j];
					me.push_back(A[j]);
				}
				for (int j = 0; j < i; j++)
					if (j > idx or a[A[j]] == mnm)
						p[++now] = A[j], me.push_back(A[j]);
			}
			else
				me = A;
			if (check(now) and (then.empty() or me < then))
				then = me;
			for (int j = 1; j <= i; j++)
				a[q[j]] ++;
		}
		for (auto it : then){
			p[++sz] = it;
			a[it] --;
		}
	}
	for (int i = 1; i <= sz; i++)
		cout << p[i] << " \n"[i == sz];
}


Measured memory_bytes: 3536
#include<iostream>
#include<algorithm>
#include<complex>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define MAX 10000

using namespace std;


string parse;
int cur;
bool overflow;

void init()
{
  overflow = false;
  cur = 0;
}

complex<long long> exp();

bool check(complex<long long> a)
{
  return -MAX > a.real() || -MAX > a.imag() || MAX < a.real() || MAX < a.imag(); 
}

complex<long long> fact()
{
  if(parse[cur] == '(')
    {
      cur++;
      complex<long long> p = exp();
      cur++;
      if(check(p))overflow = true;
      return p;
    }

  bool minus = false;
  if(parse[cur] == '+' || parse[cur] == '-')
    {
      if(parse[cur] == '-')minus = true;
      cur++;
    }
  complex<long long> p(0,0);
  long long value = 0;
  while('0' <= parse[cur] && parse[cur] <= '9')
    {
      value *= 10;
      value += (parse[cur]-'0');
      if(value > MAX || value < -MAX)overflow = true;
      cur++;
    }
  if(minus)value *= -1;
  if(parse[cur] == 'i')p.imag() = 1,cur++;
  else                 p.real() = value;
  if(check(p))overflow = true;
  return p;
}

complex<int> term()
{
  complex<long long> p = fact();
  while(parse[cur] == '*')
    {
      ++cur,p *= fact();
      if(check(p))overflow = true;
    }
  if(check(p))overflow = true;
  return p;
}

complex<long long> exp()
{
  complex<long long> p = term();
  if(check(p))overflow = true;
  while(parse[cur] == '+' || parse[cur] == '-')
    {
      if(parse[cur] == '+')++cur,p += term();
      else if(parse[cur] == '-')++cur,p -= term();
      if(check(p))overflow = true;
    }
  if(check(p))overflow = true;
  return p;
}

int main()
{
  while(getline(cin,parse))
    {
      init();
      complex<long long> res = exp();
      if(overflow)cout << "overflow\n";
      else if(res.real() == 0 && res.imag() == 0)cout << "0\n";
      else
	{
	  if(res.real() != 0)cout << res.real();
	  if(res.real() != 0 && res.imag() != 0 && res.imag() >= 0)cout << "+";
	  if(res.imag() != 0)cout << res.imag() << "i";
	  cout << endl;	   
	}
    }
}

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

#define MOD 1000000007
void print(vector<vector<int>> &dp ,int h, int w)
{

	for(int i=0;i<h;i++)
	{	for(int j=0;j<w;j++)
			cout<<dp[i][j]<<" ";
		cout<<endl;	
	}
}

long long int calc(vector<vector<int>> &grid , int h , int w )
{

 vector<vector<int>> dp(h,vector<int>(w,0));
 dp[0][0]=1;
 for(int i=0;i<h;i++)
 {
 	for(int j=0;j<w;j++)
 	{
 		if(grid[i][j]==1 || ( i==0 && j==0)) continue;
 		else
 		{	if(i-1>=0 && j-1>=0)
 			dp[i][j]=(dp[i][j-1]+dp[i-1][j])%MOD;

 			else if(i-1>=0)
 			 dp[i][j]=dp[i-1][j];

 			else 
 			 dp[i][j]=dp[i][j-1];
 		}
 	}
 }

 return dp[h-1][w-1]%MOD;
} 


int main(){
  
  int h,w;
  scanf("%d %d",&h,&w);
  vector<vector<int>> grid(h,vector<int>(w,0));

  for(int i=0;i<h;i++)
  {
  	for(int j=0;j<w;j++)
  	{
  		char c;
  		cin>>c;
  		if(c=='#')
  			grid[i][j]=1;
  	}
  }

cout<<calc(grid,h,w)<<endl;
 
	return 0;
}

Measured memory_bytes: 8192
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
n = ii()
A = set(sorted(iil()))
print(max(A)-min(A))


Measured memory_bytes: 3060
a,b,c,d=map(float,input().split())
a=complex(a,b)
b=complex(c,d)
for _ in [0]*int(input()):
    c=complex(*map(float,input().split()))
    q=b-a;c-=a
    p=a+q*(c/q).conjugate()
    print(p.real,p.imag)


Measured memory_bytes: 5680
h,w = map(int,input().split())
s = [input() for _ in range(h)]

dp = [[0 for _ in range(w)] for _ in range(h)]

for i in range(h):
    for j in range(w-1):
        if i > 0:
            dp[i][0] = dp[i-1][0] if s[i][0] == s[i-1][0] else dp[i-1][0]+1
            above = dp[i-1][j+1]
            left  = dp[i][j]
            if s[i-1][j+1] != s[i][j+1]:
                above += 1
            if s[i][j] != s[i][j+1]:
                left += 1
            dp[i][j+1] = min(above,left)
        else:
            left  = dp[i][j]
            if s[i][j] != s[i][j+1]:
                left += 1
            dp[i][j+1] = left

n = dp[-1][-1]
if s[0][0] == '.' and s[-1][-1] == '.':
    print(n//2)
elif s[0][0] == '#' and s[-1][-1] == '#':
    print(n//2+1)
else:
    print((n+1)//2)

Measured memory_bytes: 3188
#include<iostream>

using namespace std;

void trace(int N, int A[]) {
  cout << A[0];

  for (int i = 1; i < N; i++) cout << " " << A[i];

  cout << endl;
}

int main() {
  int N, A[1000], v;

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

  trace(N, A);

  for ( int i = 1; i < N; i++) {
    v = A[i];

    int j = 0;
    for ( ; j < i; j++ ) {
      if (A[i] < A[j]) {
        for (int k = i; k > j; k--) {
            A[k] = A[k-1];
        }

        A[j] = v;
        break;
      }
    }

    trace(N, A);
  }
}



Measured memory_bytes: 3104
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

#define INFTY 2000000000

int p[100], c[105][105];

void solve( int n ){

    int i, j, k, l;

    for( i = 1; i <= n; i++ ) c[i][i] = 0;

    for( l = 2; l <= n; l++ ){

        for( i = 1; i <= n - l + 1 ; i++ ){

            j = i + l - 1;

            c[i][j] = INFTY;

            for( k = i; k <= j - 1; k++ ){

                c[i][j] = min( c[i][j], c[i][k] + c[k+1][j] + p[i-1] * p[k] * p[j] );

            }

        }

    }

}


int main(){

    int n, i, trash;

    scanf("%d", &n);

    for( i = 1; i <= n; i++ ){

        scanf("%d %d", &p[i-1], &p[i] );

    }

    solve(n);

    printf("%d\n", c[1][n]);

}



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

int main() {
	char n[4];
	cin >> n;
	if (n[0] == n[1] && n[1] == n[2])
	{
		cout << "Yes";
	}
	else if (n[1] == n[2] && n[2] == n[3])
	{
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 256