akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
#define PI 3.14159265359
typedef long long ll;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  b /= g;
  a *= b;
  return a;
}

//素数判定 O(√n)
bool is_prime(int64_t n){
  for(int64_t i = 2; i*i<=n; i++){
    if(n%i==0) return false;
  }
  return n!=1;
}

//約数の列挙 O(√n)
vector<int64_t> dividor(int64_t n){
  vector<int64_t> res;
  for(int64_t i=1; i*i<=n; i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(i);
    }
  }
  return res;
}

//素因数分解 O(√n)
map<int64_t, int64_t> prime_factor(int64_t n){
  map<int64_t, int64_t> res;
  for(int64_t i=2; i*i<=n; i++){
    while(n%i==0){
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int dp[101][10001];

int main(){
  int n, w, i, j; cin >> n >> w;
  //int dp[n+1][w+1];
  vector<int> W(n);
  vector<int> V(n);
  rep(i, n) cin >> V[i] >> W[i];
  for(i=0; i<n; i++){
    for(j=0; j<=w; j++){
      if(W[i]>j) dp[i+1][j] =dp[i][j];
      else{
        dp[i+1][j] = max(dp[i][j], dp[i][j-W[i]]+V[i]);
      }
    }
  }
  cout << dp[n][w] << endl;
}



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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    if (n % 1000 == 0) {
        cout << n % 1000 << '\n';
    } else {
        cout << 1000 - n % 1000 << '\n';
    }
    return 0;
}

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

using namespace std;

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

	int count = 0;

	vector<int> A;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;

		if (a % 2 != 0) {
			//入力に奇数があった
			cout << count << endl;
			return 0;
		}
		else {
			//入力が偶数
			A.push_back(a);
		}
	}

	while (1) {
		for (int i = 0; i < N; i++) {
			if (A[i] % 2 != 0) {
				//奇数の時
				cout << count << endl;
				return 0;
			}
			else {
				//偶数の時
				A[i] = A[i] / 2;
			}
		}
		count++;
	}

	cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	// 文字列入力
	vector<string> a(1);
	int ans = 0;
	string test;
	cin >> a[0];
	if (a[0] == "RRR") {
		ans = 3;
	}
	else if (a[0] == "RRS") {
		ans = 2;
	}
	else if (a[0] == "RSS") {
	ans = 1;
	}
	else if (a[0] == "SRS") {
	ans = 1;
	}
	else if(a[0] == "SSS") {
	ans = 0;
	}
	else if(a[0] == "SSR") {
	ans = 1;
	}
	else if(a[0] == "RSR") {
	ans = 1;
	}
	else if(a[0] == "SRR") {
	ans = 2;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3624
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█
 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long lo;
typedef pair< lo,lo > PII;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define int long long
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
 
const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,x[li],y[li];
double cev;
string s;
vector<int> v;

inline void dfs(int say,vector<int> v){
	if(say==n){
		for(int i=1;i<(int)v.size();i++){
			int xx=x[v[i]];
			int xx1=x[v[i-1]];
			int yy=y[v[i]];
			int yy1=y[v[i-1]];
			cev+=sqrt((xx-xx1)*(xx-xx1)+(yy-yy1)*(yy-yy1));
		}
	}
	for(int i=1;i<=n;i++){
		flag=0;
		vector<int> vv;
		vv.clear();
		for(int j=0;j<(int)v.size();j++){
			if(v[j]==i)flag=1;
			vv.pb(v[j]);
		}
		//~ vec
		if(flag==0){
			vv.pb(i);
			dfs(say+1,vv);
		}
	}
}

main(void){
	scanf("%lld",&n);
	FOR{
		scanf("%lld %lld",&x[i],&y[i]);
	}
	//~ FOR{
		//~ for(int j=1;j<=n;j++){
			//~ cev=
			//~ if(i==j)continue;
			//~ for(int k=1;k<=n;k++){
				//~ if(i==k)continue;
				//~ if(j==k)continue;
				//~ for(int jj=1;jj<=n;jj++){
					//~ if(i==jj)continue;
					//~ if(j==jj)continue;
					//~ if(k==jj)continue;
					//~ for(int kk=1;kk<=n;kk++){
						//~ if(i==kk)continue;
						//~ if(j==kk)continue;
						//~ if(jj==kk)continue;
						//~ if(k==kk)continue;
						//~ for(int kkk=1;kkk<=n;kkk++){
							//~ if(i==kkk)continue;
							//~ if(j==kkk)continue;
							//~ if(jj==kkk)continue;
							//~ if(k==kkk)continue;
							//~ if(kk==kkk)continue;
							//~ for(int jjj=1;jjj<=n;jjj++){
								//~ if(i==jjj)continue;
								//~ if(j==jjj)continue;
								//~ if(jj==jjj)continue;
								//~ if(k==jjj)continue;
								//~ if(kk==jjj)continue;
								//~ if(kkk==jjj)continue;
								
							//~ }
						//~ }
					//~ }
				//~ }
			//~ }
		//~ }
	//~ }
	vector<int> vvv;
	vvv.clear();
	dfs(0,vvv);
	int carp=1;
	for(int i=1;i<=n;i++)carp=carp*i;
	printf("%lf\n",cev/(double)carp);
	return 0;
}



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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

vector<P> G[100001];
ll d[100001];

void dfs( int v, int prev = -1 ){
    for( auto nv : G[v] ){
        if( nv.first == prev ) continue;
        d[nv.first] = d[v] + nv.second;
        dfs( nv.first, v );
    }
}

int main(){
    int N; cin >> N;
    REP( i, N - 1 ){
        int a, b, c; cin >> a >> b >> c;
        a--, b--;
        G[a].emplace_back( b, c );
        G[b].emplace_back( a, c );
    }

    int Q, K; cin >> Q >> K;
    K--;
    d[K] = 0;
    
    dfs( K );

    REP( i, Q ){
        int x, y; cin >> x >> y;
        x--, y--;
        cout << d[x] + d[y] << endl;
    }
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()


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

  string s;
  cin>>s;
  s.insert(4," ");
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD=1000000007;
const int nmax=3012;
int n,dp[nmax],res;
char s[nmax];
int main(){
    scanf("%d",&n);
    scanf("%s",s+1);
    dp[1]=1;
    for(int i=2; i<=n; ++i){
        if(s[i-1]=='<'){
            for(int j=1,s=0,tmp=0; j<=i; ++j){
                s=dp[j-1]+tmp;
                if(s>=MOD)s-=MOD;
                tmp=dp[j];
                dp[j]=s;
            }
        }
        else
            for(int j=i-2,s=0; j>0; --j){
                dp[j]+=dp[j+1];
                if(dp[j]>=MOD)dp[j]-=MOD;
            }
    }
    for(int i=1; i<=n; ++i){
        res+=dp[i];
        if(res>=MOD)res-=MOD;
    }
    printf("%d",res);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<iterator>
#include<queue>
#include<algorithm>
#include<functional>

typedef long long ll;
typedef std::map<char, int> string_type;
typedef std::map<string_type, int> type_occurences;

struct abc_170_c {
	int run(int X, int N, std::vector<int> p) {
		std::vector<int> nums;
		if(N == 0) return X;

		for(int i = 0; i <= 101; ++i) {
			auto it = std::find(p.begin(), p.end(), i);
			if(it == p.end()) {
				nums.push_back(i);
			}
		}

		for(int i = 0; i < nums.size() -1; ++i) {
			if(nums[i] == X) {
				return X;
			}
			if(nums[i] < X && X < nums[i+1]) {
				// std::cerr << nums[i] << "\t" << nums[i+1] << std::endl;
				if(std::abs(nums[i] - X) == std::abs(nums[i+1] - X)) {
					return nums[i];
				}else if(std::abs(nums[i] - X) < std::abs(nums[i+1] - X)) {
					return nums[i];
				}
				return nums[i+1];
			}
		}

		// dummy
		return 0;
	}
};

int main(void) {
	abc_170_c solver;
	int X, N, t;
	std::vector<int> p;

	std::cin >> X >> N;

	for(int i = 0; i < N; ++i) {
		std::cin >> t;
		p.push_back(t);
	}

	std::cout << solver.run(X, N, p) << std::endl;

	return 0;
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;


signed main() {
    int N, K, S;
    cin >> N >> K >> S;
    vector<int> A;
    if (S == 1) {
        rep(i, K) {
            A.push_back(1);
        }
        while (A.size() != N) {
            A.push_back(2);
        }
    } else if (K != N) {
        rep(i, K + 1) {
            if (i % 2)A.push_back(1);
            else A.push_back(S - 1);
        }
        while (A.size() != N) {
            if (S != 1000000000)A.push_back(1000000000);
            else if (S - 1 != 2) A.push_back(2);
            else A.push_back(3);
        }
    } else {
        rep(i, N) {
            A.push_back(S);
        }
    }
    rep(i, N) {
        if (i != 0)cout << " ";
        cout << A[i];
    }
    cout << endl;
    return 0;
}


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

const ll INF = 1e18;

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

  int n, W;
  cin >> n >> W;

  vector<int> w(n), v(n);
  for(int i=0; i<n; i++) {
    cin >> w[i] >> v[i];
  }

  int sum_value = accumulate(v.begin(), v.end(), 0);

  vector<ll> dp(sum_value+1, INF);
  dp[0] = 0;

  for(int i=0; i<n; i++) {
    for(int j=sum_value-v[i]; j>=0; j--) {
      dp[j+v[i]] = min(dp[j+v[i]], dp[j] + w[i]);
    }
  }

  ll ans = 0;
  for(int i=0; i<=sum_value; i++) {
    if(dp[i] <= W)
      ans = max(ans, (ll)i);
  }
  cout << ans << '\n';
  
  return 0;
}

Measured memory_bytes: 3936
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	string s;
	cin >> s;
	rep(i, s.size()) {
		if (i % 2 == 0)
			cout << s[i];
	}
}

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

using namespace std;

template<class Func, class Callback, class T>
void recurse(int from, int to, Func f, Callback cb,
             int& i, T& p, T q) {
	if (p == q) return;
	if (from == to) {
		cb(i, to, p);
		i = to; p = q;
	} else {
		int mid = (from + to) / 2;
		recurse(from, mid, f, cb, i, p, f(mid));
		recurse(mid + 1, to, f, cb, i, p, q);
	}
}
template<class Func, class Callback>
void ConstantIntervals(int from, int to, Func f, Callback cb) {
	if (to <= from) return;
	int i = from; auto p = f(i), q = f(to - 1);
	recurse(from, to - 1, f, cb, i, p, q);
	cb(i, to, q);
}

int main() {
  int n; cin >> n;
  map<int, int> cnt;
  for (int i = 0; i < n; ++i) {
    int x; cin >> x; cnt[x] += 1;
  }
  vector<int> v;
  for (auto p : cnt)
    v.push_back(p.second);
  sort(v.rbegin(), v.rend());

  vector<int> buff;
  auto eval = [&](int k) {
    int rem = n;
    for (auto x : v) {
      if (x <= rem / k)
        return rem / k;
      rem -= x;
      k -= 1;
    }
    return 0;
  };

  vector<int> ans(n);
  ConstantIntervals(1, n + 1, eval, [&](int b, int e, int x) {
    for (int i = b; i < e; ++i)
      ans[i - 1] = x;
  });
  
  for (int i = 0; i < n; ++i)
    cout << ans[i] << '\n';

  return 0;
}


Measured memory_bytes: 16752
//?§£???????????? 80???AC

#include <iostream>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>


using namespace std;

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

const long long INF=1LL<<30;

//???????????¢????????¢,??????
pair<long long,long long> dfs(vector<vector<long long> > &dis, vector<long long> &cnt,long long &x)
{
	const long long m=dis.size();

	vector<int> vis(m,0);
	stack<P> s;
	s.push(P(0,x));
	
	P res=P(-1,-1);
	
	while(!s.empty()){
		P p=s.top(); s.pop();
		long long now=p.second;
		long long cost=p.first;
		
		if(vis[now]) continue;
		
		if(cnt[now]!=1 && res.first<cost) res=P(cost,now);
		
		vis[now]=1;
		for(long long i=0;i<m;i++){
			if(dis[now][i]!=INF && cnt[i]!=1) s.push(P(cost+dis[now][i],i));
		}
	}


/*	
	for(int i=0;i<vp.size();i++){
		cout<<vp[i].first<<" "<<vp[i].second<<endl;
	}
*/	
/*
	for(int i=vp.size()-1;i>=0;i++){
		if(cnt[vp[i].second]!=1) return vp[i];
	}
*/
	return res;

}

int main()
{
	int n;
	while(cin>>n,n){
		vector<vector<long long> > dis(n,vector<long long>(n,INF));
		for(int i=0;i<n;i++) dis[i][i]=0;
		
		vector<long long> p(n-1),d(n-1),cnt(n,0);
		for(int i=0;i<n-1;i++){
			cin>>p[i];
			p[i]--;
			//cnt[p[i]]++;
		}
		for(int i=0;i<n-1;i++) cin>>d[i];
		
		for(int i=0;i<n-1;i++){
			dis[i+1][p[i]]=dis[p[i]][i+1]=d[i];
			cnt[i+1]++;
			cnt[p[i]]++;
		}


		
		long long res=0;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(dis[i][j]!=INF){
					if(cnt[i]==1 || cnt[j]==1) res+=dis[i][j];
					else res+=3*dis[i][j];
				}
			}
		}

		P x,y;
		for(long long i=0;i<n;i++){
			if(cnt[i]!=1){
				x=dfs(dis,cnt,i);
				break;
			}
		}
		
		y=dfs(dis,cnt,x.second);

		res-=y.first;
		cout<<res<<endl;
		
	}
}

Measured memory_bytes: 6296
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int m,cnt;
vector<int>f;
vector<int>::iterator it;
int main(){
    ll n; cin>>n;
    for (m=40; n<(1ll<<m)-1; --m);
    for (int i=m; i; --i) f.push_back(i);
    for (int i=m; i; --i) f.push_back(i);
    cnt=m,n-=(1ll<<m)-1;
    for (int i=m-1; ~i; --i)
	if (n>>i&1){
	    it=f.end()-i;
	    f.insert(it,++cnt),f.insert(f.begin(),cnt);
	}
    cout<<f.size()<<endl;
    for (int i=0; i<f.size(); ++i)
	cout<<f[i]<<" ";
    return 0;
}


Measured memory_bytes: 256
ans :: [Int] -> [String]
ans (x:y:xs) = 
  replicate x $ replicate y '#'

printRec :: [[String]] -> IO()
printRec (s:[]) = do
  mapM_ putStrLn s
  putStrLn ""
printRec (s:sx) = do
  mapM_ putStrLn s
  putStrLn ""
  printRec sx

main = do
  c <- getContents
  let t = map (map read) $ map words $ lines c :: [[Int]]
      i = takeWhile (/= [0,0]) t
      o = map ans i
  printRec o

Measured memory_bytes: 3932
#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int i, j;
    int c[502], s[502], f[502];
    for (i = 0; i < n - 1; i++)
        scanf("%d %d %d", &c[i], &s[i], &f[i]);
    int ans;
    for (i = 0; i < n; i++)
    {
        ans = 0;
        for (j = i; j < n - 1; j++)
        {
            if (ans < s[j])
                ans = s[j];
            else if (ans%f[j] > 0)
                ans = ans - (ans%f[j]) + f[j];
            ans += c[j];
        }
        printf("%d\n", ans);
    }
    return 0;
}

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

using ll = long long;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

const ll INF = (ll)1e11;

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;
    if (K == 1) {
        cout << 0 << endl;
        return 0;
    }
    cout << max((N+K-1)/K - N/K, (N-K+1) - 1) << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		String s = sc.next();
		long[] a = new long[n + 1];
		long[] b = new long[n + 2];
		for (int i = 0; i < n; i++){
			if (s.charAt(i) == 'W')
				a[i + 1] = a[i] + 1;
			else
				a[i + 1] = a[i];
		}
		for (int i = n - 1; i >= 0; i--){
			if (s.charAt(i) == 'E')
				b[i + 1] = b[i + 2] + 1;
			else
				b[i + 1] = b[i + 2];
		}
		long ans = Long.MAX_VALUE;
		for (int i = 1; i <= n; i++) {
			ans = Math.min(ans, a[i] + b[i] - 1);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 32848
a,b = map(int,input().split())
ans = 0

for x in range(b+1):
  if x > a:
    break
  for y in range(b+1):
    if y > a:
      break
    z = b-x-y
    if z <= a and z >= 0:
      ans +=1
    else:
      continue  
print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++) cin >> a[i];

  ll minim = a[0],maxim = a[0];
  for(int i=1;i<n;i++){
    minim = min(minim,a[i]);
    maxim = max(maxim,a[i]);
  }

  cout << maxim - minim << endl;
}


Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    *X, = map(int, input().split())

    if (M < N):
        print(0)
        return
    X.sort()
    dx = []
    for i in range(M-1):
        dx.append(abs(X[i] - X[i+1]))
    dx.sort()
    
    res = 0
    for i in range(M-N):
        res += dx[i]
    print(res)

main()


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

template<typename T1, typename T2> void cmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T1, typename T2> void cmin(T1 &a, T2 b) { if (a > b) a = b; }

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

  long N;
  cin >> N;
  vector<long> L(N);
  for (long i = 0; i < N; i++) cin >> L.at(i);
  sort(L.begin(), L.end());

  long ans = 0;
  for (long i = 0; i < N; i++) {
    for (long j = 0; j < i; j++) {
      for (long k = 0; k < j; k++) {
        if (L.at(i) == L.at(j) || L.at(j) == L.at(k) || L.at(k) == L.at(i)) continue;
        long sum = L.at(i) + L.at(j) + L.at(k);
        if (sum - L.at(i) > L.at(i)) ans++; 
      }
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3620
n, d = map(int, input().split())
a = [input().split() for l in range(n)]#多次元配列のよみこみ
b = [[int(s) for s in row]for row in a]

d = d**2
count = 0

for i in range(n):
    if b[i][0]**2 + b[i][1]**2 <= d:
        count += 1

print(count)


Measured memory_bytes: 101064
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#define rep(i,n) for(int i(0);i<n;i++)
typedef long long ll;
using namespace std;

int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n) a[i]--;
    vector<int> idx(n);
    rep(i,n) idx[a[i]] = i;
    set<int> s;
    ll ans(0);
    for(int x=n-1; x>=0;--x){
        int i = idx[x];
        ll c = 0;
        {
            s.insert(i);
            vector<int> l(2,-1);
            vector<int> r(2,n);
            {//calc l
                auto it = s.find(i);
                rep(j,2){
                    if(it == s.begin()) break;
                    --it;
                    l[j] = *it;
                }
            }
            {//calc r
                auto it = s.find(i);
                rep(j,2){
                    ++it;
                    if(it == s.end()) break;
                    r[j] = *it;
                }
            }
            vector<int> ls(2);
            ls[0] = i-l[0]; ls[1] = l[0]-l[1];
            vector<int> rs(2);
            rs[0] = r[0]-i; rs[1] = r[1]-r[0];
            c = (ll)ls[0]*rs[1] + (ll)ls[1]*rs[0];
        }
        ans += c*(x+1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>

typedef long long LL;

LL max(LL a, LL b){
    return a > b ? a : b;
}

int n, a[100][101];
LL dp[101][101][101];

int main(void){
    int x, y, z;
    scanf("%d", &n);
    for(x = 0; x < n; x++){
        a[x][0] = 0;
        for(y = 1; y <= n; y++){
            scanf("%d", &a[x][y]);
            a[x][y] += a[x][y-1];
        }
    }
    int max_val = -(1<<30);
    for(x = 0; x < n; x++){
        for(y = x+1; y <= n; y++){
            dp[0][x][y] = a[0][y] - a[0][x];
            max_val = max(max_val, dp[0][x][y]);
        }
    }
    for(x = 1; x < n; x++){
        for(y = 0; y < n; y++){
            for(z = y+1; z <= n; z++){
                LL s = a[x][z] - a[x][y];
                dp[x][y][z] = max(s, s+dp[x-1][y][z]);
                max_val = max(max_val, dp[x][y][z]);
            }
        }
    }
    printf("%lld\n", max_val);
    return 0;
}

Measured memory_bytes: 8608
n = int(input())
ans = [0]*n

for x in range(1,100):
  for y in range(1,100):
    for z in range(1,100):
      tmp = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if tmp <= n:
        ans[tmp-1] += 1

for nn in range(n):
  print(ans[nn])

Measured memory_bytes: 9144
L = int(input())

Edges = []

n = 1
while 2**(n-1)-1 < L:
    n += 1
n -= 1

for i in range(1, n):
    Edges.append([i, i+1, 0])
    Edges.append([i, i+1, 2**(i-1)])

remain = L - 2**(n-1)
for x in range(n-1, 0, -1):
    if 2**(x-1) <= remain:
        Edges.append([x, n, L-remain])
        remain -= 2**(x-1)

print(n, len(Edges))
for u, v, w in Edges:
    print(u, v, w)




Measured memory_bytes: 38384
#include <iostream>
#include <iomanip>
#include <cassert>
using namespace std;

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

void Main()
{
	int N;
	cin >> N;
	int count = 0;
	rep(i, N)
	{
		count += i + 1;
	}

	cout << count << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);

	Main();
	return 0;
}

Measured memory_bytes: 256
arr = list(map(int, input().split()))
 
TAKA = 0
AOKI = 1
PH = 0
PW = 1
 
user = [[arr[0], arr[1]], [arr[2], arr[3]]]
 
taka = user[TAKA]
aoki = user[AOKI]
uid = TAKA
 
while (taka[PH] > 0 and aoki[PH] > 0):
  user[(uid + 1) % 2][PH] -= user[uid][PW]
  uid = (uid + 1) % 2
 
  
result = 'No' if taka[PH] <= 0 else 'Yes'
print(result)

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

int GCD(int m, int n){
	int remain;
	while((remain = m % n) != 0){
		m = n;
		n = remain;
	}
	return n;
}

int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)cin >> a[i];
	int res = GCD(a[0], a[1]);
	for(int i = 2; i < n; i++)res = GCD(res, a[i]);
	cout << res << endl;
}

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

struct P{
    int a, b, dist, atk;
    P(){}
    ~P(){}
    P(const P& r) : a(r.a), b(r.b), dist(r.dist), atk(r.atk) {}
    P(int a, int b, int c, int d) : a(a), b(b), dist(c), atk(d) {}
};

const int INF = 1<<29;

vector<P> G;
int dp[100][101];

void append_edge(int& a, int& b, int& c, int& d){
    G.push_back(P(a, b, c, d));
    G.push_back(P(b, a, c, d));
}

int N, M, L;

int main(){
    while(scanf("%d%d%d", &N, &M, &L) && (N||M||L)){
        int a, b, c, d;
        G.clear();
        for(int x = 0; x < N; x++){
            fill(dp[x], dp[x]+L+1, INF); } for(int x = 0; x < M; x++){
                scanf("%d%d%d%d", &a, &b, &c, &d);
                append_edge(--a, --b, c, d);
            }
        dp[0][0] = 0;
        for(int x = 0; x < N; x++){
            for(int v = 0; v < G.size(); v++){
                int a = G[v].a, b = G[v].b,
                    dist = G[v].dist, atk = G[v].atk;
                for(int w = 0; w <= L; w++){
                    dp[a][w] = min(dp[a][w], dp[b][w]+atk);
                    if(w >= dist) dp[a][w] = min(dp[a][w], dp[b][w-dist]);
                }
            }
        }
        int min_atk = INF;
        for(int x = 0; x <= L; x++){
            min_atk = min(min_atk, dp[N-1][x]);
        }
        printf("%d\n", min_atk);
    }
    return 0;
}

Measured memory_bytes: 1528
N = int(input())
a = list(map(int, input().split()))
colors = [False]*8
rainbow = 0
for i in range(N):
    if 1<=a[i]<=399:
        colors[0] = True
    elif 400<=a[i]<=799:
        colors[1] = True
    elif 800<=a[i]<=1199:
        colors[2] = True
    elif 1200<=a[i]<=1599:
        colors[3] = True
    elif 1600<=a[i]<=1999:
        colors[4] = True
    elif 2000<=a[i]<=2399:
        colors[5] = True
    elif 2400<=a[i]<=2799:
        colors[6] = True
    elif 2800<=a[i]<=3199:
        colors[7] = True
    else:
        rainbow += 1
ans = colors.count(True)
if ans==0:
    print(1,rainbow)
else:
    print(ans,ans+rainbow)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <boost/multi_array.hpp>

int main() {
    int N, ans = 0;
    std::priority_queue<int> que;
    
    std::cin >> N;
    
    for (int i = 0; i < N; i++) {
        int d;
        std::cin >> d;
        que.push(d);
    }
    
    int nowd = 101;
    while (!que.empty()) {
        int d = que.top();
        que.pop();
        if (d < nowd) {
            ans += 1;
            nowd = d;
        }
    }
    
    std::cout << ans << std::endl;
    return 0;
}


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

const int N = 2054;
typedef int mat[N][N];

int r, c;
mat a, f, g;
char map[N][N];

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

int work() {
    int i, j, u, d, la, ans = max(r, c) + 1;
    int *U, *D, *A;
    for(j = 1; j <= c; ++j){
        for(i = 1; i <= r; ++i)
            f[i][j] = (a[i][j] ? 0 : f[i - 1][j] + 1);
        for(i = r; i > 0; --i)
            g[i][j] = (a[i][j] ? 0 : g[i + 1][j] + 1);
    }
    for(i = 1; i <= r; ++i){
        U = f[i]; D = g[i]; A = a[i];
        la = 0; u = i - U[1]; d = i + D[1];
        up(ans, 2 * (d - u));
        for(j = 2; j <= c; ++j){
            if(A[j] == A[j - 1]){
                up(u, i - U[j]); down(d, i + D[j]);
            }else{
            	la = j - 1; u = i - U[j]; d = i + D[j];
			}
			up(ans, (d - u) * (j - la + 1));
		}
	}
	return printf("%d\n", ans), 0;
}

int main() {
	int i, j;
	scanf("%d%d", &r, &c), --r, --c;
	for (i = 0; i <= r; ++i) scanf("%s", map[i]);
	for (i = 1; i <= r; ++i)
		for (j = 1; j <= c; ++j)
			a[i][j] = (map[i][j] ^ map[i][j - 1] ^ map[i - 1][j] ^ map[i - 1][j - 1]) & 1;
	return work();
}

Measured memory_bytes: 53504
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
const int MAX_N=1<<17; //nの2倍くらい

// RSQ&RAQ
struct LazySegmentTree{
    ll node[2*MAX_N-1], lazy[2*MAX_N-1], SIZE; //SIZE:nを２べきにしたもの
    
    //初期化
    void init(int n_){
        //要素数を2べきに
        SIZE=1;
        while(SIZE<n_) SIZE*=2;
        
        //全ての値をI_MAXに
        rep(i,0,2*SIZE-1) node[i]=0;
    }
    
    //k番目のノードについて遅延評価を行う
    void eval(int k, int l, int r){
        // 遅延配列が空でない場合、自ノード及び子ノードへの値の伝播が起こる
        if(lazy[k]!=0){
            node[k]+=lazy[k];
            // 最下段かどうかのチェックをしよう
            if(r-l>1){
                lazy[2*k+1]+=lazy[k]/2;
                lazy[2*k+2]+=lazy[k]/2;
            }
            // 伝播が終わったので、自ノードの遅延配列を空にする
            lazy[k] = 0;
        }
    }
    
    void add(int a, int b, ll x, int k=0, int l=0, int r=-1){
        if(r<0) r=SIZE;
        eval(k,l,r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
        }
        else{
            add(a, b, x, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            node[k]=node[2*k+1]+node[2*k+2];
        }
    }
    
    ll getsum(int a, int b, int k=0, int l=0, int r=-1){
        if(r<0) r=SIZE;
        if(b <= l || r <= a) return 0;
        eval(k,l,r);
        if(a <= l && r <= b) return node[k];
        ll vl=getsum(a, b, 2*k+1, l, (l+r)/2);
        ll vr=getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl+vr;
    }
};
LazySegmentTree S;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,q;
    cin>>n>>q;
    S.init(n);
    rep(i,0,q){
        int b;
        cin>>b;
        if(b){
            int t;
            cin>>t;
            cout <<S.getsum(t-1, t)<<"\n";
        }
        else{
            int s,t;
            cin>>s>>t;
            ll x;
            cin>>x;
            S.add(s-1,t,x);
        }
    }
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
using Graph = vector<vector<ll>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
/****** define constant end ********/
/****** define variable start ******/
ll n, m;
vl a;
/******* define variable end *******/
int solve() {
	cin >> n >> m;
	a.resize(n);
	ll sum = 0;
	REP(i, m){
		cin >> a[i];
		sum += a[i];
	}
	if(sum > n){
		cout << -1 << endl;
	}else{
		cout << n - sum << endl;
	}
	return 0;
}

int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 11120
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,p;
	cin>>n;
	vector<int>v;
	for(int i=0;i<2*n;i++){
		cin>>p;
		v.push_back(p);
	}
	sort(v.begin(),v.end());
	long res=0;
	for(int i=0;i<2*n;i+=2){
		res+=min(v[i],v[i+1]);
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <map>

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

using namespace std;

const int INF = 1 << 29;

int main(){
	map<string, bool> out;

	string res = "?a";
	out["a"] = 1;
	while(1){
		cout << res << endl;
		cout.flush();
		if(res == "!OUT") break;
		string e;
		cin >> e;
		if(out[e] || (res[res.size()-1] != e[0])){
			res = "!OUT";
		}else{
			out[e] = 1;
			res = "?" + e.substr(e.size()-1) + e + "a";
		}
	}

	return 0;
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;  // 1e9+7
const int INF = 100100100;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> p(N + 1);
  int cnt = 0;
  FOR(i, 1, N + 1) {
    cin >> p[i];
    if (p[i] - i != 0) cnt++;
  }
  if (cnt == 0 | cnt == 2)
    cout << "YES" << '\n';
  else
    cout << "NO" << '\n';
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int h = sc.nextInt();
        int w = sc.nextInt();
        String[] a = new String[h];
        int black = 0;
        for (int i = 0; i < h; i++) {
            a[i] = sc.next();
            for (int j = 0; j < w; j++) {
                if (a[i].charAt(j) == '#') black++;
            }
        }
        if (black == h+w-1) {
            System.out.println("Possible");
        } else {
            System.out.println("Impossible");
        }
    }

}


Measured memory_bytes: 21844
n,m = map(int,input().split())
ans = [0 for _ in range(n)]

z = 0
done = []
for _ in range(m):
  s,c = map(int,input().split())
  if not s in done:
    ans[s-1] = c
    done.append(s)
  else:
    if ans[s-1] != c:
      print(-1)
      z = 1
      break
      
if n != 1 and ans[0] == 0 and z ==0:
  if 1 in done:
  	print(-1)
  else:
    ans[0] = 1
    ans = map(str,ans)
    print(int(''.join(ans)))
    
else:
  ans = map(str,ans)
  if z ==0:
    print(int(''.join(ans)))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>

void strsort( std::string &s, int order ) {
	int x[ s.size() ];

	for( int i = 0; i < s.size(); i++ ) {
		x[ i ] = s[ i ];
	}

	if( order == 0 ) {
		std::sort( x, x + s.size() );
	}
	else {
		std::sort( x, x + s.size(), std::greater<int> () );
	}

	for( int i = 0; i < s.size(); i++ ) {
		s[ i ] = x[ i ];
	}

	return;
}

int main()
{
	std::string s, t;
	std::cin >> s >> t;

	strsort( s, 0 );
	strsort( t, 1 );

	int r = s.compare( t );

	std::cout << ( r < 0 ? "Yes" : "No" ) << std::endl;
	return 0;
}



Measured memory_bytes: 256
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

#[fastout]
fn main() {
   input! {
      n:usize,k:usize,
      mut a:[isize;n]
   }
   let mut v = vec![0; n];
   for _ in 0..k {
      for i in 0..n {
         v[if a[i] as usize > i {
            0
         } else {
            i - a[i] as usize
         }] += 1;

         if a[i] as usize + i + 1 < n {
            v[i + a[i] as usize + 1] -= 1;
         }
      }
      for i in 1..n {
         v[i] += v[i - 1];
      }
      if a == v {
         break;
      }
      a = v;
      v = vec![0; n];
   }
   for i in a {
      print!("{} ", i);
   }
   println!("");
}


Measured memory_bytes: 6400
# coding: utf-8

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

trees=[]

for i in range(n):
    tmp=int(input())
    trees.append(tmp)

trees.sort()

min=trees[k-1]-trees[0]

for i in range(n-k+1):
    if min>(trees[i+k-1]-trees[i]):
        min=trees[i+k-1]-trees[i]

print(min)


Measured memory_bytes: 7384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,int> p;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if(b <= a) {
    cout << "delicious" << endl;
  } else if(b - a > x) {
    cout << "dangerous" << endl;
  } else {
    cout << "safe" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std; 

int sum_of_digit[100001];

int main() {
    int N;
    scanf("%d", &N);

    int prefix_sum = 0;
    int cur_sum = 0;
    for (int i = 0; i < N; i++) {
        int cur_digit_sum = 0;
        int cur_number = i;
        while (cur_number > 0) {
            cur_digit_sum += cur_number % 10;
            cur_number /= 10;
        }
        sum_of_digit[i] = cur_digit_sum;
    }
    
    int min = (1 << 31) - 1;
    int round = (N >> 1) + 1;
    for (int i = 1; i <= round; i++) {
        int pair = N - i;
        if (pair >= i) {
            int temp = sum_of_digit[i] + sum_of_digit[pair];
            if (temp < min) {
                min = temp;   
            }
        } else {
            break;
        }
    }
    printf("%d\n", min);
    return 0;
}

Measured memory_bytes: 512
(n, m, x, y) = list(map(int, input().split()))
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))

xs.sort()
ys.sort()

#print(n, m, x, y)
#print(xs)
#print(ys)

if(xs[-1] < x):
  xs[-1] = x
if(y < ys[0]):
  ys[0] = y

z = ys[0]
if(z <= xs[-1]):
  print("War")
elif(x < z and z <= y):
  print("No War")
else:
  print("War")

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N;
string S;

int main() {
    cin >> N;
    cin >> S;

    vvi DP(N, vi(N));
    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (S[i] == S[j]) {
                int tmp = 1;
                if (i > 0)
                    tmp += DP[i - 1][j - 1];
                if (j - i < tmp) continue;
                DP[i][j] = tmp;
            }
            ans = max(ans, DP[i][j]);
        }
    }

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


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

int main()
{
    int n, k, t;
    while(cin >>n)
    {
        if(n==0) cout<<0;
        else
        {
            vector <int> v;
            while(n != 0)
            {
                k = n % -2;
                n /= -2;
                if(k < 0)
                {
                    k -= -2;
                    n++;
                }
                v.push_back(k);
            }
            for(int i=v.size()-1; i>=0 ; i--)
                cout<<v[i];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
while True:
    try:
        x_a, y_a, x_b, y_b, x_c, y_c, x_d, y_d = map(float, input().split(","))
        ab = [x_b - x_a, y_b - y_a]
        bc = [x_c - x_b, y_c - y_b]
        cd = [x_d - x_c, y_d - y_c]
        da = [x_a - x_d, y_a - y_d]
        crs_a = -(ab[0]*da[1] - ab[1]*da[0])
        crs_b = -(bc[0]*ab[1] - bc[1]*ab[0])
        crs_c = -(cd[0]*bc[1] - cd[1]*bc[0])
        crs_d = -(da[0]*cd[1] - da[1]*cd[0])
        if crs_a*crs_b*crs_c*crs_d < 0:
            print("NO")
        else:
            print("YES")
    except:
        break



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

#define INF 0x3F3F3F3F
typedef struct point{
	int x;
	int y;
	point(){
		x=0;
		y=0;
	}
	point(int x,int y){
		this->x=x;
		this->y=y;
	}

}point;

point *children;
point *points;

int abs(int x){
	return x<0?-x:x;
}

int getDistance(int i,int j){
	return abs(children[i].x-points[j].x)+abs(children[i].y-points[j].y);
}

int N,M;
int findMin(int i){
	int min=INF;
	int cursor=1;
	for(int j=1;j<=M;j++)
		if(getDistance(i,j)<min){
			min=getDistance(i,j);
			cursor=j;
		}
	return cursor;
}

int main(){
	cin>>N>>M;
	children=new point[N+1];
	points=new point[M+1];
	for(int i=1;i<=N;i++)
		cin>>children[i].x>>children[i].y;
	for(int i=1;i<=M;i++)
		cin>>points[i].x>>points[i].y;
	for(int i=1;i<=N;i++)
		cout<<findMin(i)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,K;
  cin >> N >> K;
  vi A(N);
  int ma=0;
  rep(i,N) {
    cin >> A[i];
    chmax(ma,A[i]);
  }
  double l=0,r=ma+1;
  rep(tryi,60) {
    double m = (l+r)/2;
    int cnt = 0;
    rep(i,N) {
      cnt += ceil(A[i]/m)-1;
    }
    if(cnt>K) {
      l=m;
    } else {
      r=m;
    }
  }
  cout << setprecision(16) << ceil(l) << endl;
  return 0;
}

Measured memory_bytes: 4040
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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



int main(){
    int n; cin >> n;
    VD p(n+1), q(n+1), sump(n+1), sumq(n+2);
    FORS(i, 1, n){
        cin >> p[i]; sump[i] = sump[i-1] + p[i];
    }
    REPS(i, n){
        cin >> q[i]; sumq[i+1] = sumq[i] + q[i];//attention
    }
    vector<VD> dp(n+1, VD(n+1, 0.0));
    FORS(i, 1, n) dp[i][i] = p[i] + 2*q[i-1] + 2*q[i];

    FORS(l, 2, n){
        FORS(i, 1, n - l + 1){
            int j = i + l - 1;
            dp[i][j] = INF;
            FORS(k, i, j){
                if(k == i) chmin(dp[i][j],
                                 p[i] + 2*q[i-1] + dp[i+1][j] + sump[j] - sump[i] + sumq[j+1] - sumq[i]);
                else if(k == j) chmin(dp[i][j],
                                 p[j] + 2*q[j] + dp[i][j-1] + sump[j-1] - sump[i-1] + sumq[j] - sumq[i-1]);
                else chmin(dp[i][j],
                     dp[i][k-1] + dp[k+1][j] + sump[j] - sump[i-1] + sumq[j+1] - sumq[i-1]);
            }
        }
    }
    cout << fixed << setprecision(10) << dp[1][n] << "\n";
    return 0;
}



Measured memory_bytes: 5068
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] l = new int[n];
    for(int i=0; i<n; i++) {
      l[i] = sc.nextInt();
    }
    Arrays.sort(l);
    int total=0;
    for(int i=0; i<n-1; i++) {
      total += l[i];
    }
    if(total > l[n-1])
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mod 1000000007

int Max(int x, int y)
{
    return (((y-x)>>(32-1))&(x^y))^y;
}

int Min(int x, int y)
{
    return (((y-x)>>(32-1))&(x^y))^x;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //Initialize variables while declaring them
    int mxx[105];
    mxx[0]=mxx[1]=mxx[2]=0;
    int c=1;
    for(int i=3; i<105; i++, c++)
        mxx[i]=mxx[i-1]+c;
    int n, k;
    cin>>n>>k;
    int ansmx=mxx[n];
    // int ansmn=ansmx-(n-1);
    // ansmn=max(ansmn, 0LL);
    if(k>ansmx)
    {
        cout<<-1;
        return 0;
    }
    vector<pair<int, int>> v;
    bool adj[105][105];
    for(int i=0; i<105; i++)
        for(int j=0; j<105; j++)
            adj[i][j]=false;
    for(int i=2; i<=n; i++)
        v.pb({1, i}), adj[1][i]=adj[i][1]=true;
    // k-=v.size();
    k=ansmx-k;
    if(k>0)
    for(int i=1; i<=n; i++)
        for(int j=1; j<=n; j++)
            if(i!=j)
            {
                if(k==0)
                    break;
                if(adj[i][j]==false)
                {
                    k--;
                    adj[i][j]=adj[j][i]=true;
                    v.pb({i, j});
                }
            }
    cout<<v.size()<<endl;
    for(auto x:v)
        cout<<x.first<<" "<<x.second<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int r;
    cin >> r;
    cout << 2 * r * 3.1415926535 << endl;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;  // 1e9+7
const int INF = 100100100;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a;
  string s;
  cin >> a >> s;
  cout << ((a >= 3200) ? s : "red") << '\n';
}

Measured memory_bytes: 256
n,x=map(int,input().split())
L=list(map(int,input().split()))
D=[0]*(n+1)
o=True
for i in range(n):
    D[i+1]=D[i]+L[i]
for i in range(len(D)):
    if D[i]>x:
        print(i)
        o=False
        break
if o:
    print(n+1)

Measured memory_bytes: 3064