akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long N, long long M)
{
  if (N % 2 == 1)
  {
    for (int i = 0; i < M; i++)
    {
      cout << i + 1 << " " << N - i << endl;
    }
  }

  else
  {
    LL border = N / 4;
    for (int i = 0; i < min(M, border); i++)
    {
      cout << i + 1 << " " << N - i << endl;
    }
    for (int i = border; i < M; i++)
    {
      cout << i + 2 << " " << N - i << endl;
    }
  }
}

int main()
{
  cout << setprecision(10);
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  solve(N, M);
  return 0;
}


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

using namespace std;

int sumDigits (int n) {
    int s;
    while (n < 0) {
        s += n % 10;
        n /= 10;
    }
    return s;
}

int main() {
   int N; cin >> N;
   int res = 0;
   vector<int> v(N);
   vector<int> C(N);
   vector<int> dif(N, 0);

   for (int i = 0; i < N; i++) {
       cin >> v.at(i);
   }

   for (int i = 0; i < N; i++) {
       cin >> C.at(i);
   }

   for (int i = 0; i < N; i++) {
       dif.at(i) = v.at(i) - C.at(i);
   }
   
   for (int d : dif) {
       if (d > 0) {
           res += d;
       }
   }
   cout << res << endl;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        int count = 1;
        int b = int.Parse(str[0]);
        bool be = true;
        bool d = true;
        for(int i=1;i<N;i++){
            int n = int.Parse(str[i]);
            if(be){
                if(b > n){
                    d = true;
                    be = false;
                }
                else if(b < n){
                    d = false;
                    be = false;
                }
            }
            else{
                if(d){
                    if(b < n){
                        count++;
                        be = true;
                    }
                }
                else{
                    if(b > n){
                        count++;
                        be = true;
                    }
                }
            }
            b = n;
        }
        sb.Append(count+"\n");
    }
}

Measured memory_bytes: 18016
N = int(input())
ans = [0] * (N + 1)
for x in range(1, 10 ** 2 + 1):
    for y in range(1, 10 ** 2 + 1):
        for z in range(1, 10 ** 2 + 1):
            n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if N < n:
                continue
            ans[n] += 1
print(*ans[1:], sep='\n')


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

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

  vector<pair<ll, ll>> a(n);
  for (ll i = 0; i < n; ++i) {
    a[i].second = i;
    cin >> a[i].first;
  }
  sort(a.begin(), a.end());
  for (ll i = 0; i < n; ++i) {
    cout << a[i].second + 1 << " ";
  }

  return 0;
}




Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,s=1;
    cin>>a>>b;
    for(int i=a;i<=b;i++)
    {  
      if(i<0)
	  s*=-1;
      if(i==0)
	  {
	  cout<<"Zero"<<endl;
	  return 0;
	  } 
    }
    if(s>0)cout<<"Positive"<<endl;
    if(s<0)cout<<"Negative"<<endl;
    if(s==0)cout<<"Zero"<<endl;
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <vector>
# include <string>
using namespace std;
struct info
{
	int p = -1;
	vector<int> child;
}*a;
int main(void)
{
	char s[3][20] = {"internal node","root","leaf"};
	int n,index,cnt,k;
	scanf("%d",&n); a = new info [n];
	for(int i = 0;i < n;i++)
	{
		scanf("%d %d",&index,&cnt);
		for(int j = 0;j < cnt;j++)
		{
			scanf("%d",&k);
			a[k].p = index;
			a[index].child.push_back(k);
		}
	}
	for(int i = 0;i < n;i++)
	{
		int d = 0,m = i,w = 0;
		while(a[m].p != -1)
		{
			m = a[m].p;
			d++;
		}
		if(a[i].p == -1) w = 1;
		else if(a[i].child.size() == 0) w = 2;
		printf("node %d: parent = %d, depth = %d, %s, [",i,a[i].p,d,s[w]);
		for(int j = 0;j < a[i].child.size();j++) printf("%d%s",a[i].child[j],(j == a[i].child.size()-1)?"":", ");
		printf("]\n");
	}
	return 0;
} 


Measured memory_bytes: 7044
#include <bits/stdc++.h>
using namespace std;
int n, a[10000], dp[2010][2010], margin = 1e8, allmax = 1e8, rowmax[2010];
void chmax(int &a, int b) { a = max(a, b); }
main() {
    cin >> n;
    for(int i = 0; i < 3 * n; ++i) cin >> a[i];
    dp[a[0]][a[1]] = rowmax[a[0]] = rowmax[a[1]] = margin;
    vector<tuple<int, int, int>> update;
    auto upd = [&](int i, int j, int k) {
        for(int _ = 0; _ < 2; _++) {
            update.emplace_back(i, j, k);
            swap(i, j);
        }
    };
    for(int i = 2; i < 3 * n; i += 3) {
        if(a[i] == a[i + 1] and a[i] == a[i + 2]) {
            margin--;
            continue;
        }
        for(int _ = 0; _ < 3; _++) {
            swap(a[i], a[i + 1]), swap(a[i + 1], a[i + 2]);
            upd(a[i], a[i + 1], max(allmax, dp[a[i + 2]][a[i + 2]] + 1));
            for(int j = 1; j <= n; ++j) {
                if(a[i + 1] == a[i + 2]) upd(j, a[i], dp[j][a[i + 1]] + 1);
                upd(j, a[i], rowmax[j]);
            }
        }
        for(auto [e, f, g] : update) chmax(dp[e][f], g), chmax(rowmax[e], g), chmax(allmax, g);
        update.clear();
    }
    cout << allmax - margin << endl;
}

Measured memory_bytes: 19476
N = int(input())
H = [int(x) for x in input().split()]
for _ in range(100):
    H.append(0)

dp = [float('inf')] * (10**5 + 5)
dp[0] = 0

for i in range(N):
    dp[i+1] = min(dp[i+1], dp[i] + abs(H[i] - H[i+1]))
    dp[i+2] = min(dp[i+2], dp[i] + abs(H[i] - H[i+2]))

print(dp[N-1])




Measured memory_bytes: 13928
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define FL "a"
using namespace std;
typedef long long ll;
typedef long double dd;
const int N=2e5+10;
const int inf=2147483647;
const dd pi=acos(-1);
const ll INF=1ll<<60;
const int mod=998244353;
inline ll read(){
  ll data=0,w=1;char ch=getchar();
  while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
  if(ch=='-')w=-1,ch=getchar();
  while(ch<='9'&&ch>='0')data=data*10+ch-48,ch=getchar();
  return data*w;
}
inline void file(){
  freopen(FL".in","r",stdin);
  freopen(FL".out","w",stdout);
}

int main()
{
  int k=read(),a=read(),b=read();ll ans=0;
  if(b<=a+2||k<=a-1)printf("%d\n",k+1);
  else{
    k-=a-1;ans=a;if(k&1)k--,ans++;
    printf("%lld\n",ans+1ll*(k/2)*(b-a));
  }
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int64_t> L(87);
    L.at(0) = 2;
    L.at(1) = 1;
    for (int i = 2;i <= n;i++){
        L.at(i) = L.at(i-1) + L.at(i-2);
    }
    cout << L.at(n) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    string s,t; cin>>s>>t;
    ll a,b; cin>>a>>b;
    string u; cin>>u;
    if(s==u)cout<<a-1<<' '<<b<<endl;
    else cout<<a<<' '<<b-1<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <iomanip>
using namespace std;
const int inf = 1e9;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

void bfs_grid(queue<pair<int,int>> &wait, vector<string> &g, vector<vector<int>> &res){
    while(!wait.empty()){
        int y = wait.front().first;
        int x = wait.front().second;
        wait.pop();
        for(int d=0; d<4; d++){
            int ny = y +dy[d];
            int nx = x +dx[d];
            if(g[ny][nx] == '#' or g[ny][nx] == '*') continue;
            if(res[ny][nx] != inf) continue;
            res[ny][nx] = res[y][x] +1;
            wait.push({ny, nx});
        }
    }
}

int main(){
    int w,h;
    cin >> w >> h;
    vector<string> g(h);
    for(int i=0; i<h; i++){
        cin >> g[i];
    }

    int sy,sx,gy,gx;
    queue<pair<int, int>> wait;
    int n = 0;
    vector<vector<int>> mincost_spring(h, vector<int>(w, inf));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(g[i][j] == 's'){
                sy = i;
                sx = j;
                g[i][j] = '.';
            }
            if(g[i][j] == 'g'){
                gy = i;
                gx = j;
            }
            if(g[i][j] == '*'){
                wait.push({i, j});
                mincost_spring[i][j] = 0;
            }
            if(g[i][j] == '.'){
                n++;
            }
        }
    }
    bfs_grid(wait, g, mincost_spring);
    vector<vector<int>> mincost_goal(h, vector<int>(w, inf));
    mincost_goal[gy][gx] = 0;
    wait.push({gy, gx});
    bfs_grid(wait, g, mincost_goal);

    long double lb=0, ub=1LL<<60;
    for(int rep=0; rep<100; rep++){
        long double mid = (lb +ub) /2;
        long double sum = 0;
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                if(g[i][j] != '.') continue;
                long double tmp = 1e18;
                if(mincost_goal[i][j] != inf){
                    tmp = min(tmp, (long double)mincost_goal[i][j]);
                }
                if(mincost_spring[i][j] != inf){
                    tmp = min(tmp, mincost_spring[i][j] +mid);
                }
                sum += tmp;
            }
        }
        if(n*mid > sum){
            ub = mid;
        }else{
            lb = mid;
        }
    }
    
    long double ans = 1e18;
    if(mincost_goal[sy][sx] != inf){
        ans = min(ans, (long double)mincost_goal[sy][sx]);
    }
    if(mincost_spring[sy][sx] != inf){
        ans = min(ans, mincost_spring[sy][sx] +lb);
    }
    cout << fixed << setprecision(12);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5236
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

typedef long long ll;

using namespace std;

int main(){

    ll ans=0;
    ll n;
    cin>>n;
    vector<ll> p(n,0),q(n,0),m(n,0);
    for(ll i=0;i<n;i++){
        cin>>p[i];
    }
    for(ll i=0;i<n;i++){
        cin>>q[i];
        m[i]=i+1;
    }

    ll a=0,b=0;
    ll num=0;
    bool pb=true, qb=true;

    do{
        pb=true;
        qb=true;
        num++;
        ll j=0;
		for(auto i:m){
			if(p[j]!=i){
                pb=false;
            }
            if(q[j]!=i){
                qb=false;
            }
            j++;
		}
		if(pb){
            a=num;
            pb=false;
        }
        if(qb){
            b=num;
            qb=false;
        }
        if(pb && qb){
            break;
        }
	}while(next_permutation(m.begin(),m.end()));
    

    cout<<abs(a-b)<<endl;


    return 0;
}


Measured memory_bytes: 256
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
vi vec;
//std::ios::sync_with_stdio(false); 
ll sumo[12],a[12345];  
ll prllmin(ll n){
	ll i;
	ll maxi=inf;
	maxi*=-1;
	ll pos=0;
	rep(i,n){
		if(a[i]>maxi){
			maxi=a[i];
			pos=i;
		}
	}
	ll val=n-1;
	fd(i,val,pos+1){
		n--;
		vec.pb(i);
	}
	while(n>1){
		vec.pb(0);
		n--;
	}
	cout<<maxi<<endl;
	cout<<vec.size()<<endl;
	rep(i,vec.size()){
		cout<<vec[i]+1<<endl;
	}
	exit(0);
}
int main(){
    std::ios::sync_with_stdio(false);
    ll n,i;
    cin>>n;
    rep(i,n){
    	cin>>a[i];
    	
    }
    ll flag=0;
    rep(i,n){
    	if(a[i]>=0)
    		flag=1;
    }
    if(!flag){
    	prllmin(n);
    }
    rep(i,n){
    	if(a[i]>=0)
    		sumo[i%2]+=a[i];
    }
    if(sumo[1]>sumo[0]){
    	cout<<sumo[1]<<endl;
    	//ops++;
    	vec.pb(0);
    	n--;
    	rep(i,n){
    		a[i]=a[i+1];
    	}
    }
    else{
    	cout<<sumo[0]<<endl;
    }
    while(n>1){
    	if(n==2){
    		vec.pb(1);
    		n--;
    		continue;
    	}
    	if(a[0]<0){
    		vec.pb(0);
    		vec.pb(0);
    		n-=2;
    		rep(i,n){
    			a[i]=a[i+2];
    		}
    		continue;
    	}
    	if(a[2]>=0){
    		a[0]+=a[2];
    		vec.pb(1);
    		n-=2;
    		f(i,1,n){
    			a[i]=a[i+2];
    		}
    		continue;
    	}
    	else{
    		if(n>3){
    			vec.pb(2);
    			n-=2;
    			f(i,1,n){
    				a[i]=a[i+2];
    			}
    		}
    		else{
    			vec.pb(2);
    			n--;

    		}
    	}
    }
    cout<<vec.size()<<endl;
    rep(i,vec.size()){
    	cout<<vec[i]+1<<endl;
    }

    return 0;  
    
}



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

typedef long long tint;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend() 
#define NACHO ios::sync_with_stdio(0); cin.tie(NULL);
#define dbg cout << "hu" << endl;
 
const int INF = 11000000;
const int MOD = 1000000007;

int main(){
	string s; cin >> s;
	int n = s.size();
	forn(i, n){
		cout << 'x';
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//


ll Po(ll r,ll s, ll p, ll me, char ene){
  if(me==0&&ene=='s')return r;
  if(me==1&&ene=='p')return s;
  if(me==2&&ene=='r')return p;
  return 0;
}

void solve(long long N, long long K, long long R, long long S, long long P, std::string T){
  vector<vector<char>> mo(1,vector<char>(0));
  rep(i,N){
    if(i%K>mo.size()-1){
      vector<char> tmp(1,T[i]);
      mo.push_back(tmp);
    }else{
      mo[i%K].push_back(T[i]);
    }
  }
  
  ll ans=0;
  rep(I,mo.size()){
    mat(dp,mo[I].size(),3);
    rep(i,3){
      dp[0][i]=Po(R,S,P,i,mo[I][0]);
      //cout<<dp[0][i]<<" ";
    }
    //cout<<endl;
    repf(i,1,mo[I].size()){
      rep(j,3){
        dp[i][j]=Po(R,S,P,j,mo[I][i])+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
        //cout<<dp[i][j]<<" ";
      }
      //cout<<endl;
    }
    ll Max=0;
    rep(i,3){
      Max=max(Max,dp[mo[I].size()-1][i]);
    }
    //cout<<Max<<endl;
    ans+=Max;
  }
  op(ans);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    //dp.resize(N);
    long long K;
    scanf("%lld",&K);
    long long R;
    scanf("%lld",&R);
    long long S;
    scanf("%lld",&S);
    long long P;
    scanf("%lld",&P);
    std::string T;
    std::cin >> T;
    solve(N, K, R, S, P, T);
    return 0;
}


Measured memory_bytes: 6964
n,m = map(int,input().split())
h = list(map(int,input().split()))
x =[[]for _ in range(n)]
for _ in range(m):
  ai,bi = map(int,input().split())
  x[ai-1].append(bi-1)
  x[bi-1].append(ai-1)
ans = [1]*n
for i in range(n):
  if ans[i] != 0:
    flag = False
    for xx in x[i]:
      if h[i] <= h[xx]:
        flag = True
      else:
        ans[xx] = 0
    if flag:
      ans[i] = 0
print(sum(ans))
      
        
    
  



Measured memory_bytes: 93496
#include <bits/stdc++.h>
typedef long long int ll;
#define vaibhavv06               \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define endl '\n'
#define int long long
#define MM(a,b) memset(a,b,sizeof(a))
const ll MOD = 1000000007;
using namespace std;
 
int32_t main(){
    vaibhavv06;
	int n; cin>>n;
    int arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    int dp[n]={0};
    dp[1]=abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include<iostream>
#include<cmath>

long long int min_op(const int current, const int prev_height_pos, const int k, const std::vector<int>& heights, std::vector<std::vector<std::vector<long long int>>> &memo) {
	if (current == heights.size()) return 0;
	if (memo[current][prev_height_pos][k] >= 0) return memo[current][prev_height_pos][k];
	if (heights[current] >= heights[prev_height_pos]) {
		long long int min = min_op(current + 1, current, k, heights, memo) + heights[current] - heights[prev_height_pos];
		if (k > 0) {
			min = std::min(min, min_op(current + 1, prev_height_pos, k - 1, heights, memo));
		}
		return memo[current][prev_height_pos][k] = min;
	}
	else {
		long long int min = min_op(current + 1, current, k, heights, memo);
		if (k > 0) {
			min = std::min(min, min_op(current + 1, prev_height_pos, k - 1, heights, memo));
		}
		return memo[current][prev_height_pos][k] = min;
	}
}
int main() {
	int n, k; std::cin >> n >> k;
	std::vector<int> column(n + 1, 0); for (auto i = 1; i <= n; ++i) std::cin >> column[i];
	std::vector<std::vector<std::vector<long long int>>> memo(n + 1, std::vector<std::vector<long long int>>(n, std::vector<long long int>(k + 1, -1)));
	std::cout << min_op(1, 0, k, column, memo) << '\n';
}

Measured memory_bytes: 216192
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

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

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

bool comp(const string& f, const string& s){
    return f.size() < s.size();
}
int main(void){
    ll x;
    cin >> x;

    ll i = 0;
    ll now = 0;
    ll ans = 0;
    while(1){
        now += i;
        if(now >= x){
            ans = i;
            break;
        }
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            string szLine = Console.ReadLine();
            string[] szArr = szLine.Split(' ');
            int nTotal = szArr.Length;
            long[] arr = new long[nTotal];

            long sum = 0;
            long max = -1;
            for (int i = 0; i < szArr.Length; ++i)
            {
                long tmp = long.Parse(szArr[i]);
                sum += tmp;
                if( tmp > max)
                {
                    max = tmp;
                }
            }
            
            if ((max * 3) % 2 == sum % 2)
            {
                Console.WriteLine((max * 3 - sum) / 2);

            }
            else
            {
                Console.WriteLine(((max + 1) * 3 - sum) / 2);

            }

        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
int main(void){
	
	int a,b,d,r;
	double f;
	scanf ("%d %d",&a,&b);
	d = a / b;
	r = a % b;
	f = (double)a / b;
	printf ("%d %d %f",d,r,f);
	return 0;
}

Measured memory_bytes: 636
N,K=map(int,input().split())
S=input()
#LとRが入れ替わる回数-2Kが、終わった後の入れ替わる数
#Total-入れ替わる数-1がこたえ

trans=0
for i in range(N-1):
  if S[i]!=S[i+1]:
    trans += 1
trans_new = max(trans - 2*K,0)
print(N-trans_new-1)
               

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
namespace
{
	ll ModPow(ll a, ll p, ll mod)
	{
		if (p == 0)
			return 1;
		if (p % 2 == 0)
		{
			ll halfp = p / 2;
			ll half = ModPow(a, halfp, mod);
			return (half * half) % mod;
		}
		else
		{
			return (a * ModPow(a, p - 1, mod)) % mod;
		}
	}


ll Combination(int n, int r, ll mod)
{
	r = min(r, n - r);
	ll num = 1;
	ll den = 1;
	for (int i = 0; i < r; ++i)
	{
		num *= (n - i);
		num %= mod;
		den *= (i + 1);
		den %= mod;
	}
	ll ret = (num * ModPow(den, mod - 2, mod)) % mod;
	return ret;
}
}

void ABC151E()
{
	ll MOD = 1000000007;
	int N, K;
	cin >> N >> K;
	if (K == 1)
	{
		cout << 0 << endl;
		return;
	}

	vl A(N);
	for (auto& x : A)
		cin >> x;
	sort(A.begin(), A.end());
	vl B(N + 1);
	B[0] = 0;
	for (int i = 0; i < N; ++i)
	{
		B[i + 1] = B[i] + A[i];
		B[i + 1] %= MOD;
	}
	ll ans = 0;
	ll mult = 1;
	for (int i = 0; i < N - K + 1; ++i)
	{
		ll f = B[N] - B[K + i-1] - B[N - K - i + 1] + B[0];
		while (f < 0)
		{
			f += MOD;
		}
		f %= MOD;
	//	ll mult = Combination(K + i - 2, i, MOD);
		f *= mult;
		f %= MOD;
		ans += f;
		ans %= MOD;

		mult *= K + i - 1;
		mult %= MOD;
		mult *= ModPow(i + 1, MOD-2, MOD);
		mult %= MOD;
	}
	cout << ans << endl;
}
int main()
{
	ABC151E();
	return 0;
}

Measured memory_bytes: 1792
console.log((args=>{
  const [[N],a] = args.trim().split('\n').map(r=>r.split(' ').map(v=>v|0));
  const c = new Map();
  let count = 0;
  for ( let i = 0; i < N; i++ ) {
    if ( a[i] > N ) count++;
    else c.set(a[i], 1+(c.get(a[i])|0) );
  }
  for ( const [i,v] of c ) {
    if ( i < v ) count += v-i;
    else if ( v < i ) count += v;
  }
  return `${count}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 39876
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;


int main() {


    int N, K;
    cin >> N >> K;

    string S;
    cin >> S;

    cout << S.substr(0, K - 1);

    cout << (char) tolower(S[K - 1]);

    cout << S.substr(K);
    cout << "\n";


    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
long long N, A, B, C, D, E, ans, m;
int main(){
  cin >> N >> A >> B >> C >> D >> E;
  m = min(A, B);
  m = min(m, C);
  m = min(m, D);
  m = min(m, E);
  if ( N%m >0) ans = N/m +1;
  else ans = N/m;
  ans = ans +4;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

h,w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
b = [list(map(int, input().split())) for i in range(h)]
ma = 80*2*80
DP = [[[0]*ma for i in range(w)] for i in range(h)]

for i in range(h):
    for j in range(w):
        k = abs(a[i][j]-b[i][j])
        if i==0 and j==0:
            DP[i][j][k] = 1
            continue
        elif i == 0:
            up = min((i+j+1)*80+1, ma-k)
            for l in range(up):
                DP[i][j][l] = DP[i][j-1][abs(l-k)] | DP[i][j-1][l+k]
        elif j == 0:
            for l in range(up):
                DP[i][j][l] = DP[i-1][j][abs(l-k)] | DP[i-1][j][l+k]
        else:
            for l in range(up):
                DP[i][j][l] = DP[i][j-1][abs(l-k)] | DP[i][j-1][l+k] | DP[i-1][j][abs(l-k)] | DP[i-1][j][l+k]
for i in range(ma):
    if DP[-1][-1][i]:
        print(i)
        exit()


Measured memory_bytes: 676872
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<pair<int,int>> p_red_y(N);
  for (int i = 0; i < N; i++) {
    int x,y;
    cin >> x >> y;
    p_red_y[i] = make_pair(y, x);
  }
  vector<pair<int,int>> p_blue(N);
  for (int i = 0; i < N; i++) {
    int x,y;
    cin >> x >> y;
    p_blue[i] = make_pair(x, y);
  }
  sort(p_red_y.begin(),p_red_y.end());
  reverse(p_red_y.begin(),p_red_y.end());
  sort(p_blue.begin(),p_blue.end());
  int ans = 0;
  for(int i = 0;i < N;i++){
      for(int j = 0;j < N;j++){
        if(p_red_y[j].first < p_blue[i].second){
          if(p_red_y[j].second < p_blue[i].first){
            //p_red_y.erase(p_red_y.begin()+j);
            p_red_y[j].first = 2 * N + 10;
            ans++;
            break;
          }
        }
      }
      //cout << i << " : " << ans << endl;
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007

int main() {
    vector<int>ab(4);
    rep(i,6){
        int a;cin>>a;
        ab[a-1]++;
    }

    bool jdg=true;
    rep(i,4){
        if(ab[i]==0||ab[i]==3){
            cout<<"NO"<<endl;
            jdg=false;
            break;
        }
    }
    if(jdg){
        cout<<"YES"<<endl;
    }

}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	long n, a, b;
	scanf("%ld%ld%ld",&n,&a,&b);
	long sum = 0;
	long mod;
	long div;
	if (a == 0)
	{
		printf("0");
		return 0;
	}
	if (n >= a + b)
	{
		mod = n % (a + b);
		div = n / (a + b);
		if (a >= mod)
			sum = a * div + mod;
		else if (mod > a)
		{
			sum = div * a;
			sum += a;
		}
		printf("%ld", sum);
		return 0;
	}
	else if (n < a + b)
	{
		if (n > a)
			sum = a;
		else
			sum = n;
	}
	printf("%ld", sum);
	return (0);
}

Measured memory_bytes: 128
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#define INF 100000000000000
using namespace std;

int main() {
    long long n;
    cin >> n;
    vector<long long> A(n);
    for(int i=0; i<A.size(); i++){
        cin >> A.at(i);
    }
    for(int i=A.size()-1; i>=1; i--){
        cout << A.at(i) << " ";
    }
    cout << A.at(0) << endl;
}


Measured memory_bytes: 3128
import std.stdio;
import std.conv;
import std.string;
import core.bitop;

void main() {
  auto maxCoin500 = readln.chomp.to!uint;
  auto maxCoin100 = readln.chomp.to!uint;
  auto maxCoin50 = readln.chomp.to!uint;
  auto total = readln.chomp.to!uint;
  auto count = 0U;

  foreach (c5h;0..maxCoin500 + 1) {
    if (c5h * 500 > total) break;
    foreach (c1h;0..maxCoin100 + 1) {
      if (c5h * 500 + c1h * 100 > total) break;

      auto requireCoin50 = (total - c5h * 500 - c1h * 100) / 50;

      if (requireCoin50 <= maxCoin50) {
        ++count;
      }
    }
  }
  writeln(count);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if ( C > A && C > B ) cout << "No" << endl;
  else if ( A > C && B > C ) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc110/tasks/abc110_c

def main():
    s = input()
    t = input()

    d = {}
    for i in range(len(s)):
        if t[i] in d and d[t[i]] != s[i]:
            print('No')
            return
        elif t[i] not in d:
            d[t[i]] = s[i]
    d = {}
    for i in range(len(s)):
        if s[i] in d and d[s[i]] != t[i]:
            print('No')
            return
        elif s[i] not in d:
            d[s[i]] = t[i]
    print('Yes')


if __name__ == "__main__":
    main()

Measured memory_bytes: 41712
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
const int TIME_MAX = 100100;

int main() {
    int N, C;
    scanf("%d%d", &N, &C);
    vector<vector<int>> time(TIME_MAX, vector<int> (C, 0));
    for (int i = 0; i < N; i++) {
        int s, t, c;
        scanf("%d%d%d", &s, &t, &c);
        time[s][c-1]++; time[t][c-1]--;
    }
    
    vector<pair<int, int>> tv;
    for (int c = 0; c < C; c++) {
        int s;
        for (int i = 0; i < TIME_MAX; i++) if (time[i][c] != 0) {
            if (time[i][c] == 1) s = i;
            if (time[i][c] == -1) { tv.emplace_back(s, i); }
        }
    }
    sort(tv.begin(), tv.end());
    
    auto f = [&](int K) {
        vector<int> T(K, -1);
        for (auto tmp : tv) {
            int s, t; tie(s, t) = tmp;
            bool ok = true;
            for (int i = 0; i < K; i++) {
                if (T[i] < s) { T[i] = t; break; }
                if (i + 1 == K) ok = false;
            }
            if (!ok) return false;
        }
        return true;
    };
    
    int ok = C, ng = 0;
    while (abs(ok-ng) > 1) {
        int mid = (ok+ng)/2;
        if (f(mid)) ok = mid;
        else ng = mid;
    }
    
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 19448
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> v(n+1);
    rep(i,m){
        ll a, b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }    
    bool can = false;
    vector<ll> c1(n+1), c2(n+1);
    for(auto i:v[1]) c1[i] = 1;
    for(auto i:v[n]) c2[i] = 1;
    REP(i,1,n+1) if(c1[i]+c2[i] == 2) can = true;
    cout << (can ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}


Measured memory_bytes: 18940
import sys
def input(): return sys.stdin.readline().strip()
from itertools import combinations
from math import sqrt

def main():
    n=int(input())
    xy=[]
    for _ in range(n):
        x,y=map(int,input().split())
        xy.append((x,y))
    s=0
    c=0
    for a,b in combinations(xy, 2):
        s+=sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2)
        c+=1
    s*=(n-1)
    s/=c
    print(s)

main()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
using namespace std;

const double PI=3.14159265358979323846;

double rad(int d){
    return (double)d/360*2*PI;
}

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    double h = sin(rad(c)) * b;
    if(fabs(h - 0) < DBL_EPSILON) h = b;

    double s = sqrt(a*a + b*b - 2*a*b*cos(rad(c)));

    printf("%.4f\n%.4f\n%.4f\n", (double)a*h/2, s+a+b, h);
    return 0;
}


Measured memory_bytes: 3480
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 1e5 + 120;
 

int n ,res;
string s;
int main(){FAST;
    cin >> n >> s;
        forp(i ,1 ,n){
            int cnt=0;

            for(char ch = 'a'; ch <= 'z'; ch++){
                    bool left, right;
                    left = right = false;

                			for(int j=0;j<i;j++)
				if(s[j]==ch)
					left=true;
			
			for(int j=i;j<n;j++)
				if(s[j]==ch)
					right=true;

                    right && left ? cnt++ : cnt = cnt;
            }

            res = max(res ,cnt);
        }
        out(res);
    return 0;

}
 










Measured memory_bytes: 256
a=list(map(int,input().split()))
count5=0
count7=0

for i in range(0,3):
  if a[i]==5:
    count5 += 1
  elif a[i]==7:
    count7 += 1
  else:
    i += 1

if count5 == 2 and count7 == 1:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        long z = n+y;
        System.out.println((n+y)%2==0?(n+y)/2:"IMPOSSIBLE");
        
}
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int64_t get_int(void) {
  int64_t num;
  scanf("%lld", &num);
  return num;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int64_t *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%lld", &arr[i]);
    }
    return 0;
}

#define ROADS 5
#define NUM_MAX (int64_t)(1e+15)

int main(void) {
    int64_t num = get_int();
    static int64_t arr[ROADS];
    fget_array(arr, ROADS);

    int i;
    int64_t ans = 0;
    for(i = 0; i < 5; i++) {
        int64_t res = (num-1)/arr[i] + ROADS;
        ans = max(res, ans);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
#line 1 "test/radix_heap.aoj.test.cpp"
#define PROBLEM                                                                \
  "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A&lang=ja"

#line 1 "data_structure/radix_heap.cpp"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <utility>
#include <vector>

template <class T> class radix_heap {
  using size_t = std::size_t;
  using u64 = std::uint_fast64_t;
  using V = std::pair<u64, T>;

public:
  using key_type = u64;
  using mapped_type = T;
  using value_type = V;

private:
  static size_t log2p1(const u64 x) {
    if (x == 0)
      return 0;
    else
      return 64 - __builtin_clzll(x);
  }

  std::vector<std::vector<V>> u;
  u64 last;

public:
  radix_heap() : u(), last(0) {}

  void push(const V x) {
    assert(last <= x.first);

    const size_t i = log2p1(x.first ^ last);
    if (u.size() <= i)
      u.resize(i + 1);
    u[i].push_back(x);
  }
  V pop() {
    if (u[0].empty()) {
      size_t i = 1;
      while (u[i].empty())
        i += 1;
      last = std::numeric_limits<u64>::max();
      for (const V &e : u[i])
        last = std::min(last, e.first);
      for (const V &e : u[i])
        u[log2p1(e.first ^ last)].push_back(e);
      u[i].clear();
    }
    V ret = u[0].back();
    u[0].pop_back();
    return ret;
  }
};
#line 5 "test/radix_heap.aoj.test.cpp"

#include <iostream>
#include <limits>
#include <utility>
#include <vector>
#include <tuple>

int main() {
  int n, m, r;
  std::cin >> n >> m >> r;
  std::vector<std::vector<std::pair<int, int>>> g(n);
  for (int i = 0; i != m; i += 1) {
    int s, t, d;
    std::cin >> s >> t >> d;
    g[s].emplace_back(d, t);
  }
  constexpr int Inf = std::numeric_limits<int>::max();
  std::vector<int> dist(n, Inf);
  dist[r] = 0;
  radix_heap<int> heap;
  int size = 0;
  heap.push({0, r});
  size += 1;
  while (size != 0) {
    int c, v;
    std::tie(c, v) = heap.pop();
    size -= 1;
    if (dist[v] < c)
      continue;
    int d, u;
    for (const auto &e : g[v]) {
      std::tie(d, u) = e;
      if (c + d < dist[u]) {
        dist[u] = c + d;
        heap.push({dist[u], u});
        size += 1;
      }
    }
  }
  for (int i = 0; i != n; i += 1) {
    if (dist[i] < Inf)
      std::cout << dist[i];
    else
      std::cout << "INF";
    std::cout << std::endl;
  }
}



Measured memory_bytes: 14764
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;

int main(){
  int n;
  bool ans = true;
  cin >> n;
  vector<string> word(n);

  for(int i = 0; i < n; ++i){
    cin >> word.at(i);
  }

  char before = word.at(0).at(0);

  for(int i = 0; i < n; i++){
    if(before != word.at(i).at(0)){
      ans = false;
      break;
    }
    before = word.at(i).at(word.at(i).length() - 1);
    for(int j = i + 1; j < n; j++){
      if(word.at(i) == word.at(j)){
        ans = false;
        break;
      }
    }
  }

  if(ans){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
from math import gcd
from functools import reduce

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

mod=10**9+7

ar=list(range(1,k+1))
ar.reverse()

ans=[0]*(k+1)
for i in ar:
	ava=(k-i)//i+1
	ans[i]=pow(ava,n,mod)
	for j in range(i*2,k+1,i):
		ans[i]-=ans[j]
sum=0
for i,z in enumerate(ans):
	sum+=i*z
print(sum%mod)
	


Measured memory_bytes: 15612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll M=1e9+7;
	int n,m;cin>> n >>m;
	char v[n][m];
	for(int i=0;i<n;i++){
	for(int j=0;j<m;j++)
	cin >> v[i][j];
	}
	ll dp[n][m];
	dp[0][0]=1;
	for(int i=1;i<m;i++){
	if(v[0][i]=='#')dp[0][i]=0;
	else
	dp[0][i]=dp[0][i-1];
	}
	for(int i=1;i<n;i++){
	if(v[i][0]=='#')dp[i][0]=0;
	else
	dp[i][0]=dp[i-1][0];
	}
	for(int i=1;i<n;i++){
	for(int j=1;j<m;j++){
	if(v[i][j]=='#')dp[i][j]=0;
	else dp[i][j]=(dp[i-1][j]%M+dp[i][j-1]%M)%M;
	}
	}
	cout << dp[n-1][m-1];
	
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


vector<bool> prime_table(int n) {
    vector<bool> prime(n + 1, true);
    if(n >= 0) prime[0] = false;
    if(n >= 1) prime[1] = false;
    for(int i = 2; i * i <= n; i++) {
        if(!prime[i]) continue;
        for(int j = i + i; j <= n; j += i) {
        prime[j] = false;
        }
    }
    return prime;
}


int main(){
    int n;
    cin >> n;
    const int lim = 5000000;
    auto p = prime_table(lim);
    rep(i, lim){
        if(p[i] && i>=n){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
 
#include <fstream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main(void)
{
 
    long long x;
    long long data[3000];
    
    cin >> x;
    
    for(int i = 0; i < 300; i++)
    {
        data[i] = pow(i, 5);
    }
    
    for(int a = 0; a < 300; a++)
    {
        for(int b = 0; b < 300; b++)
        {
            if(data[a] - data[b] == x)
            {
                cout << a << " " << b;
                return 0;
            }
            if(data[a] + data[b] == x)
            {
                cout << a << " " << -b;
                return 0;
            }
            if(-data[a] - data[b] == x)
            {
                cout << -a << " " << b;
                return 0;
            }
            if(-data[a] + data[b] == x)
            {
                cout << -a << " " << -b;
                return 0;
            }
        }
    }
    
  
}

Measured memory_bytes: 4060
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x, y = map(int, readline().split())

    if abs(x - y) > 1:
        print("Alice")
    else:
        print("Brown")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61824
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
const ll maxn = 1e5 + 5;
ll a[maxn];
ll s[maxn * 10],c[maxn * 10];
ll n;
ll lowbit(ll x)
{
	return x & (-x);
}
ll query(ll x)
{
	ll sum = 0;
	for(;x;sum += c[x],x -= lowbit(x));
	return sum;
}
void update(ll x)
{
	for(;x <= maxn * 2;c[x]++,x += lowbit(x));
}
bool check(ll x)
{
	memset(c,0x00,sizeof(c));
	s[0] = 0;
	for(ll i = 1;i <= n; ++i)
	{
		s[i] = s[i - 1] + (a[i] >= x ? 1 : -1);
	}
	ll sum = 0;
	for(ll i = 0;i <= n; ++i)
	{
		sum += query(s[i] + maxn);
		update(s[i] + maxn);
	}
	return sum >= n * (n + 1) / 4;
}
int main()
{
	scanf("%lld",&n);
	ll left = 0,right = 0;
	for(ll i = 1;i <= n; ++i)
	{
		scanf("%lld",&a[i]);
		right = max(right,a[i]);
	}
	while(left <= right)
	{
		ll mid = left + right >> 1;
		if(check(mid))
		{
			left = mid + 1;
		}
		else
		{
			right = mid - 1;
		}
	}
	cout<<right<<endl;
	return 0;
}

Measured memory_bytes: 12544
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(void){
	long int x,sum;
	while(scanf("%d",&x)!=EOF){
		sum=1;
		for(1;x>0;x--)sum+=x;
		printf("%ld\n",sum);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int n;
    cin >> n;
    vi as(n);
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }
    sort(as.begin(), as.end());
    i64 ans = 0;
    for (int i = 0; i < n - 1; i++) {
        ans += as[i];
    }
    ans += as.back() / 2;
    cout << ans;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
  int n;cin >>n;
  vector<vector<int>>cnt(n,vector<int>(26,0));
    for (int i = 0; i < n; ++i) {
        string s;cin >>s;
        int m=s.size();
        for (int j = 0; j < m; ++j) {
            cnt[i][s[j]-'a']++;
        }
    }
    vector<int>ans(26,INF);
    for (int i = 0; i < 26; ++i) {
        for (int j = 0; j < n; ++j) {
            ans[i]=min(ans[i],cnt[j][i]);
        }
    }
    string res="";
    for (int k = 0; k <26; ++k) {
        for (int i = 0; i < ans[k]; ++i) {
            res+=(char)('a'+k);
        }
    }
    cout <<res<<endl;
}


Measured memory_bytes: 3592
N,M,*X = `dd`.split.map(&:to_i)
ns = {}
X.each{ |x| ns[x] = (ns[x] || 0) + 1 }
ds = Array.new(M,0)
ss = Array.new(M,0)
ns.each{ |x,n| 
  ds[x%M] += n/2
  ss[x%M] += n%2
}
#p ss, ds
ans = ds[0] + ss[0]/2
if M%2 == 0 
  ans += ds[M/2] + ss[M/2]/2
end
#p ans
(1..(M-1)/2).each{ |k|
  s = ss[k] - ss[M-k]
  ans += [ss[k], ss[M-k]].min
  ans += [s.abs/2, (s < 0 ? ds[k] : ds[M-k])].min
  ans += ds[k] + ds[M-k]
  #p [k,M-k,ans]
}
p ans

Measured memory_bytes: 19600
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>

using namespace std;

int main() {
    int N,K,i,t,ans=999999999;
    vector<int> trees;
    cin>>N>>K;
    for(i=0;i<N;i++){
        cin>>t;
        trees.push_back(t);
    }
    sort(trees.begin(),trees.end());
    for(i=0;i<=N-K;i++){
        ans=min(ans,trees[i+K-1]-trees[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 892