akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int unsigned long long

#define MAN 200000

int main(){
  int N;
  int a[100000];
  bool f=0,s=0;
  cin >> N;
  LOOP(i,N){
    cin >> a[i];
    if(a[i]%2==0)  f=1;
    else           s=1;
  }
  if(s) cout << "first" << endl;
  else  cout << "second" << endl;
}


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

int main() {

    string s, t;
    cin >> s >> t;

    vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1));

    for (int i = 1; i <= s.size(); i++)
        dp[i][0] = i;
    for (int i = 1; i <= t.size(); i++)
        dp[0][i] = i;

    for (int i = 1; i <= s.size(); i++) {
        for (int j = 1; j <= t.size(); j++) {
            int m = min(dp[i - 1][j] + 1, dp[i][j - 1] + 1);

            if (s[i - 1] == t[j - 1]) {
                m = min(m, dp[i - 1][j - 1]);
                dp[i][j] = m;
            } else {
                m = min(m, dp[i - 1][j - 1] + 1);
                dp[i][j] = m;
            }
        }
    }

    cout << dp[s.size()][t.size()] << endl;

    return 0;
}


Measured memory_bytes: 6812
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin>>s;
  
  int ans=0;
  if(s.size()%2==0){
    for(int i =0;i<s.size()/2;i++){
      if (s.at(i)==s.at(s.size()-1-i)){
        continue;
      }
      ans++;
    }
  }
  else{
    for(int i=0;i<s.size()/2;i++){
      if(s.at(i)==s.at(s.size()-1-i)){
        continue;
      }
      ans++;
    }
  }
  cout<<ans<<endl;
}

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

int c[101];
int top=1;
void push(int);
int pop(void);

int main(){
	int b,e;
	char d[1000];
	while(1){
		if(scanf("%s",d)==EOF)break;
		if(d[0]=='+'){
			b=pop();
			e=pop();
			push(b+e);
		}else if(d[0]=='-'){
			b=pop();
			e=pop();
			push(e-b);
		}else if(d[0]=='*'){
			b=pop();
			e=pop();
			push(b*e);
		}else if(d[0]!=' '){
			b=atoi(d);
			push(b);
		}
	}
	printf("%d\n",pop());
	return 0;
}

void push(int d){
	c[top]=d;
	top++;
}
int pop(){
	top--;
	return c[top];
}



Measured memory_bytes: 2100
#include<stdio.h>
int main(void)
{
	int A, B, wa, sa, seki;

	scanf("%d", &A);  scanf("%d", &B);

	wa = A + B;
	sa = A - B;
	seki = A * B;

	if (wa >= sa && wa >= seki)
		printf("%d", wa);
	else if (sa >= wa && sa >= seki)
		printf("%d", sa);
	else if (seki >= wa && seki >= sa)
		printf("%d", seki);
	else


	return 0;

	

}

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

bool bsearch(const int array[], int left, int right, int value) {
	while (left + 1 < right) {
		int med = (left + right) / 2;
		if (array[med] > value) right = med;
		else left = med;
	}
	return array[left] == value;
}

signed main() {
	int n, s[100010], q, t, cnt = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> s[i];
	cin >> q;
	for (int i = 0; i < q; ++i) {
		cin >> t;
		if (bsearch(s, 0, n, t)) cnt++;
	}

	cout << cnt << endl;
}



Measured memory_bytes: 3464
#include<iostream>
#include<complex>
#include<cmath>
#include<vector>
using namespace std;

typedef complex<double> xy_t;
vector <xy_t> v;

double heron(xy_t p1, xy_t p2, xy_t p3) {
    double a = abs(p2 - p1);
    double b = abs(p3 - p2);
    double c = abs(p1 - p3);
    double s = (a + b + c) / 2;
    return sqrt(s*(s - a)*(s - b)*(s - c));
}
int main()
{
    double x, y;
    char c;
    while (cin >> x >> c >> y) {
        complex<double> tmp(x, y);
        v.push_back(tmp);
    }
    double sum = 0;
    for (int i = 1; i < v.size() - 1; i++) {
        sum += heron(v[0], v[i], v[i + 1]);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1304
require 'pp'

def gets; ARGF.gets; end

class Solver

  def initialize
  end

  def main
    x, t = gets.chomp.split.map(&:to_i)

    ans = x - t
    ans = 0 if ans < 0

    puts ans
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopb(i,a,b) for(int i=a;i>=b;i--)
#define loopm(i,a,b,step) for(int i=a;i<b;i+=step)
#define loopbm(i,a,b,step) for(int i=a;i>=b;i-=step)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define INF 1000000007
#define MOD 1000000007
#define BINF 1000000000000000001
#define int long long int
#define double long double

using namespace std;

#undef int
int main()
{
#define int long long int
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x,a,b;
    cin>>x>>a>>b;
    x-=a;
    int left=x-b*(x/b);
    cout<<left;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;


class ford_fulkerson{
	int maxv;
	struct edge{ int to, cap, rev; };
public:
	vector<vector<edge>> G;
	vector<bool> used;

	
	ford_fulkerson(int maxv = 0) : maxv(maxv){
		resize(maxv);
	}
	
	void init(){
		G.clear();
		used.clear();
	}
	
	void resize(int v){
		G.resize(v);
		used.resize(v);
	}
	
	void add_edge(int from, int to, int cap){
		G[from].push_back((edge){to,cap,(int)G[to].size()});
		G[to].push_back((edge){from, 0, (int)G[from].size()-1});
	}

	int dfs(int v, int t, int f){
		if(v == t) return f;
		used[v] = true;
		for(int i = 0; i < G[v].size(); i++){
			edge &e = G[v][i];
			if(!used[e.to] && e.cap > 0){
				int d = dfs(e.to, t, min(f,e.cap));
				if(d > 0){
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	int max_flow(int s, int t){
		int flow = 0;
		for(;;){
			fill(used.begin(), used.end(), false);
			int f = dfs(s,t,INF);
			if(f == 0) return flow;
			flow += f;
		}
	}
};

void input(int &N, vector<int> &X){
	cin>>N;
	
	X.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>X[i];
	}
}

void output(vector<int> &ans){
	for(int i = 0; i < ans.size(); i++){
		if(i) cout<<" ";
		cout<<ans[i];
	}
	cout<<endl;
}

void solve(int &N, vector<int> &X, vector<int> &ans){
	int largest_antichain;
	int max_flow;
	vector<int> used(N);
	
	ford_fulkerson ff(N*2+2);
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			if(i != j && X[j] % X[i] == 0) {
				ff.add_edge(i, j + N, 1);
			}
		}
		
		ff.add_edge(2 * N, i, 1);
		ff.add_edge(i + N, 2 * N + 1, 1);
	}
	
	largest_antichain = N - ff.max_flow(2 * N, 2 * N + 1);
	
	
	for(int k = 0; k < N; k++){
		int con = 0;
		ff.init();
		
		ff.resize(N * 2 + 2);
		
		for(int i = k; i < N; i++){
			if(X[k]%X[i] == 0|| X[i]%X[k] == 0 || used[i]) continue;
			con++;
			
			for(int j = 0; j < N; j++){
				if(i != j && X[j] % X[i] == 0) {
					ff.add_edge(i, j + N, 1);
				}
			}
			ff.add_edge(2 * N, i, 1);
			ff.add_edge(i + N, 2 * N + 1, 1);
			
		}
		
		int flow = ff.max_flow(2 * N, 2 * N + 1);
		
		if(con - flow == largest_antichain - ans.size() - 1 && used[k] == false) {
			
			ans.push_back(k+1);
			
			for(int i = 0; i < N; i++){
				if(X[i] % X[k] == 0) used[i] = true;
				if(X[k] % X[i] == 0) used[i] = true;
			}
		}
	}
}

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	vector<int> X, ans;
	
	input(N, X);
	
	solve(N, X, ans);
	
	output(ans);
	
	return 0;
}


Measured memory_bytes: 3272
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <cstring>
#define ll long long

using namespace std;

int main()
{
    ll int i,j,n,k,count=0,sum=0;
    cin>>n>>k;
    ll int a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(i=0;i<n;i++){
        k=k-a[i];
        if(k>=0)
            count++;
        else break;
    }
    if(k>0)
        count--;
    cout<<count<<endl;
    return 0;
}



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

vector<vector<ll>> M;
vector<ll> is(200000);
const ll MOD = 1e9+7;

struct BW
{
	ll b,w;
};

BW dfs(ll now)
{
	BW res;
	res.b = 1;
	res.w = 1;
	for(auto i:M[now])
	{
		if(is[i]==0)
		{
			is[i] = 1;
			BW rs = dfs(i);	
			res.w = (rs.w+rs.b)%MOD*res.w%MOD;
			res.b =(rs.w*res.b)%MOD;
		}
	}

//	cout<<res.w<<';'<<res.b<<endl;
	return res;
}

int main()
{
	ll n;
	cin >> n;
	M = vector<vector<ll>>(n);

	for(ll i  =0;i<n-1;i++)
	{
		ll x,y;
		cin >> x >> y;
		x--;y--;
		M[x].push_back(y);
		M[y].push_back(x);
	}
	is[0]=1;
	BW ans = dfs(0);
	cout<<(ans.b+ans.w)%MOD<<endl;
	return 0;
}


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

int main() {
    int childrenNum(0);
    cin >> childrenNum;

    int candiesNum(0);
    for(int i(1); i <= childrenNum; i += 1) {
        candiesNum += i;
    }
    
    cout << candiesNum << endl;

    return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  if(k % 2 == 1)
    cout << b - a  << endl;
  else 
    cout << a - b  << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

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...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    ll max_a = 0;
    REP(i, N) {
        cin >> A[i];
        if (A[i] == K) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
        if (A[i] > max_a) max_a = A[i];
    }
    if (max_a < K) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    set<ll> k_diff;
    REP(i, N) k_diff.insert(abs(A[i] - K));
    debug(k_diff);
    sort(A.begin(), A.end());

    vector<ll> diff;
    set<ll> s;
    REP(i, N - 1) { s.insert(A[i + 1] - A[i]); }
    debug(s);

    for (auto i : s) {
        for (auto j : k_diff) {
            debug(i, j);
            if (i != 0) {
                if (j % i == 0) {
                    cout << "POSSIBLE" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 7168
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int D, G;
int p[11];
int c[11];

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

	cin >> D >> G;
	rep(i, 0, D)cin >> p[i] >> c[i];

	int ans = INF;
	rep(i, 0, 1 << D)
	{
		int tans = 0;
		int tc = 0;
		int maxj = -1;
		rep(j, 0, D)
		{
			if (i&(1 << j))
			{
				tans += p[j];
				tc += 100 * (j+1)*p[j] + c[j];
			}
			else
			{
				chmax(maxj, j);
			}
		}
		if (tc >= G)
		{
			chmin(ans, tans);
		}
		else
		{
			int n = (G - tc + 100 * (maxj + 1) - 1) / (100 * (maxj + 1));
			if (n < p[maxj])
			{
				chmin(ans, tans + n);
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <climits>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;

int n;
int x,ans;
int dp[400100];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        dp[x]=dp[x-1]+1;
    }
    for(int i=1;i<=n;i++)
        ans=max(ans,dp[i]);
    cout<<n-ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

ll dp[1000001][2];

void solve_abc_e() {
	string s;
	ll ans = 0;

	cin >> s;

	rep(i, 101)rep(j, 2) {
		dp[i][j] = 0;
	}

	s = '0' + s;
	dp[0][0] = 0;
	dp[0][1] = 1;
	rep(i, s.size()) {
		ll d = s[i] - '0';
		dp[i + 1][0] = min(dp[i][0] + d, dp[i][1] + 10 - d);
		//dp[i + 1][0] = min(dp[i + 1][0], dp[i][1] + d + 1);

		dp[i + 1][1] = min(dp[i][0] + d + 1, dp[i][1] + 10 - (d + 1));
		//dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + (d + 2) % 9);
	}

	ans = dp[s.size()][0];

	cout << ans << "\n";
}

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

	solve_abc_e();

	return 0;
}

Measured memory_bytes: 16968
// Problem : B - Homework
// Contest : AtCoder - AtCoder Beginner Contest 163
// URL : https://atcoder.jp/contests/abc163/tasks/abc163_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	int n,m;
	cin >> n >> m;
	vector<int> v(m);
	for(int i=0;i<m;++i)
	{
		cin >> v[i];
		n-=v[i];
	}
	if(n<0)
	cout << -1 << endl;
	else
	cout << n << endl;
	
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


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

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

Measured memory_bytes: 2936
// @DateTime:    2020-04-26 20:06:12
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define SZ(a) int(a.size())
#define ALL(x) (x).begin(),(x).end()
#define trav(a,x) for (auto& a: x)
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int mod = 1e9+7;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base=2333, P_1=19260811, P_2=999998639;
void add(int &a,int b) {a+=b; if(a>=mod) a-=mod;}
void dec(int &a,int b) {a-=b; if(a<0) a+=mod;}
int main()
{
    int a, b , c, d;
    cin >> a >> b >> c>>d;
    int kp = 1;
    while(a > 0 && c > 0){
        if(kp)c-=b;
        else a-=d;
        kp ^= 1;
    }
    int fl = 0;
    // cout << a << "  " << c << endl;
    puts(a > 0?"Yes":"No");
    
}

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

using namespace std;

int main() {
	long long int n, k;
	cin>>n>>k;
	vector<long long int> arr(n, 0);
	for(long long int& x: arr)
		cin>>x;

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

	long long int ans = 0;
	for(long long int i = 0; i < n-k; i++) 
		ans += arr[i];
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int a=in.nextInt();
        int b=in.nextInt();
        if(a<b){
            System.out.println("0");
        }else{
            System.out.println("10");
        }
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){

	unsigned long long N;
	cin >> N;

	vector<unsigned long long> A(N, 0);
	vector<unsigned long long> val(N, 0);
	unsigned long long v;
	for (unsigned long long i = 0; i < N; i++) {
		cin >> v;
		A[v - 1] += 1;
		val[i] = v;
	}

	unsigned long long sum = 0;
	for (unsigned long long i = 0; i < N; i++) {
		sum += A[i] * (A[i] - 1) / 2;
	}

	unsigned long long ans = 0;
	for (unsigned long long i = 0; i < N; i++) {
		ans = sum - A[val[i] - 1] + 1;
		cout << ans << endl;
	}

	return 0;
}



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

void dfs(int i, int n, std::vector< std::pair<int, int> >& robo, std::vector<int>& to) {
  int j = to[i] = i + 1;
  while(j < n && robo.at(j).first < robo.at(i).second)
    if(to[j]) j++; else {
      dfs(j, n, robo, to);
      j = to[i] = to[j];
    }
}

int main() {
  int n;
  std::cin >> n;
  std::vector< std::pair<int, int> > robo(n);
  std::vector<int> to(n); // i に連動して to[i] の手前まで起動
  for(int i = 0; i < n; i++) {
    int x, d;
    std::cin >> x >> d;
    robo.at(i) = std::make_pair(x, x + d);
  }
  std::sort(robo.begin(), robo.end());
  
  for(int i = 0; i < n; i++)
    if(!to[i]) dfs(i, n, robo, to);

  std::vector< int > dp(n+1); // i 以上だけ見ると dp[i] 通り
  dp[n-1] = 2; dp[n] = 1;
  for(int i = n-2; i >= 0; i--)
    dp.at(i) = (dp.at(i+1) + dp.at(to[i])) % 998244353;
  
  std::cout << dp.at(0) << '\n';
  
  return 0;
}
    

Measured memory_bytes: 18944
class Accumulate2D:
    def __init__(self, a):
        self.height = len(a)
        self.width = len(a[0])
        self.acc = self.accumulate(a)

    def accumulate(self,a):
        b = [[0]*(self.width+1) for i in range(self.height+1)]
        b[1][1] = a[0][0]
        for i in range(self.height):
            for j in range(self.width):
                b[i+1][j+1] = b[i+1][j]+b[i][j+1]-b[i][j]+a[i][j]
        return b

    def sum(self, p, q):
        y1,x1 = p
        y2,x2 = q
        b = self.acc
        if y1>y2 or x1>x2:
            return 0
        else:
            return b[y2+1][x2+1]-b[y2+1][x1]-b[y1][x2+1]+b[y1][x1]


n,k = map(int, input().split())

kk = k*2

z = [[0]*kk for i in range(kk)]

for i in range(n):
    x,y,c = input().split()
    x = (int(x) + (k if c=='W'else 0)) % kk
    y = int(y) % kk
    z[x][y]+=1

z = Accumulate2D(z)

ans = 0
for i in range(k):
    for j in range(k):
        a = z.sum([0,0],[i-1,j-1])\
            + z.sum([i,j],[i+k-1,j+k-1])\
            + z.sum([0,j+k],[i-1,kk-1])\
            + z.sum([i+k,0],[kk-1,j-1])\
            + z.sum([i+k,j+k],[kk-1,kk-1])
        ans = max(ans,a,n-a)

print(ans)



Measured memory_bytes: 112732
from collections import defaultdict

n = int(input())
def fn(x,y,z):
    return x**2 + y**2 + z**2 + x*y + y*z + x*z
def cnt(x,y,z):
    n = len(set([x,y,z]))
    if n == 3:
        return 6
    elif n == 2:
        return 3
    else:
        return 1
    
d = defaultdict(int)

for x in range(1,101):
    ix = fn(x,1,1)
    if ix > n:
        break
    for y in range(x,101):
        iy = fn(x,y,1)
        if iy > n:
            break
        for z in range(y,101):
            i = fn(x,y,z)
            if i <= n:
                d[fn(x,y,z)] += cnt(x,y,z)
            else:
                break
                
for i in range(1,n+1):
    print(d[i])

Measured memory_bytes: 10088
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> S >> T;
    rep(i,S.size())
    {
        rep(j,S.size())
        {
            char s = i+j >= S.size() ? S[i+j-S.size()] : S[i+j];
            if(s!=T[j])break;
            else if(j+1==S.size())
            {
                cout<<"Yes";
                return 0;
            }
        }
    }
    
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD=1000000007;

int main() {
    int n; cin>>n;
    vector<int> ans(26,51);
    for(int i=0;i<n;i++){
        string S; cin>>S;
        vector<int> A(26,0);
        for(int j=0;j<S.size();j++){
            A[S[j]-'a']++;
        }
        for(int k=0;k<26;k++){
            ans[k]=min(ans[k],A[k]);
        }
    }

    for(int i=0;i<26;i++){
        for(int j=0;j<ans[i];j++){
            char a='a'+i;
            cout<<a;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;
import java.util.Arrays;
import static java.lang.Math.*;

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

  private void solve() {
    try(InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out)) {

      int n = in.nextInt();
      int[] a = in.mapInt(n);

      Arrays.parallelSort(a);
      int ans = a[n-1] - a[0];
      out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  int atoi(String s) { return Integer.parseInt(s); }
  long atol(String s) { return Long.parseLong(s); }

  static class InputReader implements AutoCloseable {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream), 32768);
      st = null;
    }

    public String nextLine() throws IOException {
      return br.readLine();
    }
    public String next() {
      if (st == null || !st.hasMoreTokens()) {
        try { st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          throw new UncheckedIOException(e);
        }
      }
      return st.nextToken();
    }
    public int nextInt() { return Integer.parseInt(next()); }
    public long nextLong() { return Long.parseLong(next()); }
    int[] mapInt(int len) {
      int[] ret = new int[len];
      for (int i = 0; i < len; i++) ret[i] = Integer.parseInt(next());
      return ret;
    }
    long[] mapLong(int len) {
      long[] ret = new long[len];
      for (int i = 0; i < len; i++) ret[i] = Long.parseLong(next());
      return ret;
    }
    @Override public void close() throws IOException { br.close(); }
  }
}

Measured memory_bytes: 20948
F=->z,c{f=G[c].size==2?1:0;r=[0,c];G[c].map{|e|e!=z&&(x,y=F[c,e];r=[r,[x+f,y]].max)};r}
G=(0..gets.to_i).map{[]}
$<.map{|e|a,b=e.split.map &:to_i;G[a]<<b;G[b]<<a}
p~-G.count{|x,y|!y}+F[-1,F[-1,1][1]][0]

Measured memory_bytes: 15868
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#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 ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i=0; i<N; i++) cin >> H[i];

    int ans = 0, i = 0;
    while(i<N) {
        int tmp = 0;
        while(1) {
            if(H[i] >= H[i+1] && i+1<N) {
                i++;
                tmp++;
            } else {
                break;
            }
        }
        i++;
        if(tmp > ans) ans = tmp;
    }

    cout << ans << endl;
    return 0;
}

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

int dp[31];
int n;

int solve( int now ) {
  if( n == now ) return 1;
  if( dp[now] ) return dp[now];

  int sum = 0;
  for(int i=1; i<=3; i++) {
    if( now + i <= n ) sum += solve( now + i );
  }

  return dp[now] = sum;
}

int main()
{
  while( cin >> n, n ) {
    fill_n(dp, 31, 0);
    int ans = solve( 0 );
    if( ans % 3650 == 0 ) {
      cout << ans / 3650 << endl;
    } else {
      cout << ans / 3650 + 1 << endl;
    }
  }
}

Measured memory_bytes: 1160
#!/usr/bin/env python3
import sys
import collections as cl


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    N, M, K = MI()
    friends = [[] for i in range(N)]
    blocks = [[] for i in range(N)]

    for _ in range(M):
        a, b = MI()
        a -= 1
        b -= 1
        friends[a].append(b)
        friends[b].append(a)

    for _ in range(K):
        a, b = MI()
        a -= 1
        b -= 1
        blocks[a].append(b)
        blocks[b].append(a)

    flag = [-1] * N
    group = 0
    for i in range(N):
        if flag[i] != -1:
            continue
        deque = cl.deque(friends[i])
        flag[i] = group
        while len(deque) > 0:
            target = deque.popleft()
            flag[target] = group
            friends_i = friends[target]
            for frend in friends_i:
                if flag[frend] != -1:
                    continue
                flag[frend] = group
                deque.append(frend)
        group += 1

    groups = [[] for i in range(N)]
    for i in range(len(flag)):
        groups[flag[i]].append(i)
    ans = []
    for i in range(len(groups)):
        groups[i] = set(groups[i])

    for i in range(N):
        i_group = flag[i]
        candidate = len(groups[i_group]) - len(friends[i]) - 1
        for blocking in blocks[i]:
            if blocking in groups[i_group]:
                candidate -= 1
        ans.append(candidate)
    print(" ".join(map(str, ans)))


main()


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

int field[7][7];

int main(){
    int h,w,k;
    cin>>h>>w>>k;
    ll sum = 0;
    rep(i,h){
        string s;
        cin>>s;
        rep(j,w){
            if(s[j]=='.'){
                field[i][j]=0;
            }else{
                field[i][j] =1;
                sum++;
            }        
        }
    }


    ll ans=0;
    
    vector<int> hsum,wsum;
    for(int i=0;i<h;i++){
        int tmp=0;
        rep(j,w){
            tmp+=field[i][j];
        }
        hsum.push_back(tmp);
    }
    for(int i=0;i<w;i++){
        int tmp=0;
        rep(j,h){
            tmp+=field[j][i];
        }
        wsum.push_back(tmp);
    }

    for(int hbit=0;hbit<(1<<h);hbit++){
        for(int wbit=0;wbit<(1<<w);wbit++){
            vector<int> hvec,wvec;
            rep(i,h){
                if(hbit&(1<<i)){
                    hvec.push_back(i);
                }
            }
            rep(i,w){
                if(wbit&(1<<i)){
                    wvec.push_back(i);
                }
            }
            ll t = 0;
            for(auto v:hvec){
                for(auto z:wvec){
                    if(field[v][z]==1) t++;
                }
            }
            ll tans = 0;
            for(auto v:hvec) tans+=hsum[v];
            for(auto v:wvec) tans+=wsum[v];

            if(sum-tans + t==k) ans++;

        }
    }

    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
n, m = gets.chomp.split(' ').map(&:to_i)

gates = []

max_l = -1
min_r = -1

m.times do |i|
  l, r = gets.chomp.split(' ').map(&:to_i)
  if max_l < 0 || max_l < l
    max_l = l
  end
  if min_r < 0 || min_r > r
    min_r = r
  end
  gates << [l,r]
end

cleard_num = 0

num = min_r - max_l + 1
if num > 0
  print "#{num}"
else
  print "0"
end

Measured memory_bytes: 9468
#include <stdio.h>
int main () {
    int r, c, data;
    int a[100+1][100+1];
    scanf("%d %d", &r, &c);
    
    for (int i = 0; i < r + 1; i++)
        a[i][c] = 0;
    for (int j = 0; j < c + 1; j++)
        a[r][j] = 0;
    
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            scanf("%d", &data);
            a[i][j] = data;
            a[i][c] += data;
            a[r][j] += data;
        }
        a[r][c] += a[i][c];
    }
    
    for (int i = 0; i < r + 1; i++) {
        for (int j = 0; j < c; j++) {
            printf("%d ", a[i][j]);
        }
        printf("%d\n", a[i][c]);
    }
    return 0;
}



Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		sc.close();
		
		if(Math.abs(a - c) > d) {
			if(Math.abs(a - b) <= d && Math.abs(c - b) <= d)
				System.out.println("Yes");
			else
				System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll dp[55][2];

signed main(){
	int n; ll k; cin>>n>>k;
	VL a(n); rep(i,n) cin>>a[i];
	memset(dp, -1, sizeof(dp));
	dp[0][0]=0;
	int m=50;
	rep(d,m){
		ll mask = 1LL<<(m-d-1);
		int cnt=0;
		rep(i,n)if(a[i]&mask) cnt++;
		ll cost0=mask*cnt, cost1=mask*(n-cnt);
		if(dp[d][1]!=-1) chmax(dp[d+1][1], dp[d][1]+max(cost0,cost1));
		if(dp[d][0]!=-1)if(k&mask) chmax(dp[d+1][1], dp[d][0]+cost0);
		if(dp[d][0]!=-1){
			if(k&mask) chmax(dp[d+1][0], dp[d][0]+cost1);
			else chmax(dp[d+1][0],dp[d][0]+cost0);
		}
	}
	cout<<max(dp[m][0],dp[m][1])<<endl;

	return 0;
}


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

typedef long long int ll;
typedef pair <ll, ll> pll;

const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const ll Inf = 1LL << 62;

int mp[Max];
int main() {
#ifdef Mr_Emrul
        freopen("inputf.in", "r", stdin);
#endif /// Mr_Emrul

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

        int n;
        cin >> n;
        for(int i = 1; i <= n - 1; i++) {
                int m; cin >> m; mp[m]++;
        }
        for(int i = 1; i <= n; i++) {
                cout << mp[i] << endl;
        }
        return 0;
}

Measured memory_bytes: 4388
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Iterator;
import java.util.Set;
import java.util.Stack;
import java.util.Vector;
import java.util.HashSet;

 public class  Main {
	 
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
	    
		//inputs
		 
		int r = input.nextInt();
		
		System.out.println(2 * Math.PI * r);
	}
 }

Measured memory_bytes: 27104
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
   

    int a,b,c;
    cin >> a >> b >> c;
    if((a-c)*(c-b) >= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) { cin >> v[i]; }
  ll s = accumulate(v.begin(), v.end(), 0);
  ll res = 0, ans = INF;
  for (int i = 0; i < n; i++) {
    res += v[i];
    ans = min(ans, abs(res - (s - res)));
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    vector<vector<char>> hoge(3, vector<char> (3));
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin>>hoge.at(i).at(j);
        }
    }
    cout<<hoge.at(0).at(0)<<hoge.at(1).at(1)<<hoge.at(2).at(2)<<endl;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k; cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];
  sort(h.begin(), h.end());
  int res = 1001001001;
  for (int i = 0; i < n - k + 1; i++) {
    res = min(res, h[i+k-1] - h[i]);
  }
  cout << res << '\n';
  return 0;
}

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

/* define const */

/* finish defineing const */

char a, b;

int main()
{
    cin >> a >> b;
    if (a == 'H')
    {
        if (b == 'H')
        {
            cout << "H" << endl;
        }
        else
        {
            cout << "D" << endl;
        }
    }
    else
    {
        if (b == 'H')
        {
            cout << "D" << endl;
        }
        else
        {
            cout << "H" << endl;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll gcd(ll a, ll b) {
  ll v0=a, v1=b, v2=v0%v1;
  while(v2>0) {
    v0 = v1;
    v1 = v2;
    v2 = v0%v1;
  }
  return v1;
}

int main() {
  int N;
  cin>>N;
  ll T[N];
  for(int i=0;i<N;++i) cin>>T[i];
  ll ans = T[0];
  for(int i=1;i<N;++i) ans = (ans/gcd(ans, T[i]))*T[i];
  cout<<ans<<endl;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int n,in;
	ll ans = 0;
	vi v;
	cin >> n;
	rep(i, n * 3) {
		cin >> in;
		v.push_back(in);
	}
	sort(all(v),greater<int>());
	rep(i, n) {
		ans += v[i*2+1];
	}
	cout << ans << endl;
}

Measured memory_bytes: 2420
K,N=map(int,input().split())
A=list(map(int,input().split()))
list=[0]*N
for i in range(N-1):
    list[i]=A[i+1]-A[i]
    
list[N-1]=A[0]+K-A[N-1]
L=K-max(list)
print(L)

Measured memory_bytes: 26100
@sum = 0

def dfs(s, pos)
  if s.size() == pos
    # puts s
    @sum += eval(s)
  else
    dfs(s[0...pos] + '+' + s[pos...s.size()], pos+2)
    dfs(s[0...pos] + s[pos...s.size()], pos+1)
  end
end

dfs(gets.chomp, 0)

puts @sum/2


Measured memory_bytes: 1916
n = int(input())
heights = [int(c) for c in input().split()]
beauty = [int(c) for c in input().split()]



base = 1
while base <= n:
    base *= 2

tree = [0] * (2 * base)

dp = [0] * (n+1)
for i in range(n):
    x = heights[i] + base
    best = 0
    while x > 1:
        if x % 2 == 1:
            best = max(best, tree[x-1])
        x //= 2

    dp[heights[i]] = best + beauty[i]

    j = base + heights[i]
    while j >= 1:
        tree[j] = max(tree[j], dp[heights[i]])
        j //= 2


    # for j in range(i):
    #     if heights[i] > heights[j] and beauty[i] + dp[j] > max_beauty:
    #         max_beauty = beauty[i] + dp[j]


ans = max(dp)
print(ans)


Measured memory_bytes: 122960
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#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;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N; cin >> N;
    if(N % 2 == 0) {
        vector< pair<int, int> > edges;
        for(int i=1; i<=N; i++) {
            for(int j=i+1; j<=N; j++) {
                if(i+j == N+1) continue;
                edges.emplace_back(i, j);
            }
        }
        cout << edges.size() << endl;
        for(auto e : edges) {
            int u, v; tie(u, v) = e;
            printf("%lld %lld\n", u, v);
        }
    }
    else {
        vector< pair<int, int> > edges;
        for(int i=1; i<=N; i++) {
            for(int j=i+1; j<=N; j++) {
                if(i + j == N) continue;
                edges.emplace_back(i, j);
            }
        }
        cout << edges.size() << endl;
        for(auto e : edges) {
            int u, v; tie(u, v) = e;
            printf("%lld %lld\n", u, v);
        }
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main() {
	const ll MOD = 1e9 + 7;
	int N, M;
	cin >> N >> M;
	vector<ll> a(N);
	vector<ll> b(M);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }
	for (int i = 0; i < M; ++i) { cin >> b[i]; }

	vector<ll> h(N * M + 1, 0);
	vector<ll> w(N * M + 1, 0);
	vector<ll> x(N * M + 1, 0);
	bool ok = true;
	for (int i = 0; i < N; ++i) {
		if (h[a[i]] > 0) { ok = false; }
		h[a[i]] += 1;
	}
	for (int i = 0; i < M; ++i) {
		if (w[b[i]] > 0) { ok = false; }
		w[b[i]] += 1;
		if (h[b[i]] > 0) { x[b[i]] = 1; }
	}

	if (!ok) {
		cout << 0 << endl;
		return 0;
	}

	for (int i = N * M - 1; i >= 0; --i) {
		h[i] += h[i + 1];
		w[i] += w[i + 1];
	}

	for (int i = 0; i < N; ++i) {
		if (x[a[i]] > 0) { continue; }
		x[a[i]] = w[a[i]];
	}
	for (int i = 0; i < M; ++i) {
		if (x[b[i]] > 0) { continue; }
		x[b[i]] = h[b[i]];
	}
	for (int i = N * M; i >= 0; --i) {
		if (x[i] > 0) { continue; }
		x[i] = ((h[i] * w[i]) % MOD - (N * M - i) + MOD) % MOD;
	}

	ll res = 1;
	for (int i = 1; i < x.size(); ++i) {
		res = (res * x[i]) % MOD;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 23680
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        int ans = 0;
        for (int i = 0; i < 2; i++) {
            if (a > b) {
                ans += a;
                a--;
            } else {
                ans += b;
                b--;
            }
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 24148
#include <bits/stdc++.h>
using namespace std;
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; }

// UnionFindの実装
struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }

    // 集合をマージする
    // すでに同じ集合ならfalseが返る
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if(x == y) return false;
        //要素数の少ない方を多い方に繋げる
        if(data.at(y) < data.at(x)) swap(x, y);
        data.at(x) += data.at(y);
        data.at(y) = x;
        return true;
    }

    // ある要素がどの集合に属しているかを返す
    int root(int x) {
        // 根に直接つなぎ直す
        return data.at(x) < 0 ? x : (data.at(x) = root(data.at(x)));
    }

    // ある集合の大きさを答える
    int size(int x) {
        return -data.at(root(x));
    }

    // ある二つの要素が同じ集合か判定
    bool same(int x, int y) {
        x = root(x); y = root(y);
        return x == y;
    }
};

int n, m;
vector<int> a(55, 0);
vector<int> b(55, 0);

int main() {
    cin >> n >> m;
    int cnt = 0;
    for(int i = 0; i < m; ++i) {
        cin >> a.at(i) >> b.at(i);
        a.at(i)--; b.at(i)--;
    }

    for(int i = 0; i < m; ++i) {
        UnionFind tree(n);
        int ta = a.at(i); int tb = b.at(i);
        for(int j = 0; j < m; ++j) {
            if(i != j) {
                tree.merge(a.at(j), b.at(j));
            }
        }
        if(!tree.same(ta, tb)) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256