akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <cstring>
#include <climits>
#include <iomanip>

#define EPS 1e-7
#define LLMAX 9223372036854775807
#define INTMAX 2147483647
#define ULLMAX 18446744073709551615
#define precision(n) cout << setprecision(n) << fixed
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define forr(i, t, n) for (int i = t; i<n; ++i)
#define rforr(i, t, n) (int i = n-1; i>=t; --i)
#define rfor(i, n) for (int i = n-1; i>=0; --i)
#define rmod(x, y) (((x%y)+y)%y)
#define pb push_back
#define emp emplace_back
using namespace std;
typedef vector<int>::iterator vit;
typedef unsigned int uint;
typedef unsigned short ushort;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int MAXN = 1024;

//STRUCTS


//OPERATORS


//GLOBALS


//FUNCTIONS


//PROBLEM: 
//LINK: 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
		priority_queue<int> q;
		int n, m;
		cin >> n >> m;
		int aux;
		forn(i, n)
		{
			cin >> aux;
			q.push(aux);
		} 
		while (m>0)
		{
			int aux = q.top();
			q.pop();
			aux/=2;
			m--;
			q.push(aux);
		}
		ll ans = 0;
		while (q.size())
		{
			ans+= q.top();
			q.pop();
		}
		cout << ans;


	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 1000005, mod = 1000000007;
int n, m;
ll fac[MX], inv[MX], res;

ll pot (ll b, int p) {
	ll res = 1;
	while (p) {
		if (p & 1) (res *= b) %= mod;
		(b *= b) %= mod;
		p /= 2;
	}
	return res;
}

ll comb (int n, int k) {
	return fac[n] * inv[k] % mod * inv[n - k] % mod;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	fac[0] = inv[0] = 1;
	for (int i = 1; i < MX; i++) {
		fac[i] = i * fac[i - 1] % mod;
		inv[i] = pot(fac[i], mod - 2);
	}

	cin >> n >> m;

	for (int i = 0, f = 1; i <= n; i++, f *= -1) {
		ll a = fac[n] * comb(m, n) % mod;
		(a *= comb(n, i)) %= mod;

		ll b = fac[n - i] * comb(m - i, n - i) % mod;

		(res += f * a * b) %= mod;
	}

	cout << MOD(res, mod) << endl;

	return 0;
}

Measured memory_bytes: 19220
#include <bits/stdc++.h>
using namespace std;
int N,inp;
map<int,int> mp;

int main(){
    cin >> N;
    for(int i=1;i<N+1;i++) mp[i] = 0;
    for(int i=1;i<N;i++){
        cin >> inp;
        mp[inp]++;
    }
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) cout << itr->second << endl;
    return 0;
}


Measured memory_bytes: 13004
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; 
typedef vector<int> vi; 
typedef pair<int, int> ii; 
typedef vector<ii> vii; 
typedef set<int> si; 
typedef map<string, int> msi; 
 
  
int main() 
{ 
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
   string s,s2;ll n,i,s1=0;
   cin>>s;
   n=s.length();
   for(i=0;i<n;i++){
       s2=s[i];
       stringstream geek(s2); 
  
    ll x = 0; 
    geek >> x;
    s1+=x;
   }
// cout<<s1;
  if(s1%9==0) cout<<"Yes";
  else cout<<"No";
    return 0; 
} 

Measured memory_bytes: 3724
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstring>
#include<map>

using namespace std;

const int INF = (1<<28);
const int MAX = 16;

typedef pair<string,int> P;
typedef pair<int,int> Pii;

struct edge{int to, cost;};
struct State{
  Pii t;
  int pos, need;
  bool operator < (const State& st) const {
    return t > st.t;
  }
};

map<string, int> idx;
int val[MAX];
vector<edge> E[MAX];
Pii T[MAX][(1<<MAX)];
int shop[MAX];
int N,wanted;

void init(){
  fill(T[0], T[0]+MAX*(1<<MAX), Pii(INF,INF));
  idx.clear();
  memset(val, -1, sizeof(val));
  wanted = 0;
  for(int i = 0; i < MAX; i++){
    E[i].clear();
    shop[i] = 0;
  }
}

void input(){
  vector<P> v[N];
  int cnt = 0;
  for(int i = 0; i < N; i++){
    int q;
    cin >> q;
    v[i].resize(q);
    for(int j = 0; j < q; j++){
      cin >> v[i][j].first >> v[i][j].second;
      if(!idx.count(v[i][j].first)) idx[v[i][j].first] = cnt++; 
      if(val[idx[v[i][j].first]] == -1) val[idx[v[i][j].first]] = v[i][j].second;
      else val[idx[v[i][j].first]] = min(val[idx[v[i][j].first]], v[i][j].second);
    }
  }


  for(int i = 0; i < N; i++)
    for(int j = 0; j < (int)v[i].size(); j++)
      if(val[idx[v[i][j].first]] == v[i][j].second) shop[i+1] |= (1<<idx[v[i][j].first]);
      
  int q;
  cin >> q;
  while(q--){
    string name;
    cin >> name;
    if(!idx.count(name)) idx[name] = cnt++;
    wanted |= (1<<idx[name]);
  }


  int m;
  cin >> m;
  while(m--){
    int a,b,c;
    cin >> a >> b >> c;
    E[a].push_back((edge){b,c});
    E[b].push_back((edge){a,c});
  }
}

void solve(){

  T[0][wanted] = Pii(0,0);
  priority_queue<State> Q;
  Q.push((State){Pii(0,0),0,wanted});

  while(!Q.empty()){
    const State st = Q.top();
    Q.pop();

    if(T[st.pos][st.need] < st.t) continue;

    for(int i = 0; i < (int)E[st.pos].size(); i++){
      State nex = st;
      nex.t.first = st.t.first;
      nex.t.second += E[st.pos][i].cost;
      nex.pos = E[st.pos][i].to;
      nex.need = st.need;

      int canbuy = shop[nex.pos]&nex.need;
      for(int i = 0; i < MAX; i++)
	if(canbuy & (1<<i)){
	  nex.need -= (1<<i);
	  nex.t.first += val[i];
	}
      
      if(T[nex.pos][nex.need] > nex.t){
	T[nex.pos][nex.need] = nex.t;
	Q.push(nex);
      }
    }
  }
  
  if(T[0][0].first == INF) cout << "impossible" << endl;
  else cout << T[0][0].first << " " << T[0][0].second << endl;
}

int main(){
  
  while(cin >> N && N){
    init();
    input();
    solve();
  }
  return 0;
}

Measured memory_bytes: 9448
#include <iostream>
#include <algorithm>
#include <vector>
typedef long long LL;
using namespace std;

const LL mod=1000000007;

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

    vector<int>oks(n+1,true);
    vector<LL>dp(n+1);

    for(int i=0; i<m; i++){
        cin >> tmp;
        oks[tmp]=false;
    }
    dp[0]=1;
    for(int now=0; now<n; now++){
        for(int next=now+1; next<=min(n,now+2);next++){
            if(oks[next]){
                dp[next]+=dp[now];
                dp[next]%=mod;
            }
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1408
from math import sqrt
n = int(input())

def check(x):
    for i in range(2, int(sqrt(x))+2):
        if x % i == 0:
            return False
    return True

a = []
i = 0
while len(a) < n:
    i += 1
    if check(5*i+1):
        a.append(5*i+1)

print(*a, sep=" ")


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

using namespace std;

void solve() {
    int K; cin >> K;
    if (K == 1) {
        cout << "1\n1"; return;
    }
    int n = 2;
    while ((n&1) || K > 2*n ) {
        n++;
    }
    vector<int> a(n), b(n);
    iota(a.begin(), a.end(), 1);
    iota(b.begin(), b.end(), n+1);
    int cnt = 2*n - K;
    while (cnt > 0) {
        b[n-cnt] = a[n-cnt];
        cnt--;
    }
    cout << n << "\n";
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int c = (i&1)? b[(i+j)%n] : a[(i+j)%n];
            cout << c << ' ';
        }cout << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 1280
#include<iostream>
using namespace std;
typedef long long int ll;

int main()
{
	ll n, m, l;
	cin >> n >> m >> l;
	const ll max_ = 100;
	ll a[max_][max_];
	ll b[max_][max_];
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	for (ll i = 0; i < m; i++) {
		for (ll j = 0; j < l; j++) {
			cin >> b[i][j];
		}
	}
	
	
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < l; j++) {
			ll c = 0;
			for (ll k = 0; k < m; k++) {
				c += a[i][k] * b[k][j];
			}
			if (j != l - 1)cout << c << " ";
			else cout << c << endl;
		}
	}

    return 0;
}

Measured memory_bytes: 1312
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};
 
  
 

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


int n;
cin>>n;

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

else {
  int k=log2(n); 
  int ans=pow(2,k+1);
  cout<<ans-1;
}
   
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;

int n,a[N];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i=1;i<=n;i++){
		cin >> a[i];
	}
	sort(a+1,a+n+1);
	int res=0,last=0;
	for (int i=1;i<=n;i++){
		if (a[i]!=a[i-1]){
			if ((a[i]-a[last])&1){
				res^=n-i+1;
			}
			last=i;
		}
	}
	cout << (res ? "first" :
	"second") << "\n";
}

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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll n,a;
	bool ans=true;
	set<ll> st;
	cin>>n;
	forn(i,n){
		cin>>a;
		if(st.cn(a)==1)ans=false;
		st.in(a);
	}
	(ans)?cout<<"YES\n":cout<<"NO\n";
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""
 



Measured memory_bytes: 12992
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    string *S = new string[N];
    rep(i,N) cin >> S[i];

    map<string, int> map;
    rep(i,N) {
        if (map.find(S[i]) == map.end()) map[S[i]] = 0;
        else map[S[i]] += 1;
    }

    int max = 0;
    vector<string> vec;
    for (auto i = map.begin(); i != map.end(); ++i) {
        if (max < i->second) {
            vec.clear();
            vec.push_back(i->first);
            max = i->second;
        } else if (max == i->second) {
            vec.push_back(i->first);
        }
    }

    sort(vec.begin(), vec.end());
    for (string s : vec) {
        cout << s << endl;
    }

    return 0;
}


Measured memory_bytes: 28912
//:::: Alien :::://
// Muhammad Eid //
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define prINT pair<int, int>

const int N = 100 +5;
string s[N];

void Mo35(){ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}

int main(){
Mo35();

    int n, l; cin>> n>> l;
    for(int i=0; i<n; ++i) cin>> s[i];
    sort(s, s+n);
    for(int i=0; i<n; ++i) cout<< s[i];

return 0;
}


Measured memory_bytes: 3676
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  cout << (N / 3) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int A[100],N,i,j,b,s=0;

  scanf("%d",&N);

  for(i=0;i<N;i++){
    scanf("%d",&A[i]);}
  
  for(i=0;i<N-1;i++){
    for(j=N-1;j>i;j--){
      if(A[j]<A[j-1]){
	b=A[j];
	A[j]=A[j-1];
	A[j-1]=b;
	s++;}}}
for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i != N-1){printf(" ");}
 }
  printf("\n%d\n",s);
      return 0;}



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

using namespace std;

int main() {
  int n, m; cin >> n >> m;
  vector<int> dp(50505, (int)1e9);
  dp[0] = 0;
  for (int i = 0; i < m; ++i) {
    int c; cin >> c;
    for (int j = 0; j <= n; ++j) {
      if (j - c < 0) continue;
      dp[j] = min(dp[j], dp[j - c] + 1);
    }
  }
  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N = Integer.parseInt(sc.next());
	static int W = Integer.parseInt(sc.next());
	static int[] w = new int[N];
	static int[] v = new int[N];
	static long[][] dp = new long[N+1][W+1];
	public static void main(String[] args) {
		for (int i = 0; i < N; i++) {
			w[i] = Integer.parseInt(sc.next());
			v[i] = Integer.parseInt(sc.next());
		}
		for (int i = N-1; i >= 0; i--) {
			for (int j = 0; j <= W; j++) {
				if (j < w[i]) {
					dp[i][j] = dp[i+1][j];
				} else {
					dp[i][j] = Math.max(dp[i+1][j], dp[i+1][j-w[i]] + v[i]);
				}
			}
		}
		System.out.println(dp[0][W]);
	}
}


Measured memory_bytes: 128980
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define lb long double
#define vec vector<int>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<string>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	int kotae = 0;
	for (int i = 0; i < n - 1; i++) {
		if (a[i] != a[i + 1])kotae++;
	}
	cout << kotae+1 << endl;
}

Measured memory_bytes: 9544
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define ll long long
# define ln cout<<'\n'
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
 
ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

using namespace std;

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 (b<a) { a=b; return 1; } return 0; }


int main(){
    ll N,X;
    cin >> N >> X;
    vector<int> Map(N);
    rep(i,N){
        cin >> Map[i];
    }

    int ans = abs(X-Map[0]);
    for(int i=1;i<N;i++){
        ans = gcd(ans,abs(X-Map[i]));
    }
    cout << ans << endl;


}

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

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

bool ed(int x,int y,int r,int c){
    return x==0||x==r||y==0||y==c;
}

int nm(int x,int y,int r,int c){
    if(x==0) return y;
    if(y==c) return c+x;
    if(x==r) return r+(c<<1)-y;
    if(y==0) return ((r+c)<<1)-x;
}

class EConnected {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int r,c,n;
        in>>r>>c>>n;
        int x,y,z,w;
        vector<pair<int,int>> e;
        fr(i,n){
            in>>x>>y>>z>>w;
            if(ed(x,y,r,c)&&ed(z,w,r,c)){
                e.emplace_back(nm(x,y,r,c),nm(z,w,r,c));
            }
        }
        n=e.size();
        fr(i,n) if(e[i].first>e[i].second) swap(e[i].first,e[i].second);
        sort(e.begin(),e.end());
        int rc=(r+c)<<1;
        e.resize(n<<1);
        fr(i,n) e[i+n]=make_pair(e[i].first+rc,e[i].second+rc);
        stack<int> v;
        fr(i,n<<1){
            while(!v.empty()&&v.top()<e[i].first) v.pop();
            if(v.empty()){
                v.push(e[i].second);
                continue;
            }
            int m=v.top();
            if(e[i].second<m){
                v.push(e[i].second);
                continue;
            }
            out<<"NO"<<endl;
            return;
        }
        out<<"YES"<<endl;
    }
};

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


Measured memory_bytes: 2676
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  ios::sync_with_stdio(false);
  ll n;
  cin>>n;
  vector<ll> a(n),b(n),c(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n) cin>>c[i];
  sort(ALL(a));
  sort(ALL(b));
  sort(ALL(c));
  ll ans=0;
  rep(i,n){
    ll x=ll(lower_bound(ALL(a),b[i])-a.begin());
    ll y=ll(c.end()-upper_bound(ALL(c),b[i]));
    ans+=x*y;
  }
  cout<<ans<<endl;
  
  
  
  
}

Measured memory_bytes: 2560
#include <vector>
#include <functional>
#include <deque>
#include <stdexcept>


template<typename T, typename Container = ::std::deque<T>, typename Compare = ::std::greater<typename Container::value_type>>
class sliding_window {
    using value_compare = Compare;
    using value_type = T;
    using const_reference = const value_type &;

    value_compare comp;
    size_t length;
    Container val;

public:
    void push(const value_type &v) {
        while (!val.empty() && comp(val.back(), v))val.pop_back();
        val.push_back(v);
        ++length;
    }

    void pop(const value_type &v) {
        if (v == val.front())val.pop_front();
        --length;
    }

    explicit sliding_window(const Compare &_comp = Compare()) : length(0), comp(_comp), val({}) {}
    template<typename ForwardIterator>
    sliding_window(ForwardIterator begin, ForwardIterator end, const Compare &_comp = Compare()) : length(0), comp(_comp), val({}) {
        while(begin != end){
            push(*begin);
            ++begin;
        }
    }

    const size_t size() const {
        return length;
    }

    const_reference top() const {
        return val.front();
    }

};

#include <iostream>
#include <algorithm>

int main() {
    unsigned long long N, M, K;
    scanf("%llu%llu%llu", &N, &M, &K);

    std::vector<unsigned long long> A(N), dp1(N), dp2(N);
    for (auto &i : A)scanf("%llu", &i);

    std::copy(A.begin(), A.end(), dp1.begin());

    for (unsigned long long i = 1; i != K; ++i) {
        sliding_window<unsigned long long, std::deque<unsigned long long>, std::less<>> slidingWindow{};
        std::transform(A.begin(), A.end(), dp2.begin(), [&i](auto a) { return a * (i + 1); });

        for (unsigned long long j = 0; j != N; ++j) {
            if (j >= i)dp2[j] += slidingWindow.top();
            if (slidingWindow.size() == M)slidingWindow.pop(dp1[j - M]);
            slidingWindow.push(dp1[j]);
        }

        std::swap(dp1, dp2);
    }

    std::cout << *std::max_element(dp1.begin(), dp1.end()) << std::endl;

    return 0;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
#define ll long long;


int main(){
	std::ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> a(N);
	vector<int> b(N);
	vector<int> c(N);
	for(int x=0;x<N;x++){
		cin>>a[x];
	}
	for(int x=0;x<N;x++){cin>>b[x];
	}
	for(int x=0;x<N-1;x++){cin>>c[x];
	}
	int prev = -5;
	int sum = 0;
	for(int x = 0; x<N; x++){
		sum = sum+b[a[x]-1];
		if(a[x]==(prev+1)){
			sum+=c[a[x]-2];
		}
		prev = a[x];
	}
	cout << sum;
}

 


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

#define ll long long
#define NIL 0
#define INF 1e18
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vl vector<ll>
#define vvl vector<vector<ll>> 
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define pb push_back
#define F first
#define S second
#define pp pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define rpk(i,k,n) for(int i=k;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++) 
#define RPK(i,k,n) for(int i=k;i<=n;i++) 
#define ritr(i,gr) for(auto i=gr.begin();i!=gr.end();i++)

const int M = 1e9+7;

int V, E, i, j, k, u, v, x, y, p, q, r, t, n;
vi *g;
vb sn;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;
    int h[n];
    rep(i,n) cin>>h[i];
    ll dp[n];
    dp[0]=0;
    REP(i,n-1) dp[i] = INF;
    
    
    REP(i,n-1) {
        j = 1;
        while(j<=k && i-j>=0) {
            dp[i]  = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
            j++;
        }
    }
    
    
    cout<<dp[n-1]<<endl;
}
    
    
    

Measured memory_bytes: 4800
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9 + 7;
const int inf = 1e8;

int main() {
	string N;
	string ans = "NO";
	cin>>N;
	if(N == "7" or N == "3" or N == "5")ans = "YES";

	cout<<ans<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 998244353
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, s = LI()
a = LI()

dp = [[0]*(s+1) for _ in range(n+1)]
dp[0][0] = 0
for i in range(1, n+1):
    x = a[i-1]
    for j in range(s+1):
        if j == 0:
            dp[i][j] += dp[i-1][j] + 1
            dp[i][j] %= mod
        elif dp[i-1][j]:
            dp[i][j] += dp[i-1][j] * 2
            dp[i][j] %= mod
        if j - x < 0:
            continue
        if j - x == 0:
            dp[i][j] += pow(2, dp[i-1][j-x], mod)
            dp[i][j] %= mod
        elif dp[i-1][j-x]:
            dp[i][j] += dp[i-1][j-x]
            dp[i][j] %= mod
print(dp[-1][-1])


Measured memory_bytes: 139648
while True:
    [H,W] = raw_input().split()
    H = int(H)
    W = int(W)
    if H == 0 and W == 0:
        break
        
    for y in range(0,H):
        s = ''
        for x in range(0,W):
            s = s + '#'
        print s
    print ''

Measured memory_bytes: 4204
def main():
    H, W = list(map(int, input().split(' ')))
    S = [input() for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if S[h][w] == '.':
                continue
            # check adjacent cells
            if h - 1 >= 0 and S[h - 1][w] == '#':
                continue
            if h + 1 <= H - 1 and S[h + 1][w] == '#':
                continue
            if w - 1 >= 0 and S[h][w - 1] == '#':
                continue
            if w + 1 <= W - 1 and S[h][w + 1] == '#':
                continue
            # all adjacent cells are white -> NG
            print('No')
            return
    print('Yes')


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
<?php
// B
fscanf(STDIN, '%s', $s);
if ($s[0] !== 'A') exit('WA');
$cc = -1;
for ($i = 1; $i < strlen($s); $i++) {
    if ($s[$i] === 'C') {
        if ($cc !==  -1) exit('WA');
        $cc = $i + 1;
    } elseif (preg_match('/[A-Z]/', $s[$i])) {
        exit('WA');
    }
}
if ($cc >= 3 && $cc <= strlen($s) - 1) echo 'AC';
else echo 'WA';

Measured memory_bytes: 4856
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


struct node {
	int begin;
	int end;
	int sum = 0;
	node* child1;
	node* child2;
	node(int begin, int end) {
		this->begin = begin;
		this->end = end;
	}
};

node* root;

node* init(int begin, int end) {
	node* parent = new node(begin, end);
	if (begin != end) {
		int mid = (begin + end) / 2;
		parent->child1 = init(begin, mid);
		parent->child2 = init(mid + 1, end);
	}
	return parent;
}

void add(int x, int y) {
	node* nod = root;
	while (nod->begin != nod->end) {
		nod->sum += y;
		if (x <= nod->child1->end)
			nod = nod->child1;
		else
			nod = nod->child2;
	}
	nod->sum += y;
}

int getSum(node* nod, int x, int y) {
	if (nod->end < x)
		return 0;
	if (nod->begin > y)
		return 0;
	if (nod->begin == x && y == nod->end)
		return nod->sum;
	return getSum(nod->child1, x, min(y,nod->child1->end)) + getSum(nod->child2, max(nod->child2->begin,x), y);	
}

int main() {
	int n, q;
	cin >> n >> q;
	root = init(1, n);
	for (int i = 0; i < q; ++i) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0)
			add(x, y);
		else
			cout << getSum(root,x, y) << endl;
	}
}

Measured memory_bytes: 12472
using System;
 
namespace ConsoleApplication11
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
 
            int[] n = new int[3];
            n[0] = int.Parse(s[0]);
            n[1] = int.Parse(s[1]);
            n[2] = int.Parse(s[2]);
 
            Array.Sort(n);
            Console.WriteLine(n[0] + " " + n[1] + " " + n[2]);
             
 
        }
    }
}
 

Measured memory_bytes: 9380
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll X;
    cin >> X;
    ll happy = 0;
    ll Y = X / 500;
    happy += Y * 1000;
    X -= Y * 500;
    ll Z = X / 5;
    happy += Z * 5;
    cout << happy << endl;
}



Measured memory_bytes: 3568
/** Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std;

#define l long // -2^31 to +2^31-1 (upper limit ~ 2*(10^9))
#define ul unsigned long // 0 to +2^32-1
#define ll long long // -2^63 to +2^63-1 (upper limit ~ 9*(10^18))
#define ull unsigned long long // 0 to +2^64-1
#define mod(x, m) ((((x)%(m))+(m))%(m))
#define vi vector<int>
#define pi pair<int,int>
#define vl vector<ll int>
#define pl pair<ll int,ll int>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const ll MOD = 1e9 + 7;
const double pie = 3.141592653589793;
const ll int MD = 998244353 ;

#define setcount(x) __builtin_popcount(x) // counts set bits
#define parity(x) __builtin_parity(x) // checks parity of the number
#define lzcount(x) __builtin_clz(x) // count leading zeros in binary representation of number
#define tzcount(x) __builtin_ctz(x) // count trailing zeros in binary representation of number

template<typename T> T inf() { return (T)__builtin_inf();} // syntax for use inf<datatype>();
template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return (a*b)/gcd(a,b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

string IntToString(ll a){ ostringstream temp; temp << a; return temp.str();}
ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M,only if M is prime
ll add(ll a,ll b,ll M) { return ( mod(a,M ) + mod(b,M ))%M; }
ll sub(ll a, ll b,ll M) { return (mod(a,M ) + M - mod(b,M ))%M; }
ll mult(ll a,ll b,ll M) { return  ( mod(a,M)*mod(b,M) ) %M ; }
bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 

/************************** main program **************************/

int main()
{
	FASTIO
	//code
	ll int n;
	cin>>n;
	if(n&1)	cout<<0;
	else
	{
		ll int k=5,ans=0;
		n = n/2;
		ll int t = n/k;
		while(t > 0)
		{
			ans += (n/k);
			k *= 5;
			t = n/k;
		}
		cout<<ans;
	}	
	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;

void main(){
    int n = stdin.readln.chomp.to!int;
    int money = 100_000;
    while(n--){
        money = cast(int)(money * 1.05);
        if(money % 1_000)
            money = money - (money % 1_000) + 1_000;
    }
    writeln(money);
}

Measured memory_bytes: 964
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
using namespace std;
long long a[120];
long long gcd(long long a,long long b)
{
	return b==0?a:gcd(b,a%b);
}
int main(void)
{
	long long b,c,d,i,j,k,n,sum;
	scanf("%lld",&n);
	for(i=0;i<n;i++)
	scanf("%lld",&a[i]);
	sort(a,a+n);
	k=a[0];
	sum=a[0];
	for(i=1;i<n;i++)
	{
		k=gcd(sum,a[i]);
		sum=sum/k*a[i];
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;


int main(){
   string s;
   cin>>s;
   string ans;

   rep(i,s.size()){
      if(s[i]=='0') ans+='0';
      else if(s[i]=='1') ans+='1';
      else {
         if(ans.size()==0) continue;
         else ans.pop_back();
      }
   }
   cout<<ans;
   

return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a,b,c;
  cin >> a >> b >> c;
  int* take = new int[8];
  for(int i=0;i<n;i++)cin >> take[i];
  int ser = 1;
  ser <<= 2*n;

  int ans = 1000000;
  for(int i=0;i<ser;i++){
    int ss = i;
    int mp = 0;
    int al=0;
    int bl=0;
    int cl=0;
    for(int j=0;j<n;j++){
      int num = ss%4;
      if(num==1){
        if(al!=0) mp += 10;
        al += take[j];
      }
      if(num==2){
        if(bl!=0) mp += 10;
        bl += take[j];
      }
      if(num==3){
        if(cl!=0) mp += 10;
        cl += take[j];
      }
      ss /= 4;
    }
    if(al==0 || bl == 0 || cl == 0) continue;
    mp += abs(al-a);
    mp += abs(bl-b);
    mp += abs(cl-c);
    ans = min(ans,mp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
  
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    out.println((n - 1) / 2);
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] nextArray(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDoubleArray(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public int[][] nextIntMatrix(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLongMatrix(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDoubleMatrix(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
}


Measured memory_bytes: 21076
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string s;
	cin >> s;

	string t = "keyence";
	if (s.substr(0, 7) == t) {
		cout << "YES\n";
		return 0;
	}

	int sz = s.size();
	if (s.substr(sz - 7, 7) == t) {
		cout << "YES\n";
		return 0;
	}

	int i = 0, j = sz - 1;
	while (s[i] == t[i]) {
		++i;
	}

	int k = t.size() - 1;
	while (j > i && s[j] == t[k]) {
		--j;
		--k;
	}

	if (i == 0 || j == sz - 1) {
		cout << "NO\n";
	} else {
		if (i + sz - j - 1 == 7) {
			cout << "YES\n";
		} else {
			cout << "NO\n";
		}
	}

	return 0;

}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int ans;
int n, a[maxn];

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

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

  for (int i=0; i<n; i++) {
    for (int j=i+1; j<n; j++) {
      int *x = lower_bound(a,a+n,a[i]+a[j]);
      int dist = x - 1 - (a + j);
      ans += dist;
    }
  }

  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
    int n,m;
    cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
    return 0;
}

Measured memory_bytes: 256
N,M,X = map(int,input().split())
c = []
a = []

for i in range(N):
    C, *A = map(int,input().split())
    c.append(C)
    a.append(A)

min_prices = 10**9
for i in range(1 << N):#パターン数
    prices = 0
    rikaido = [0] * M
    for j in range(N): #000 ~ 111 参考書の組み合わせ
        if ((i >> j) & 1) == 1: #参考書の番号（N冊）#011など
            prices += c[j]
            for k in range(M):#アルゴリズムの理解度加算
                rikaido[k] += a[j][k]
        if all(l>=X for l in rikaido):
            min_prices = min(min_prices,prices)
print(min_prices if min_prices != 10**9 else -1)            
                
            

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

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define MAXN 100013

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

int N;
vpi arr;
int ans;
multiset<int> lts, rts;

bool cmp(pii a, pii b)
{
	if (a.fi != b.fi) return a.fi < b.fi;
	return a.se > b.se;
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	int mx = 0;
	cin >> N; arr.resize(N);
	FOR(i, 0, N)
	{
		cin >> arr[i].fi >> arr[i].se;
		ckmax(mx, arr[i].se - arr[i].fi + 1);
		lts.insert(arr[i].fi);
		rts.insert(arr[i].se);
	}
	//thus all intervals inside you are to your right.
	sort(ALL(arr), cmp);
	FOR(i, 0, N)
	{
		pii p = arr[i];
		lts.erase(lts.find(p.fi));
		rts.erase(rts.find(p.se));
		ckmax(ans, p.se - p.fi + 1 + max(0, *rts.begin() - *lts.rbegin() + 1));
		lts.insert(p.fi);
		rts.insert(p.se);
	}
	//for each range, try having it as the only one.
	vpi tmp;
	int x = 1000000007;
	FORD(i, N, 0)
	{
		if (arr[i].se >= x)
		{
			continue;
		}
		else
		{
			tmp.PB(arr[i]);
			x = arr[i].se;
		}
	}
	arr = tmp; reverse(ALL(arr));
	FOR(i, 0, SZ(arr) - 1)
	{
		//0...i for the first contest
		//i+1...N-1 for the second contest
		ckmax(ans, max(0, (arr[0].se - arr[i].fi + 1)) + max(0, arr[i + 1].se - arr[N - 1].fi + 1));
	}
	// cerr << SZ(arr) << endl;
	cout << ans << '\n';
	return 0;
	//first of all, if an interval contains another then it's useless.
	//then it's just some ranges.

}


Measured memory_bytes: 11640
#include <bits/stdc++.h>
using namespace std;
int n;
int minx=9999999;
 
int work(int x)
{
	int ans=0,a=10,b=1;
	int k=x,m=0;
	while(k){
		ans++;
		k/=10;
	}
	for(int j=1;j<=ans;j++){
	m+=x%a/b;	
	a*=10;
	b*=10;
	}
	return m;
}
 
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n-i;i++){
		minx=min(minx,work(i)+work(n-i));
	}
	printf("%d",minx);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int kaijo(int x)
{
    if (x==0) return 1;
    return x * kaijo(x-1);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;cin>>n;
    pair<double, double> points[n];
    rep(i,n)
    {
        double x,y;cin>>x>>y;
        points[i] = make_pair(x,y);
    }
    double sum_d = 0;
    rep(i,n-1)
    {
        REP(j,i+1,n)
        {
            sum_d += pow(pow((points[i].first-points[j].first), 2.0) + pow(points[i].second-points[j].second, 2.0), 0.5);
        }
    }
    cout << fixed << setprecision(10) << sum_d*2/n << endl;
    
    
}




Measured memory_bytes: 640
n,m = map(int,input().split())
edge = []
for _ in range(m):
  a,b,c = map(int,input().split())
  edge.append((a,b,-c))
dis = [float("inf")]*(n+1)
dis[1] = 0
f = 0
for i in range(n):
  for a,b,c in edge:
    if dis[b] > dis[a] + c:
      dis[b] = dis[a] + c
      if i == n-1:
        f = 1
ans = dis[n]
if f:
  for _ in range(n):
    for a,b,c in edge:
      if dis[b] > dis[a] + c:
        dis[b] = dis[a] + c
        if b == n:
          print("inf")
          exit(0)
print(-ans)

Measured memory_bytes: 3316
<?php
fscanf(STDIN,"%d",$n);
$sum = 0;
for($i=0;$i<$n;$i++){
	fscanf(STDIN,"%f%s",$x,$u);
  	//echo $x." ".$u."\n";
  if($u=='BTC'){
    $sum += ($x*380000);
  }else{
    $sum += $x;
	}		
}

echo $sum;

Measured memory_bytes: 16176
#include<iostream>
#include <vector>
#include <cmath>

using namespace std;

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

	string yoko;
	vector<vector<string>> strArray(N, vector<string>(M));

	for (int i = 0;i < N;i++)
	{
		cin >> yoko;
		for (int j = 0;j < M;j++)
		{

			if (yoko.find("#") != std::string::npos)
			{
				strArray.at(i).at(j) = yoko[j];
			}

		}
	}


	for (int j = 0;j < M;j++)
	{
		string sss;
		
		for (int i = 0;i < N;i++)
		{
			sss = sss + strArray.at(i).at(j);
		}

		if (sss.find("#") == std::string::npos)
		{
			for (int i = 0;i < N;i++)
			{
				strArray.at(i).at(j)="";
			}
		}
	}

	for (int i = 0;i < N;i++)
	{
		
		string out;

		for (int j = 0;j < M;j++)
		{

			out = out + strArray.at(i).at(j);

		}

		cout << out << endl;
	}
	

	
	return 0;


}


Measured memory_bytes: 3944
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
a.sort()

def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

check=a[0]
for i in range(1,n):
    check=gcd(check,a[i])

if k%check==0 and k<=a[-1]:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 14252
from sys import stdin

l,r = [int(x) for x in stdin.readline().rstrip().split()]
m = 2020
if r - l > 2018:
    print(0)
    exit()
for i in range(l,r):
    for j in range(i+1,r+1):
        if i*j%2019 == 0:
            print(0)
            exit()
        else:
            m = min(m,i*j%2019)
print(m)

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

int main(){
	queue<long long> que;
	long long A, B;
	cin >> A >> B;
	long long ans = 0;
	long long tmp = A;
	que.push(1);
	for(long long i=2;i*i<=A;i++){
		if(tmp % i == 0){
			que.push(i);
			while(tmp % i == 0)tmp /= i;
		}
	}
	if(tmp > 1)que.push(tmp);
	while(!que.empty()){
		long long j = que.front();
		que.pop();
		if(B % j == 0)ans++;
	}
	cout << ans << endl;
}

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

int main()
{
     ios::sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
     
     int a;
     cin>>a;
     
     cout<<a+ (a*a) + (a*a*a)<<endl;
    return 0;
}


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

int	main()
{
	int	N;
	int	i, count;
	char	*S;

	i = 0;
	count = 0;
	scanf("%d\n", &N);
	S = (char *)malloc(sizeof(char) * (N + 1));
	scanf("%s\n", S);
	while (i < N)
	{
		if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
		{
			count++;
			i += 2;
		}
		i++;
	}
	printf("%d\n", count);
	return (0);
}


Measured memory_bytes: 128
from itertools import accumulate

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

ans = 0
for l in range(min(n, k) + 1):
    for r in range(min(n, k) - l + 1):
        bag = sorted(v[:l] + v[n - r:])
        minus = sum(vi for vi in bag[:k - l - r] if vi < 0)
        ans = max(ans, sum(bag) - minus)
print(ans)


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

int main(){
   string s;
   cin >> s;
   int c0=0,c1=0;
   rep(i,s.size()){
       if(s[i]=='0') c0++;
       else if(s[i]=='1') c1++;
   }
   cout << 2*min(c0,c1);
}

Measured memory_bytes: 512
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk)
{
  var x = parseInt(chunk.trim(), 10);
  var h = Math.floor(x / 3600);
  var mod = x % 3600;
  var m  = Math.floor(mod / 60);
  s = mod % 60;
  console.log(h + ":" + m + ":" + s);
});

Measured memory_bytes: 7644
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define ld             long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int n, m, k;
ld p[N], a[N];

void solve()
{
	cin >> n >> k;
	for (int i = 1; i <= 10000; i++)
	{
		ld x = (i * (i + 1)) / 2, y = i;
		p[i] = x / y;
	}
	ld ans = 0;
	for (int i = 1; i <= n; i++)
	{
		int x; cin >> x;
		a[i] = p[x];
		a[i] += a[i - 1];
	}
	for (int i = k; i <= n; i++)
		ans = max(ans, a[i] - a[i - k]);

	cout << ans;

}

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


	cout << setprecision(9) << fixed;
	clock_t z = clock();
	solve();
	cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

	return 0;
}

Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int a,b,c;
	cin >> a >> b >> c;
  
  	int ans = a+b+c-max({a,b,c});
  	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main ()
{
    int k,ll=0;
    cin >>k;
    for (int m=1;m<=k;m+=2)
    {
        for (int n=2;n<=k;n+=2)
        {
            ll++;
        }
    }
    cout <<ll<<endl;
    return 0;
}


Measured memory_bytes: 256