akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int max = 0;
    int min = 100000000;
    int ans = 0;
    for(int i = 0; i < N; i++){
      int M = Integer.parseInt(sc.next());
      if(M > max){
        max = M;
      }
      if(M <= min){
        min = M;
        ans++;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 50944
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)


//ABC050_a
int main() {
	int A, B;
	string op;
	cin >> A >> op >> B;

	if (op == "+") {
		cout << A + B << endl;
	}
	else {
		cout << A - B << endl;
	}

}

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

using namespace std;

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define PQ priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define FORD(i, n) for (int (i) = (int)(n) - 1; i>= 0; i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define EACH(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define DEBUG(x) cout << #x << " = " << (x) << endl;
#define PR(a, n) {cout << #a << " = "; FOR(_, 1, n) cout << a[_] << ' '; puts(""); }
#define PRO(a, n) { cout << #a << " = "; REP(_, n) cout << a[_] << ' '; puts(""); }
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

const int INF = 1 << 30;
const int N = 1005;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

inline ll read()
{
	ll x = 0; int f = 1, c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
	return x * f;
}

int h, a, n; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	h = read(), n = read(); 
	REP(i, n) a += read(); 
	if (a >= h) puts("Yes"); 
	else puts("No"); 
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N; cin >> N;
  vector<vector<pair<int, int>>> g(N);
  rep(i, N) {
    int p; cin >> p;
    if(p != 0) {
      g[i].emplace_back(0, i + p);
    } else {
      REP(j, 1, 7) {
        g[i].emplace_back(1, min(i + j, N-1));
      }
    }
  }

  vector<int> vis(N, inf);
  vis[0] = 0;
  deque<pair<int, int>> q;
  q.emplace_back(0, 0);
  while(!q.empty()) {
    auto p = q.front(); q.pop_front();
    int co = p.first, po = p.second;
    if(po == N-1) {
      cout << co << endl;
      break;
    }

    for(auto && e: g[po]) {
      int pcost = e.first, to = e.second;
      if(vis[to] > co + pcost) {
        vis[to] = co + pcost;
        if(pcost == 0) {
          q.emplace_front(vis[to], to);
        } else {
          q.emplace_back(vis[to], to);
        }
      }
    }
  }

  return 0;
}

Measured memory_bytes: 10216
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	string s;
	int K;
	cin >> s >> K;
	int leng = s.l_ength();
	vector<string> d;
	for( int range = 0; range < K; ++range ){
		for( int l = 0; l + range < leng; ++l ){
			d.push_back( s.substr( l, range+1 ) ) ;			
		}
	}
	sort(d.begin(), d.end());
	auto itr = unique(d.begin(), d.end());
	d.erase(itr, d.end());
	cout << d[K-1] << endl;
	return 0;
}

Measured memory_bytes: 1660
n = int(input())
s = []
AC = 0
WA = 0
TLE = 0
RE = 0
for _ in range(n):
    s.append(input())
for i in range(len(s)):
    if s[i] == 'AC':
        AC += 1
    elif s[i] == 'WA':
        WA += 1
    elif s[i] == 'TLE':
        TLE += 1
    elif s[i] == 'RE':
        RE += 1
print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))

Measured memory_bytes: 82424
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;

#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1.0)

#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pf(a) printf("%lld\n",a)

#define stll(a) stoll(a,nullptr,10)
#define PII pair<ll,ll>
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define EL printf("\n")
#define ff first
#define ss second


#define mem(ar,val) memset(ar,val,sizeof(ar))
#define ssort(ar) sort(ar.begin(),ar.end())
#define csort(ar,comp) sort(ar.begin(),ar.end(),comp)

#define bug1(a) cout<<"test "<<a<<endl;
#define bug2(a,b) cout<<"test "<<a<<" "<<b<<endl;
#define bug3(a,b,c) cout<<"test "<<a<<" "<<b<<" "<<c<<endl;
#define bug4(a,b,c,d) cout<<"test "<<a<<" "<<b<<" "<<c<<" "<<d<<endl;

#define fout freopen("output.txt","w",stdout)
#define fin  freopen("input.txt","r",stdin)

/// unordered_map<int,int>mp;
/// mp.reserve(1024);
/// mp.max_load_factor(0.25);

/// pbds
/// *find_by_order(k) - return k th largest element.. 0 based
/// order_of_key(k) - number of items strictly smaller than k

/*
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
*/

typedef long long ll;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;


ll ar[200005];
ll lot[200005];
int main()
{
    ll n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>ar[i];
    ll fl=0;
    for(int i=2;i<=n;i+=2)
        fl =fl^ ( ar[i]^ar[i-1]);

    for(int i=1;i<=n;i++)
        lot[i]=ar[i]^fl;
    for(int i=1;i<=n;i++)
    {
        if(i!=1)cout<<" ";
        cout<<lot[i];
    }
    cout<<endl;




}




Measured memory_bytes: 6648
N=int(input())
W=list(map(int,input().split()))
l=[]
for i in range(1,N+1):
    S1=0
    S2=0
    for j in range(N):
        if (j+1)<=i:
            S1+=W[j]
        else:
            S2+=W[j]
    l.append(abs(S1-S2))
print(min(l))

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

int main() {
	int n, a[100], b[100], ans=0;
	cin>>n; for(int i=0;i<n-1;i++) cin>>b[i];
	
	a[0]=b[0]; a[n-1]=b[n-2];
	for(int i=1;i<n-1;i++) a[i]=min(b[i-1],b[i]);
	for(int i=0;i<n;i++) ans+=a[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto s = readln.chomp;

  auto l_res = new int[](s.length + 1);
  auto r_res = new int[](s.length + 1);
  foreach (i; 0..s.length) {
    if (s[i] == '<') {
      l_res[i+1] = l_res[i] + 1;
    }
    if (s[$-1-i] == '>') {
      r_res[$-1-i-1] = r_res[$-1-i] + 1;
    }
  }

  long res;
  foreach (i; 0..l_res.length) {
    res += max(l_res[i], r_res[i]);
  }
  
  res.writeln;
}


Measured memory_bytes: 7184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//

int main(){
    int n;
    cin >> n;
    n %= 10;
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
        cout << "hon";
    }else if(n == 0 || n == 1 || n == 6 || n == 8){
        cout << "pon";
    }else{
        cout << "bon";
    }
}

Measured memory_bytes: 3612
# define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<" :"<<x<<endl;
# define EPS 1e-12
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };

int main()
{
	int n;
	while (cin >> n&&n)
	{
		double a=999999999999999.0; int ans = 0;
		FOR(i, n)
		{
			INT(id);
			double h, w;
			cin >> h >> w;
			h /= 100;
			double bmi = w / h / h;
			if (a > fabs(22.0 - bmi))
			{
				a = fabs(22.0 - bmi);
				ans = id;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3148
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

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


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec) {
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

#define solvsh
//#define multi
#ifdef solvsh

#define LOG(FMT...) fprintf(stderr, FMT)

const int INF = 1e9;

ll mod = 1e9 + 7;

ll ml(ll a, ll b){
    return(a * b) % mod;
}

ll add(ll a, ll b) {
    return (a + b) % mod;
}

const int MAXN = 5e5 + 20;

ll fact[MAXN];
ll b_fact[MAXN];



ll b_p(ll b, ll p) {
    if (p == 0)
        return 1;

    if (p % 2) {
        return ml(b, b_p(b, p - 1));
    }
    ll v = b_p(b, p >> 1);
    return ml(v, v);
}

ll g_back(ll elem) {
    return b_p(elem, mod - 2);
}

ll preff[MAXN];

ll getnCr(ll n, ll r) {
    return ml(fact[n], ml(b_fact[n - r], b_fact[r]));
}

ll ml_s(ll a, ll b, int s){
    if (s == 1){
        return ml(a, b);
    }
    return (mod - ml (a, b))  % mod;
}


int n, m;
void prec() {

    fact[0] = 1;
    b_fact[0] = 1;

    for (int i = 1; i < MAXN; ++i) {
        fact[i] = ml(fact[i - 1], i);
        b_fact[i] = g_back(fact[i]);
    }

}


void solve() {


    cin >> n >> m;
    prec();

    ll answr = 0;

    int s = 1;

    for (ll i = 0; i <= n; ++i) {
        ll cnt = getnCr(m - i, n - i);
        cnt = ml(cnt, cnt);

        ll f = ml(fact[n - i], fact[n - i]);


        f = ml(f, getnCr(m, i));
        f = ml(f, getnCr(n, i));
        f = ml(f, fact[i]);

        ll curr = ml_s(cnt, f, s);

        s *= -1;

        answr = add(answr, curr);
    }

    cout << answr;
}


#else

void solve() {

}

#endif


void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Mission #" << (i++) << ": \n";

        solve();
//        cout << "\n";
    }
}



#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
//    gen();

//    doo();

    multisolve();
#else
    solve();
    //    gen();
#endif

}


Measured memory_bytes: 11432
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N);
    int sum = 0;
    REP(i, 0, N) {
        cin >> a[i];
        sum += a[i];
    }

    int ans = 0;
    int metric = 1e+9;
    REP(i, 0, N) {
        if (max(N * a[i] - sum, sum - N * a[i]) < metric) {
            metric = max(N * a[i] - sum, sum - N * a[i]);
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            String S = sc.next();
            String T = sc.next();

            int ans = 0;
            for (int i = 0; i < 3; i++) {
                if (S.charAt(i) == T.charAt(i)) {
                    ans++;
                }
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 21332
#include<iostream>
#include<algorithm>
using namespace std;
int N,a,b,c;
long ans;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		string s;cin>>s;
		for(int j=0;j+1<s.size();j++)
		{
			if(s[j]=='A'&&s[j+1]=='B')ans++;
		}
		if(s[0]=='B'&&s[s.size()-1]=='A')c++;
		else if(s[0]=='B')b++;
		else if(s[s.size()-1]=='A')a++;
	}
	if(a>0&&b>0)
	{
		ans+=c+1;
		c=0;
		a--,b--;
		ans+=min(a,b);
	}
	else if(a>0)
	{
		ans+=c;
	}
	else if(b>0)
	{
		ans+=c;
	}
	else
	{
		if(c>0)ans+=c-1;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    String c = sc.next();
    if(a.substring(a.length()-1,a.length()).equals(b.substring(0,1))&&b.substring(b.length()-1,b.length()).equals(c.substring(0,1))){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }

  }
  

  
}


Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<int> h(n+1);
        for(int i=0; i<n+1; ++i)
            cin >> h[i];

        for(int i=0; ; ++i){
            vector<int> h2 = h;
            h2.erase(h2.begin() + i);

            vector<int> d(n-1);
            for(int i=0; i<n-1; ++i)
                d[i] = h2[i+1] - h2[i];

            if(d == vector<int>(d.size(), d[0])){
                cout << h[i] << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pll pair<ll,ll>
#define pb push_back
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
#define endl '\n'

ll power(ll a, ll b, ll mod){ ll c = 1; while(b>0){ if(b%2) c*=a, c%=mod; b/=2; a*=a; a%=mod; } return c; }
 
const ll N = (1e5) + 10;
const ll M = 320;
const ll Mod = 1e9 + 7;
ll ar[N],br[N];
vll u;

ll go(ll a, ll b){
	if(a == b) return 0;
	ll mid = (a+b)/2;
	ll ans = go(a,mid)+go(mid+1,b);
	u.clear();
	ll i,j;
	i = a; j = mid+1;
	while(i <= mid && j <= b){
		while(i<=mid && br[i] <= br[j]) u.pb(br[i++]), ans += j-(mid+1);
		if(i > mid) break;
		while(j<=b && br[j] < br[i]) u.pb(br[j++]);
	}
	while(i<=mid) u.pb(br[i++]), ans += j-(mid+1);
	while(j<=b) u.pb(br[j++]);
	for(i=a;i<=b;i++)
		br[i] = u[i-a];
	return ans;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout<<setprecision(25);
    ll n,hi,lo,mid,a,b,c,d,i,j,k;
    cin>>n; vll v;
    for(i=1;i<=n;i++) cin>>ar[i], v.pb(ar[i]);
    ll amt = (n*(n+1))/2;
	ll inv,ans;
	sort(all(v)); v.resize(unique(all(v))-v.begin());
	lo = 0;
	hi = sz(v);
    while(hi > lo){
    	mid = (hi+lo)/2; ll aha = 0;
    	for(i=1;i<=n;i++) {br[i] = ((ar[i] >= v[mid]) ? 1 : -1), br[i] += br[i-1]; if(br[i] < 0) aha++;}
		inv = amt - go(1,n) - aha;
    	if(2*inv >= amt){
    		lo = mid+1;
    	}
    	else{
    		hi = mid;
    	}
    }
    cout<<v[lo-1]<<endl;
    return 0;
}

Measured memory_bytes: 4084
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cassert>
#include <string>
#include <set>
#include <map>
#include <random>
#include <bitset>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using ld = long double;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s, t;
	cin >> s;
	ll ans = 0, cnt = 0, p = 0;
	while (p < s.size()) {
		if (s[p] == 'A')
			cnt++;
		else if (p + 1 < s.size() && s[p] == 'B' && s[p + 1] == 'C') {
			ans += cnt;
			p++;
		}
		else
			cnt = 0;
		p++;
	}
	cout << ans;
}

Measured memory_bytes: 720
package main

import (
	"bufio"
	"fmt"
	"os"
)

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	input := bufio.NewReader(os.Stdin)

	var N int
	fmt.Fscanf(input, "%d\n", &N)
	H := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Fscanf(input, "%d", &H[i])
	}
	// fmt.Println(N, H)

	var curr int
	for i := 0; i < N; i++ {
		if curr > H[i] {
			fmt.Println("No")
			return
		}
		if curr < H[i] {
			curr = H[i] - 1
		}
		// fmt.Printf("%d ", curr)
	}
	// fmt.Printf("\n")
	fmt.Println("Yes")
}


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

const long long inf = 1e18;

const int maxn = 333;

long long f[maxn][maxn];

int a[maxn];

int main() {
	//freopen("inp.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = 0;
	cin >> n;
	int k = 0;
	cin >> k;
	
	for(int i=1;i<=n;i++) cin >> a[i];
	
	for(int j=0;j<=n;j++) for(int i=0;i<=n;i++) f[j][i] = inf;
	f[0][0] = 0;
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			for(int l = i+1; l<= n; l ++) {
				f[l][j + 1] = min(f[l][j + 1], f[i][j] + max(0, a[l] - a[i]));
			} 
		}
	}	
	
	long long res = inf;
	for(int i=0;i<=n;i++) {
		res = min(res, f[i][n - k]);
	}
	
	cout << res;
	
	return 0;
}


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

int main() {
	int N, M;
	int A;
	cin >> N;
	cin >> M;

	for (int i = 0; i < M; i++) {
		cin >> A;
		N -= A;
		if (N < 0) {
			cout << -1 << endl;
			return 0;
		}
	}

	cout << N << endl;
	
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define fup(i,a,b) for(int i=a;i<=b;++i)
#define fdw(i,a,b) for(int i=a;i>=b;--i)
#define sync ios::sync_with_stdio(false);cin.tie(0)
#define cl(a) memset(a,0,sizeof(a))
#define gcd __gcd
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
//ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//ll ksm(ll a,ll b,ll mod){ll ans=1;a%=mod;for(;b;b>>=1){if(b&1) ans=ans*a%mod;a=a*a%mod;}return ans;}
//ll oula(ll n){ ll res=n;for(ll i=2;i*i<=n;i++){if(n%i==0){ res=res-res/i;while(n%i==0) n/=i;}}if(n>1) res=res-res/n;return res;}
//bool MRT(ll x){if(x==2)return true;fup(i,1,30){ll now=rand()%(x-2)+2;if(ksm(now,x-1,x)!=1)return false;}return true;}
//void shai(int n)fup(i,2,n){if(isprime[i]){v.push_back(i);for(int j=2*i;j<=10000;j+=i)isprime[j]=0;}}//"埃氏筛筛选素数"
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int N = 2e5 + 10 ;
int n;
int a[N];
int sum[N];
string s;
int main()
{
    sync;
    int k;
    cin>>n>>k;
    fup(i,1,k)
    {
        cin>>a[i];
    }
    fup(i,1,k)
    {
        sum[1]+=a[i];
    }
    int maxx=sum[1],id=1;
    fup(i,k+1,n)
    {
        cin>>a[i];
        sum[i-k+1]=sum[i-k]-a[i-k]+a[i];
        if(maxx<sum[i-k+1])
        {
            maxx=sum[i-k+1];
            id=i-k+1;
        }
    }
    double ans=0;
    fup(i,id,id+k-1)
    {
        ans+=1.0*(1+a[i])/2;
    }
    printf("%.12lf\n",ans);
    return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n+1);
    rep(i,n+1) cin >> a[i];
    ll ans = 0;
    rep(i,n){
        int b;
        cin >> b;
        if(b <= a[i]) ans += b;
        else{
            ans += a[i];
            b -= a[i];
            if(b <= a[i+1]){
                ans += b;
                a[i+1] -= b;
            }
            else{
                ans += a[i+1];
                a[i+1] = 0;
            }
        }
    }
    cout << ans << endl;
	return 0;
}

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

int main(){
  ll N,cnt=1,ans=0;
  cin>>N;
  ll a[N];
  for(int i=0;i<N;i++) cin>>a[i];
  sort(a,a+N);
  for(int i=0;i<N;i++){
    if(a[i]==a[i+1]) cnt++;
    else{
      ans+=cnt%2;
      cnt=1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        String str[]=br.readLine().split(" ");
        int h=Integer.parseInt(str[0]);
        int w=Integer.parseInt(str[1]);
        int k=Integer.parseInt(str[2]);
        char carr[][]=new char[h][w];
        for(int i=0;i<h;i++)
        carr[i]=br.readLine().toCharArray();
        int b=0;
        for(int i=0;i<h;i++)
        {
            for(int j=0;j<w;j++)
            {
                if(carr[i][j]=='#')
                b++;
            }
        }
        ArrayList<String> sub1=new ArrayList<>();
        ArrayList<String> sub2=new ArrayList<>();
        for(int i=0;i<(1<<h);i++)
        {
            StringBuffer sb=new StringBuffer();
            for(int j=0;j<h;j++)
            {
                if((i&(1<<j))>0)
                {
                    sb.append(j);
                    sb.append(' ');
                }
            }
            sub1.add(sb.toString());
        }
        for(int i=0;i<(1<<w);i++)
        {
            StringBuffer sb=new StringBuffer();
            for(int j=0;j<w;j++)
            {
                if((i&(1<<j))>0)
                {
                    sb.append(j);
                    sb.append(' ');
                }
            }
            sub2.add(sb.toString());
        }
        int cntr=0;
        for(String s1:sub1)
        {
            for(String s2:sub2)
            {
                int temp=b;
                boolean vis[][]=new boolean[h][w];
                String str1[]=s1.split(" ");
                String str2[]=s2.split(" ");
                for(int i=0;i<str1.length;i++)
                {
                    if(!str1[i].equals(""))
                    {
                        int r=Integer.parseInt(str1[i]);
                        for(int j=0;j<w;j++)
                        {
                            if(carr[r][j]=='#'&&!vis[r][j])
                            {
                                temp--;
                                vis[r][j]=true;
                            }
                        }
                    }
                }
                for(int i=0;i<str2.length;i++)
                {
                    if(!str2[i].equals(""))
                    {
                        int c=Integer.parseInt(str2[i]);
                        for(int j=0;j<h;j++)
                        {
                            if(carr[j][c]=='#'&&!vis[j][c])
                            {
                                temp--;
                                vis[j][c]=true;
                            }
                        }
                    }
                }
                if(temp==k)
                cntr++;
            }
        }
        pw.println(cntr);
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 40652
a = input()

for i in range(0,len(a)):
  c = 0
  for j in range(0,len(a)):
    if(a[i] == a[j]):
      c = c + 1
    else:
      continue
  if(c%2 != 0):
    print("No")
    exit()
  else:
    continue
    
print("Yes")

Measured memory_bytes: 38896
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * User: ngupta
 * Date: 4/5/2020 AD
 * Time: 23:41
 */
class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String[] NK = sc.nextLine().trim().split(" ");
        int N = Integer.parseInt(NK[0]);
        int K = Integer.parseInt(NK[1]);
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < K; i++) {
            sc.nextLine();
            String[] snukes = sc.nextLine().trim().split(" ");
            for (String sn : snukes)
                set.add(Integer.parseInt(sn));
        }

        System.out.println(N - set.size());
    }
}


Measured memory_bytes: 29176
#include<bits/stdc++.h>
using namespace std;
//int dp[3001][3001];
const int mod=1e9+7;
#define ll long long
int main()
{
int n,k;
cin>>n>>k;
int a[n];
vector<ll> dp(k+1);
dp[0]=1;
for(int i=0;i<n;i++) cin>>a[i];
for(int i=0;i<n;i++)
{
   // int dp1[k+1]={};
   vector<ll> dp1(k+1);
   vector<ll> fake(k+1);
    for(int already=0;already<=k;already++)
    {
        fake[already]=(fake[already]+dp[already])%mod;
        fake[already]%=mod;
        if(already+a[i]<k)
        {fake[already+a[i]+1]=(fake[already+a[i]+1]-dp[already]); if(fake[already+a[i]+1]<0)fake[already+a[i]+1]+=mod;}

        // for(int j=0;j<=a[i];j++)
        // {
        //     if(already+j<=k) dp1[already+j]=(dp1[already+j]+dp[already])%mod;
        // }
    }
    for(int j=1;j<=k;j++)
    {
        fake[j]=(fake[j]+fake[j-1])%mod;
        fake[j]%=mod;
    }
    for(int j=0;j<=k;j++)
    {
        dp1[j]=(dp1[j]+fake[j])%mod;
        dp1[j]%=mod;
    }
    dp=dp1;
}
cout<<dp[k]%mod<<endl;

}


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

#define rep(i,n) for(int i = 0; i < (int)n; ++i)

#define INF 100000000

int main() {
  int N, K;
  cin >> N >> K;
  vector<int64_t> H(N);
  rep(i, N) cin >> H.at(i);

  sort(H.begin(), H.end(), greater<int64_t>());
  int64_t atack = 0;
  if (N <= K){
    cout << 0 << endl;
  }
  else{
    for(int i = K; i < N; ++i){
      atack += H.at(i);
    }
    cout << atack << endl;
  }

  return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#define REP(i,n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
  int num;
  vector<int> v;
  REP(i,10)  {
    scanf("%d", &num);
    v.push_back(num);
  }
  sort(v.begin(), v.end(),greater<int>());
  REP(i,3) printf("%d\n", v[i]);
  return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n;
    map<string, int> cnt;
    string s;
    rep(i,n){
        cin >> s;
        cnt[s]++;
    }
    cin >> m;
    rep(i,m){
        cin >> s;
        cnt[s]--;
    }
    int ans = 0;
    for(auto p : cnt){
        chmax(ans, p.second);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> S;
    bool flag = true;
    REP(i, S.size()) {
        dump(S[i]);
        if ((i + 1) & 1) {
            if (S[i] == 'L') {
                flag = false;
            }
        } else {
            if (S[i] == 'R')
                flag = false;
        }
    }
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3632
from sys import stdin
def I():
    return stdin.readline().rstrip()
def MI():
    return map(int,stdin.readline().rstrip().split())
def LI():
    return list(map(int,stdin.readline().rstrip().split()))
#main part
s=I()
if s[-1]=='s':
    print(s+'es')
else:print(s+'s')

Measured memory_bytes: 61660
x = list(map(int, input().split()))

if x[0] > x[1]:
    x[0],x[1]=x[1],x[0]

if x[1]>x[2]:
    x[1],x[2]= x[2],x[1]
if x[0]>x[1]:
    x[0],x[1]= x[1],x[0]

print(*x)


    
    


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

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (B < C || D < A){
        cout << 0 << endl;
    }
    else{
        cout << min(B, D)-max(A,C) << endl;
    }
}


Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int N, M, P;

main(){
	while(cin >> N >> M >> P, N){
		int t, sum = 0;
		REP(i, N){
			int x;
			cin >> x;
			sum += x;
			if(i == M-1) t = x;
		}
		sum *= (100-P);
		cout << (t?sum/t:0) << endl;
	}
	return 0;
}

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

typedef long long LL;
typedef pair<int, int> II;

LL f(LL n, LL k) {
    LL ans = 0;
    while (n) {
        ans += n / k;
        n /= k;
    }
    return ans;
}

int main() {
    LL n;
    cin >> n;

    if (n % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    printf("%lld\n", f(n / 2, 5));
    return 0;
}

Measured memory_bytes: 256
from collections import deque


n = int(input())
lst_a = list(map(int, input().split()))
b = deque([])


for i in range(n):
    if n % 2 ==0:
        if i % 2 == 0:
            b.append(lst_a[i])
        else:
            b.appendleft(lst_a[i])
    else:
        if i % 2 == 0:
            b.appendleft(lst_a[i])
        else:
            b.append(lst_a[i])


print(*b)


Measured memory_bytes: 100664
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;
const int MOD = 1000 * 1000 * 1000 + 7;

const double EPS = 1e-6;
const int MAX = 33;



int main()
{
    //freopen("in.txt", "r", stdin);
    int n, m, d;
    cin >> n >> m >> d;
    string S = "RGBY";
    FOR(i, 0, n)
    {
        FOR(j, 0, m)
        {
            int ii = (i + j);
            int jj = (i - j + d * 1000);
            int ib = ii / d;
            int jb = jj / d;
            
            int col = (ib % 2) * 2 + (jb % 2);
            printf("%c", S[col]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <climits>
#include <cmath>
#include <cstring>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <utility>
#include <sstream>
#include <algorithm>
#include <stack>
#include <set>
#include <list>
#include <map>
#include <queue>
#include <vector>
#include <stdint.h> //uint32_t
#include <chrono>

typedef long long ll;
typedef double lf;

#define ull unsigned long long

#define FileIn(file) freopen("input.txt", "r", stdin)
#define FileOut(file) freopen("output.txt", "w", stdout)
#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0)

#define For(i, a, b) for (__typeof (a) i=a; i<=b; i++)
#define Rof(i, b, a) for (__typeof (a) i=b; i>=a; i--)
#define Rep(i, n) for (__typeof (n) i=0; i<n; i++)
#define Forit(i, s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define all(ar) ar.begin(), ar.end()
#define fill(ar, val) memset(ar, val, sizeof(ar))
#define clr(a) memset(a, 0, sizeof a)
#define sfll(a) scanf("%lld", &a)
#define pfll(a) printf("%lld", a)
#define sflf(a) scanf("%lf", &a)
#define pflf(a) printf("%lf", a)
#define sff(a) scanf("%f", &a)
#define pff(a) printf("%f", a)
#define sf(a) scanf("%d", &a)
#define pf(a) printf("%d", a)
#define nl cout << '\n';
#define SP cout << ' ';
#define gc getchar
#define chk cout << "##########\n"
#define debug1(x) cout << #x << ": " << x << endl
#define debug2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl
#define debug3(x, y, z) cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z << endl

#define PB push_back
#define max(a, b) (a < b ? b : a)
#define min(a, b) (a > b ? b : a)
#define sq(a) a * a
#define INF 0x7fffffff
#define MOD 1000000007
#define PI acos(-1.0)
#define MAX 100000000

using namespace std;
using namespace std::chrono;

/********************* Code starts here ************************/


int main() {
    __FastIO;
    int n{};
    cin >> n;
    ll ans{};
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++)
            for(int m = 1; m <= n; m++)
                ans += __gcd(i, __gcd(j, m));
    cout << ans << '\n';
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
typedef long long ll;
const int INF = 1<<29;
const int N = 1e6 + 9;
ll a[N];
bool cmp(const pair<double, ll> &a, const pair<double, ll> &b)
{
    if(a.first == b.first){
        return a.second < b.second;
    }
    return a.second > b.second;
}
int main()
{
    fio;
    ll n, ans = 0;
    cin >> n;
    ll minn = INF;
    for(int i = 0; i < n; i ++){
        cin >> a[i];
    }
    for(int i = -100; i <= 100; i ++)
    {
        for(int j = 0; j < n; j ++)
        {
            ans += ((a[j] - i) * (a[j] - i));
        }
        minn = min(ans, minn);
        ans = 0;
    }
    cout << minn;
    return 0;
}


Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, y, sum[ohara], k, q;

bool check(ll x) {
  ll res = 0;
  rep(i, n) {
    auto it = lower_bound(a, a + n, x - a[i]);
    tmp = it - a;
    res += n - tmp;
  }
  if (res >= m)
    return true;
  else
    return false;
}

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

  cin >> n >> m;
  rep(i, n) cin >> a[i];
  sort(a, a + n);
  ll le = 0, ri = LINF, mid;
  while (ri - le > 1) {
    mid = (le + ri) / 2;
    if (check(mid))
      le = mid;
    else
      ri = mid;
  }
  ll to;
  rrrep(i, ri, le) {
    if (check(i)) {
      to = i;
      break;
    }
  }
  rep(i, n) sum[i] = a[i];
  rrrep(i, n - 1, 0) sum[i] += sum[i + 1];
  rep(i, n) {
    auto it = upper_bound(a, a + n, to - a[i]);
    tmp = it - a;
    ans += sum[tmp];
    ans += (n - tmp) * a[i];
    cnt += (n - tmp);
  }
  ans += (m - cnt) * to;
  Cout(ans);
  return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
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; }

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

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

    int N;
    cin>>N;
    vector<int> a(N+1);
    rep1(i,N+1)cin>>a[i];
    vector<int> b(N+1,0);
    int M = 0;
    for(int i = N; i >= 1;i--){
        int sum = 0;
        //jはiの倍数 N / i 回
        for(int j = 2 * i;j <= N;j += i){
            sum = (sum + b[j]) % 2;
        }
        if(sum % 2 == 0 && a[i] == 0)b[i] = 0;
        if(sum % 2 == 0 && a[i] == 1)b[i] = 1;
        if(sum % 2 == 1 && a[i] == 0)b[i] = 1;
        if(sum % 2 == 1 && a[i] == 1)b[i] = 0;
        if(b[i])M++;
    }
    
    cout<<M<<endl;
    rep1(i,N+1){
        if(b[i]){
            cout<<i<<endl;
        }
    }
}

Measured memory_bytes: 2560
import itertools

s = input()
op = ["+","-"]
for ops in itertools.product(op, repeat=3):
  result = int(s[0]) 
  for i in range(len(ops)):
    if ops[i] == "+":
      result += int(s[i+1]) 
    else :
      result -= int(s[i+1]) 
  if result == 7:
    print(s[0]+ops[0]+s[1]+ops[1]+s[2]+ops[2]+s[3]+"="+str(result))
    break

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

int main() {
  int n, x, a, b, c, d;

  for (;;) {
    cin >> n >> x;

    if (n == x && n == 0) {
      break;
    }

    d = 0;

    for (a = 1; a <= n; a++) {
      for (b = a + 1; b <= n; b++) {
        for (c = b + 1; c <= n; c++) {
          if (a == b || b == c || a == c) {
            continue;
          }

          if ((a + b + c) == x) {
            d++;
          }
        }
      }
    }

    cout << d << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll N, M;
    cin >> N >> M;
    VV<ll> modm(M);
    V<ll> cnt(M);
    for(ll i = 0; i < N; i++) {
        ll X;
        cin >> X;
        modm[X % M].push_back(X);
    }
    
    for(ll i = 0; i < M; i++) {
        sort(ALL(modm[i]));
        ll pre = -1;
        ll cnt_e = 0;
        for(ll e : modm[i]) {
            DEBUG(e, cnt_e);
            if(pre == e) {
                cnt_e++;
            } else {
                cnt[i] += cnt_e / 2;
                cnt_e = 1;
            }
            pre = e;
        }
        cnt[i] += cnt_e / 2;
    }

    ll ans = modm[0].size() / 2;
    DEBUG(cnt);
    for(ll mod = 1;; mod++) {
        ll i = mod, j = M - mod;
        if(j <= i) break;
        if(modm[i].size() < modm[j].size()) swap(i, j);
        ans += modm[j].size();
        ll diff = modm[i].size() - modm[j].size();
        ans += min(cnt[i], diff / 2);
    }
    if(M % 2 == 0) ans += modm[M / 2].size() / 2;
    cout << ans << endl;
    return 0;
}


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

int main(){
	int i = 0;					/*阿弥陀くじの番号を格納する配列の添え字*/
	int count = 0;				/* 入れ替える値の組数 */
	int tate = 0;				/* 縦棒の数 */
	int yoko = 0;				/* 横棒の数 */
	int change = 0;
	int in_out_box[30 + 1];		/* 阿弥陀くじの番号を格納する配列 */
	int num1 = 0;				/* 入れ替える値を格納する変数 */
	int num1_index = 0;			/*  */
	int num2 = 0;				/* 入れ替える値を格納する変数 */
	int num2_index = 0;			/*  */
	char str[10];				/* 改行取得用の配列 */
	
	/* 縦棒の数の取得 */
	scanf("%d",&tate);
	/* 改行を取得 */
	fgets(str,(sizeof(str)),stdin);
	for(i = 0; i < tate; i++){
		in_out_box[i] = i + 1;
	}
	/* 横棒の数の取得 */
	scanf("%d",&yoko);
	/* 改行を取得 */
	fgets(str,(sizeof(str)),stdin);
	
	for(count = 0; count < yoko; count++){
		scanf("%d,%d",&num1, &num2);
		for(i = 0; i < tate; i++){
			if(i + 1 == num1){
				change = in_out_box[i];
				num1_index = i;
			}
			if(i + 1 == num2){
				in_out_box[num1_index] = in_out_box[i];
				in_out_box[i] = change;
			}
		}
	}
	
	for(i = 0; i < tate; i++){
		printf("%d\n",in_out_box[i]);
	}
	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <unordered_map>
using namespace std;
#define INF 100000000
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)

int main(){
    int N;cin>>N;
    vector<int> L(N);
    for(int i = 0; i < L.size(); i++)
    {
        cin>>L[i];
    }
    sort(L.begin(),L.end());
    if(L[N-1] < accumulate(L.begin(),L.end()-1,0)){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256