akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,e)for(int i=0;i<e;i++)
using namespace std;

int main(){
    int n, i, j;
    int x[1005];
    int y[1005];
    double D=0;
    cin >> n;
    rep(i,n) cin >> x[i];
    rep(i,n) cin >> y[i];
    rep(i,n) D += abs(x[i]-y[i]);
    printf("%.8f\n", D);
    D = 0;
    rep(i,n) D += pow(x[i]-y[i], 2);
    printf("%.8f\n", sqrt(D));
    D = 0;
    rep(i,n) D += pow(abs(x[i]-y[i]), 3);
    printf("%.8f\n", pow(D,(double)1/3));
    D = 0;
    int max = abs(x[0]-y[0]);
    rep(i, n) if(max < abs(x[i]-y[i])) max = abs(x[i]-y[i]);
    D = max;
    printf("%.8f\n", D);
    return 0;
}


Measured memory_bytes: 3332
#include <bits/stdc++.h>
using namespace std;
long long ans;
int N;
pair<int,int>a[111111];
pair<int,int>b[111111];
map<int,vector<pair<int,int>>>mp;
struct PCSZ {
  // assumption: every root node points itself.
  struct node_t {
    int parent;
    int size;
    node_t() : size(1) {}
  };
  vector<node_t> nodes;

  PCSZ(int size) : nodes(size) {
    for (int i = 0; i < size; i++) {
      nodes[i].parent = i;
    }
  }

  // find root node
  int find(int index) {
    int root = index;
    while (root != nodes[root].parent) {
      root = nodes[root].parent;
    }
    while (root != nodes[index].parent) {
      int next = nodes[index].parent;
      nodes[index].parent = root;
      index = next;
    }
    return root;
  }

  // true if merge was successful
  bool merge(int first, int second) {
    int r1 = find(first);
    int r2 = find(second);
    if (r1 == r2) {
      return false;
    }
    if (nodes[r1].size < nodes[r2].size) {
      // careful, first and second not swapped
      swap(r1, r2);
    }
    nodes[r1].size += nodes[r2].size;
    nodes[r2].parent = r1;
    return true;
  }

  int group_size(int index) {
    return nodes[find(index)].size;
  }
};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>N;
    for(int i=0;i<N;i++){
        int x,y;
        cin>>x>>y;
        a[i]={x,i};
        b[i]={y,i};
    }
    sort(a,a+N);
    sort(b,b+N);
    for(int i=0;i<N-1;i++){
        mp[a[i+1].first-a[i].first].push_back({a[i+1].second,a[i].second});
        mp[b[i+1].first-b[i].first].push_back({b[i+1].second,b[i].second});
    }
    PCSZ uf(N);
    for(auto &p:mp){
        for(auto &q:p.second){
            if(uf.find(q.first)!=uf.find(q.second)){
                uf.merge(q.first,q.second);
                ans += p.first;
            }
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 8064
N = int(input())

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
      
print(num2alpha(N).lower())

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll PrimeMax = 1000001;
int is_prime[PrimeMax];
void Eratosthenes(){
  for(int i = 0; i < PrimeMax; i++){
    is_prime[i] = 1;
  }
  is_prime[0] = 0;
  is_prime[1] = 0;
  for(int i = 2; i < PrimeMax ; i++){
    if(is_prime[i]){
      for(int j = 0; i * (j + 2) < PrimeMax; j++){
        is_prime[i *(j + 2)] = 0;
      }
    }
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  Eratosthenes();
  vector<ll> pr;
  rep(i,PrimeMax){
    if(i > 105000) break;
    if(is_prime[i] ){
      pr.push_back(i);
    }
  }
  /* std::cout << pr.size() << std::endl; */
  ll n,p;
  while(cin >> n >> p && (n+p > 0)){
    auto lw = upper_bound(all(pr),n);
    vector<ll> ans(150000);
    int k = 0;
    for(auto it = lw; it != pr.end();it++){
      for(auto it2 = it; it2 != pr.end();it2++){
        /* if(*it + *it2 > n * n && ans.size() > p) break; */
        if(k >= ans.size()) break;
        ans[k] = (*it + *it2);
        ++k;
      }
    }
    sort(ans.begin(),ans.begin()+k);
    /* rep(i,40){                        */
    /* std::cout << ans[i] << std::endl; */
    /* }                                 */
    cout << ans[p-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 8176
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
    ll x; cin >> x;
    ll ans = 0;
    ans += x / 500 * 1000;
    x %= 500;
    ans += x / 5 * 5;
    cout << ans << endl;
    return 0;
}

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

//{{{
#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif
using namespace std;
typedef long long LL;
typedef vector<int> VI;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
// clang-format off
#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr<<endl;}
 vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x;
 while (getline(ss, x, c)) v.push_back(x); return v;} void err(vector<string>::iterator) {}
 template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args)
{cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}
// clang-format on
//}}}
//

int T;

const int mod = 1e9 + 7;
const int N = 2e5 + 10;
int x;

int a, b, c, k;

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif

    // scanf("%d", &T);

    // for (int i = 400; i <= 1999; i++)
    //{
    // int v = func(i);
    // debug(i, v);
    //}
    // int cas = 1;
    while (cin >> a >> b >> c >> k)
    {
        int cnt = 0;
        while (b <= a)
        {
            b *= 2;
            cnt++;
        }
        while (c <= b)
        {
            c *= 2;
            cnt++;
        }
        if (cnt <= k)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>

using namespace std;

int main()
{
	int N, I;
	bool result = true;

	cin >> N;
	for(int i = 0; i < N; i++)
	{
		cin >> I;
		if (I % 2 == 0)
		{
			if(I % 3 != 0 and I % 5 != 0)
			{
				result = false;
			}
		}
	}
	if(result)
	{
		cout << "APPROVED" << endl;
	}
	else
	{
		cout << "DENIED" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n;
  vector<string> S(n); rep(i, n) cin >> S[i];
  cin >> m;
  vector<string> T(m); rep(i, m) cin >> T[i];
  map<string, int> mp;
  rep(i, n) mp[S[i]]++;
  rep(i, m) mp[T[i]]--;
  int ans = 0;
  for(auto ele: mp) chmax(ans, ele.second);
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 3632
/*
Author : Hocky Yudhiono
5/31/2020 7:01:14 PM

1. You can sort the query if offline!
2. Don't bring the dp remaining state when dfsing on DP on Tree.
3. Try to reverse (Think from the back) if you stuck.
4. Be careful when submitting Div. 2 D-F, dont waste it on stupid WAs.
5. Try to reduce a problem
*/

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <cstdio>
#include <limits>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef vector<int> vi;
typedef pair<LL,LL> PLL;
typedef pair<LL,int> PLI;
typedef pair<int,int> PII;
typedef pair<int,int> pii;
typedef vector<vector<LL>> VVL;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define popf pop_front
#define pf push_front
#define popb pop_back
#define mp make_pair
#define pb push_back
#define remove erase
#define fi first
#define se second

//If the time limit is strict, try not to use long double

//Remember to undefine if the problem is interactive
#define endl '\n'
#define DEBUG(X) cout << ">>> DEBUG(" << __LINE__ << ") " << #X << " = " << (X) << endl

const double EPS = 1e-9;
const int INFMEM = 63;
const int INF = 1061109567;
const LL LINF = 4557430888798830399LL;
const double DINF = numeric_limits<double>::infinity();
const LL MOD = 1000000007;
const int dx[8] = {0,0,1,-1,1,-1,1,-1};
const int dy[8] = {1,-1,0,0,1,-1,-1,1};
// Do dir^1 to get reverse direction
const char dch[4] = {'R','L','D','U'};
// const string ds[8] = {"E","W","S","N","SE","NW","SW","NE"};
const double PI = 3.141592653589793;

inline void open(string a){
    freopen((a+".in").c_str(),"r",stdin);
    freopen((a+".out").c_str(),"w",stdout);
}

inline void fasterios(){
    //Do not use if interactive
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

LL n;
LL maksi = 1000000000000000000LL;

void cant(){
    cout << -1 << endl;
    // cout << "Impossible" << endl;
    exit(0);
}

vector <LL> isi;

int main(){
    cin >> n; isi.resize(n);
    LL ans = 1;
    for(int i = 0;i < n;i++){
        cin >> isi[i];
    }
    sort(isi.begin(),isi.end());
    trav(tmp,isi){
        if(tmp == 0){
            ans = 0;
            break;
        }
        if(ans > maksi/tmp) cant();
        ans *= tmp;
    }
    if(ans == -1 || ans > maksi) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

ll dp[100005][15];
int main() {
	string S;
	cin>>S;
	dp[0][0] = 1;
	ll N = S.size();
	ll keta = 1;
	for (int i = 0; i < N; ++i){
		int d = N - 1 - i;
		if(S[d] == '?'){
			rep(j,13)rep(k,10){
				dp[i+1][((k*keta)%13 + j)%13] += dp[i][j];
				dp[i+1][((k*keta)%13 + j)%13] %= MOD;			}
		}
		else{
			int x = int(S[d] - '0');
			rep(j,13){
			dp[i+1][((x * keta) % 13 + j)%13] += dp[i][j];
			dp[i+1][((x * keta) % 13 + j)%13] %= MOD;
			}
		}
		keta *= 10;
		keta %= 13;
	}
	ll ans = dp[N][5];
	cout<<ans<<endl;
}

Measured memory_bytes: 12160
while True:
    a,op,b=input().split()
    a = int(a)
    b = int(b)
    if op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(a//b)
    else:
        break


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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

const int MAXN = 100010;
const int MOD = 1000000007;

int n, m;
int pos[MAXN];
int c1[3][3], c2[3][3], ha[3][3], ret[3][3], tmp[3][3];

void mul(int A[3][3], int B[3][3], int C[3][3])
{
	memset(tmp, 0, sizeof tmp);
	FOR(i, 0, 2) FOR(k, 0, 2) {
		int pyh = A[i][k];
		FOR(j, 0, 2) tmp[i][j] = (tmp[i][j] + pyh * 1ll * B[k][j]) % MOD;
	}
	memcpy(C, tmp, sizeof tmp);
}

void solve()
{
	std::sort(pos + 1, pos + m + 1);

	int lst = 1;

	c1[0][0] = c1[0][2] = c1[1][1] = c1[1][2] = c1[2][0] = 1;
	c1[0][1] = c1[2][1] = c1[2][2] = 2;

	c2[0][0] = c2[0][2] = c2[1][1] = c2[1][2] = c2[2][2] = 1;
	c2[0][1] = 2;

	ret[0][0] = ret[1][1] = ret[2][2] = 1;
	
	FOR(i, 1, m) {
		memcpy(ha, c1, sizeof c1);
		int step = pos[i] - lst;
		while (step) {
			if (step & 1) mul(ret, ha, ret);
			mul(ha, ha, ha);
			step >>= 1;
		}
		mul(ret, c2, ret);
		lst = pos[i] + 1;
	}
	memcpy(ha, c1, sizeof c1);
	int step = n - lst;
	while (step) {
		if (step & 1) mul(ret, ha, ret);
		mul(ha, ha, ha);
		step >>= 1;
	}
	printf("%d\n", ((ret[0][2] + 2 * ret[1][2] % MOD) % MOD + ret[2][2]) % MOD);
}

int main()
{
	in(n); in(m);
	FOR(i, 1, m) in(pos[i]);
	solve();
	return 0;
}


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

#define int long long
#define ci(m)     for(int i=0;i<m;i++)
#define cj(m)     for(int j=0;j<m;j++)
#define ck(m)     for(int k=0;k<m;k++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;
int n;
int a[200001];
map<pair<pair<int,int>,int>,int>m;
int solve(int index,int last_selected,int selected)
{
    int idx=index-1;
    if(index==n+1)
    {
        if(selected==n/2)
            return 0;
        else
            return -1e15;
    }
    if(m.count({{index,last_selected},selected}))
        return m[{{index,last_selected},selected}];
   if((n/2)-((n-idx+1)/2)<=selected)
   {

       if(last_selected)
          return  m[{{index,last_selected},selected}]=solve(index+1,false,selected);
       else
           return m[{{index,last_selected},selected}]=max(solve(index+1,true,selected+1)+a[index],solve(index+1,false,selected));
   } else
       return -1e15;

}
int32_t main() {
    nitin;
    cin>>n;
    ci(n) cin>>a[i+1];
    cout<<solve(1,false,0);
    return 0;
}

Measured memory_bytes: 67712
import sys

from numba import njit

input = sys.stdin.readline


@njit
def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table


def main():
    N = int(input())

    table = num_divisors_table(N)

    ans = 0
    for i, v in enumerate(table):
        ans += i * v

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 266356
#include<bits/stdc++.h>
using namespace std;
bool ispal(string a)
{
    long long int n=a.length();
    if(n==1)
        return true;
    else{
    int i=0,j;
    j=n-1;
    while(1)
    {
        if(a[i]!=a[j])
        {
            cout<<i<<" "<<j;
           return false;
        }
        i++,j--;
        if(i==j)
         {
        //     cout<<i<<" ";
             break;
        }
    }
    return true;
}}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
    long long int n;
    cin>>n;
    int a[n],ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(i%2==1)
        {
            if(a[i]%2==1)
                ans++;
        }
    }
    cout<<ans;
}

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

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

Measured memory_bytes: 256
#include<stdio.h>

int main(int argc, char* argv[])
{
  char a, b, c;
  int i, j, h, w;
  scanf("%d %d", &h, &w);

  while((h != 0)||(w != 0)){
    a = '.'; b = '#';
    for(i = 0; i < h; i++){
      c = a; a = b; b = c;
      for(j = 0; j < w; j++){
        if((j+1)%2 == 1){
          printf("%c", a);
        }else{
          printf("%c", b);
        }
      }
      printf("\n");
    }
    printf("\n");
    scanf("%d %d", &h, &w);
  }
  return(0);
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int add = 10;
  int ans = 0;
  rep (i,0,5) {
    int temp;
    cin >> temp;
    int mod = temp % 10;
    ans += temp - temp % 10;
    if (mod != 0) {
      ans += 10;
      add = min(add, mod);
    }
  }
  ans -= (10 - add);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const int MOD = 1000000007;
ll gcd(ll x, ll y){
  if(y==0)return x;
  else return gcd(y,x%y);
}
int main() {
  int n;
  cin >> n;
  vector<int>vec(n);
  vector<int>seat(n);
  rep(i,n) cin >> vec[i];
  rep(i,n){
    int num=n+1-vec[i];
    if(num%2!=0){
      cout << 0 << endl;
      return 0;
    }
    int k = abs(num/2);
    seat[k-1]++;
    if((k-1)!=(n-k))seat[n-k]++;
  }
  ll ans=1;
  rep(i,(n+1)/2){
    
    if(seat[i]<2){
      if(n%2==0){
        cout << 0 << endl;
        return 0;
      }
      else{
        if(i!=(n+1)/2-1){
          cout << 0 << endl;
          return 0;
        }
      }
    }
    ans*=seat[i];
    ans%=MOD;
  }
  cout <<ans << endl;
  
}

Measured memory_bytes: 1024
n = int(input())
a = []

for i in range(n):
    inp = input()
    if "-1" in inp:
        inp = inp.replace("-1","10000")
    a.append(list(map(int, inp.split())))

w = 0
v = set()
v.add(0)

while len(v) < n:
    min_w   = 10000
    min_idx = 0
    i = 0
    for node in v:
        if min_w > min(a[node]):
            min_w = min(a[node])
            i = node
            min_idx = a[i].index(min_w)
    if min_idx in v:
        a[i][min_idx] = 10000
        continue
    else:
        w += min_w
        v.add(min_idx)

print(w)

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

#define lli long long int
#define endl "\n"
#define forn(i, in, fin) for(int i = in; i<fin; i++)
#define all(v) v.begin(), v.end()
#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;


int main()
{
    //fastIO();
    lli n; cin>>n;

    lli dp[n][n];

    vector<lli> nums(n);

    for(auto &x: nums)
    {
        cin>>x;
    }
    for(int L = n-1; L>=0; L--) 
    {
        for(int R = L; R<n; R++)
        {
            if(L==R) 
            {
                dp[L][R] = nums[L];
                continue;
            }
            dp[L][R] = max(nums[L] - dp[L+1][R],  nums[R] - dp[L][R-1]);
            //cout<<dp[L][R]<<endl;
        }
    }

    cout<<dp[0][n-1]<<endl;

    return 0;
}

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

using namespace std;

int main(void)
{
    string s;
    int len_max = 0;
    cin >> s;
    int len=0;
    
    for (int i = 0; i < s.size(); i++)
    {
        for (int j = i; j < s.size(); j++)
        {
            string sub;
            for(int k = i;k<=j;k++)
            {
                sub.push_back(s[k]);
            }

            bool isATGC=true;
            for(auto ss :sub)
            {
                if(!(ss == 'A'||ss == 'T'||ss == 'C'||ss == 'G'))
                {
                    isATGC=false;
                    break;
                }
            }
            if(isATGC)
            {
                len=j-i+1;
            }else{
                len=0;
            }

            if(len>len_max)
            {
                len_max=len;
            }
        }
    }

    cout << len_max<<endl;;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i=0; i<n; i++) cin >> h[i];
  vector<int> dp(n);
  dp[0] = 0;
  dp[1] = abs(h[0]-h[1]);
  for(int i=0; i<n-1; i++){
    dp[i+2] = min(dp[i]+abs(h[i]-h[i+2]),dp[i+1]+abs(h[i+1]-h[i+2]));
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
//#define ivorysi
using namespace std;
typedef long long int64;
template<class T> 
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int64 t[3],D;
vector<pair<int64,int64> > v;
int ans;
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
int mul3(int a,int b,int c) {
    return mul(mul(a,b),c);
}
void update(int &x,int y) {
    x = inc(x,y);
}
void Solve() {
    for(int i = 0 ; i < 3 ; ++i) read(t[i]);read(D);
    for(int64 i = 0 ; i <= D ; ++i) {
	for(int j = 0 ; j < 3 ; ++j) {
	    if(i && i < t[j]) v.pb(mp(i,t[j]));
	    if(t[j] - 1 - i > 0) v.pb(mp(t[j] - i - 1,t[j]));
	}
    }
    sort(v.begin(),v.end(),[](pair<int64,int64> a,pair<int64,int64> b){return a.fi * b.se < b.fi * a.se;});
    v.erase(unique(v.begin(),v.end()),v.end());
    int64 a[3] = {0,0,0};
    update(ans,mul3(min(t[0],D + 1),min(t[1],D + 1),min(t[2],D + 1)));
    for(auto k : v) {
	int64 b[3] = {a[0],a[1],a[2]};
	for(int j = 0 ; j < 3 ; ++j) {
	    a[j] = t[j] * k.fi / k.se;
	}
	int64 d[3];
	for(int j = 0 ; j < 3 ; ++j) {
	    d[j] = min(b[j] + D,t[j] - 1) - max(b[j] - D,0LL) + 1;
	}
	for(int j = 0 ; j < 3 ; ++j) {
	    if(a[j] + D < t[j]) {
		int t = a[j] - b[j];
		for(int h = 0 ; h < 3 ; ++h) {
		    if(h != j) t = mul(t,d[h]);
		}
		update(ans,t);
	    }
	}
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 10604
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		long K = sc.nextLong();
		long[] aSum = new long[N+1];
		long[] bSum = new long[M+1];
		
		for(int i=0; i<N; i++) {
			int A = sc.nextInt();
			aSum[i+1] = aSum[i] + A;
		}
		for(int i=0; i<M; i++) {
			int B = sc.nextInt();
			bSum[i+1] = bSum[i] + B;
		}
		
		int ans = 0;
		
		for(int i=0; i<=N; i++) {
			if(aSum[i]>K)
				continue;
			int index = Arrays.binarySearch(bSum, K-aSum[i]);
			if(index<0) {
				index = -index - 2;
			}
			ans = Math.max(ans, i+index);
		}
		
		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 53464
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}
#define UNIT_MAX 100
#define NUM_MAX 100000

int main(void) {
    int ulimit = get_int();
    static int dp[NUM_MAX+1];
    int i;
    int units[UNIT_MAX];
    int uidx = 0;
    int unit = 6;
    while(ulimit >= unit) {
        units[uidx++] = unit;
        unit *= 6;
    }
    unit = 9;
    while(ulimit >= unit) {
        units[uidx++] = unit;
        unit *= 9;
    }
    int k;
    for(i = 0; i <= ulimit; i++) dp[i] = i;
    for(k = 0; k < uidx; k++) {
        int unit = units[k];
        for(i = 0; i <= ulimit-unit; i++) {
            dp[i+unit] = min(dp[i+unit], dp[i]+1);
        }
    }
    printf("%d\n", dp[ulimit]);
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int k=nxt();
   string s;
   cin>>s;
   if(s.length()<=k)
   {
    cout<<s<<endl;
    return 0;
   }
   for(int i=0;i<k;i++)
    cout<<s[i];
cout<<"...\n";
    
    
    return 0;   
}




 
 


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

const int INF = 1001001001;

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s.at(i);
  vector<vector<int>> dp(h, vector<int>(w, INF));
  if(s.at(0).at(0) == '.') dp.at(0).at(0) = 0;
  else dp.at(0).at(0) = 1;
  rep(i, h){
    rep(j, w){
      int di[] = {1, 0}, dj[] = {0, 1};
      rep(k, 2){
        int ni = i + di[k], nj = j + dj[k];
        if(nj < 0 || w <= nj || ni < 0 || h <= ni) continue;
        int add = 0;
        if(s.at(i).at(j) == '.' && s.at(ni).at(nj) == '#')add++;
        dp.at(ni).at(nj) = min(dp.at(ni).at(nj), dp.at(i).at(j) + add);
      }
    }
  }
  cout << dp.at(h-1).at(w-1) << endl;
  return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=105;
ll a[N],val[N];
vi v[4],v2[4];
int fun(int i,int j,int k,int c)
{
  ll done=(ll)(i+j+k)*a[1]+j+2*k;
  if(done>c) return 0;
  int take=(c-done)/(a[1]+3);
  return v2[0][i]+v2[1][j]+v2[2][k]+v2[3][take];
}
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n,c;
  cin>>n>>c;
  rep(i,1,n+1) cin>>a[i]>>val[i],v[a[i]-a[1]].pb(val[i]);
  rep(i,0,4) sort(all(v[i])),reverse(all(v[i]));
  rep(i,0,4)
    {
      v2[i].resize(sz(v[i])+1);
      v2[i][0]=0;
      rep(j,0,sz(v[i]))
	v2[i][j+1]=v2[i][j]+v[i][j];
    }
  int ans=0;
  rep(i,0,sz(v[0])+1)
    rep(j,0,sz(v[1])+1)
    {
      ll done=(ll)(i+j)*a[1]+j;
      if(done>c) continue;
      int low=0,high=sz(v[2]);
      while(high-low>=10)
	{
	  int mid1=low+(high-low+1)/3;
	  int mid2=high-(high-low+1)/3;
	  if(fun(i,j,mid1,c)>=fun(i,j,mid2,c)) high=mid2;
	  else low=mid1;
	}
      rep(k,low,high+1)
	ans=max(ans,fun(i,j,k,c));
    }
  cout<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
#define int long long
using namespace std;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int l) { uniform_int_distribution<int> uid(0, l - 1); return uid(rang); }

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n; cin >> n;
	int W; cin >> W;
	std::vector<int> v(n);
	vector<int> w(n); for (int o = 0; o < n; o++) { cin >> w[o] >> v[o]; }
	std::vector<int> minweight(102005, 100000000000ll);
	minweight[0] = 0;
	for (int i = 0; i < n; ++i)
		for (int j = 100000; j >= 0; --j) 
			minweight[j + v[i]] = min(minweight[j + v[i]], minweight[j] + w[i]);
	for (int i = 100000; i >= 0; --i) 
		if (minweight[i] <= W) {
			cout << i;
			exit(0);
		}
}

Measured memory_bytes: 1024
#include<cstdio>

int main(void){
  unsigned long long int s[1000000]={},k;
  int a,b,n;

  scanf("%d %llu",&n,&k);

  for(int i=0;i<n;i++){
    scanf("%d %d",&a,&b);
    s[a]+=b;
  }
  int i=0;
  unsigned long long int m=0;
  while(1){
    m+=s[i];
    if(m>=k){
      printf("%d\n",i);
      break;
    }
    i++;
  }

  return 0;
}



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

#define pb push_back

const int MAXN = 10004;

int N,small,cross,run[MAXN];
string T,s,p,q,a[MAXN];

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

    cin >> N;

    for(int i=0;i<N;i++){
        cin >> s;
        a[i] = s;
        int flag=0;
        for(int j=0;j<s.size();j++){
            if(s[j]=='?') flag = 1;
        }
        run[i] = flag;
    }
    cin >> T;

    for(int i=0;i<N;i++){
        s = a[i];
        if(run[i]){
            p = s; q = s;
            for(int j=0;j<s.size();j++){
                if(p[j]=='?') p[j] = 'a';
                if(q[j]=='?') q[j] = 'z';
            }

            if(p<=T && T<=q) cross++;
            else if(p<T && q<T) small++;
        }
        if(!run[i]){
            if(s<T) small++;
            if(s==T)cross++;
        }
    }

    for(int i=small+1;i<small+cross+1;i++){
        cout << i << " ";
    }
    cout << small+cross+1 << endl;

    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
 #define rep(i,n) for(int i=0;i<n;i++)
 using namespace std;
  int main(){
     long long n;   
   cin >> n;
   //cout << n << endl;
    long long an=1;
    int unti=n;
     while(unti>=10){
      unti= unti/10;
      an++;
     // cout << unti << endl;
     }
    int sn=0;
           // cout << an << endl;
            int ans=0;
     rep(i,an){
         int s=1;
         rep(j,i){
             s=s*10;
         }
        // cout << n << " " << s << endl;
         ans=(n/s)%10;
        //cout << ans << endl;
       sn=sn+ans;  
      // cout << sn << endl;
      }

    if(n%sn==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
  }

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

using namespace std;

int main()
{
    const int win = 3;
    const int draw = 1;

    string str;
    cin >> str;
    int n = stoi(str);
    int taro = 0, hanako = 0;
    string str_taro, str_hanako;
    for(int i = 0; i < n; i++)
    {
        cin >> str_taro;
        cin >> str_hanako;
        if     (str_taro > str_hanako){ taro   += win; }
        else if(str_taro < str_hanako){ hanako += win; }
        else           { taro += draw; hanako += draw; }

    }

    cout << taro << " " << hanako << endl;
    return 0;
}

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

using namespace std;
using lint = long long;

inline char decode(int i) {
    return i + (i < 10 ? '0' : 'A' - 10);
}

bool solve() {
    int N, M, Q;
    cin >> N >> M >> Q;
    if (N == 0) return false;

    vector<lint> pos(M, (1LL << N) - 1);
    lint light = 0;

    for (int q = 0; q < Q; ++q) {
        string S;
        cin >> S;
        for (int i = 0; i < N; ++i) {
            if (S[i] == '1') light ^= (1LL << i);
        }

        string B;
        cin >> B;
        for (int i = 0; i < M; ++i) {
            if (B[i] == '0') {
                pos[i] &= (~light & ((1LL << N) - 1));
            } else {
                pos[i] &= light;
            }
        }
    }

    for (auto pat : pos) {
        vector<int> ans;
        for (int i = 0; i < N; ++i) {
            if ((pat >> i) & 1) ans.push_back(i);
        }
        if (ans.size() > 1) {
            cout << '?';
        } else {
            cout << decode(ans[0]);
        }
    }
    cout << endl;
    return true;
}

int main() {
    while (solve()) {}
    return 0;
}



Measured memory_bytes: 3140
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdlib>
#include <set>
#include <stack>
#include <queue>
using namespace std;

#define X first
#define Y second
#define N 100010
#define M 400010
typedef long long ll;
typedef pair<int,int> pii;
const int Mod=1000000007;

ll Solve(ll x)
{
	if (x<=6) return 1;
	if (x<=11) return 2;
	
	ll ans=x/11*2; x%=11;
	if (x==0) return ans;
	if (x<=6) return ans+1;
	return ans+2;
}

int main()
{
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
	
	ll x; 
	cin >> x;
	cout<< Solve(x)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
  
using namespace std;

#define pi 3.141592653589793

bool Isprime(int n)
{
	if(n == 1) return false;
	if(n == 2) return true;
	for(int i = 2; i * i < n + 1; i++){
		if(n % i == 0) return false;
	}
	return true;
}


int main()
{
	int prime[10000];
	int cnt = 0;
	for(int i = 1; i < 10000; i++){
		if(Isprime(i)){
			prime[cnt] = i;
			cnt++;
		}
		// cout << i << " " << isprime[i] << endl;
	}
	int m, a, b;
	while(1){
		cin >> m >> a >> b;
		if(m == 0) break;
		int answ = 0, ansh = 0;
		for(int i = 0; i < cnt; i++){
			for(int j = i; j < cnt; j++){
				if(prime[i] * prime[j] > m || a * prime[j] > b * prime[i]) break;
				if(prime[i] * prime[j] > answ * ansh){
					answ = prime[i];
					ansh = prime[j];
				}
			}
		}
		cout << answ << " " << ansh << endl;
	}
	return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define PI atan(1)*4
typedef long long int ll;
using namespace std;
int num[200005];
int main(){
	io;
    memset(num,0,sizeof(num));
	int n;
	int a;
	cin >> n;
	int maxx = INT_MIN;
	for(int i = 1;i < n;++i){
		cin >> a;
		maxx = max(maxx,a);
		num[a]++;
	} 
	for(int i = 1;i <= n;++i){
		cout << num[i] << endl;
	}
	return 0;
} 

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

int main(){
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty; 
    int nx=sx, ny=sy;
    //往路１
    while (ny!=ty){//上
        cout << 'U';
        ny++;
    }
    while (nx!=tx){//右
        cout << 'R';
        nx++;
    }
    //復路１
    //cout << endl << "==============" << endl;
    while (ny!=sy){//下
        cout << 'D';
        ny--;
    }
    while (nx!=sx){//左
        cout << 'L';
        nx--;
    }
    //往路２
    //cout << endl << "==================" << endl;
    cout << 'L';//左
    nx--;
    while (ny!=ty+1){//上
        cout << 'U';
        ny++;
    }
    while (nx!=tx){//右
        cout << 'R';
        nx++;
    }
    cout << 'D';//下
    ny--;
    //復路２
    //cout << endl << "============" << endl;
    cout << 'R';//右
    nx++;
    while (ny!=sy-1){//下
        cout << 'D';
        ny--;
    }
    while (nx!=sx){//左
        cout << 'L';
        nx--;
    }
    cout << 'U';//上
    ny++;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,n) for(int _tmp=n,i=a;i<=_tmp;++i)
#define dep(i,a,n) for(int _tmp=n,i=a;i>=_tmp;--i)
#define fec(i,a) for(__typeof a.begin() i=a.begin();i!=a.end();++i)
#define For(i,u) for(int i=H[u];i;i=nxt[i])
#define re(i,a,b) for (int i=a;i<b;++i)
#define si(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
template<class T> inline void read(T&x){char c;bool fu=0;for(c=getchar();c<=32;c=getchar());if(c=='-')fu=1,c=getchar();for(x=0;c>32;c=getchar())x=x*10+c-'0';if(fu)x*=-1;}
template<class T> inline void read(T&x,T&y){read(x);read(y);}
template<class T> inline void read(T&x,T&y,T&z) {read(x,y);read(z);}
typedef long long ll;
typedef pair<int,int> pii;
const int N=111111;
//head
int n,k;
int main() {
	read(n,k);
	ll ans=k;
	rep(i,2,n)ans*=(k-1);
	cout<<ans;
	return 0;
}

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

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(int i=x;i<n;i+=y)
#define FF(i,x,n,y) for(int i=x;i>=n;i-=y)
#define fa(x,y) for(auto x:y)

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;

//Warsaw debug template
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1,debug&>::type operator<<(c i){
sim > struct rge {c b,e;};
sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug{
#ifdef LOCAL
~debug() {cerr<<endl; }
eni(!=) cerr<< boolalpha << i; ris;}
eni(==) ris <<range(begin(i),end(i)); }
sim, class b dor(pair<b,c> d){
ris<<"("<<d.first<<","<<d.second<<")";
}
sim dor(rge<c> d){
    *this << "[";
    for(auto it=d.b;it!=d.e;++it)
        *this <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n,l;
    cin>>n>>l;
    vi v(n);
    int mn=1000000;
    int mx=-1000000;
    int sm=0;
    f(n){
        v[i]=l+i;
        sm+=v[i];
        if(v[i]>=0) mn=min(mn,v[i]);
        else mx=max(mx,v[i]);
    }
    if(mn==1000000) cout<<sm-mx;
    else cout<<sm-mn;
    return 0;
}



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

using namespace std;
long long n;

int main()
{
	cin >> n;
	int res = 1e9;
	for(long long i = 1; i <= sqrt(n); i++) 
	if(n % i == 0){
		int k = 0, k1 = 0;
		long long x = i;
		long long y = n / i;
		while(x > 0)
		{
		k++;
		x /= 10;
		}
		while(y > 0)
		{
		k1++;
		y /= 10;
		}
		res = min(res, max(k, k1));
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int N;
    int A[100001];
    int jumban[100001]={0};
    
    scanf("%d",&N);
    int i;
    for(i=1;N>=i;i++){
        scanf("%d",&A[i]);
        jumban[A[i]] = i;
    }
    for(i=1;N>=i;i++){
        printf("%d",jumban[i]);
        if(i!=N) printf(" ");
        else    printf("\n");
    }
    
    return 0;
    
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    ll ans_total = 100 * a, ans_sugar = 0;
    double dns = 0;
    for(int ia = 0; ia * a <= f; ia++) {
        for(int ib = 0; ib * b <= f - ia * a; ib++) {
            ll water = 100 * (ia * a + ib * b);
            ll maxsugar = min(f - water, e * (water / 100));
            for(int ic = 0; ic * c <= maxsugar; ic++){
                for(int id = 0; id * d <= maxsugar - ic * c; id++) {
                    if (ia == 0 && ib == 0) continue;
                    ll sugar = ic * c + id * d;
                    ll total = water + sugar;
                    if (total > f) continue;
                    if (sugar  * (100 + e) > e * total) continue;

                    double tmp = ((double)sugar/(double)total);
                    if (tmp > dns) {
                        dns = tmp;
                        ans_total = total;
                        ans_sugar = sugar;
                    }
                }
            }
        }
    }
    cout << ans_total << " " << ans_sugar << endl;
}

Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;
//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

int main() {
	char a, b;
	cin >> a >> b;
	if (a < b) {
		cout << "<" << "\n";
	}else if(a==b) {
		cout << "=" << "\n";
	}
	else {
		cout << ">" << "\n";
	}
}


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


int main() {
    int x, a, b;
    cin >> x >> a >> b;
    int disa = abs(x-a);
    int disb = abs(x-b);
    if(disa < disb){
        cout <<  "A" << endl; 
    }else{
        cout <<  "B" << endl; 
    }
    
    return 0;
}

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
int n, m;

void solve() {
  cin>>n>>m;
  int x=m-m/2,y=m/2;
  rep(i,1,x)printf("%d %d\n",i,x*2-i+1);
  rep(i,1,y)printf("%d %d\n",x*2+i,x*2+y*2-i+2);
}

int main() {
//  int T = read();
//  while (T--) solve();
  solve();
  return 0;
}


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

#define Abigail inline void
typedef long long LL;

const int N=100000;

int n,a[N+9],vis[N+9];
struct side{
  int y,next;
}e[N*2+9];
int lin[N+9],cs;

void Ins(int x,int y){e[++cs].y=y;e[cs].next=lin[x];lin[x]=cs;}
void Ins2(int x,int y){Ins(x,y);Ins(y,x);}

struct state{
  int x,v;
  state(int X=0,int V=0){x=X;v=V;}
  bool operator > (const state &p)const{return v>p.v;}
};
priority_queue<state,vector<state>,greater<state> >q;

bool Bfs_ans(){
  for (int i=1;i<=n;++i)
    if (vis[i]) q.push(state(i,a[i]));
  for (;!q.empty();){
  	int t=q.top().x;q.pop();
  	for (int i=lin[t];i;i=e[i].next)
  	  if (vis[e[i].y]){
  	  	if (abs(a[t]-a[e[i].y])^1) return 0;
  	  }else{
  	    vis[e[i].y]=1;
	    q.push(state(e[i].y,a[e[i].y]=a[t]+1));
  	  }
  }
  return 1;
}

Abigail into(){
  scanf("%d",&n);
  for (int i=1;i<n;++i){
  	int x,y;
  	scanf("%d%d",&x,&y);
  	Ins2(x,y);
  }
  int m;
  scanf("%d",&m);
  for (int i=1;i<=m;++i){
  	int x,v;
  	scanf("%d%d",&x,&v);
  	a[x]=v;vis[x]=1;
  }
}

Abigail outo(){
  if (Bfs_ans()){
  	puts("Yes");
  	for (int i=1;i<=n;++i)
  	  printf("%d\n",a[i]);
  }else puts("No");
}

int main(){
  into();
  outo();
  return 0;
}

Measured memory_bytes: 4596
/*
  __________    							|										   ___  __
	|       |     						    |											|   /
	|       |     						    |									  		|  /
	|       |                               |                         __                | /      _______
	|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
	| \               | |      | |          |      |          | / | /   |               |\       |
	|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
	|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void solve(){
	int n;cin>>n;
	int a[n];
	fo0(i,n){
		cin>>a[i];
	}
	int mini=INT_MAX;
	int cnt=0;
	fo0(i,n){
		mini=min(mini,a[i]);
		if(mini==a[i]){
			cnt++;
		}
	}
	cout<<cnt;
}

int32_t main()
{

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

}

Measured memory_bytes: 1792