akhauriyash/Code-Regression huggingface dataset:
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

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

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug "<< i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

ll digit(ll b,ll n){
  if(b<2||n<1){
    return -MOD;
  }else if(n<b){
    return n;
  }else{
    return digit(b,n/b)+(n%b);
  }
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,s;
  std::cin>>n>>s;

  if(n==s){
    std::cout<<n+1;
    return 0;
  }

  ll i=2;

  for(;i*i<=n;i++){
    if(digit(i,n)==s){
      std::cout<<i;
      return 0;
    }
  }

  if(i*i==n)i--;

  for(;i>0;i--){
    if(((n-s)%i==0)&&(digit((n-s)/i+1,n)==s)){
      std::cout<<(n-s)/i+1;
      return 0;
    }
  }

  std::cout<<-1;

  return 0;
}


Measured memory_bytes: 384
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#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>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a, b;
  cin >> a >> b;
  if(a == b) cout << "EQUAL" << endl;
  else if(a.size() > b.size()) cout << "GREATER" << endl;
  else if(a.size() < b.size()) cout << "LESS" << endl;
  else if(a.size() == b.size()) {
    REP(i,a.size()) {
      if(a[i]>b[i]) {
        cout << "GREATER" << endl;
        break;
    }
    if(a[i]<b[i]) {
      cout << "LESS" << endl;
      break;
    }
  }
}
}



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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;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> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  cin>>a;

  int ans = 0;
  for(int i=0;i<n;++i){
    ans += min(a[i]*2,abs(k-a[i])*2);
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=2000;

int n;
char spiece[MAXN+1];
vector<int> adj[MAXN];

bool done[MAXN][MAXN+1];
int sum[MAXN][MAXN+1];
int cnt[MAXN][MAXN+1];
int dp[MAXN][MAXN+1];

void rec(int at,int par) {
	if(done[at][par]) return; else done[at][par]=true;
	sum[at][par]=0,cnt[at][par]=spiece[at]-'0';
	int heavy=-1;
	REPSZ(i,adj[at]) {
		int to=adj[at][i];
		if(to==par) continue;
		rec(to,at);
		cnt[at][par]+=cnt[to][at];
		sum[at][par]+=sum[to][at]+cnt[to][at];
		if(heavy==-1||cnt[to][at]+sum[to][at]>cnt[heavy][at]+sum[heavy][at]) heavy=to;
	}
	if(heavy==-1||2*(cnt[heavy][at]+sum[heavy][at])<=sum[at][par]) {
		dp[at][par]=sum[at][par]%2;
	} else {
		int other=sum[at][par]-cnt[heavy][at]-sum[heavy][at];
		if(dp[heavy][at]+cnt[heavy][at]<=other) {
			dp[at][par]=sum[at][par]%2;
		} else {
			dp[at][par]=dp[heavy][at]+cnt[heavy][at]-other;
		}
	}
	//printf("rec(%d,%d): cnt=%d sum=%d dp=%d\n",at+1,par==n?0:par+1,cnt[at][par],sum[at][par],dp[at][par]);
}

int solve() {
	REP(i,n) REPE(j,n) done[i][j]=false;
	int ret=INT_MAX;
	REP(i,n) {
		rec(i,n);
		if(dp[i][n]==0) {
			assert(sum[i][n]%2==0);
			ret=min(ret,sum[i][n]/2);
		}
	}
	return ret==INT_MAX?-1:ret;
}

void run() {
	scanf("%d",&n);
	scanf("%s",spiece); assert(strlen(spiece)==n);
	REP(i,n-1) { int a,b; scanf("%d%d",&a,&b); --a,--b; adj[a].PB(b); adj[b].PB(a); }
	printf("%d\n",solve());
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 51072
S = input()

A = [0]
C = [0]
Q = [0]
a=0
c=0
q=0
for i in range(len(S)):
    if S[i]=="A":
        a+=1
    if S[i]=="C":
        c+=1
    if S[i]=="?":
        q+=1
    A.append(a)
    C.append(c)
    Q.append(q)

a = 1
a0 = 1
a1 = 1
a2 = 1
a3 = 1
for i in range(Q[len(S)]):
    a = (a*3)%(10**9 + 7)
    if i==Q[len(S)]-4:
        a3 = a
    elif i==Q[len(S)]-3:
        a2 = a
    elif i==Q[len(S)]-2:
        a1 = a
    elif i==Q[len(S)]-1:
        a0 = a

count = 0
for i in range(1,len(S)):
    if S[i]=="B":
        count=(count+a0*A[i]*(C[len(S)]-C[i+1])+a1*A[i]*(Q[len(S)]-Q[i+1])+a1*Q[i]*(C[len(S)]-C[i+1])+a2*Q[i]*(Q[len(S)]-Q[i+1]))%(10**9 + 7)
    elif S[i]=="?":
        count=(count+a1*A[i]*(C[len(S)]-C[i+1])+a2*A[i]*(Q[len(S)]-Q[i+1])+a2*Q[i]*(C[len(S)]-C[i+1])+a3*Q[i]*(Q[len(S)]-Q[i+1]))%(10**9 + 7)
print(count)

Measured memory_bytes: 8992
#include<bits/stdc++.h>
using namespace std;
#define clr(a,b) memset(a,b,sizeof a)
#define PII pair<int,int>
#define PI acos(-1.0)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
typedef long long ll;
typedef unsigned long long ull;
const int INF=0x3f3f3f3f;
const int maxn=1e5+10;
int dp[1<<16],V[maxn],cnt[16];
int n,x,y,a;

int Work(int S)
{
    if(S==0) return 0;
    if(dp[S]!=-1) return dp[S];
    dp[S]=INF;
    for(int i=1;i<16;i++)
    {
    	if(S&(1<<i))
            for(int j=1;j<16;j++)
            {
            	
            	if(S&(1<<j))
                {
                    int cs=S^(1<<i)^(1<<j)^(1<<(i^j));
                    if(i!=j)
					{
						if(((1<<(i^j)) & S) == (1<<(i^j))) dp[S]=min(dp[S], Work(cs) + 2);
						else dp[S]=min(dp[S], Work(cs) + 1 ); 
					}
                }
			}
	}
    return dp[S];
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        scanf("%d%d%d",&x,&y,&a);
        V[x]^=a; V[y]^=a;
    }
    for(int i=0;i<n;i++) if(V[i]) cnt[V[i]]++;
    int ans=0,s=0;
    for(int i=0;i<16;i++) ans += cnt[i]/2, s^=(cnt[i]&1)<<i;
    memset(dp,-1,sizeof dp);
    ans+=Work(s);
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 896
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;

int main()
{
  int K;
  cin >> K;
  ll ans = 0;
  rep2(i, 1, K+1)
  {
    rep2(j, 1, K+1)
    {
      rep2(l, 1, K+1)
      {
        ll gcd = __gcd(__gcd(i, j), l);
        // cout << gcd << endl;
        ans += gcd;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

struct Mystruct
{
    long long atack;
    long long mp;
    double cost;

    Mystruct(long long input_a, long long input_b)
    {
        atack = input_a;
        mp = input_b;
        cost = input_a * 1.0 / input_b;
    }
    bool operator<(const Mystruct &another) const
    {
        if (cost == another.cost)
        {
            return mp < another.mp;
        }
        return cost < another.cost; //年齢を比較
    };
};

double expect(int n)
{
    return (1 + n) * 1.0 / 2;
}

int main()
{
    int n, k;
    cin >> n >> k;

    VI v(n);
    vector<double> e(n);

    REP(i, n)
    {
        cin >> v[i];
        e[i] = expect(v[i]);
    }

    double m = 0;
    REP(i, k)
    {
        m += e[i];
    }
    double sum = m;

    FOR(i, k, n-1)
    {
        sum = sum + e[i] - e[i-k];
        m = max(m, sum);
    }

    cout << fixed << setprecision(10) << m << endl;

    return 0;
}


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

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

  int X = max({A, B, C});
  if (X % 2 != (A + B + C) % 2) X++;
  cout << (3 * X - A - B - C) / 2 << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int main(){
  int N,L,x1,x2,sum,i;
  cin >> N >> L;
  x1 = L;
  x2 = L+N-1;
  if(x1>0){
    sum = (2*L+N)*(N-1)/2;
  }else if(x2<0){
    sum = (2*L+N-2)*(N-1)/2;
  }else{
    sum = (2*L+N-1)*N/2;
  }
  
  cout << sum;
  return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll, ll>;
const ll INF = ll(1e18);
const ll mod = ll(1e9 + 7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (b) - 1; (i) >= (a); --(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
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 dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

vector<ll> FactorialInv, Factorial;

void init_combination(ll MAX){
    Factorial.resize(MAX + 1);
    FactorialInv.resize(MAX + 1);
    Factorial[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = power(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    if(b < 0) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}


//modの値の確認をすること
int main(){
    ll n,m,k;
    cin >> n >> m >> k;
    vl a(n + 2,0),b(m + 2,0);
    rep1(i, n){
        cin >> a[i];
        a[i] += a[i - 1];
    }
    rep1(i, m){
        cin >> b[i];
        b[i] += b[i - 1];
    }
    a[n + 1] = INF;
    b[m + 1] = INF;
    ll ans = 0;
    rep0(i, n + 2)if(a[i] <= k)chmax(ans, ll(i + (upper_bound(all(b), k - a[i]) - b.begin()) - 1));
    pf(ans);
    return 0;
}


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

int main(void){
    int n;
    string h = "Hoshino";
    string s;
    cin >> n;
    getline(cin, s);
    stringstream ss(s);
    ss >> n;
    rep(loop, n) {
        getline(cin, s);
        rep(i, s.size()){
            if(i+h.size()-1 >= s.size()) break;
            bool same = true;
            rep(j, h.size()) {
                if(s[i+j]!=h[j]) {
                    same = false;
                    break;
                }
            }
            if(same) s[i+h.size()-1] = 'a';
        }
        cout << s << endl;
    }
}

Measured memory_bytes: 1224
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i, n) cin>>a[i];
	sort(all(a));
	if(a[n-1]-a[0]>1){
		cout<<"No"<<endl;
		return 0;
	}
	int t = a[0];
	if(a[0]==a[n-1]){
		if(t==n-1 || (1<=t && t<=n/2)) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
		return 0;
	}
	int c = 0;
	rep(i, n){
		if(a[i]==t) c++;
	}
	n -= c;
	t -= c - 1;
	if(1<=t && t<=n/2) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& e : a) cin >> e;
  int w = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] != i + 1) w++;
  }
  cout << (w <= 2 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include<cstdio>

int main(){
    int count[750];
    // for(int i = 0; i < 1201; i++){
    //     count[i] = 0;
 	// }
    char ch;
    while(scanf("%c",&ch) != EOF){
        if(ch >= 'a' && ch <= 'z'){
            count[ch - 'a']++;
        }
        else if(ch >= 'A' && ch <= 'Z'){
            count[ch - 'A']++;
        }
    }
    for(int j = 0;j < 26; j++){
        printf("%c : %d\n",j + 'a',count[j]);
    }
    return 0;
}


Measured memory_bytes: 2756
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

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;}
const ll INF = 1e9+1;

int N, M;

int par[100000];
ll num[100000];


int main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        par[i] = i;
        num[i] = 1;
    }
    vector<ll> res(M);
    res[M-1] = (ll) N * (N-1) / 2;
    vector<ll> A(M), B(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }
    

    for (int i = M-1; i >= 1; i--) {
        int a = A[i], b = B[i];
        while (a != par[a]) a = par[a];
        while (b != par[b]) b = par[b];
        if (a != b) {
            res[i-1] = res[i] - num[a] * num[b];
            if (num[a] > num[b]){
                par[b] = a;
                num[a] += num[b];
            } else {
                par[a] = b;
                num[b] += num[a];
            }
        } else {
            res[i-1] = res[i];
        }
    }

    for (int i = 0; i < M; i++) {
        cout << res[i] << endl;
    }




}

Measured memory_bytes: 4864
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            int iN = int.Parse(Console.ReadLine().Trim());

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            List<long> lstLuc = new List<long>();
            lstLuc.Add(2);
            lstLuc.Add(1);
            for (int i = 2; i <= iN; i++)
            {
                lstLuc.Add(lstLuc[i - 2] + lstLuc[i - 1]);
            }

            // 出力
            Console.WriteLine("{0}", lstLuc[iN].ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <utility>
#include <cctype>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

#define C const
#define R register
#define fast ios::sync_with_stdio(0);cin.tie(0)
#define ll long long
#define ld long double
#define ull unsigned long long
#define eps 1e-8
#define pi 3.141592653589793
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define PII pair<int,int>
#define sqr(a) ((a)*(a))
#define ls rt<<1
#define rs rt<<1|1
#define lowbit(i) ((i)&(-(i)))
#define FOR(i,a,b) for(R int i=(a);i<=(b);++i)
#define REP(i,a,b) for(R int i=(a);i>=(b);--i)
#define FOR_edge(i)  for(R int i=head[u];i;i=e[i].nxt)

using namespace std;

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

void judge() {
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
inline char nc() {
	static char buf[1000001],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
template <typename T> inline T Read() {
	R T s=0,w=1;
	R char c=nc();
	while(c<'0'||c>'9'){if(c=='-')w=-1;c=nc();}
	while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+c-48,c=nc();
	return s*w;
}
template <typename T> inline void Read(R T &s) {
	s=0;
	R T w=1;
	R char c=nc();
	while(c<'0'||c>'9'){if(c=='-')w=-1;c=nc();}
	while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+c-48,c=nc();
	s*=w;
}
template <typename T> inline void write(R T x) {
	if(x<0)  putchar('-'),x=-x;
	if(x>9)  write(x/10);
	putchar(x%10+'0');
}
template <typename T> inline void print(C T &x,C char &end) {
	write(x);
	putchar(end);
}

template <typename T> inline T gcd(C T &x,C T &y){return(y==0?x:gcd(y,x%y));}
template <typename T> inline void Swap(R T &x,R T &y){x^=y;y^=x;x^=y;}
template <typename T> inline void Swap_com(R T &x,R T &y){C T t=x;x=y;y=t;}
template <typename T> inline T POW(T x,T p,T mod) {
	R T res=1;
	while(p) {
		if(p&1)  res=(res*x)%mod;
		x=(x*x)%mod;  p>>=1;
	}
	return res;
}

///////////////////////////////////////////////////////////////////////////////
/////////////////////////////       Program       /////////////////////////////
/////////////////////////////        Heads        /////////////////////////////
/////////////////////////////    Don not touch    /////////////////////////////
///////////////////////////////////////////////////////////////////////////////

#define read Read<int>
#define readll Read<ll>



int main() {
//	judge();
	int n;  cin>>n;
	if(n>999)  cout<<"ABD\n";
	else  cout<<"ABC\n";
	
	
	return 0;
}

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

int main()
{
    ll h, w;
    cin >> h >> w;
    
    ll ans = 1;
    if (!(h == 1 || w == 1))
    {
        ans = (h * w + 1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Extentions;

class IO
{
    int idx;
    string[] input = In.ReadToEnd().Split(new[] { " ", "\n", "\r" },
        StringSplitOptions.RemoveEmptyEntries);

    T Get<T>(Func<string, T> parser) => parser(input[idx++]);

    public string S => Get(s => s);
    public char C => Get(char.Parse);
    public int I => Get(int.Parse);
    public long L => Get(long.Parse);
    public double F => Get(double.Parse);
    public decimal D => Get(decimal.Parse);
    public BigInteger B => Get(BigInteger.Parse);

    T[] Gets<T>(int n, Func<string, T> parser)
        => input.Skip((idx += n) - n).Take(n).Select(parser).ToArray();

    public string[] Ss(int n) => Gets(n, s => s);
    public char[] Cs(int n) => Gets(n, char.Parse);
    public int[] Is(int n) => Gets(n, int.Parse);
    public long[] Ls(int n) => Gets(n, long.Parse);
    public double[] Fs(int n) => Gets(n, double.Parse);
    public decimal[] Ds(int n) => Gets(n, decimal.Parse);
    public BigInteger[] Bs(int n) => Gets(n, BigInteger.Parse);

    public void Write<T>(params T[] xs) => WriteLine(string.Join(" ", xs));
    public void Write(params object[] xs) => WriteLine(string.Join(" ", xs));
}

#region Library

static class Extentions
{
}

#endregion

static class Program
{
    public static void Main()
    {
        var sw = new StreamWriter(OpenStandardOutput()) { NewLine = "\n" };
#if DEBUG
        sw.AutoFlush = true;
#else
        sw.AutoFlush = false;
#endif
        SetOut(sw);
        Solve(new IO());
        Out.Flush();
    }

    static void Solve(IO io)
    {
        var n = io.L;
        var m = io.L;
        var k = io.L;

        for (var i = 0L; i <= n; i++)
        {
            for (var j = 0L; j <= m; j++)
            {
                if (k == (n - i) * j + (m - j) * i)
                {
                    io.Write("Yes");
                    return;
                }
            }
        }

        io.Write("No");
        return;
    }
}

Measured memory_bytes: 13268
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i,a,b) for(ll i=(a);i<(b);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

struct state{ int y,x,dir,bs,s; };

int main(){
    int h,w,a;
    cin>>h>>w>>a;
    vector<string> vs(h);
    rep(i,h)cin>>vs[i];
    
    pii s,g;
    rep(i,h)rep(j,w){
        if(vs[i][j]=='S')s = pii(i,j);
        if(vs[i][j]=='G')g = pii(i,j);
    }
    
    static int dp[101][101][4][11][11];
    rep(i,101)rep(j,101)rep(k,4)rep(l,11)rep(m,11)dp[i][j][k][l][m] = INF;
    dp[s.first][s.second][0][0][0] = 0;
    
    queue<state> que;
    que.push(state{s.first, s.second, 0, 0, 0});
    
    // '\', '/'
    //テ、ツクツ? テ・ツ渉ウ, テ、ツクツ? テ・ツキツヲ
    int dy[]={1,0,-1,0};
    int dx[]={0,1,0,-1};
    
    while(que.size()){
        state q = que.front();
        que.pop();
        
        for(int k = 1;;k++){
            int ddy = q.y+dy[q.dir]*k;
            int ddx = q.x+dx[q.dir]*k;
            
            if( q.dir == 2 && pii(ddy,ddx)==s)break;
            if(pii(ddy,ddx)==s)continue;
            
            if(ddx<0 || ddy<0 || ddx>=w || ddy>=h)break;
            if(vs[ddy][ddx]=='#')break;
            
            int bsnum,snum;
            
            //テヲツ卍づィツィツ暗・ツ崢榲」ツつ甘・ツ崢榲ィツサツ「
            if(q.dir%2==0)  bsnum = 0, snum = 1;
            else            bsnum = 1, snum = 0;
            if( q.bs+bsnum<=a && q.s+snum<=a ){
                if( dp[ddy][ddx][(q.dir+3)%4][q.bs+bsnum][q.s+snum] == INF ){
                    dp[ddy][ddx][(q.dir+3)%4][q.bs+bsnum][q.s+snum] = dp[q.y][q.x][q.dir][q.bs][q.s] + 1;
                    que.push( state{ddy, ddx, (int)(q.dir+3)%4, q.bs+bsnum, q.s+snum} );
                }
            }
            
            //テ・ツ渉催ヲツ卍づィツィツ暗・ツ崢榲」ツつ甘・ツ崢榲ィツサツ「
            if(q.dir%2==1)  bsnum = 0, snum = 1;
            else            bsnum = 1, snum = 0;
            if( q.bs+bsnum<=a && q.s+snum<=a ){
                if( dp[ddy][ddx][(q.dir+1)%4][q.bs+bsnum][q.s+snum] == INF ){
                    dp[ddy][ddx][(q.dir+1)%4][q.bs+bsnum][q.s+snum] = dp[q.y][q.x][q.dir][q.bs][q.s] + 1;
                    que.push( state{ddy, ddx, (int)(q.dir+1)%4, q.bs+bsnum, q.s+snum} );
                }
            }
        }
    }
    
    int ans = INF;
    rep(i,4){
        for(int k=1;;k++){
            int ddy = g.first+dy[i]*k;
            int ddx = g.second+dx[i]*k;
            
            if(ddx<0 || ddy<0 || ddx>=w || ddy>=h)break;
            if(vs[ddy][ddx]=='#')break;

            if( i == 0 && pii(ddy,ddx)==s)break;

            rep(l,a+1){
                rep(m,a+1){
                    ans = min(ans, dp[ddy][ddx][(i+2)%4][l][m]);
                }
            }
        }
    }
    if(ans>2*a)cout<<-1<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 23196
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
bool check(const vector<pair<int, int>>& s) {
    int h = 0;
    for (const auto& p : s) {
        if (h + p.first < 0)
            return false;
        h += p.second;
    }
    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, total = 0;
    cin >> n;
    vector<pair<int, int>> ls, rs;
    for (int i = 0; i < n; i++) {
        string tmp;
        int l = 0, b = 0;
        cin >> tmp;
        for (const char& c : tmp) {
            if (c == '(')
                l++;
            else
                l--;
            b = min(b, l);
        }
        if (l > 0)
            ls.emplace_back(b, l);
        else
            rs.emplace_back(b - l, -l);
        total += l;
    }
    sort(ls.rbegin(), ls.rend());
    sort(rs.rbegin(), rs.rend());
    /*
    cout << total << endl;
    for (auto& p : ls)
        cout << "(" << p.first << ", " << p.second << ") ";
    cout << endl;
    for (auto& p : rs)
        cout << "(" << p.first << ", " << p.second << ") ";
    cout << endl;
    */
    if (check(ls) && check(rs) && total == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 11296
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;

int N;

int main() {
    vector<int> A(3);
    cin >> A[0] >> A[1] >> A[2];
    sort(A.begin(), A.end());
    int ans = 0;
    if ((A[1] - A[0]) % 2) {
        A[0]++; A[2]++; ans++;
    }
    ans += (A[1] - A[0]) / 2 + A[2] - A[1];
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
	int i,n, x = 100000;
	while(scanf("%d",&n) != EOF){
		for(i=0;i<n;i++){
			x = x*1.05;
			if((x%1000)>0) x = x-(x%1000)+1000 ;
		}
		printf("%d\n",x);
	}
	
	
	return 0;
}

Measured memory_bytes: 592
def main():
    A, B = input().split()

    A = int(A)
    B = float(B)

    B100 = int(B * 100 + 0.001)  # 100倍しても1にならない数を足している?

    print(A * B100 // 100)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9148
// ABC067_A.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
	int a, b;
	char op;
	cin >> a >> op >> b;
	if (op == '+') {
		cout << a + b << endl;
		return 0;
	}
	cout << a - b << endl;
	return 0;
}



Measured memory_bytes: 256
function judge(N, number){
  var devide = Math.floor(N/number);
  return (N%number==devide)
}

function main(input){
  const lines = input.split('\n');
  const N = parseInt(lines[0]);

  var result = 0;
  for(var i=1;i<Math.sqrt(N);i++){
//  console.log('---');
//  console.log(i);
    if(N/i-Math.floor(N/i)>0){continue;}
    var favorited_number = N/i-1
    if(judge(N,favorited_number)){result+=favorited_number}
//  console.log(favorited_number);
  }

  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 11596
#include <iostream>
#define MAXN 100
using namespace std;
int main(){
	int N, M;
	int v[MAXN], sum = 0;
	int thres, cnt = 0;
	cin >> N >> M;
	for(int i=0; i<N; i++){
		cin >> v[i];
		sum += v[i];
	}
	thres = (sum - 1) / (4 * M);
	for(int i=0; i<N; i++)
		cnt += (v[i] > thres);
	cout << ((cnt >= M)? "Yes\n":"No\n");
}



Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var nx = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long X = nx[1];
        //ちゅーごくじょーよてーり
        //オーダーによってSの終端が決定する
        //まず影響するのは降順のみなことは自明に分かって、
        //で、「次」を選ぶことができる順番は
        //「確率」「期待値」
        //aを取り除いた場合、その後に適用できるのはそれ以前全て。

        List<int> s = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToList();
        ModInt[] dp = new ModInt[X + 1];
        dp[X] = 1;
        long remain = s.Count - 1;
        foreach (var mod in s)
        {
            ModInt[] newDP = new ModInt[X + 1];

            for (int i = 0; i < dp.Length; i++)
            {
                newDP[i % mod] += dp[i];
                newDP[i] += dp[i] * remain;
            }
            remain--;
            dp = newDP;
        }
        ModInt res = 0;
        for (int i = 0; i < dp.Length; i++)
        {
            res += dp[i] * i;
        }
        Console.WriteLine(res);
    }
}

struct ModInt
{
    static int MOD = 1000000007;
    long Data;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public ModInt(long data) { if ((Data = data % MOD) < 0) Data += MOD; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator long(ModInt modInt) => modInt.Data;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator ModInt(long val) => new ModInt(val);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator +(ModInt a, ModInt b)
    {
        long res = a.Data + b.Data;
        return new ModInt() { Data = res >= MOD ? res - MOD : res };
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator +(ModInt a, long b) => new ModInt(a.Data + b);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator -(ModInt a, ModInt b)
    {
        long res = a.Data - b.Data;
        return new ModInt() { Data = res < 0 ? res + MOD : res };
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator -(ModInt a, long b) => new ModInt(a.Data - b);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator /(ModInt a, ModInt b) => a * Power(b, MOD - 2);

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    static ModInt Power(ModInt n, long m)
    {
        ModInt res = 1;
        while (m > 0)
        {
            if ((m & 1) == 1) res *= n;
            n *= n;
            m >>= 1;
        }
        return res;
    }
}


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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  ll n;
  cin >> n;
  vll a(n);
  REP(i, n) {
    cin >> a[i];
  }
  vll b = a;
  RSORT(a);

  REP(i, n) {
    if (b[i] == a[0]) {
      COUT(a[1]);
    }
    else {
      COUT(a[0]);
    }
  }
}


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

/*
3
1
4
3
*/


Measured memory_bytes: 6376
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <limits>
typedef long long ll;
#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 in cin
#define out cout
#define pb push_back
using namespace std;
int main(){
	//a??£?§£b????????¶c??£?§£?????????d???????????°
	int n, m, a[101];
	in >> n >> m;
	REP(i, n)in >> a[i];
	FOR(i, 1, m) {
		REP(j, n - 1) {
			if (a[j] % i > a[j + 1] % i) {
				int tmp = a[j];
				a[j] = a[j + 1];
				a[j + 1] = tmp;
			}
		}
	}
	REP(i, n) {
		out << a[i] << endl;
	}
	in >> n;
	return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
const int N = 200003;
int n, sr, sb, p1[N], p2[N], fab[N], disb[N], disr[N], q[N], front, rear;
vector<int> Er[N], Eb[N];
bool vis[N], win[N];
inline void dfs(int x){
	for(Rint v : Eb[x]) if(v != fab[x]){
		fab[v] = x; disb[v] = disb[x] + 1; dfs(v);
	}
}
inline bool check(int x, int y){
	return fab[x] == y || fab[y] == x || fab[x] == fab[y] || fab[fab[x]] == y || fab[fab[y]] == x;
}
inline void bfs(int S){
	front = rear = 0; q[rear ++] = S;
	memset(disr, 0x3f, sizeof disr);
	disr[S] = 0;
	while(front < rear){
		int now = q[front ++];
		vis[now] = 1;
		for(Rint v : Er[now])
			if(disr[v] > disr[now] + 1 && disb[v] > disr[now] + 1){
				disr[v] = disr[now] + 1; q[rear ++] = v;
			}
	}
}
int main(){
	scanf("%d%d%d", &n, &sr, &sb);
	for(Rint i = 1;i < n;i ++)
		scanf("%d%d", p1 + i, p2 + i);
	for(Rint i = 1;i < n;i ++){
		int x, y;
		scanf("%d%d", &x, &y);
		Eb[x].push_back(y); Eb[y].push_back(x);
	}
	dfs(sb);
	for(Rint i = 1;i < n;i ++)
		if(!check(p1[i], p2[i])) win[p1[i]] = win[p2[i]] = true;
		else {Er[p1[i]].push_back(p2[i]); Er[p2[i]].push_back(p1[i]);}
	bfs(sr);
	int ans = 0;
	for(Rint i = 1;i <= n;i ++)
		if(vis[i] && win[i]){puts("-1"); return 0;}
		else if(vis[i]) ans = max(ans, disb[i]);
	printf("%d", ans << 1);
}

Measured memory_bytes: 32000
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 

int main() {
    ll a,b,c; cin >> a >> b >> c;
 
    set<ll> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
 
    cout << s.size() << endl;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N,K;
int main(){
	string str;
	cin>>str;
	str='>'+str+'<';
	N=str.size();
	vi memo;
	int ans[514514];
	rep(i,514514)ans[i]=-1;
	rep(i,N-1){
		if(str[i]=='>'&&str[i+1]=='<'){
			ans[i+1]=0;
			int temp=i;
			int now=0;
			while(temp>=0&&str[temp]=='>'){
				now++;
				ans[temp]=max(now,ans[temp]);
				temp--;
			}
			now=0;
			temp=i+1;
			while(temp<N&&str[temp]=='<'){
				now++;
				ans[temp+1]=max(now,ans[temp]);
				temp++;
			}

		}
	}
	/*rep(i,N)cout<<ans[i]<<" ";
	cout<<endl;*/
	ll ret=0;
	rep(i,N-1){
		ret+=(ll)ans[i+1];
	}
	cout<<ret<<endl;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll a, b, c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " <<  b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<bool> vb;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;
typedef vector<double> vd;


const int mod = 1000000007;
const int inf = 1000000000;
const int N = 200007, M = N;
ll i,j,cnt,par,n;

void solve() {
   ll n;
   cin>>n;

   vi vec(n) , temp(n);

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

   temp[0] = vec[0];
   for(int i=1;i<n;i++) temp[i] = max(temp[i-1] , vec[i]);

   ll ans = 0;
   for(int i=n-1;i>=0;i--) {
     ans+=abs(temp[i] - vec[i]);
   }
   cout<<ans<<"\n";
}



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

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

    return 0;
}




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

using namespace std;

typedef long long ll;

#define FOR(a, b, i) for(int i=a; i<b; i++)
#define RFOR(a, b, i) for(int i=a; i>=b; i--)
#define PB push_back
#define MP make_pair
#define MOD 1e9+7
#define newline cout<<"\n"




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

    int x, a; cin>>x>>a;
    if(x<a) cout<<0<<endl;
    else cout<<10<<endl;

    return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    let mut v2 = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let v = s.trim().split_whitespace()
            .map(|e| e.parse().ok().unwrap()).collect();
        v2.push(v);
    }
    v2
}

fn main() {
    let n: usize = read();
    let mut s = Vec::new();
    for i in 0..n {
        let ss: usize = read();
        s.push(ss);
    }
    s.sort();
    let sum = s.iter().fold(0, |sum, ss| sum + ss);
    if sum % 10 != 0 {
        println!("{}", sum);
    } else {
        let mut min = 1000000;
        for i in 0..n {
            if s[n-i-1] % 10 != 0 {
                min = s[n-i-1];
            }
        }
        if min == 1000000 {
            print!("{}", 0);
        } else {
            println!("{}", sum-min);
        }
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define rep(i,a,b) for(int i = a ; i < b ; ++i)

typedef long long ll ; 
typedef long double ld ; 
typedef pair<int,int> pii ; 
typedef pair<ll,ll> pll ;

template<class T> bool umin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool umax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int MOD = 1e9+9 ;
const ll inf = 1e18 ;  
const ll mod = 1e9+7 ;  

ll nCr(ll n,ll r){ll t=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){t*=(n-i);t/=(i+1);}return t;}
ll power(ll a, ll n) { ll r=1;while(n){if(n&1)r=(r*a)%MOD;n>>=1;a=(a*a)%MOD;}return r%MOD;}



vt<pii> dir =  {{-1,0} , {1, 0} , {0,-1} , {0,1}} ; 

// ==========Start Here==============

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
 	int n , k ;
 	cin >> n >> k ; 
 	vt<int> a(n) ; 
 	rep(i,0,n) cin >> a[i] ; 
 	sort(all(a) , greater<int>()) ; 
 	ll ans= 0 ; 
 	rep(i,k,n) 
 		ans += a[i] ; 
 	cout << ans ;

	return 0 ; 
}

Measured memory_bytes: 3940
const main = (input) => {
  let [S, L, H, M] = input.trim().split(' ').map(Number)
  H = H % 12
  M = M % 60

  const l_angle = 360 * (M / 60)
  const s_angle = 360 * (H / 12) + (30 * (M / 60))

  if (Math.abs(s_angle - l_angle === 180)) return console.log(S + L)

  const dif = Math.abs(s_angle - l_angle)
  let angle = dif > 180 ? 360 - (dif) : dif
  angle = angle * Math.PI / 180

  return console.log(Math.sqrt((S**2) + (L**2) - (2 * S * L * Math.cos(angle))))
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

int N, R;

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> R;
    if (N>=10) cout << R << endl;
    else cout << R+100*(10-N) << endl;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  ll n, m;
  scanf("%lld %lld", &n, &m);

  ll ans = 0;
  if (n == 1 and m == 1) {
    ans = 1;
  }
  else if (n == 1 or m == 1) {
    ans = max(0LL, max(n, m) - 2);
  }
  else {
    ans = (n - 2) * (m - 2);
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256