akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

namespace {

#define VEVE(i, a, b) for (ll i = a, __##i = b; i < __##i; ++i)
#define DYDY(i, a, b) for (ll i = a, __##i = b; i > __##i; --i)
#define RARA(x, seq) for (auto &x : seq)
#define SIZE(x) ((ll)(x.size()))
#define ALL(x) x.begin(), x.end()

typedef int ll;
typedef double dd;

void Min(ll& a, ll b) {
  a = min(a, b);
}

void Solve(ll) {
  ll n, k;
  cin >> n >> k;
  vector<vector<ll>> adj(n);
  VEVE(e, 0, n - 1) {
    ll a, b;
    cin >> a >> b;
    --a, --b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  vector<vector<ll>> dp(n, vector<ll>(n + 1, n));
  vector<ll> size(n);
  ll res = n;
  vector<ll> temp(n + 1);
  function<void(ll, ll)> dfs = [&](ll at, ll par) {
    size[at] = 1;
    RARA(to, adj[at]) if (to != par) {
        dfs(to, at);
      }
    dp[at][0] = 0;
    RARA(to, adj[at]) if (to != par) {
        fill(ALL(temp), n);
        VEVE(cur_dep, 0, size[at]) {

          // delete entire child
          Min(temp[cur_dep], dp[at][cur_dep] + size[to]);

          VEVE(child_dep, 0, size[to]) if (cur_dep + child_dep + 1 <= k) {
              Min(temp[max(cur_dep, child_dep + 1)], dp[at][cur_dep] + dp[to][child_dep]);
            }
        }
        swap(dp[at], temp);
        size[at] += size[to];
      }
    res = min(res, n - size[at] + *min_element(ALL(dp[at])));
  };
  dfs(0, 0);
  cout << res << endl;
}

void Init() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}
}

int32_t main() {
#ifdef AZN
  freopen("input.txt", "r", stdin);
#endif
  Init();
  ll tests = 1;
  VEVE(test, 1, tests + 1) Solve(test);
  return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


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

    return 0;
}

Measured memory_bytes: 3628
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

void solve() {
    cini(n);
    int cnt=0;
    string ans="No";
    for(int i=0; i<n; i++) {
        cini(d1);
        cini(d2);
        if(d1==d2)
            cnt++;
        else
            cnt=0;

        if(cnt>=3)
            ans="Yes";
    }
    cout<<ans<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 3612
#include <set>
#include <cstdio>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

char ring[2011];
double dp[2][2011];

int main(){
  while(true){
    int n = getInt();
    int t = getInt();

    if(n + t == 0) break;

    scanf("%s", ring);

    REP(i,n) dp[0][i] = 0.0;
    dp[0][0] = 1.0;

    int now  = 0;
    int next = 1;

    REP(i,t){
      REP(j,n) dp[next][j] = 0.0;
      REP(j,n) if(dp[now][j] > 0.0){
        REP(k,6){
          dp[next][(j + k) % n] += dp[now][j] / 6.0;
        }
      }
      swap(now, next);
    }

    double ans = 0.0;
    REP(i,n){
      double tmp = 0.0;

      REP(j,n) if(ring[(i + j) % n] == 'R'){
        tmp += dp[now][j];
      }

      ans = max(ans, tmp);
    }

    printf("%.10f\n", ans);
  }

  return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.tie(0)
#define MAXX 1005

int n;

bool f(int n){
    int s = 0;
    while(n > 0){
        s++;
        n /= 10;
    }
    if(s % 2)
    return true;
    return false;
}

int a , b , c;

int main()
{
    _FastIO;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(f(i))
            ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	string S;
	const int fav = 753;
	int ans = 1000;
	cin >> S;

	for (int i=0; i < S.size() - 2; i++) {
		int diff = abs(fav - ((S.at(i) - '0') * 100 + (S.at(i + 1) - '0') * 10 + (S.at(i + 2) - '0')));
		if (diff < ans) ans = diff;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
        public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            String line = reader.readLine();
            int x = Integer.parseInt(line);
            System.out.println(x*x*x);
        } catch (IOException e) {
            System.out.println(e);
        } catch (NumberFormatException e) { 
             System.out.println("The input age was not correct.");
        }
    }
}


Measured memory_bytes: 24460
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

c = []
for i in range(3):
    c.append(list(map(int, input().split())))

for a1 in range(0, 101):
    b1 = c[0][0] - a1
    b2 = c[0][1] - a1
    b3 = c[0][2] - a1
    for a2 in range(0, 101):
        if not (b1 == (c[1][0] - a2) and b2 == (c[1][1] - a2) and b3 == (c[1][2] - a2)):
            continue
        for a3 in range(0, 101):
            if (b1 == (c[2][0] - a3) and b2 == (c[2][1] - a3) and b3 == (c[2][2] - a3)):
                print('Yes')
                sys.exit(0)
print('No')


Measured memory_bytes: 64236
#include<bits/stdc++.h>
using namespace std;
#include <string>
int main(){
    int K,X;
    cin >> K >> X;
    long Max,Min;
    Max=X+K-1;
    Min=X-K+1;
    if(Max > 1000000){
        Max = 1000000;

    }
    if(Min < -1000000){
        Min = -1000000;

    }
    for (int ans=Min ; Min<=ans &&ans<=Max ;ans++){
        cout << ans <<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[10]:


X,Y = map(int, input().split())


# In[12]:


mylist = []
for i in range(Y//X):
    tmp = X*(2**i)
    if tmp <= Y:
        mylist.append(tmp)
    else:
        break
print(len(mylist))


# In[ ]:






Measured memory_bytes: 9124
#include <iostream>
#include <vector>
using namespace std;
 
class Dice{
public:
    long r[6];
    Dice(){};
    void roll(long a, long b, long c, long d){swap(r[a], r[b]);swap(r[b], r[c]);swap(r[c], r[d]);}
    void spin(char c){if (c == 'W') roll(0, 2, 5, 3);else roll(0, 1, 5, 4);}
};
 
int main() {
    bool ans = 0;
    int n;
    cin >> n;
    vector<Dice> D(n);
    for (int i = 0; i < n ; i++) {for (int j = 0; j < 6; j++) cin >> D[i].r[j];}
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            char SWS[8]={"NNNWNNN"};
            for (int k = 0; k < 8; k++){
                if (D[i].r[1] == D[j].r[1]) break;
                D[j].spin(SWS[k]);
            }
            for (int k = 0; k < 4; k++){
                if (D[i].r[0] == D[j].r[0]){
                    if (D[i].r[1] == D[j].r[1] && D[i].r[2] == D[j].r[2] && D[i].r[3]==D[j].r[3] && D[i].r[4] == D[j].r[4] && D[i].r[5] == D[j].r[5])
                        ans = 1;
                }
                D[j].spin('W');
            }
        }
    }
    if (ans == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int n,k;
    cin >> n >> k;
    int a[n];
    rep(i,n)cin>>a[i];
    int dp[k+1] = {};

    rep(i,k+1){
        int flag = 1;
        rep(j,n){
            if(i-a[j]<0)continue;
            if(i-a[j]==0){
                flag = 0;
                break;
            }
            if(dp[i-a[j]]==1){
                flag = 0;
                break;
            }
        }
        dp[i] = flag;
    }

    if(dp[k]==1){
        cout << "Second" << endl;
    }else{
        cout << "First" << endl;
    }

    return 0;
}
 
 


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<int, int>pi;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

int n;
ll fact[100010], ans = 1;
P p[200010];


int main() {
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> p[i].fr;
		p[i].sc = 1;
	}
	for (int i = 0;i < n;i++) {
		cin >> p[i + n].fr;
		p[i + n].sc = 2;
	}
	fact[1] = 1;
	for (int i = 2;i <= n;i++) {
		fact[i] = fact[i - 1] * i;
		fact[i] %= MOD;
	}
	queue<int>aa, bb;
	sort(p, p + 2 * n);
	for (int i = 0;i < 2 * n;i++) {
		if (p[i].sc == 1 && bb.empty()) {
			aa.push(1);
		}
		else if (p[i].sc == 2 && aa.empty()) {
			bb.push(1);
		}
		else if (p[i].sc == 1 && !bb.empty()) {
			ans *= bb.size();
			bb.pop();
			ans %= MOD;
		}
		else if (p[i].sc == 2 && !aa.empty()) {
			ans *= aa.size();
			aa.pop();
			ans %= MOD;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4608
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;
 
#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999
 
#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
 
typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;
 
typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;
 
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;
 
namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}
 
int main() {
    int n;
    int m = 0;
    cin >> n;

    pii a[20];
    rep(i,0,n) {
        cin >> a[i].second >> a[i].first;
        m = max(m, a[i].first);
    }

    sort(a, a+n);
    int ans = lower_bound(a, a+n, pii(m,0)) - a;
    cout << a[ans].second << " " << a[ans].first << endl;
    return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <type_traits>
using namespace std;

#define INF 1e18
#define int long long

template<typename T>
void printVec(vector<T>& v) {
    for(int i = 0; i < v.size(); i++) {
        cout << v[i] << " ";
    }
    cout << endl;
}

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

    int sum = 1;
    for(int i = 0; i < n; i++) {
        if(a[i] % 2 == 0) sum *= 2;
    }

    int ans = pow(3, n) - sum;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)	   for(int i = 0; i < (n); ++i)
#define all(c)		   begin(c), end(c)
#define rall(c)		   rbegin(c), rend(c)
#define SZ(a)		   ((ll) a.size())

typedef long long		   ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<ll> X(N);
  vector<ll> X2(N);
  rep(i,N){
    scanf("%lld",&X[i]);
  }
  copy(all(X),X2.begin());
  sort(all(X2));
  ll med1=X2[N/2-1];
  ll med2=X2[N/2];
  rep(i,N){
    if(X[i]<=med1) printf("%lld\n",med2);
    else if(X[i]>=med2) printf("%lld\n",med1);
  }
}


Measured memory_bytes: 5376
def cre_permu(a, temp, unused, digit):
    if digit==n:
        a.append(temp*10+unused[0])
        #print(a[-1])
        return
    else:
        for i in unused:
            cre_permu(a, temp*10+i, [k for k in unused if k!=i], digit+1)
    return

n = int(input())
p = int(input()[0::2])
q = int(input()[0::2])
lis = []
cre_permu(lis, 0, [i for i in range(1, n+1)], 1)
print(abs(lis.index(p)-lis.index(q)))

Measured memory_bytes: 4632
#include <stdio.h>
#include <stdint.h>
#include <memory.h>

int main(void)
{
    uint32_t N, M, X;
    uint32_t fee[101];
    scanf("%u %u %u", &N, &M, &X);

    /* default: fee is 0 */
    memset(fee, 0, sizeof(fee));

    /* set fee */
    for (uint32_t m = 0; m < M; m++) {
        uint32_t idx;
        scanf("%u", &idx);
        fee[idx] = 1;
    }

    /* to 0 */
    uint32_t costTo0 = 0;
    for (uint32_t idx = 0; idx <= X; idx++) {
        costTo0 += fee[idx];
    }

    /* to N */
    uint32_t costToN = 0;
    for (uint32_t idx = X; idx <= N; idx++) {
        costToN += fee[idx];
    }

    /* answer */
    printf("%u\n", (costTo0 < costToN) ? costTo0 : costToN);

    return 0;
}



Measured memory_bytes: 128
from collections import deque
H,W = map(int,input().split())
grid = [list(input()) for _ in range(H)]

def bfs():
    dist = [[-float('inf')]*W for _ in range(H)]
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    q = deque()
    q.append([sy,sx])
    dist[sy][sx] = 0
    while q:
        p = q.popleft()
        for i in range(4):
            ny = p[0] + dy[i]
            nx = p[1] + dx[i]
            if 0 <= nx < W and 0 <= ny < H and grid[ny][nx] == '.' and dist[ny][nx] == -float('inf'):
                q.append([ny,nx])
                dist[ny][nx] = dist[p[0]][p[1]] + 1
    longest_dist = 0
    for y in range(H):
        for x in range(W):
            longest_dist = max(longest_dist,dist[y][x])
    return longest_dist
ans = 0
for sy in range(H):
    for sx in range(W):
        if grid[sy][sx] == '.':
            ans = max(bfs(),ans)

print(ans)


Measured memory_bytes: 48240
Scanf.scanf "%d %s" (fun n a ->
    let a = Array.init n (fun i -> int_of_char a.[i] - 49) in

    let bits k =
        let rec loop i acc =
            if i = 0 || i land 1 = 1 then acc else loop (i lsr 1) (acc + 1)
        in
        loop k 0
    in

    let calc aa =
        let l = Array.length aa in
        let rec loop a b acc ev =
            if a < 0 then ev else
                let ev = if acc > 0 then ev else ev lxor aa.(a) in
                let acc = acc + bits a - bits b in
                loop (a - 1) (b + 1) acc ev
        in
        loop (l - 1) 1 0 0
    in
    Printf.printf "%d\n" @@
    if calc a mod 2 = 1 then 1 else
        if Array.exists (fun a -> a = 1) a then 0 else
            calc (Array.map (fun a -> a / 2) a) * 2
)

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

int main() {
    string a, b;
    cin >> a >> b;
    string s1 = "", s2 = "";
    rep(i, stoi(b)) { s1 += a; }
    rep(i, stoi(a)) { s2 += b; }
    cout << min(s1, s2) << endl;
    return 0;
}


Measured memory_bytes: 3620
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    D, G = map(int, input().split())
    pc = [tuple(map(int, input().split())) for _ in range(D)]

    ans = 10 ** 9
    for i in range(2 ** D):
        sum_v = 0
        cnt = 0
        for j, (p, c) in enumerate(pc):
            if i & 1 << j:
                sum_v += (j+1) * 100 * p + c
                cnt += p
        if sum_v >= G:
            if cnt < ans:
                ans = cnt
            continue
        for j, (p, c) in enumerate(pc[::-1]):
            k = D - j
            if not (i & 1 << k-1):
                for _ in range(p):
                    sum_v += k * 100
                    cnt += 1
                    if sum_v >= G:
                        if cnt < ans:
                            ans = cnt
                        break
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
S = [int(_) for _ in input()][::-1]
N = len(S)
ans = 0
for i in range(1 << N - 1):
    digit = 0
    ans += S[0]
    for j in range(N - 1):
        if i & 1:
            digit += 1
        else:
            digit = 0
        i >>= 1
        ans += S[j + 1] * 10**digit
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <stdlib.h>
#include <string>
#include <stack>
using namespace std;

int main()
{
	string s;
	stack<int> st;

	while ( cin >> s ) {
		if ( s == "+" ) {
			int op2 = st.top();
			st.pop();
			int op1 = st.top();
			st.pop();
			st.push(op1 + op2);
		} else if ( s == "-" ) {
			int op2 = st.top();
			st.pop();
			int op1 = st.top();
			st.pop();
			st.push(op1 - op2);
		} else if ( s == "*" ) {
			int op2 = st.top();
			st.pop();
			int op1 = st.top();
			st.pop();
			st.push(op1 * op2);
		} else {
			st.push(atoi(s.c_str()));
		}
	}
	cout << st.top() << endl;
}



Measured memory_bytes: 3212
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define _FasterIO  ios_base::sync_with_stdio(false);  cin.tie(0); cout.tie(0);

/*
 Author: Fuad Ashraful Mehmet
 University of Asia Pacific
 created :8 Sep 2019  8.30  pm
 Category : DP
 Problem: https://www.spoj.com/problems/MIXTURES/
*/
using namespace std;
//long long int row[]= {-1,0,1,0};
//long long int col[]= {0,-1,0,1};

//long long int row [] = {+1,-1,+0,+0,-1,-1,+1,+1}; ///fuck array for eight direction
//long long int col [] = {+0,+0,+1,-1,+1,-1,-1,+1}; /// fuck array for eight direction
int n,m;

const int N=5005;

int A[102];
int B[102];
int C[102];



void Solve()
{

   int n;
   cin>>n;
   for(int i=1;i<=n;++i)
   cin>>A[i];
   for(int i=1;i<=n;++i)
   cin>>B[i];

   for(int i=1;i<n;++i)
    cin>>C[i];

   int result=0;
   int prev=0;
   for(int i=1;i<=n;++i)
   {
       int x=A[i];
       result+=B[x];
       if(x-prev==1&&prev!=0)
       {
           result+=C[prev];
       }
       prev=x;

   }


   cout<<result<<endl;



}
int main()
{

    _FasterIO
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //   fuad:

    Solve();

    return 0;
}


Measured memory_bytes: 256
k,n = map(int,input().split())
a = list(map(int,input().split()))
dist = [0]*n
for i in range(n-1):
  dist[i] = a[i+1]-a[i]
dist[-1] = k-a[-1]+a[0]
dist.sort()
dist.remove(dist[-1])
print(sum(dist))

Measured memory_bytes: 77516
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

l,r = na()
mod = 2019
ans = mod

for i in range(mod):
    for j in range(mod):
        ll = l+i
        rr = r-j
        if ll >= rr:
            continue
        ans = min(ans,ll*rr%mod)

print(ans)

Measured memory_bytes: 41180
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
    int i,j;
    for (i=0 ,j=1;i<10000  ; i++)
    {cin>>j;
     if(j==0) break;
     cout <<"Case "<<i+1<<": "<<j<<endl;}
}



Measured memory_bytes: 3088
N = int(input())
for i in range(N):
    x, y, b, p = map(int, input().split())
    if b >= 5 and p >= 2:
        print(int((x*b + y*p) * 0.8))
    else:
        regular_price = x*b + y*p
        if b < 5:
            b = 5
        
        if p < 2:
            p = 2

        discount = int((x*b + y*p) * 0.8)
        if regular_price <= discount:
            print(regular_price)
        else:
            print(discount) 



Measured memory_bytes: 5620
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**7)
inf = float('inf')
mod = 10**9+7
ans = inf ;count = 0 ;pro = 1

a,b=map(int,input().split())
print(math.ceil((a+b)/2))

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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  s[k-1] = s[k-1] + 32;
  cout << s << endl;

  return 0;
}

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

int main(int argc, char *argv[])
{
  int N, L;
  char **S;
  
  int i, j, k, ii;
  char *tmp;
  
  scanf("%d%d", &N, &L);
  S = (char **)malloc(sizeof(char *)*N);
  for( i=0; i<N; i++) {
    S[i] = (char *)malloc(sizeof(char)*(L+1));
    scanf("%s", S[i]);
  }
  
  for( i=N-1; i; i--) {
    for( j=0; j<i; j++) {
      for( k=0; k<L; k++) {
        if( strcmp(S[j], S[j+1]) > 0 ) {
          tmp = S[j];
          S[j] = S[j+1];
          S[j+1] = tmp;
          break;
        }
      }
      //for( ii=0; ii<N; ii++)
      //  printf("%s ", S[ii]);
      //printf("\n");
    }
  }
  
  for( ii=0; ii<N; ii++)
    printf("%s", S[ii]);
  printf("\n");
  
  return 0;
}

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

set<int> s;
int a, n;

int main(){
    cin >> n;
    for (int i = 0; i < n; ++i){
        cin >> a;
        if (s.find(a) != s.end()){
            cout << "NO";
            return 0;
        }
        else s.insert(a);
    }
    cout << "YES";
    return 0;
}

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

int main(){

	int n;
	vector<int> vc;
	
	while(cin >> n){
		if(n == -1) break;
		vc.clear();
		
		if(n == 0){
			cout << '0' << endl;
			continue;
		}
		
		while(1){
			if(n == 0) break;
			vc.insert(vc.begin(), n % 4);
			n = (n - n % 4) / 4;
		}
		
		for(int i=0; i<vc.size(); i++){
			cout << vc[i];
		}
		cout << endl;
	}

	return 0;

}

Measured memory_bytes: 1216
#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 int
#define endl "\n"
#define db(x) cout<<#x<<" ->"<<x<<endl
#define db2(x,y) cout<<#x<<"->"<<x<<", "<<#y<<" -> "<<y<<endl
#define db3(x,y,z) cout<<#x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define db4(w,x,y,z) cout<<#w <<" -> " << w << " , " << #x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define prt(x) for(auto it = x.begin(); it!=x.end(); it++) { cout<<*it<<" "; } cout<< endl
#define IN freopen("input.txt","r",stdin)
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = (int)1e5+4;
const int lim = (int)1e9;

int32_t main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
//    IN;
    vector< ll > V;
    ll n , m;
    cin >>  n >> m;
    for(int i = 0;i < n; i++){
        ll x;
        cin >> x;
        x/=2;
        V.push_back(x);
    }
    ll lcm = V[0];
    bool fl = 1;
    bool lol = 0;
    for(int i = 1; i < V.size(); i++){
        lcm = (1LL * V[i] * lcm) / __gcd(V[i],lcm);
        if(lcm > m){ fl = 0; break ;}
    }
    for(auto &x : V){
        if( ( lcm / x ) % 2 == 0 ){ fl = 0; break ;}
    }
    if(fl==0){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0LL;
    ll cur = m / lcm;
    ans+=(cur+1) / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  auto n=scanElem;
  if(n>=1200)end("ARC");end("ABC");
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

		static void solve() {
			Scanner sc = new Scanner(System.in);
			int r = sc.nextInt();
			int d = sc.nextInt();
			int x = sc.nextInt();
			for(int i = 0; i<10;i++) {
				int x1 = r*x - d;
				System.out.println(x1);
				x = x1;
			}
			sc.close();
		}
	public static void main(String[] args) {
		solve();

	}

}


Measured memory_bytes: 22356
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int min = 100;
        for(int i = 1;i+i <= n;i++){
            int a = i;
            int b = n-i;
            int asum = solve(a);
            int bsum = solve(b);
            int total = asum + bsum;
            min = Math.min(min,total);
        }
        System.out.println(min);
    }
    public static int solve(int x){
        int sum = 0;
        while(x > 0){
            sum += x % 10;
            x /= 10;
        }
        return sum;
    }
}


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

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

    int answer;

    answer=max({a+b,a-b,a*b});


    cout<< answer <<endl;
}


Measured memory_bytes: 256
while 1:
    s1 = input().split('"')
    if s1 == ['.']:
        break
    s2 = input().split('"')
    if len(s1) != len(s2):
        print("DIFFERENT")
        continue
    r = [0]*2
    for i in range(len(s1)):
        if s1[i] != s2[i]:
            r[i%2] += 1
    if [0,1]<r:
        print("DIFFERENT")
    else:
        print(["IDENTICAL","CLOSE"][r[1]])

Measured memory_bytes: 7464
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
struct edge{
    int from, to, cost;
};

const int INF = 1001001001;

int par[100010];
void init(int n);
int find(int n);
void unite(int a, int b);
bool same(int a, int b);
bool comp(edge& e1, edge& e2);

int main(){
    int N;
    cin >> N;
    vector<P> x(N), y(N);
    for(int i = 0; i < N; ++i){
        int temp;
        cin >> temp;
        x[i] = P(temp, i);
        cin >> temp;
        y[i] = P(temp, i);
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    
    vector<edge> ed;
    for(int i = 0; i < N - 1; ++i){
        edge e;
        e.from = x[i].second;
        e.to = x[i + 1].second;
        e.cost = x[i + 1].first - x[i].first;
        ed.push_back(e);
        e.from = y[i].second;
        e.to = y[i + 1].second;
        e.cost = y[i + 1].first - y[i].first;
        ed.push_back(e);
    }
    sort(ed.begin(), ed.end(), comp);
    
    init(N);
    ll res = 0;
    for(int i = 0; i < ed.size(); ++i){
        edge e = ed[i];
        // 辺を作る2頂点が部分最小全域木に含まれていればcontinue
        if(same(e.from, e.to))      continue;
        
        unite(e.from, e.to);
        res += e.cost;
    }
    
    cout << res << endl;
}

void init(int n){
    for(int i = 0; i < n; ++i){
        par[i] = i;
    }
}

int find(int n){
    if(n == par[n]){
        return n;
    }
    else{
        return par[n] = find(par[n]);
    }
}

void unite(int a, int b){
    a = find(a);
    b = find(b);
    
    if(a == b)      return;
    // a != b
    par[b] = a;
    return;
}

bool same(int a, int b){
    return find(a) == find(b);
}

bool comp(edge& e1, edge& e2){
    return e1.cost < e2.cost;
}

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

int main() {
  int num,val,sum = 0, count = 0;
  cin >> num;
  val = num;
  while (num) {
    sum += num%10;
    num /= 10;
  }
  int pow = 1;
  while (pow < val) {
    pow *= 10;
  }
  if (pow == val)
    cout << 10 << endl;
  else 
    cout << sum << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(long i = 0; i < (n); i++)
using namespace std;
using P = pair<long, long>;
long mod = (long) 1e9 + 7;
long ans[2001][2001] = {};

int main(){
    
    long n;
    cin >> n;
    set<P> s;
    
    rep(i,n){
        long x;
        cin >> x;
        s.emplace(P((-1 * x),i));
    }
    
    long x = 0;
    
    for(auto i:s){
        
        ans[x + 1][0] = ans[x][0] + i.first * -1 * abs(i.second - x);
        ans[0][x + 1] = ans[0][x] + i.first * -1 * abs(i.second + x + 1 - n);
        rep(j,x){
            ans[x - j][1 + j] = max(ans[x - j - 1][1 + j] + i.first * -1 * abs(i.second - x + j + 1),
                                    ans[x - j][j] + i.first * -1 * abs(i.second + j + 1 - n));
        }
        x++;
    }
    
    long res = 0;
    rep(i,n + 1){
        res = max(res, ans[n - i][i]);
    }
    
    cout << res << "\n";
    
    return 0;
}




Measured memory_bytes: 25904
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <cctype>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;
const int maxn = 1e6+7;

int main(){
	int n;
	string str;
	cin>>n>>str;
	for(int i=0;i<str.length();i++){
		if(str[i]+n>'Z'){
			str[i]=str[i]+n-'Z'+'A'-1;
		}
		else{
			str[i]+=n;
		}
	}
	for(int i=0;i<str.length();i++){
		cout<<str[i];
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////


typedef struct _ufTree{ 
	typedef long idx_type;
	
	vector<idx_type> par;
	vector<idx_type> rank;

	//n要素で初期化
	void init(idx_type n){
		par.assign(n,0);
		rank.assign(n,0);	
		for(idx_type i=0;i<n;i++) par[i]=i;
	}
	
	//木の根を求める
	idx_type root(idx_type x){
		if(par[x]==x) return x;
		else return par[x]=root(par[x]);
	}
	
	//xとyが同じ集合に属するかを調べる
	bool same(idx_type x,idx_type y){
		return root(x)==root(y);
	}
	
	//xとyの属する集合を併合
	void unite(idx_type x,idx_type y){
		x=root(x);
		y=root(y);
		if(x==y) return;
		if(rank[x]<rank[y]) par[x]=y;
		else{
			par[y]=x;
			if(rank[x]==rank[y]) rank[x]++;
		}
	}
}ufTree;

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

	ufTree u;
	u.init(m);
	
	int la[n];
	rep(i,0,n){
		int k;
		cin >> k;
		int l0;
		cin >> l0;
		l0--;
		la[i] = l0;
		rep(j,1,k){
			int l;
			cin >> l;
			l--;
			u.unite(l0,l);
		}
	}
	
	rep(i,1,n){
		if(u.root(la[i] )!= u.root(la[0])){
			NO;
			ret 0;
		}
	}	
	
	YES;
	ret 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<int>());
  for(int i=0;i<min(s.size(), t.size());i++){
    if(s[i] == t[i]) continue;
    if(s[i]>t[i]){
      cout << "No" << endl;
      return 0;
    }
    if(s[i]<t[i]){
      cout << "Yes" << endl;
      return 0;
    }    
  }
  cout << (s.size()>=t.size()?"No":"Yes") << endl;
}

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

using namespace std;

using ll = long long;
using us = unsigned short;

int main (void){
  us r, g, b;
  cin >> r >> g >> b;

  us num;
  num = g * 10 + b;
  if(num % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


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


int N;
string s;

void read() {
    cin >> N >> s;
}


void work() {
    for (int i = 0; i < s.size(); ++i) {
        cout << (char)((s[i] - 'A' + N) % 26 + 'A');
    }
    cout << endl;
}


int main() {
    read();
    work();
    return 0;
}


Measured memory_bytes: 256
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#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 <cstdalign>
#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;

int main()
{
  ll n, k;
  string s;
  cin >> n >> k >> s;

  switch (s[k - 1])
  {
  case 'A':
    s[k - 1] = 'a';
    break;
  case 'B':
    s[k - 1] = 'b';
    break;
  case 'C':
    s[k - 1] = 'c';
    break;
  }
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

map<ll, int> prime_factors(const ll init_n) {
    map<ll, int> ans;
    ll n = init_n;
    for (ll i = 2; i * i <= init_n; i++) {
        if (n % i == 0) {
            int cnt = 0;
            while (n % i == 0) {
                n /= i;
                cnt++;
            }
            ans[i] = cnt;
        }
    }

    if (n != 1) {
        ans[n]++;
    }

    return ans;
}

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

    if(N == 1) {
        cout << 0 << endl;
        return 0;
    }

    map<ll, int> factors = prime_factors(N);
    // for (auto &p : factors) {
    //     cout << p.first << ": " << p.second << endl;
    // }

    vector<int> acc;
    for (auto &p : factors) {
        ll prime = p.first;
        int cnt = p.second;
        int x = 0;
        int i = 1;
        for (;;) {
            x += i;
            if (x > cnt) {
                break;
            }
            i++;
        }
        i--;
        acc.push_back(i);
    }

    int ans = 0;
    for (auto x : acc) {
        ans += x;
        // cout << x << endl;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rept(k,i,n) for(int i = (k); i < (int)(n); i++)
typedef long long ll;
typedef pair<double,double> Pdd;

int main(){
    int n;cin>>n;vector<int> l(n);
    rep(i,n) cin>>l[i];
    sort(l.begin(),l.end());
    int ans=0;
    rep(i,n-2){
        rept(i+1,j,n-1){
            int sm=l[i]+l[j];
            int k=lower_bound(l.begin(),l.end(),sm)-l.begin();
            if(j<k-1){
                ans+=k-1-j;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
    int N, T, A;
    int H[1100];
    cin >> N;
    cin >> T >> A;
    int x = 1;
    for(int i = 1; i <= N; i++)
        cin >> H[i];
    
    int min = ((1000*T -6*H[1]) - A*1000);
    if(min < 0) min = -min;
    for(int i = 1; i <= N; i++){
        int d = 1000*T -6*H[i] - A*1000;
        if(d < 0) d = -d;
        if(min >= d){
            min = d;
            x = i;
        }
    }
    cout << x << endl;
    return 0;
}

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

typedef long long ll;

ll n;

int main() {
	cin >> n;
	ll ans = n / 11LL * 2LL; n %= 11LL;
	if(n > 6) ans += 2;
	else if(n) ans += 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long int
int main(){
    ll a, b, ans=-1;
    cin>>a>>b;
    ll w[a], v[a], dp[a][b+1];
    for (ll i=0; i<a; i++){
        for (ll j=0; j<=b; j++){
            dp[i][j]=-1;
        }
    }
    for (ll i=0; i<a; i++){
        cin>>w[i]>>v[i];
        dp[i][w[i]]=v[i];
//      dp[i][0]=0;
    }
    for (ll i=0; i<a-1; i++){
        for (ll j=0; j<=b; j++){
            if (dp[i][j]==-1) continue;
            dp[i+1][j]=max(dp[i+1][j], dp[i][j]);
            if (j+w[i+1]>b) continue;
            dp[i+1][j+w[i+1]]=max(dp[i+1][j+w[i+1]], dp[i][j]+v[i+1]);
        }
    }
    for (ll j=1; j<=b; j++) ans=max(ans, dp[a-1][j]);
    cout<<ans<<endl;
}


Measured memory_bytes: 78336
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 1'000'100
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;

/*
ll PascalsTriangle[SIZE][SIZE];
void initPascalsTriangle(){
	PascalsTriangle[0][0] = 1;
	rep(i, SIZE-1){
		rep(j, i+1){
			PascalsTriangle[i+1][j] += PascalsTriangle[i][j];
			PascalsTriangle[i+1][j] %= MOD;
			PascalsTriangle[i+1][j+1] += PascalsTriangle[i][j];
			PascalsTriangle[i+1][j] %= MOD;
		}
	}
}

//nCk
ll comb(int n, int k){
	return PascalsTriangle[n][k];
}
*/

ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

ll moddiv(ll x, ll y) {
	return (x * mod_pow(y, MOD - 2)) % MOD;
}


int main() {
	ll X, Y;
	cin >> X >> Y;
	if(X > 2 * Y) {
		cout << 0 << endl;
		return 0;
	}
	if(Y > 2 * X) {
		cout << 0 << endl;
		return 0;
	}
	ll b = 2 * X - Y;
	if(b % 3) {
		cout << 0 << endl;
		return 0;
	}
	b /= 3;
	ll a = X - 2 * b;
	//a+bCb

	ll ans = 1;
	for(ll i = 1; i <= b; i++) {
		ans *= moddiv(a + b + 1 - i, i);
		ans %= MOD;
	}
	cout << ans << endl;
}

/*
int main(void){
	int x, y; cin >> x >> y;
	map<LLPair, long> dp;
	dp[make_pair(0, 0)] = 1;
	dp[make_pair(y, x)] = 0;
	priority_queue<LLPair> que;
	que.push(make_pair(0, 0));
	//que.push(make_pair(1, 2));
	//que.push(make_pair(1, 1));

	while(1){
		if(que.empty()) break;
		int ny = -1 * que.top().first;
		int nx = -1 * que.top().second;
		que.pop();
		if(ny == y && nx == x) break;
		if(dp[make_pair(ny, nx)] == 0) continue;

		if(ny+1 <= y && nx+2 <= x){
			dp[make_pair(ny+1, nx+2)] += dp[make_pair(ny, nx)];
			dp[make_pair(ny+1, nx+2)] %= MOD;
			que.push(make_pair(-1*(ny+1), -1*(nx+2)));
		}
		if(ny+2 <= y && nx+1 <= x){
			dp[make_pair(ny+2, nx+1)] += dp[make_pair(ny, nx)];
			dp[make_pair(ny+1, nx+2)] %= MOD;
			que.push(make_pair(-1*(ny+2), -1*(nx+1)));
		}
		dp.erase(make_pair(ny, nx));
	}
	cout << dp[make_pair(y, x)] << endl;
	return 0;
}
*/

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);

$line = fgets(STDIN);
$nums = preg_split('/ /', trim($line));

list($min, $max, $total) = array_reduce($nums, function ($carry, $n) {
    if ($n < $carry[0]) {
        $carry[0] = $n;
    }

    if ($carry[1] < $n) {
        $carry[1] = $n;
    }

    $carry[2] += $n;

    return $carry;
}, array(1000001, -1000001, 0));

echo "$min $max $total\n";

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

/*zzzzdfadfadfad*/
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long LL;
const int N=100500;
int read(int &n)
{
    char ch=' ';int q=0,w=1;
    for(;(ch!='-')&&((ch<'0')||(ch>'9'));ch=getchar());
    if(ch=='-')w=-1,ch=getchar();
    for(;ch>='0' && ch<='9';ch=getchar())q=q*10+ch-48;n=q*w;return n;
}
int m,n,ans;
int a[N];
int g[N];
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int main()
{
    int w;
/*zzzzdfadfadfad*/
    LL q;
    read(n);
    fo(i,1,n)q+=(LL)read(a[i]);
    if(n==1&&a[1]==1)return printf("Second\n"),0;
    if(n==1)return printf("First\n"),0;
    if(!(n&1))
    {
        if(q&1)printf("First\n");
        else printf("Second\n");
        return 0;
    }
    if(!(q&1))return printf("First\n"),0;
    for(bool I=0;1;I=!I)
    {
        g[n]=a[n];
        LL t=a[n]-1;
/*zzzzdfadfadfad*/
        fod(i,n-1,1)g[i]=gcd(g[i+1],a[i]),t+=(LL)a[i];
        bool OK=0;
        q=a[1];
        if(a[1]-1&&(1&(t/(ans=gcd(g[2],a[1]-1)))))OK=1,--a[1];
        else fo(i,2,n)if(a[i]-1)
        {
            w=gcd(q,a[i]-1);
            if(i<n)w=gcd(w,g[i+1]);
            if((1&(t/(ans=w))))
            {
                OK=1,--a[i];
                break;
            }
/*zzzzdfadfadfad*/
            q=gcd(q,a[i]);
        }else break;
        if(!OK)
/*zzzzdfadfadfad*/
        {
            if(I)printf("First\n");
            else printf("Second\n");
            return 0;
        }
        fo(i,1,n)a[i]/=ans;
    }
    return 0;
}

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

using namespace std;

int main(){
    int n, d, x;
    cin >> n >> d >> x;
    int a[n];
    for(int i = 0; i < n; ++i) cin >> a[i];
    int c = 0;
    for(int i = 0; i < n; ++i){
        c += d / a[i] + 1;
        if(d % a[i] == 0) c--;
    }
    cout << c + x << endl;
}

Measured memory_bytes: 3640
#include"bits/stdc++.h"

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> a(N);

	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	sort(a.begin(), a.end(),greater<int>());

	int sum = 0;
	for (int i = 0; i < N; i += 2) {
		sum += a[i];
	}
	int sum1 = 0;
	for (int i = 1; i < N; i += 2) {
		sum1 += a[i];
	}

	cout << sum - sum1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int H,R;
    cin>>H>>R;
    if(R+H==0){
        cout<<"0"<<endl;
    }
    else if(R+H>0){
        cout<<"1"<<endl;
    }
    else{
        cout<<"-1"<<endl;
    }
}


Measured memory_bytes: 3096
x = int(input())

count_500 = 0
count_5 = 0
while x >= 500:
  x -= 500
  count_500 += 1

while x >= 5:
  x -= 5
  count_5 += 1
  
ans = 1000 * count_500 + 5 * count_5
print(ans)

Measured memory_bytes: 2940