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


// type {{{

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;

// }}}


// macro {{{

#define rep(i,n) for (ll i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i,n) for (ll i=1, i##_len=(n); i<=i##_len; ++i)
#define FOR(i,a,n) for (ll i=(a), i##_len=(n); i<i##_len; ++i)

#define SZ(x) ((ll)(x).size())

#define all(x) begin(x),end(x)

// }}}


// debug {{{

#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    rep (i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "(" << p.first << " " << p.second << ")";
}

// }}}


// chmax, chmin {{{

template<class T>
bool chmax(T& a, const T& b) {
    if (a < b) { a = b; return true; }
    return false;
}
template<class T>
bool chmin(T& a, const T& b) {
    if (b < a) { a = b; return true; }
    return false;
}

// }}}



// constants {{{

#define inf(T) numeric_limits<T>::max()

const ll MOD = 1e9+7;
const ld EPS = 1e-9;

// }}}


using Real = double;
const Real PI = acos(-1);

struct Point3D {
    double x, y, z;
    Point3D() {}
    Point3D(double x, double y, double z) : x(x), y(y), z(z) {}
    Point3D operator+(const Point3D& b) const {
        return Point3D(x + b.x, y + b.y, z + b.z);
    }
    Point3D operator-(const Point3D& b) const {
        return Point3D(x - b.x, y - b.y, z - b.z);
    }
    friend double norm(const Point3D& p) {
        return p.x * p.x + p.y * p.y + p.z * p.z;
    };
    friend double abs(const Point3D& p) { return sqrt(norm(p)); }

    friend ostream &operator<<(ostream &os, Point3D &p) {
        return os << "(" << p.x << "," << p.y << "," << p.z << ")";
    }
    friend istream &operator>>(istream &is, Point3D &p) {
        return is >> p.x >> p.y >> p.z;
    }
};

double dot(const Point3D &a, const Point3D &b) {
    return a.x * b.x + a.y * b.y + a.z * b.z;
}


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N, M; cin >> N >> M;

    vector<Point3D> p(N);
    rep(i, N) {
        cin >> p[i];
    }

    double ans = 0;
    rep(s, 1<<N) if (__builtin_popcount(s) == M) {
        double sum = 0;
        rep(i, N) if (s >> i & 1) {
            FOR(j, i+1, N) if (s >> j & 1) {
                sum += dot(p[i] - p[j], p[i] - p[j]);
            }
        }
        chmax(ans, sum);
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3300
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fr(i,j,p)   for(int i=j; i<p ;i++)
#define frr(i,j,p)  for(int i=j; i>=p ;i--)
#define PI          3.14159265358979323846
#define pb          push_back
#define mkp         make_pair
#define print(m)    std::cout << std::fixed << std::setprecision(11) << m <<endl;
#define ff          first
#define ss          second
#define mod         1000000007

int main() {
    lli n;  cin>>n;
        lli a[n],b[n],c[n],dpa[n],dpb[n],dpc[n];
        fr(i,0,n) cin>>a[i]>>b[i]>>c[i];
        dpa[0]=a[0];
        dpb[0]=b[0];
        dpc[0]=c[0];
        fr(i,1,n) {
            dpa[i]=a[i]+max(dpb[i-1],dpc[i-1]);
            dpb[i]=b[i]+max(dpa[i-1],dpc[i-1]);
            dpc[i]=c[i]+max(dpa[i-1],dpb[i-1]);
        }
        cout<<max(dpa[n-1],max(dpb[n-1],dpc[n-1]));
    return 0;
}



Measured memory_bytes: 8284
// HOPE IS A GOOD THING MAY BE THE BEST OF THINGS AND NO GOOD THINGS EVER DIES  <3 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define pii pair <int, int>
#define pll pair <long long, long long >
#define PI 2 * acos(0.0)
#define testcase ll T; cin >> T; for (int tc = 1; tc <= T; tc++)
const long long M = 2e5 + 10, M2 = 1e6 + 10, oo = 1e9 + 7;

int main () {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
    cin >> s >> t;
    t.erase(t.size() - 1, 1);
    if (s == t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3652
N = int(input())
A = list(map(int, input().split()))
B = [0] * N
ans = []

for i in range(N, 0, -1):
  j = 1
  cnt = 0

  while i * j <= N:
    cnt += B[(i*j) - 1]
    j += 1
  
  cnt %= 2
  B[i-1] = A[i-1] ^ cnt #排他的論理和XOR
  
  if B[i-1] == 1:
    ans.append(i)

print(sum(B))
print(*ans)

Measured memory_bytes: 14120
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c)%mod;
    if (b&1) return (c*a)%mod;
    return c;
}
ll powerwithoutmod(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c);
    if (b&1) return (c*a);
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)1e5+5;
const int Q = 301;
const int logN = 18;

vector<string> ans;
void dfs(string& str, int pos, char mx, int& n) {
    if (pos==n) ans.pb(str);
    else {
        str += 'a';
        for (char ch='a';ch<=mx;ch++) {
            str[pos] = ch;
            dfs(str,pos+1,mx+(ch==mx),n);
        }
        str.ppb();
    }
}
void solve() {
    int n;
    cin>>n;
    string temp = "";
    dfs(temp,0,'a',n);
    sort(all(ans));
    for (auto it:ans) {
        cout<<it<<"\n";
    }
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        //cout<<"\n";
    }
}


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

typedef long long ll;
const int N = 108, M = N * 2;

int n, E = 0;
int to[M], first[N], next[M];
int p[N], dep[N], buf[N];
int D1, D2, ret, diam;

inline void up(int &x, const int y) {x < y ? x = y : 0;}
inline void down(ll &x, const ll y) {x > y ? x = y : 0;}

inline void addedge(int u, int v) {
	to[++E] = v, next[E] = first[u], first[u] = E;
	to[++E] = u, next[E] = first[v], first[v] = E;
}

void __builtin_dfs(int x, bool upd) {
	int i, y, deg = 0;
	if (dep[x] > dep[ret]) ret = x;
	for (i = first[x]; i; i = next[i])
		if ((y = to[i]) != p[x])
			p[y] = x, dep[y] = dep[x] + 1, ++deg, __builtin_dfs(y, upd);
	if (upd) up(buf[ dep[x] ], deg);
}

inline void dfs(int x, int parent, bool upd = false) {dep[x] = 0, p[x] = parent, __builtin_dfs(x, upd);}

int main() {
	int i, j, u, v; ll ans, product;
	scanf("%d", &n);
	for (i = 1; i < n; ++i) scanf("%d%d", &u, &v), addedge(u, v);
	dfs(ret =  1, 0), D1 = ret;
	dfs(ret = D1, 0), D2 = ret;
	for (diam = dep[D2], u = D2; u && dep[u] * 2 > diam; v = u, u = p[u]);
	if (diam & 1) {
		dfs(u, v, true), dfs(v, u, true);
		for (ans = 2, i = 0; i < diam / 2; ++i) ans *= buf[i];
	} else {
		dfs(u, 0, true);
		for (ans = 1, i = 0; i < diam / 2; ++i) ans *= buf[i], buf[i] = 0;
		for (j = first[u]; j; j = next[j]) {
			v = to[j], dfs(u, v, true), dfs(v, u, true);
			for (product = 2, i = 0; i < diam / 2; ++i) product *= buf[i], buf[i] = 0;
			down(ans, product);
		}		
	}
	printf("%d %lld\n", diam / 2 + 1, ans);
	return 0;
}

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

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<int> a(n);
    double ans = 0;
    for (size_t i = 0; i < n; i++) {
        int a;
        cin >> a;
        ans += 1/(double)a;
    }
    ans = 1/ans;
    printf("%.10f\n", ans);
    return 0;
}


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

using namespace std;

double dp[301][301][301],p;

double solve(int n,int m,int k)
{
    if(n < 0 || m < 0 || k < 0)
        return 0;

    if(n == 0 && m == 0 && k == 0)
        return 0;

    double ans;

    if(dp[n][m][k] > 0)
        return dp[n][m][k];

    ans = p + n*solve(n-1,m,k) + m*solve(n+1,m-1,k) + k*solve(n,m+1,k-1);

    return dp[n][m][k] = ans/(n+m+k);
}

int main()
{
    double i,j,n,a,c1=0,c2=0,c3=0;

    cin>>p;

    for(i=0;i<p;i++)
    {
        cin>>a;

        if(a == 3)
        {
            c3++;
        }
        else if(a == 2)
        {
            c2++;
        }
        else
        {
            c1++;
        }
    }

    memset(dp,0,sizeof(dp));
    cout<<fixed<<setprecision(10)<<solve(c1,c2,c3);

    return 0;
}


Measured memory_bytes: 213376
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9

ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll n,k;cin>>n>>k;
    ll w[n],v[n];
    f(i,0,n)cin>>w[i]>>v[i];
    ll dp[n+1][k+1];
    f(i,0,n+1){
        f(j,0,k+1){
            if(i==0 || j==0)dp[i][j]=0;
            else if(w[i-1]<=j)dp[i][j]=max(v[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][k];
    return 0;
}   


Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
void __print(int x) {cerr << x;}void __print(long x) {cerr << x;}void __print(long long x) {cerr << x;}void __print(unsigned x) {cerr << x;}void __print(unsigned long x) {cerr << x;}void __print(unsigned long long x) {cerr << x;}void __print(float x) {cerr << x;}void __print(double x) {cerr << x;}void __print(long double x) {cerr << x;}void __print(char x) {cerr << '\'' << x << '\'';}void __print(const char *x) {cerr << '\"' << x << '\"';}void __print(const string &x) {cerr << '\"' << x << '\"';}void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define read            freopen("in.txt","r",stdin)
#define write           freopen("out.txt","w",stdout)
#define loop(i,a,b)     for (ll i = a; i <= b; i++)
#define rloop(i,a,b)    for (ll i = a; i >= b; i--)
#define ms(a,x)         memset(a,x,sizeof a)
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd((a),(b))
#define lcm(a,b)        ((a)*(b))/(gcd(a,b))
#define sq(a)           (a)*(a)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)

int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        string s;
        cin>>s;
        ll n=sz(s);
        vector<ll> a(n,0);
        ll cnt=0;
        loop(i,0,n-1)
        {
            if(s[i]=='R') cnt++;
            else
            {
                a[i]+=cnt/2;
                a[i-1]+=cnt-(cnt/2);
                cnt=0;
            }
        }
        cnt=0;
        rloop(i,n-1,0)
        {
            if(s[i]=='L') cnt++;
            else
            {
                a[i]+=cnt/2;
                a[i+1]+=cnt-(cnt/2);
                cnt=0;
            }
        }
        loop(i,0,n-1) cout<<a[i]<<' ';
    }
    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ans[101][101];
void solve() {
	int h, w, n;
	cin >> h >> w >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int p = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (i % 2 == 0) {
				ans[i][j] = p + 1;
			}
			else {
				ans[i][w - j - 1] = p + 1;
			}
			a[p]--;
			if (a[p] == 0) {
				p++;
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << ans[i][j] << ' ';
		}
		cout << '\n';
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) {
		solve();
	}
}

Measured memory_bytes: 3692
n = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
    exit()

A = [0]*n

for i in range(n):
    A[D[i]] += 1

#print(A)

if A[0] != 1:
    print(0)
    exit()

ans = 1
mod = 998244353
for i in range(1, n):
    ans *= A[i-1]**A[i]
    ans %= mod
print(ans)


Measured memory_bytes: 53300
#include<iostream>
#include<cmath>
using namespace std;
int main() {
	long long n;
	cin >> n;
	long long count = 1;
	long long coo = 1;
	while (n > 1) {
		n = floor(n / 2);
		count += std::pow(2, coo);
		coo += 1;
	}
	cout << count << endl;
	return 0;
}
  

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

int main(void){
    int i,n,m,l;
	int max,min;
    scanf("%d",&n);
	scanf("%d",&min);
	scanf("%d",&m);
	max = m-min;
	if(min>m){
		min = m;
	}
	for(i=2;i<n;i++){
		scanf("%d",&m);
		l = m-min;
		if(max<l){
			max = l;
		}
		if(min>m){
			min = m;
		}
	}
	
	printf("%d\n",max);
	return 0;
}



Measured memory_bytes: 2144
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Console;
using static System.Math;
class Simple
{
    int X, t;
    void Solve() {
        //input
        X = io.Int;
        t = io.Int;
        //cal
        var ans = Max(X - t, 0);
        //ret
        WriteLine(ans);
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] { ' ', '"', ',' };
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
        AutoFlush = false
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if (_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == "")
            st = ReadLine();
        if (st != null)
            _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else
            st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


Measured memory_bytes: 11092
N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(M)]
S = [l[0] for l in L]
C = [str(l[1]) for l in L]
if N == 1:
  hani = (0, 10)
elif N == 2:
  hani = (10, 100)
elif N == 3:
  hani = (100, 1000)
lst = []
for n in range(*hani):
  n = str(n)
  iscond = True
  for s, c in zip(S, C):
    iscond *= (n[s-1] == c)
  if iscond:
    lst.append(int(n))
if lst:
  print(min(lst))
else:
  print(-1)

Measured memory_bytes: 3064
#include <sstream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cassert>
#include <ctime>
#include <map>
#include <math.h>
#include <cstdio>
#include <set>
#include <deque>
#include <memory.h>
#include <queue>

#pragma comment(linker, "/STACK:64000000")
typedef long long ll;

using namespace std;

const int MAXN = 1 << 18;
const int MOD = 1; // 1000 * 1000 * 1000 + 7;
const int INF = 2e9;

int main() {
#ifdef _MSC_VER
	freopen("input.txt", "r", stdin);
#endif

	int n, m;
	while (cin >> n >> m) {
		vector<int> p(n), q(m);
		for (int i = 0; i < n; i++) cin >> p[i];
		for (int j = 0; j < m; j++) cin >> q[j];

		multiset<pair<int, int> > st;
		for (int i = 0; i < n; i++) {
			st.insert(make_pair(p[i], 0));
		}
		for (int j = 0; j < m; j++) {
			st.insert(make_pair(q[j], 1));
		}

		int cur0 = 0, cur1 = 0;
		ll ans = 0;
		while (!st.empty()) {
			int cost = st.begin()->first;
			int type = st.begin()->second;
			st.erase(st.begin());

			if (type == 0) {
				ans += 1LL * cost * (m + 1 - cur1);
				cur0++;
			}
			else {
				ans += 1LL * cost * (n + 1 - cur0);
				cur1++;
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 10496
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;


namespace atPra
{
    class Class1
    {
        static void Main()
        {
            string[] str = Console.ReadLine().Split(' ');
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int X = int.Parse(str[2]);
            bool possible = true;
            if (A + B < X) possible= false;
            if (A > X) possible = false;

            if (possible == false) Console.WriteLine("NO");
            if (possible == true) Console.WriteLine("YES");

        }
    }
}

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

int main()
{
    ll n, k, ans = 0;
    cin >> n >> k;
    vector<ll> v(n, 0);
    rep(i, n){
        int x;
        cin >> x;
        v[x-1]++;
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < n-k; i++){
        ans += v[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int n;
typedef long long ll;
struct pt{
    int idx;
    int val;
};
 
vector<pt> v;
vector<ll> ans;
 
bool cmp(pt a, pt b) {
   
        return a.val > b.val;
    
}
 
int main() {
    scanf("%d", &n);
    v.assign(n, pt());
    ans.assign(n, 0);
    for(int i=0;i<n;i++) {
        scanf("%d", &v[i].val);
        v[i].idx = i;
    }
    sort(v.begin(), v.end(), cmp);
    int min_idx = 100020;
    v.push_back(pt());
    v[n].val = 0;
    for(int i=0;i<n;i++) {
        min_idx = min(min_idx, v[i].idx);
        ans[min_idx] += (ll)(i+1)*(v[i].val - v[i+1].val);
    }
 
    for(int i=0;i<n;i++) {
        printf("%lld\n", ans[i]);
    }
}

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

using namespace std;

typedef long long int 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; }
 
typedef pair<int,int> pair;

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

  s[k-1]+='a'-'A';

  cout << s <<endl; 
  //cout << 'a'-'A' << endl;
}

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

int main() {
	int n,l;
    bool tf=false;
    cin>>n>>l;
    int a,num;
    cin>>a;
    for(int i=1;i<n;i++){
        int b;
        cin>>b;
        if(a+b>=l){
            tf=true;
            num=i;
            break;
        }
        a=b;
    }
    if(tf){
        cout<<"Possible"<<endl;
        for(int i=1;i<num;i++){
            cout<<i<<endl;
        }
        for(int i=n-1;i>=num;i--){
            cout<<i<<endl;
        }
    }else cout<<"Impossible"<<endl;

	return 0;
}

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

//string C[1000] = {};

//	long long dp[2000][2000] = {};
int main(){
//	string t,b;
//	cin >> t >> b;
//	dp[0][0] = 1LL;
//
//	for(int i=0; i<t.size(); i++){
//		for(int j=0; j<b.size(); j++){
//			dp[i+1][j] += dp[i][j];
//			if(t[i] == b[j]){
//				dp[i+1][j+1] += dp[i][j];
//			}
//			dp[i+1][j] %= 1000000007;
//			dp[i+1][j+1] %= 1000000007;
//		}
//		dp[i+1][b.size()] += dp[i][b.size()];
//	}
//
//	cout << dp[t.size()][b.size()]%1000000007 << endl;
//
//	return 0;
/*	int p, m, c;
	cin >> p >> m >> c;

	cout << p + m + c << endl;*/
	/*int ha, hb, ka, kb, a, b, c, d, x, y;
	cin >> ha >> hb >> ka >> kb >> a >>b >>c >>d;

	x = ha*a+hb*b+(ha/10)*c+(hb/20)*d;
	y = ka*a+kb*b+(ka/10)*c+(kb/20)*d;

	if(x > y){
		cout << "hiroshi" << endl;
	}

	else if(y > x){
		cout << "kenjiro" << endl;
	}

	else{
		cout << "even" << endl;
	}*/
	/*
	int D, L;
	cin >> D >> L;

	cout << D/L+D%L << endl;
	*/
	
	int n;
	cin >> n;

	int x[100],y[100],z[100],X,Y,Z,a=0,sol[100][3] = {};

	//A
	cin >> X;
	for(int i=0; i<X; i++){
		int xm;
		cin >> xm;
		sol[xm][0] = 1;
	}

	//B
	cin >> Y;
	for(int i=0; i<Y; i++){
		int ym;
		cin >> ym;
		 sol[ym][1] = 1;
	}

	//C
	cin >> Z;
	for(int i=0; i<Z; i++){
		int zm;
		cin >> zm;
		if(sol[zm][1] == 1)a++;
		else if(sol[zm][0] != 1)a++;
	}

	cout << a << endl;
	
/*
	int n;
	cin >> n;

	int P[100];

	for(int i=0; i<n; i++){
		int p;
		cin >> p;
		P[i] = p;
	}

	int j=0,nol=1;

	while(true){
		for(int i=0; i < n; i++){
			if(P[i] >= nol)j++;
		}
		if(j < nol)break;
		nol++;
		j=0;
	}



	cout << nol-1 << endl;
	*/
	/*
	int c,n;
	cin >> c >> n;

	for(int i=0; i<n; i++){
		string s;
		cin >> s;
		C[i] = s;
	}

	int cor=0,mir=0;

	for(int i=0; i<n/2; i++){
		string J;
		J = C[i];
		for(int j=0; j<n/2; j++){
			if(J[j] == C[0][i][n-j)mir++;
			if(C[0][j][i] == C[0][n-j][i])mir++;
		}
	}

	if(mir == n*n)cor++;

	for(int i=0; i<c-1; i++){

		//repair
		int diff;
		cin >> diff;
		for(int j=0; j<diff; j++){
			int ry,rx;
			cin >> ry >> rx;
			if(C[i][ry][rx] == 0){
				C[i][ry][rx] = 1;
			}
			else C[i][ry][rx] = 0;
		}

		//mirror?
		mir = 0;

		for(int j=0; j<n/2; j++){
			for(int k=0; k<n/2; k++){
				if(C[i+1][j][k] == C[i+1][j][n-k])mir++;
				if(C[i][k][j] == C[i][n-k][j])mir++;
			}
		}
	
		if(mir == n*n)cor++;


	}
	
	cout << cor << endl;
	*/





	return 0;

}



Measured memory_bytes: 3108
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

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

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

class BTaxRate {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      for(int i=0; i<=100000; i++) {
        int tmp = i*108/100;
        if (tmp == n) {
          cout << i << endl;
          return;
        }
      }
      cout << ":(" << endl;
    }
};

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

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
s=[I() for i in range(n)]
print(len(list(set(s))))

Measured memory_bytes: 3316
subroutine solve ( a, b, ans )
        integer*8 a, b, ans
        integer*8 lim, low, high
        integer*8 mid, mul
        if ( a .eq. b ) then
          ans = (a-1)*2
          return
        endif

        lim = a*b - 1
        low  = 1
        high = 1
        high = ishft(high, 32)
        do while( high - low > 1 )
          mid = (low + high) / 2
          mul = (mid+1)/2 * (mid+1 - (mid+1)/2)
          if ( mul .gt. lim ) then
            high = mid;
          else
            low = mid;
          endif
        enddo
        ans = low - 1
        RETURN
      end

      program main
        implicit none
        integer*8 I, Q
        integer*8 A, B, ans
        read(*,*) Q

        do I = 1, Q
          read(*,*) A, B
          call solve(A, B, ans)
          write(*,*) ans
        enddo
      end

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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define int long long
#define pb push_back
#define pii pair<int,int>
#define ppii pair<pii,pii>
#define fr(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define ccM 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int32_t main()
{   fastio;
    int n;
    cin>>n;
    float pi =3.14159265359;
    cout<<float(2*pi*n)<<"\n";

}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;


const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MAXN = 3e3 + 10;
const ll INF = 1e18;
ll dp[MAXN][MAXN];
ll n, a[MAXN];
int main(){
	IOS;
	cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++){
		dp[i][i + 1] = a[i];
	}
	for (int i = 1; i < n; i++){
		dp[i][i + 2] = max(a[i], a[i + 1]) - min(a[i], a[i + 1]);
	}
	for (int i = 3; i <= n; i++){
		for (int j = 1; j <= n - i + 1; j++){
			dp[j][j + i] = min(dp[j][j + i - 2] - a[j + i - 2], dp[j + 1][j + i - 1] - a[j]) + a[j + i - 1];
			dp[j][j + i] = max(dp[j][j + i], min(dp[j + 2][j + i] - a[j + 1], dp[j + 1][j + i - 1] - a[j + i - 1]) + a[j]); 
			//cout << j << ' ' << j + i - 1<< ' ' << dp[i][j] << '\n';
		}
	}
	cout << dp[1][1 + n];
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




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

int main() {
    int K, S;
    cin >> K >> S;

    int res = 0;
    for (int x = 0; x <= K; x++) {
        for (int y = 0; y <= K; y++) {
            int z = S - x - y;
            if (z >= 0 && z <= K)
                res++;
        }
    }
    cout << res << endl;
    return 0;
}

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

int main() {
  long long N;
  std::cin >> N;
  long long min_val, tmp;
  std::cin >> min_val;
  for (int i=0; i<4; i++) {
    std::cin >> tmp;
    if (min_val > tmp) min_val = tmp;
  }
  long long cnt = N / min_val;
  if (N % min_val != 0) cnt++;
  std::cout << cnt + 4 << std::endl;
}

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

int main() {
    int x,y; cin >> x >> y;

    for(int i=0; i<=x; ++i) {
        if(2 * i + 4 * (x - i) == y) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)
#define myforInv(i,N) for(i=N;i>=0;i--)
#define myforFLInv(i,f,l) for(i=f;i>l;i--)

using namespace std;

int main(){
	long N,M,H[100000],A[100000],B[100000],i,j,ans=0;
	bool good[100000];
	cin >> N >> M;
	myfor(i,N){
		cin >> H[i];
		good[i]=true;
	}
	myfor(i,M){
		cin >> A[i] >> B[i];
		if(H[A[i]-1] >= H[B[i]-1])good[B[i]-1] = false;
		if(H[A[i]-1] <= H[B[i]-1])good[A[i]-1] = false;
	}
	myfor(i,N){
		if(good[i]){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5616
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
const double M=1.000000000000;
int n;
double a[3005],f[3005][3005],ans;
int main(){
    in(n);
    for(int i=1;i<=n;i++)scanf("%lf",&a[i]);
    f[1][1]=a[1];
    f[1][0]=M-a[1];
    for(int i=2;i<=n;i++)f[i][0]=f[i-1][0]*(M-a[i]);
    for(int i=2;i<=n;i++){
        for(int j=1;j<=i;j++){
            f[i][j]=f[i-1][j]*(M-a[i])+f[i-1][j-1]*a[i];
        }
    }
    for(int i=n/2+1;i<=n;i++)ans+=f[n][i];
    printf("%.10lf\n",ans);
	return 0;
}


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

int main(){

    //入力
    int n, m, k; cin >> n >> m >> k;
    map<int, int> M;
    for(int i = 0; i < m; i++){
        int input; cin >> input;
        M[input] = i;
    }

    vector<vector<int> > G(m + 1, vector<int> (k, -1));
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < k; j++){
            int input; cin >> input;
            int a, b;
            if(M.count(i)) a = M[i];
            else a = m;

            if(M.count(input)) b = M[input];
            else b = m;

            G[a][j] = b;
        }
    }
    G[m][m] = -1;

    /*for(int i = 0; i <= m; i++){
        for(int j = 0; j < k; j++){
            cout << G[i][j] << " ";
        }
        cout << endl;
    }
    cout << endl;*/

    priority_queue<pair<int, int> > pb;
    pb.push({0, 0});
    vector<bool> used((1<<m), false);
    used[0] = true;
    while(1){

        int bit = pb.top().second;
        int cost = -pb.top().first;
        //cout << bitset<8>(bit) << " " << pb.size() << endl;
        //int q; cin >> q; 
        if(bit == (1<< m) - 1){
            cout << cost << endl;
            return 0;
        }

        pb.pop();

        for(int i = 0; i < k; i++){
            int nextbit = (1<<m) - 1;
            for(int j = 0; j < m; j++){
                if(~bit & (1<<j)){
                    nextbit &= ~(1<<G[j][i]);
                }
            }

            nextbit &= ~(1<<m);

            if(!used[nextbit]){
                pb.push({-(cost + 1), nextbit});
                used[nextbit] = true;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3568
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#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 <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    string s, t; cin>>s>>t;
    int n = s.size();
    int m = t.size();

    vector<vector<int>> alp(30);
    for(int i=0; i<n; i++){
        int index = s[i] - 'a';
        alp[index].emplace_back(i); 
    }

    /*
    for(int i=0; i<26; i++){
        for(auto j : alp[i]) cout << j << " ";
        cout << endl;
    }*/

    int cur = -1;
    ll ans = 0;
    for(int i=0; i<m; i++){
        int index = t[i] - 'a';

        if(alp[index].size() == 0){
            cout << -1 << endl;
            return 0;
        }

        auto nxt = upper_bound(alp[index].begin(), alp[index].end(), cur);

        if(nxt == alp[index].end()){
            nxt = lower_bound(alp[index].begin(), alp[index].end(), 0);
            ans += (n - 1 - cur) + (*nxt + 1);
        }
        else{
            ans += (*nxt - cur);
        }

        //cout << ans << endl;

        cur = *nxt;
    }

    cout << ans << endl;
}

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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}


signed main() {
    //my-code
    int n, m; cin >> n >> m;
    vi a(n); REP(i, n) cin >> a[i];
    int cnt = 0;
    int sum = accumulate(ALL(a), 0);
    REP(i, n) {
        if (a[i] < sum*1.0/(4*m)) {
            ;
        } else {
            cnt++;
        }
    }
    if(cnt >= m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	string A;
	cin >> A;
	ll N = A.size();
	vector<ll> s(26);
	REP(i, N) s[A[i]-'a']++;
	ll res = N*(N+1)/2;
	REP(i, 26){
		res -= s[i]*(s[i]+1)/2;
	}
	cout << res+1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 1e5 + 5;
int n, m, a[N];
vi e[N], v[2], tmp;
bool y[N];
void dfs(int i){
  y[i] = true;
  tmp.pb(a[i]);
  for(int j: e[i]) if(!y[j]) dfs(j);
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(i, 0, n) cin >> a[i];
  FOR(i, 0, m){
    int x, y;
    cin >> x >> y;
    e[x].pb(y);
    e[y].pb(x);
  }
  FOR(i, 0, n){
    if(y[i]) continue;
    tmp.clear();
    dfs(i);
    sort(rng(tmp));
    FOR(j, 0, sz(tmp)) v[!!j].pb(tmp[j]);
  }
  int s = sz(v[0]);
  if(s == 1){
    cout << 0 << endl;
    return 0;
  }
  if(s * 2 - 2 > n){
    cout << "Impossible" << endl;
    return 0;
  }
  sort(rng(v[1]));
  ll ans = 0;
  for(int i: v[0]) ans += i;
  FOR(i, 0, s-2) ans += v[1][i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7416
N,T=map(int,input().split())
c=[]
t=[]
for i in range(N):
  tmpc,tmpt=map(int,input().split())
  if tmpt <=T:
    c.append(tmpc)
    t.append(tmpt)
print('TLE')if len(c)==0 else print(min(c))


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N, L; cin >> N >> L;
  vector<int> taste(N);
  rep(i, N) taste[i] = L + (i + 1) - 1;
  int sum = accumulate(taste.begin(), taste.end(), 0);
  int ans = 0;
  int diff = INF;
  for (int i = 0; i < N; ++i){
    int tmp = 0;
    for (int j = 0; j < N; ++j){
      if (j != i) tmp += taste[j];
    }
    if (chmin(diff, abs(sum - tmp))) ans = tmp;
  }
  cout << ans << endl;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    ll n, t;
    cin >> n >> t;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll ans = 0;
    rep(i, n - 1) ans += min(a[i + 1] - a[i], t);

    ans += t;
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main() {

	string s; cin >> s;

	int memo[26];
	for (int i = 0; i < 26; i++) memo[i] = 0;

	for (auto c : s) {
		if (memo[c - 'a'] == 1) { cout << "no" << endl; return 0; }
		else memo[c - 'a'] = 1;
	}

	cout << "yes" << endl;

	return 0;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

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

    string s;
    read(s);

    const int N = s.length();
    vector<int> ans(N + 1);

    reps(i, 0, N - 1) if (s[i] == '<') {
        chmax(ans[i + 1], ans[i] + 1);
    }
    repr(i, N - 1, 0) if (s[i] == '>') {
        chmax(ans[i], ans[i + 1] + 1);
    }
    trace(ans);
    print(accumulate(all(ans), 0LL));

    return 0;
}


Measured memory_bytes: 2844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<pair<ll, ll>, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

ll n, m, l;

struct Edge {
  ll to;
  ll cost;
};
using Graph = vector<vector<Edge>>;
const long long INF = 1LL << 60;
/* dijkstra(G,s,dis,prev)
  入力：グラフ G, 開始点 s, 距離を格納する dis, 最短経路の前の点を記録するprev
  計算量：O(|E|log|V|)
  副作用：dis, prevが書き換えられる
*/
void dijkstra(const Graph &G, int s, vector<pair<ll, ll>> &dis, vi &prev) {
  int N = G.size();
  dis.resize(N, {INF, INF});
  prev.resize(N, -1);  // 初期化
  priority_queue<P, vector<P>, greater<P>>
      pq;  // 「仮の最短距離, 頂点」が小さい順に並ぶ
  dis[s] = {0, 0};
  pq.emplace(dis[s], s);
  while(!pq.empty()) {
    P p = pq.top();
    pq.pop();
    int v = p.second;
    if(dis[v] < p.first) {  // 最短距離で無ければ無視
      continue;
    }
    for(auto &e : G[v]) {
      pair<ll, ll> nd = dis[v];
      if(nd.second + e.cost > l) {
        nd.first++;
        nd.second = e.cost;
      } else {
        nd.second += e.cost;
      }
      if(dis[e.to] > nd) {  // 最短距離候補なら priority_queue に追加
        dis[e.to] = nd;
        prev[e.to] = v;  // 頂点 v を通って e.to にたどり着いた
        pq.emplace(dis[e.to], e.to);
      }
    }
  }
}
/* get_path(prev, t)
  入力：dijkstra で得た prev, ゴール t
  出力： t への最短路のパス
*/
vi get_path(const vi &prev, int t) {
  vi path;
  for(int cur = t; cur != -1; cur = prev[cur]) {
    path.push_back(cur);
  }
  reverse(path.begin(), path.end());  // 逆順なのでひっくり返す
  return path;
}

int main() {
  cin >> n >> m >> l;
  Graph g(n);
  rep(i, m) {
    ll a, b, c;
    cin >> a >> b >> c;
    if(c > l) continue;
    a--, b--;
    Edge e;
    e.to = b;
    e.cost = c;
    g[a].push_back(e);
    e.to = a;
    g[b].push_back(e);
  }
  vector<vector<pair<ll, ll>>> dis(n);
  vi prev;
  rep(i, n) dijkstra(g, i, dis[i], prev);
  ll q;
  cin >> q;
  rep(_, q) {
    ll s, t;
    cin >> s >> t;
    s--, t--;
    ll ans = dis[s][t].first;
    cout << (ans == INF ? -1 : ans) << '\n';
  }
}

Measured memory_bytes: 8476