akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main()
{
    int n;
      cin>>n;
      int arr[n];
      for(int i=0;i<n;i++)
      cin>>arr[i];
      double res[n];
      for(int i=0;i<n;i++)
      res[i]=1.0/arr[i];
      double sum=0.0;
      for(int i=0;i<n;i++)
      sum+=res[i];
      double ans=1.000000/sum;
      cout.precision(5);
      cout<<fixed<<ans<<endl;
  
  return 0;



}


Measured memory_bytes: 256
from collections import deque
s=input()
n=len(s)
stack=deque([])
for i in range(n):
    if s[i]=="0":
        stack.append("0")
    elif s[i]=="1":
        stack.append("1")
    else:
        if stack:
            x=stack.pop()
stack=list(stack)
print("".join(stack))

Measured memory_bytes: 9328
n = int(input())
arr = list(map(int, input().split()))

ind = [0]*(n+1)
for i in range(n):
    ind[arr[i]] = i
temp = 100000000
ans = 0
for i in range(1,n+1):
    if ind[i]<temp:
        ans+=1
        temp = ind[i]
print(ans)


Measured memory_bytes: 26012
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        v.push_back(a);
    }
    //sort(begin(v), end(v));
    //v.erase(unique(begin(v), end(v)), end(v));

    int q;
    cin >> q;
    for (int l = 0; l < q; ++l) {
        int m;
        cin >> m;

        // cout << m << endl;
        vector<bool> dp(m + 1);
        for (int i : v) {
            vector<int> pos;
            if (m == 100026) {
                cout << i << endl;
            }
            for (int j = 0; j < dp.size(); ++j) {
                if (dp[j]) {
                    pos.push_back(j);
                    pos.push_back(j + i);
                }
                else if (i == j) {
                    pos.push_back(j);
                }
            }
            dp = vector<bool>(m + 1);
            for (int j : pos) {
                if (m == 100026)
                    cout << j << ' ';
                if (j < dp.size()) {
                    dp[j] = true;
                }
            }
            if (m == 100026)
                cout << endl;
            if (m == 100026) {
                for (int k = 0; k < dp.size(); ++k) {
                    if (dp[k]) {
                        cout << k << ' ';
                    }
                }
                cout << endl;
            }
        }
        // for (bool i : dp) {
        //    cout << boolalpha << i << ' ';
        //}
        // cout << endl;
        //cout << m << ' ';
        if (dp[m]) {
            cout << "yes" << endl;
        }
        else {
            cout << "no" << endl;
        }
    }
}

Measured memory_bytes: 3136
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

vector<int> i2g;          // i2g[i] := アイテム i の所属するグループの番号(find)
vector<vector<int>> g2i;  // g2i[g] := グループ g に所属するアイテムたち

void union_init(int n) {
  i2g.resize(n);
  g2i.resize(n);
  for (int i = 0; i < n; ++i) {
    // 最初はアイテム i はグループ i に所属
    i2g[i] = i;
    g2i[i].assign(1, i);
  }
}

int find(int i){
  return i2g[i];
}

// アイテム ia の所属するグループとアイテム ib の所属するグループを 1 つにする
void merge(int ia, int ib) {
  if(i2g[ia]==i2g[ib])return;
  // ia の所属するグループが ib の所属するグループより小さくならないようにする
  if (g2i[i2g[ia]].size() < g2i[i2g[ib]].size()) {
    swap(ia, ib);
  }
  int ga = i2g[ia], gb = i2g[ib];
  // グループ gb に所属する全てのアイテムをグループ ga に移す
  for (int j : g2i[gb]) i2g[j] = ga;
  g2i[ga].insert(g2i[ga].end(), g2i[gb].begin(), g2i[gb].end());
  g2i[gb].clear();
}

// アイテム ia とアイテム ib は同じグループに所属しているか？
bool is_same_group(int ia, int ib) {
  return i2g[ia] == i2g[ib];
}


const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n,m,k;
    cin>>n>>m>>k;
    vi a(m),b(m);
    vi c(k),d(k);
    union_init(n);
    map<pii,int> mp;
    vi ans(n,0);
    FOR(i,0,m){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
        merge(a[i],b[i]);
        ans[a[i]]--;
        ans[b[i]]--;
    }
    FOR(i,0,n){
        ans[i]+=g2i[i2g[i]].size()-1;
    }

    FOR(i,0,k){
        cin>>c[i]>>d[i];
        c[i]--;d[i]--;
        //mp[MP(c[i],d[i])]=1;
        //mp[MP(d[i],c[i])]=1;
        if(is_same_group(c[i],d[i])){
            ans[c[i]]--;
            ans[d[i]]--;
        }    
    }


    FOR(i,0,n){
        cout<<ans[i]<<" ";
    }

}


Measured memory_bytes: 9628
#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
#define ff first
#define ss second
/*----------------------------------------------------------------------*/

const int N = 1e5+5;
vi g[N];
int n,u,v,dist[2][N];
bool visited[N];

void bfs(int src, int idx) {
	queue<int> q;
	memset(visited, false, sizeof(visited));
	q.push(src); dist[idx][src]=0;
	visited[src] = true;
	while(!q.empty()) {
		int curr = q.front(); q.pop();
		for(auto nxt : g[curr]) {
			if(!visited[nxt]) {
				visited[nxt] = true;
				dist[idx][nxt] = dist[idx][curr] + 1;
				q.push(nxt);
			}
		}
	}
}

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>n;
    FOR(i, 0, n-1) {
    	cin>>u>>v; u--; v--;
    	g[u].push_back(v);
    	g[v].push_back(u);
    }
    memset(dist, 0, sizeof(dist));
    bfs(0, 0);
    bfs(n-1, 1);
    int cnt[2] = {0};
    FOR(i, 0, n) {
    	if(dist[0][i] <= dist[1][i]) {
    		cnt[0]++;
    	} else {
    		cnt[1]++;
    	}
    }
    if(cnt[0] > cnt[1]) {
    	cout<<"Fennec";
    } else {
    	cout<<"Snuke";
    }

    return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

struct segmentTree{

    int N;
    vector< pair<int, int> > node;
    const int INF = -1;
    
    void init(int siz){
        N = 1;
        while(N < siz){
            N <<= 1;
        }
        node.resize(N * 2 - 1, {INF, -1});
    }

    void build(vector<int> &dat){
        for(int i = 0, len = dat.size() ; i < len ; ++i){
            node[i + N - 1] = {dat[i], -i};
        }
        for(int i = N - 2 ; i >= 0 ; --i){
            node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
        }
    }

    void update(int k, int x){
        k += N - 1;
        node[k].first = x;
        while(k > 0){
            k = (k - 1) / 2;
            node[k] = max(node[k * 2 + 1], node[k * 2 + 2]);
        }
    }

    pair<int, int> getMax(int a, int b, int k, int l, int r){
        if(r <= a || b <= l){
            return {INF, -1};
        }
        if(a <= l && r <= b){
            return node[k];
        }
        pair<int, int> vl = getMax(a, b, k * 2 + 1, l, (l + r) / 2);
        pair<int, int> vr = getMax(a, b, k * 2 + 2, (l + r) / 2, r);
        return max(vl, vr);
    }

    pair<int, int> getMax(int a, int b){
        return getMax(a, b, 0, 0, N);
    }

};

int main(){
    int n, q;
    cin >> n >> q;
    vector<int> v(n, 0);
    segmentTree st;
    st.init(n);
    st.build(v);
    rep(i, q){
        int a, x;
        cin >> a >> x;
        --a;
        v[a] += x;
        st.update(a, v[a]);
        P ans = st.getMax(0, n);
        cout << -ans.second + 1 << " " << ans.first << endl;
    }
    return 0;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
ll sqr(ll a)
{
    return ((a % MOD) * (a % MOD)) % MOD;
}
ll msub(ll a, ll b)
{
    return ((a - b) % MOD + MOD) % MOD;
}
ll madd(ll a, ll b)
{
    return (a + b) % MOD;
}
ll mmul(ll a, ll b)
{
    return ((a % MOD) * (b % MOD)) % MOD;
}
int t;
ll cal(ll i)
{
    return i * i * i * i * i;
}
bool check(ll a)
{
    double val = log10(a) / log10(5.0);
    if(ceil(val) == floor(val)) return 1;
    return 0;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    ll x;
    cin >> x;
    FOR(i, -1000, 1000)
        FOR(j, -1000, 1000)
        {
            if(cal(i) - cal(j) == x)
            {
                cout << i << " " << j;
                return 0;
            }
        }
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define rep(i, n) for (i = 0; i < n; i++)
using namespace std;
 
signed main() {
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
/*********************************************************************| 
|---------|    /\  ....                  ....                         |         
     |        /  \   \                    /  /------| ----- |-------| |
     |       /    \   \                  /  /           |   |         |
     |      /      \   \       /\       /  |            |   |         |
     |     /        \   \     /  \     /   |---|        |   |----|    |
     |    /__________\   \   /    \   /        |---|    |   |         |
     |   /            \   \ /      \ /              |   |   |         |
     |  /              \   |        |               /   |   |         |
     _ __              __ ...      ...      |------/  ----- _         |
                                                                      |  
        Md Tawsif Rahman                                              |
        Institute Of Information Technology                           |
        Jahangirnagar University                                      |                                                                         
                                                                      |
**********************************************************************/                 
#include<bits/stdc++.h>

using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define pii pair <int, int>
#define xx first
#define yy second
#define vi vector < int >
#define vl vector < ll >
#define inf  100000000 
#define f(i, c, n) for(i = c; i < n; i++)
#define fe(i, c, n) for(i = c; i <= n; i++)
#define fr(i, n, c) for(i = n - 1; i >= 0; i--) 
#define vbe(a) a.begin(), a.end()
#define vsort(a) sort(a.begin(), a.end())
#define mem(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))

#define srti(a, n) sort(a, a + n)
#define srtd(a, n) sort(a, a + n, greater<int>())
#define LB(a, x) (lower_bound(vbe(a), x) - a.begin())
#define UB(a, x) (upper_bound(vbe(a), x) - a.begin())

#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

#define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)


int i, j, k, cs, n;


void solve() {
    int n;
    cin >> n;
    int arr[n + 10];
    f(i, 0, n) cin >> arr[i];
    srtd(arr, n);
    int sum1 = 0, sum2 = 0;
    f(i, 0, n) {
        if(i % 2 == 0) sum1 += arr[i];
        else sum2 += arr[i];
    }
    cout << sum1 - sum2 << endl;
}
int main() {
    // int t; cin >> t; while(t--) 
    solve();
}
   

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Set<Character> set = new HashSet<>();
        for (char c : s.toCharArray()) {
            if (set.contains(c)) {
                System.out.println("no");
                return;
            }
            set.add(c);
        }

        System.out.println("yes");
    }
}

Measured memory_bytes: 35636
#include <bits/stdc++.h>
using namespace std;
#define ACL
#ifdef ACL
#include <atcoder/all>
using namespace atcoder;
#endif
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
using LD = long double;
using VI = vector<int>;
using VVI = vector<vector<int> >;
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T> >;
template <typename T> using VVV = vector<vector<vector<T> > >;
void print() {cout << endl;}
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <typename T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <typename T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T> void SORT (T &v) {sort(v.begin(), v.end());}
template <typename T> void SORTR (T &v) {sort(v.begin(), v.end(), greater<>());}
template <typename T> T GCD(T x,T y) {return __gcd(x,y);}
template <typename T> T LCM(T x,T y) {return x/__gcd(x,y)*y;}
template <typename T> int SZ(T v) {return v.size();}
template <typename T> T PCNT(T x) {return __builtin_popcountll(x);}
template <typename T> T BIT(T x) {return 1LL<<(x);}
int INF = 2000000000;
long double PI = acosl(-1);
int MOD = 1000000007;


int32_t main() {
    chrono::system_clock::time_point start_time, end_time;
    start_time = chrono::system_clock::now();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int N, M;
    cin >> N;
    vector<int> a(N);
    cin >> M;
    vector<int> b(M);
    REP (i, N) {
        cin >> a[i];
    }
    REP (i, M) {
        cin >> b[i];
    }

    V<int> c = convolution(a,b);
    print(c);

    
    

    end_time = chrono::system_clock::now();
    assert(chrono::duration_cast<chrono::milliseconds>(end_time-start_time).count() < 2000);
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/practice2/practice2_f && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/practice2/practice2_f && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/practice2/practice2_f && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 27280
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main() {
	double A,B,H,M;
	cin  >> A  >> B >> H >> M;
	double min;
	min = 60*H + M;
	double zishinx,zishiny,hunshinx,hunshiny;
	zishinx = sin(M_PI*min/360);
	zishiny = cos(M_PI*min/360);
	hunshinx = sin(M_PI*M/30);
	hunshiny = cos(M_PI*M/30);
	double disdis;
	disdis = pow(A*zishinx-B*hunshinx,2)+pow(A*zishiny-B*hunshiny,2);
	double dis;
	dis = sqrt ( disdis );
	cout << fixed << setprecision(20) << dis << endl;
	return 0;
	}


Measured memory_bytes: 4100
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    long long int n,i,k,j;
    cin>>n>>k;
    long long int a[n],dp[n],mini;
    for(i=0;i<n;i++)
        cin>>a[i];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(i=2;i<=min(n,k);i++)
    {
        mini=1000000009;
        for(j=i;j>0;j--)
        {
            if((dp[i-j]+abs(a[i]-a[i-j]))<mini)
                mini=dp[i-j]+abs(a[i]-a[i-j]);
        }
        dp[i]=mini;
    }
    for(i=k+1;i<n;i++)
    {
        mini=inf;
        for(j=1;j<=k;j++)
        {
            if((dp[i-j]+abs(a[i]-a[i-j]))<mini)
                mini=dp[i-j]+abs(a[i]-a[i-j]);
        }
        dp[i]=mini;
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace VirtualAtCorder
{
    class Program
    {

        static void Main(string[] args)
        {
            string[] inputs = Console.ReadLine().Split(' ');

            int aCoin = 0, bCoin = 0, price = 0;

            aCoin = int.Parse(inputs[0]);

            bCoin = int.Parse(inputs[1]);

            price = int.Parse(inputs[2]);

            string able = (aCoin + bCoin >= price) ? "Yes" : "No";

            Console.WriteLine(able);

            Console.ReadKey();
        }



    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
const ll mod=1e9+7;
int main(void){
    // Your code here!
    ll n,k;
    cin>>n>>k;
    vector<ll>v(n);
    rep(0,i,n){
        cin>>v[i];
    }
    ll ans=0;
    rep(0,i,n){
        ll r=0,a=0;
        rep(i+1,j,n)if(v[i]>v[j])++r;
        rep(0,j,n)if(v[i]>v[j])++a;
        ans+=r*k%mod;
        ans%=mod;
        ans+=k*(k-1)/2%mod*a%mod;
        ans%=mod;
    }
    cout<<ans;
}

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

int main(void) {
	long long int n, a, b = 0, i, ans = 0;

	scanf("%lld", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", &a);
		if (i == 0) {
			b = a;
		}
		if (b > a) {
			ans += b - a;
		}
		else {
			b = a;
		}
	}
	printf("%lld", ans);
}

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

int main() {
    int n,k,r,s,p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    string player;
    int ans = 0,i = 0;
    for(; i<k; i++){
            if(t.at(i) == 'r'){
                ans += p;
                player.push_back('p');
            }
            else if(t.at(i) == 'p'){
                ans += s;
                player.push_back('s');
            }
            else {
                ans += r;
                player.push_back('r');
            }
        }

    for(; i<n; i++){
        if(t.at(i) == 'r'){
            if(player.at(i-k) != 'p'){
                ans += p;
                player.push_back('p');
            }
            else player.push_back('x');
        }
        else if(t.at(i) == 'p'){
            if(player.at(i-k) != 's'){
                ans += s;
                player.push_back('s');
            }
            else player.push_back('x');
        }
        else {
            if(player.at(i-k) != 'r'){
                ans += r;
                player.push_back('r');
            }
            else player.push_back('x');
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
n, t = map(int, input().split())
ct = []
for i in range(n):
    ct.append(list(map(int, input().split())))
num = 1001
has_tle = False

for i in range(n):
    if t >= ct[i][1]:
        if num >= ct[i][0]:
            num = ct[i][0]
        has_tle = True

if has_tle == True:
    print(num)
else:
    print('TLE')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N, x, tmpInt;
	vector<int> buf;
	cin >> N >> x;
	for (int i = 0; i < N; ++i) {
		cin >> tmpInt;
		buf.push_back(tmpInt);
	}
	sort(buf.begin(), buf.end());
	int ret = 0;
	for (auto i : buf) {
		if (x >= i) {
			++ret;
			x -= i;
		}
		else {
			cout << ret << endl;
			return 0;
		}
	}
	cout << ret - (x > 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
template<typename T>
struct Edge {
    int from, to;
    T cost;
    Edge(int from, int to, T cost) {
        this->from = from;
        this->to = to;
        this->cost = cost;
    }
};
bool operator == (Edge<int> e1, Edge<int> e2) {
    return e1.from == e2.from &&
            e1.to == e2.to &&
            e1.cost == e2.cost;
}
template<typename T>
using Edges = std::vector<Edge<T>>;
template<typename T>
using Graph = std::vector<Edges<T>>;
template <typename T>
std::vector<T> dijkstra(const Graph<T> &g, int s) {
    int sz = (int)(g.size());
    std::vector<T> dist(sz, std::numeric_limits<T>::max());
    std::priority_queue<std::pair<T, int>, std::vector<std::pair<T, int>>, std::greater<std::pair<T, int>>> pq;
    dist[s] = 0;
    pq.push({0, s});
    while(!pq.empty()) {
        int d = pq.top().first, now = pq.top().second;
        pq.pop();
        if(d > dist[now]) continue;
        for(int i=0;i<(int)(g[now].size());++i) {
            int next = g[now][i].to, cost = g[now][i].cost;
            if(dist[next] > dist[now] + cost) {
                dist[next] = dist[now] + cost;
                pq.push({cost, next});
            }
        }
    }
    return dist;
}
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vector<ll>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const ll INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(ll i=0;i<(ll)(s.size());++i) {
    cout << s[i];
    if(i == (ll)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
signed main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  ll n, m, s, t; cin >> n >> m >> s >> t;
  s--; t--;
  Graph<ll> g(n);
  vector<P> eds;
  for(ll i=0;i<m;++i) {
    ll u, v; cin >> u >> v;
    u--; v--;
    g[u].push_back(Edge<ll>(u, v, 1));
    g[v].push_back(Edge<ll>(v, u, 1));
    eds.push_back({u, v});
  }
  vector<ll> froms = dijkstra(g, s), fromt = dijkstra(g, t);
  ll d = froms[t];
  map<ll, ll> cnts, cntt;
  for(ll i=0;i<n;++i) {
    cnts[froms[i]]++;
  }
  for(ll i=0;i<n;++i) {
    cntt[fromt[i]]++;
  }
  ll ans = 0;
  for(ll i=0;i<=d-2;++i) {
    ans += cnts[i] * cntt[d-2 - i];
  }
  cout << ans << endl;
}



Measured memory_bytes: 24388
import sys


def cumsum(li):
    ret = [0]
    sum = 0
    for i in li:
        sum += i
        ret.append(sum)
    return ret


sys.setrecursionlimit(10000)
INF = float('inf')

N = int(input())
A = list(map(int, input().split()))
# 最初が0
cs = cumsum(A)
assert len(cs) == N + 1


def calc_diff(d1, d2, d3):
    diffs = [
        cs[d1] - cs[0],
        cs[d2] - cs[d1],
        cs[d3] - cs[d2],
        cs[N] - cs[d3]
    ]
    return max(diffs) - min(diffs)


# 切る位置
# dn: n 番目の数列の開始インデックス
d0 = 0
d1 = 1
d2 = 2
d3 = 3
d4 = N
ans = INF
while d2 < d4 - 1:
    d012 = abs((cs[d1] - cs[d0]) - (cs[d2] - cs[d1]))
    while d1 < d2 - 1 and d012 > abs((cs[d1 + 1] - cs[d0]) - (cs[d2] - cs[d1 + 1])):
        d1 += 1
        d012 = abs((cs[d1] - cs[d0]) - (cs[d2] - cs[d1]))
    d234 = abs((cs[d3] - cs[d2]) - (cs[d4] - cs[d3]))
    while d3 < d4 - 1 and d234 > abs((cs[d3 + 1] - cs[d2]) - (cs[d4] - cs[d3 + 1])):
        d3 += 1
        d234 = abs((cs[d3] - cs[d2]) - (cs[d4] - cs[d3]))
    ans = min(ans, calc_diff(d1, d2, d3))
    d2 += 1

print(ans)


Measured memory_bytes: 25676
#include <stdio.h>
int main(void)
{
	int i,n,box[10001],temp,max,min;
	long long sum;
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&box[i]);
	}
	sum = 0;
	max=min=box[0];
	for(i=0;i<n;i++){
		if(box[i]>max)
			max=box[i];
		if(box[i]<min)
			min=box[i];
		sum += box[i];
	}
		
printf("%d %d %lld\n",min,max,sum);
	return 0;
}


Measured memory_bytes: 2756
import java.util.*;

class Main {
	Scanner sc;
	int N;
	
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		boolean approved = true;
		for (int i = 0; i < N; i++) {
			int A = sc.nextInt();
			if (!approved) continue;
			if (A%2 != 0) continue;
			if (A%2 == 0 && (A%3 == 0 || A%5 == 0)) continue;
			approved = false;
		}
		System.out.println(approved?"APPROVED":"DENIED");
	}

	public static void main(String[] args) {
		new Main().calc();
	}
}


Measured memory_bytes: 24404
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        k: usize,
        s: Chars,
    }

    if s.len() <= k {
        for i in s {
            print!("{}", i);
        }
        println!("");
    } else {
        for i in 0..k {
            print!("{}", s[i]);
        }
        println!("...");
    }
}

Measured memory_bytes: 2160
#include <stdio.h>
#include <string.h>

int main(void)
{
	int len, i,j, ans = 0;
	char s[28], ch;
	scanf("%s", s);
	len = strlen(s);
	for(i = 0; i < len; i++){
		ch = s[i];
		for(j = i+1; j < len; j++){
			if(ch == s[j])
				ans++;
		}
		if(ans > 0)
			break;
	}
	if(ans > 0)
		printf("no");
	else
		printf("yes");
	return 0;
}

Measured memory_bytes: 128
n = int(input())
ws = [ int(x) for x in input().split() ]

s1 = 0
s2 = sum(ws)
m = 10000

for w in ws:
    s1 += w
    s2 -= w
    d = abs(s1 - s2)
    if (d < m):
        m = d

print(m)

Measured memory_bytes: 2940
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >=65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if   r >=50:
            print("C")
        else:
            print("D")
    else:
        print("F")


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

const int N=1e2+20;

int n,a[N];

bool diff(int x,int y,int z)
{
	set <int> s;
	s.insert(x);
	s.insert(y);
	s.insert(z);
	return s.size()==3;
}

int main()
{
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);

	int ans=0;
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			for(int k=j+1;k<n;k++)
				if(diff(a[i],a[j],a[k]) and a[i]+a[j]>a[k]) ans++;
	cout<<ans;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
typedef long long ll;
#define INF 10000000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    double n;
    cin>>n;
    double x[5];
    for(int i=0;i<5;i++){
        cin>>x[i];
    }
    ll ans=-INF;
    for(int i=0;i<5;i++){
        ll tmp=(ceil(n/x[i]));
        ans=max(tmp,ans);
    }
    cout<<ans+4<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int cntSort;

void printArray(int A[], int N) {
	for (int i = 0; i < N - 1; i++)
		cout << A[i] << " ";
	cout << A[N - 1] << endl;
}

void inputArray(int A[], int N) {
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
}

void selectionSort(int A[], int N) {
	//i?????????????????¨??????????????????????????????
	for (int i = 0; i < N; i++) {
		int minj = i;	//minj???i??\?????§????°????????´??????????????????????
		for (int j = i + 1; j < N; j++) {
			if (A[j] < A[minj])
				minj = j;
		}
		if (minj != i) {
			swap(A[minj], A[i]);
			cntSort++;
		}
	}
}

int main() {
	int N;
	cin >> N;
	int A[N];
	inputArray(A, N);
	selectionSort(A, N);
	printArray(A, N);
	cout << cntSort << endl;
}

Measured memory_bytes: 3084
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);   
    int N, M;
    cin >> N >> M;
    string A[51], B[51];
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];
    rep(i, N - M + 1) {
        rep(j, N - M + 1) {
            bool ok = true;
            rep(s, M) {
                rep(t, M) {
                    if (A[i + s][j + t] != B[s][t]) ok = false;
                }
            }
            if(ok) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;



    return 0;
}


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

const ll MOD = 1000000007;

ll mod_add(ll a, ll b){
    return ((a % MOD) + (b % MOD)) % MOD;
}

ll mod_sub(ll a, ll b){
    return ((a + MOD) - b) % MOD;
}
 
ll mod_mul(ll a, ll b){
    return ((a % MOD) * (b % MOD)) % MOD;
}

ll mod_pow(ll x, ll r){
    if (r == 0) return 1;

    else if (r == 1) return x % MOD;

    else if (r % 2 == 0){
        ll t = mod_pow(x, r/2) % MOD;
        return mod_mul(t, t);
    }

    else{
        ll t = mod_pow(x, r/2) % MOD;
        ll k = mod_mul(t, t);
        return ((k % MOD) * (x % MOD)) % MOD;
    }
}

ll mod_div(ll a, ll b){
    return mod_mul(a, mod_pow(b, MOD - 2));
}

ll mod_fac(ll n){
    ll ret = 1;
    for(ll i = 1; i <= n; ++i){
        ret = (ret*i) % MOD;
    }
    return ret;
}

ll mod_comb(ll n, ll k){
    ll numerator = 1;
    for(ll i = 0; i < k; ++i){
        numerator = numerator*(n-i) % MOD;
    }
    ll denominator = mod_fac(k);
    return mod_div(numerator, denominator);
}

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

    ll x, y;
    cin >> x >> y;

    if((x+y)%3 != 0 || min(x, y)*2 < max(x, y)){
        cout << 0 << endl;
        return 0;
    }

    // coordinate transformation
    ll n = (x+y) / 3;
    x %= n;
    y %= n;

    ll res = mod_comb(n, x);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>

using namespace std;

#define MOD 1000000007

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef vector<mint> vec;
typedef vector<vec> mat;

mat operator*(mat a, mat b) {
    const int n = a.size();
    mat c(n, vec(n));
    for (int i = 0; i < n; i++) {
        for (int k = 0; k < n; k++) {
            for (int j = 0; j < n; j++) {
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    return c;
}

mat pow(mat a, long long b) {
    const int n = a.size();
    mat res(n, vec(n));
    for (int i = 0; i < n; i++) {
        res[i][i] = 1;
    }
    while (b > 0) {
        if (b & 1) res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int main() {
    int N;
    long long K;
    scanf("%d %lld", &N, &K);
    mat a(N, vec(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            scanf("%d", &a[i][j].n);
        }
    }
    a = pow(a, K);
    mint ans;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            ans += a[i][j];
        }
    }
    printf("%d\n", ans.n);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[100100];

int main(){
  for(int i = 0; i < 100100; i++){ dp[i] = 0;}
  
  int N; cin >> N; 
  for(int i = 0; i < N; i++){ int a; cin >> a; dp[a]++;}
  int a = 0; int b = 0;
  
  for(int i = 0; i < 100100; i++){
    if(dp[i] == 0){ continue;}
    if(dp[i]%2){ a++;} else{ b++;}}
  
  if(b%2){ cout << a+b-1 << endl;} else{ cout << a+b << endl;}
  return 0;}
  

Measured memory_bytes: 640
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
now = inpl()
for _ in range(k):
    pre = now[::]
    cnt = [0] * (n+1)
    for i in range(n):
        l = max(0, i - pre[i])
        r = min(n, i + pre[i] + 1)
        cnt[l] += 1
        cnt[r] -= 1
    # print(cnt)
    now = [0] * n
    now[0] = cnt[0]
    for i in range(1,n):
        now[i] = now[i-1] + cnt[i]
    if min(now) == n:
        break
print(*now)

Measured memory_bytes: 222488
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#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>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

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

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

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll x, ll y){return x / gcd(x, y) * y % MOD;};

ll disit(ll N){
  ll res = 0;
  while(N > 0){
    res += N % 10;
    N /= 10;
  }
  return res;
}

int main(){
  ll N;
  cin >> N;
  ll ans = disit(N);
  N -= N % 10;
  for(int i = 2; i < 17; i++){
    N--;
    ans = max(ans, disit(N));
    N -= N % pow_long(10, i);
    if(N == 0) break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
using Graph = vector<vector<int>>;

#define INF (1 << 21);

int main(){
  int N, K;cin >> N >> K;
  int x, ans = 0;
  for(int i = 0;i < N;++i){
    cin >> x;
    if(x > abs(x - K))
      ans += 2 * abs(x - K);
    else
      ans += 2 * x;
  }
  cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
    x=0;int f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    x*=f;
}
inline void judge(){
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
}
/******************************head*******************************/

int n, m, ex, ey;
const int N(105);
short sumr[N][N], sumc[N][N];
char st[N][N], b[N][N];
short dp[N][N][N][N];
int main() {
    read(n);read(m);
    for(int i(0); i < n; i++) {
        scanf("%s", st[i]);
        for(int j(0); j < m; j++) {
            if(st[i][j] == 'E') {
                ex = i; ey = j;
            }
        }
    }
    int ans(0);
    for(int i(0); i < n; i++) {
        for(int j(0); j < m; j++) {
            sumr[i][j] = j == 0 ? st[i][j] == 'o' : sumr[i][j - 1] + (st[i][j] == 'o');
            sumc[i][j] = i == 0 ? st[i][j] == 'o' : sumc[i - 1][j] + (st[i][j] == 'o');
        }
    }
    dp[0][0][0][0] = 0;
    for(int l(0); l <= m; l++) {
        for(int r(0); r + l <= m; r++) {
            for(int u(0); u <= n; u++) {
                for(int d(0); u + d <= n; d++) {
                    if(l + r < m) {
                        int a(max(d, ex - u)), b(min(n - 1 - u, ex + d));
                        short delta(ey + r + 1 <= m - 1 - l ? sumc[b][ey + r + 1] - (a == 0 ? 0 : sumc[a - 1][ey + r + 1]) : 0);
                        dp[l][r + 1][u][d] = max((int)dp[l][r + 1][u][d], dp[l][r][u][d] + delta);
                        delta = ey - l - 1 >= r ? sumc[b][ey - l - 1] - (a == 0 ? 0 : sumc[a - 1][ey - l - 1]) : 0;
                        dp[l + 1][r][u][d] = max((int)dp[l + 1][r][u][d], dp[l][r][u][d] + delta);
                    }
                    if(u + d < n) {
                        int a(max(r, ey - l)), b(min(m - 1 - l, ey + r));
                        short delta(ex + d + 1 <= n - 1 - u ? sumr[ex + d + 1][b] - (a == 0 ? 0 : sumr[ex + d + 1][a - 1]) : 0);
                        dp[l][r][u][d + 1] = max((int)dp[l][r][u][d + 1], dp[l][r][u][d] + delta);
                        delta = ex - u - 1 >= d ? sumr[ex - u - 1][b] - (a == 0 ? 0 : sumr[ex - u - 1][a - 1]) : 0;
                        dp[l][r][u + 1][d] = max((int)dp[l][r][u + 1][d], dp[l][r][u][d] + delta);
                    }
                }
            }
        }
    }
    for(int l(0); l <= m; l++) {
        for(int u(0); u <= n; u++) {
            ans = max(ans, (int)dp[l][m - l][u][n - u]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 227584
#include<iostream>
using namespace std;
int main(){
	int sx,sy,tx,ty;
	int i;
	cin >> sx >> sy >> tx >> ty;
	int y=ty-sy;
	int x=tx-sx;
	for(i=0;i<y;i++)cout<<'U';
	for(i=0;i<x;i++)cout<<'R';
	for(i=0;i<y;i++)cout<<'D';
	for(i=0;i<x+1;i++)cout<<'L';
	for(i=0;i<y+1;i++)cout<<'U';
	for(i=0;i<x+1;i++)cout<<'R';
	cout<<'D';
	cout<<'R';
	for(i=0;i<y+1;i++)cout<<'D';
	for(i=0;i<x+1;i++)cout<<'L';
	cout<<'U';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int cnt=0,n,s[10000],q,t; cin>>n;
  for(int i=0;i<n;++i) cin>>s[i];
  cin>>q;
  for(int i=0;i<q;++i){
    cin>>t;
    for(int j=0;j<n;++j)
      if(t==s[j]){ ++cnt; break; }
  }
  cout<<cnt<<endl;
  return 0;
}



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

int main() {
	int N;
	cin >> N;
	vector<int> A(N + 1);
	vector<int> B(N);
	for (int i = 0; i < N + 1; i++) {
		int n;
		cin >> n;
		A[i] = n;
	}
	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		B[i] = n;
	}
	long total_kill = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] >= B[i]) {
			total_kill += B[i];
			continue;
		}
		else {
			total_kill += A[i];
			B[i] -= A[i];
		}
		if (A[i + 1] > B[i]) {
			total_kill += B[i];
			A[i + 1] -= B[i];
		}
		else {
			total_kill += A[i + 1];
			A[i + 1] = 0;
		}
	}
	cout << total_kill << endl;
	return 0;
}


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

typedef long long ll;
#pragma GCC optimize ("Ofast")
#define rep(i,a,b) for(ll i = (a); i < (b); ++i)
#define iter(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define pb push_back
#define fs first
#define sc second
#define MOD 1000000007
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

inline int modulo(int a, int b) {
  const int result = a % b;
  return result >= 0 ? result : result + b;
}

int mnincr(int arr[], int n)
{
    multiset<int> last;
    for (int i = 0; i < n; i++) {

        multiset<int>::iterator it = last.lower_bound(arr[i]);


        if (it == last.begin())

            last.insert(arr[i]);

        else {
            it--;


            last.erase(it);
            last.insert(arr[i]);
        }
    }
    return last.size();
}


int main()
{
    int arr[100100];
    int n;
    cin >> n;
    rep(i,0,n) cin >> arr[i];
    cout << mnincr(arr,n);
}


Measured memory_bytes: 5376
from collections import Counter

N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
C = Counter(A)
keys = set(A)

ans = 0
for a in A:
    target_2_pow = 2 ** a.bit_length()
    b = target_2_pow - a
    if b not in keys:
        continue

    if a != b:
        if C[a] == 0 or C[b] == 0:
            continue
    else:
        if C[b] < 2:
            continue
    ans += 1
    C[a] -= 1
    C[b] -= 1

print(ans)


Measured memory_bytes: 40076
n = int(input())
d = [[0] * 10 for _ in range(10)]

for i in range(1, n + 1):
  a, b = map(int, [str(i)[0], str(i)[-1]])
  d[a][b] += 1

cnt = 0
for i in range(1,10):
  for j in range(1,10):
    cnt += d[i][j] * d[j][i]
print(cnt)


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

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

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


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

Measured memory_bytes: 256
// 

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector <int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }

    sort(d.begin(), d.end());

    int mid = n / 2;
    cout << d[mid] - d[mid - 1] << endl;

    return 0;
}


Measured memory_bytes: 768
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;



int main(void)
{
	//変数の宣言
	int n,m;
	char s[20];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int temp3=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	char stemp[11];
	
	//データの読み込み


//	scanf("%d",&n);
//	scanf_s("%d",&n);

	scanf("%s",&s);
//	scanf_s("%s",&s,20);


/*	for(i=0;i<n;i++){
//		scanf("%d",&b[i]);
		scanf_s("%d",&b[i]);
	}*/


/*	for(i=0;i<3;i++){
//		scanf("%s",&s);
		scanf_s("%s",&s[i],10);
	}*/


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

//	clock_t start=clock();

	s[3]='8';

	printf("%s",s);

//	clock_t end=clock();

	//	printf("計算部分終了\n");

	//出力
	//printf("%d",min(sum+2*m,n-1));

//	printf("time=%lf",(double)(end-start)/CLOCKS_PER_SEC);
	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 256