akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)
// コンパイル　g++ -std=c++17 a.cpp

struct UnionFind
{
    vector<ll> d;
    UnionFind(ll n = 0) : d(n, -1)
    {    
    }

    //root : -size, not root: root
    ll root(ll x){
        if(d[x] < 0){
            return x; 
        }
        return d[x] = root(d[x]);
    }

    bool unite(ll x, ll y){
        x = root(x);
        y = root(y);
        if(x == y){
            return false;
        }
        if(d[x] > d[y]){
            swap(x, y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    }

    ll size(ll x){
        return -d[root(x)];
    }

    bool issame(ll a, ll b){
        return root(a) == root(b);
    }
};


//unionfind
int main() {
    ll n, m, k;
    cin >> n >> m >> k;

    UnionFind uf(n);
    vector<ll> friend_num(n);
    for (ll i = 0; i < m; i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        friend_num.at(a)++;
        friend_num.at(b)++;
        uf.unite(a,b);
    }

    vector<ll> block_num(n);
    for (ll i = 0; i < k; i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        if(uf.issame(a, b)){
            block_num.at(a)++;
            block_num.at(b)++;
        }
    }
    
    rep(i,n){
        cout << uf.size(i) -1 -friend_num.at(i) -block_num.at(i) << " ";
    }
    cout << endl;

}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in).useDelimiter("(\\s|,)+");
		String a;
		while (in.hasNext()) {
			String num = in.next();
			double w = in.nextDouble();
			double h = in.nextDouble();
			if (25 <= w / (h * h)) {
				System.out.println(num);
			}
		}
	}
}

Measured memory_bytes: 19300
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define P ((int)1e9+7)
#define N 1048576

char s[N];

int pow(int a, int k)
{
    int r = 1;
    while(k)
    {
        if(k&1) r = (lli)r*a%P;
        a = (lli)a*a%P;
        k>>=1;
    }
    return r;
}

int main()
{
    int k,n;
    scanf("%d%s", &k, s), n = strlen(s);
    lli res = 0;
    for(int i=0,comb = 1;i<=k;++i, comb=(lli)comb * (n-1+i) %P * pow(i,P-2) %P)
        res += (lli) pow(25,i) * pow(26,k-i) %P * comb %P;
    printf("%d\n",(int)(res%P));
    return 0;
}


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

int main() {
    string S;
    cin >> S;
    int N = S.size();
    int i,j;

    int judge_1 = 1;
    int judge_2 = 1;

    if(((N-1)/2)%2 == 0){
        //小さい回文が偶数個の要素だったとき
        for(i = 0; i < (N-1)/4; i++){
            if(S.at(i) == S.at((N-3)/2 - i)){
                judge_1 *= 1;
            }else{
                judge_1 *= 0;
            }
        }
        for(j = 0; j < (N-1)/2; j++){
            if(S.at(j) == S.at(N-1 - j)){
                judge_2 *= 1;
            }else{
                judge_2 *= 0;
            }
        }
    }else if(N == 3){
        if(S.at(0) == S.at(2)){
        }else{
            judge_1 = 0;
        }
    }else{
        //奇数個(3を除く)
        for(i = 0; i < (N-3)/4; i++){
            if(S.at(i) == S.at((N-3)/2 - i)){
                //N >= 7
                judge_1 *= 1;
            }else{
                judge_1 *= 0;
            }
        }
        for(j = 0; j < (N-1)/2; j++){
            if(S.at(j) == S.at(N-1 - j)){
                judge_2 *= 1;
            }else{
                judge_2 *= 0;
            }
        }
    }

    if(judge_1 * judge_2 == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,K;
ll A[200010];
int main(){
    cin>>N>>K;
    for(ll i=0;i<N;i++)cin>>A[i];
    
    for(ll i=K;i<N;i++){
        if(A[i]>A[i-K]){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}

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

int main() {
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  if (x1 == 0) cout << 1;
  else if (x2== 0) cout << 2;
  else if (x3== 0) cout << 3;
  else if (x4== 0) cout << 4;
  else if (x5== 0) cout << 5;
}
  
  

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    stack<ll> s;
    ll cnt = 0;
    ll max1 = 0;
    for(ll i=0;i<n;i++)
    {
        if(s.empty())
        {
            s.push(a[i]);
        }
        else if(a[i] <= s.top())
        {
            s.push(a[i]);
            cnt++;
        }
        else
        {
        
            cnt = 0;
            while(!s.empty())
            {
                s.pop();
            }
            s.push(a[i]);
        }
        max1 = max(max1 , cnt);
        
    }
    cout<<max1;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr int inf=0xE869120;
struct Point{
	int x,y;
};

bool compx(const Point &a,const Point &b){
	return a.x<b.x;
}
bool compy(const Point &a,const Point &b){
	return a.y<b.y;
}

int H,W,K;
string S[1000000];
vector<vector<int>>G;
Point s,g;

int main(){
	cin>>H>>W>>K;
	G=vector<vector<int>>(H,vector<int>(W,inf));
	cin>>s.x>>s.y>>g.x>>g.y;
	s.x--;
	s.y--;
	g.x--;
	g.y--;
	for(int i=0;i<H;i++)cin>>S[i];
	vector<Point>v;
	v.push_back(s);
	G[s.x][s.y]=0;
	while(!v.empty()){
		vector<Point>w;
		sort(v.begin(),v.end(),compx);
		for(Point p:v){
			for(int i=1;i<=K;i++){
				if(p.x-i<0||S[p.x-i][p.y]=='@'||G[p.x-i][p.y]<=G[p.x][p.y])break;
				if(G[p.x-i][p.y]==inf){
					w.push_back({p.x-i,p.y});
					G[p.x-i][p.y]=G[p.x][p.y]+1;
				}
			}
		}
		reverse(v.begin(),v.end());
		for(Point p:v){
			for(int i=1;i<=K;i++){
				if(p.x+i>=H||S[p.x+i][p.y]=='@'||G[p.x+i][p.y]<=G[p.x][p.y])break;
				if(G[p.x+i][p.y]==inf){
					w.push_back({p.x+i,p.y});
					G[p.x+i][p.y]=G[p.x][p.y]+1;
				}
			}
		}
		sort(v.begin(),v.end(),compy);
		for(Point p:v){
			for(int i=1;i<=K;i++){
				if(p.y-i<0||S[p.x][p.y-i]=='@'||G[p.x][p.y-i]<=G[p.x][p.y])break;
				if(G[p.x][p.y-i]==inf){
					w.push_back({p.x,p.y-i});
					G[p.x][p.y-i]=G[p.x][p.y]+1;
				}
			}
		}
		reverse(v.begin(),v.end());
		for(Point p:v){
			for(int i=1;i<=K;i++){
				if(p.y+i>=W||S[p.x][p.y+i]=='@'||G[p.x][p.y+i]<=G[p.x][p.y])break;
				if(G[p.x][p.y+i]==inf){
					w.push_back({p.x,p.y+i});
					G[p.x][p.y+i]=G[p.x][p.y]+1;
				}
			}
		}
		swap(v,w);
	}
	if(G[g.x][g.y]==inf)G[g.x][g.y]=-1;
	cout<<G[g.x][g.y]<<endl;
}


Measured memory_bytes: 42316
#include <cctype>
#include <string>
#include <iostream>

int main() {
	std::string str;
	int i;
	std::getline(std::cin, str);
	for (std::string::iterator it = str.begin(); it != str.end(); ++it) {
		*it = toupper(*it);
	}
	std::cout << str << '\n';
	return 0;
}

Measured memory_bytes: 0
n = int(input())
digit_sum_list = []

def digit_sum(t):
    r = t
    result_digit_sum = 0
    while(r > 0):
        result_digit_sum += r % 10
        r //= 10
    return result_digit_sum

for i in range(1, n+1):
    if digit_sum(i)+ digit_sum(n-i) >=2:
        digit_sum_list.append((digit_sum(i) + digit_sum(n-i)))
print(min(digit_sum_list))

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

int main(){
    
    long long N,A,B;
    cin >> N >> A >> B;
    
    if(A>B){
        cout << 0 << endl;
        return 0;
    }
    if(N==1){
        if(A==B)cout << 1 << endl;
        else cout << 0 << endl;
        return 0;
    }
    long long mn = B;
    long long mx = A;
    for(int i = 0; i < N-1;i++){
        
        mx += B;
        mn += A;
    }
    
    //cout << mx <<" "<<mn <<endl;
    cout << (mx-mn+1) <<endl;
}

    
    



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>


using namespace std;


struct UnionFind {
    std::vector<int> parent;

    UnionFind(int N) : parent(N){
        for(int i=0; i<N; i++) parent[i] = i;
    }

    int root(int x){
        if(parent[x]==x) return x;
        return parent[x] = root(parent[x]);
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        parent[rx] = ry;
    }

    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    int edges[1300][2];

    for(int i=0; i<M;i++){
        int a,b; cin >> a >> b;
        edges[i][0] = a-1; edges[i][1] = b-1; 
    }

    int cnt = 0;
    for(int i=0; i<M; i++){
        UnionFind union_find_tree(N);

        for(int j=0; j<M; j++){
            if(j!=i){
                union_find_tree.unite(edges[j][0], edges[j][1]);
            }
        }

        int root = union_find_tree.root(0);
        bool pass = false;
        for(int j=1; j<N; j++){
            if(union_find_tree.root(j) != root){
                pass = true; break;
            }
        }

        if(pass) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

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

using namespace std;
#define ll long long int

int main()
{
    ll t;
    t = 1;
    // cin t;
    while (t--)
    {
        ll n,k;
        cin >> n >> k;
        int count[n + 1] = {0};
        for(int i =0 ; i < k ; i ++)
        {
            int x;
            cin >> x;
            for(int j = 0 ;j < x;  j ++)
            {
                int y;
                cin >> y;
                count[y] =1;
            }
        }
        int ans = 0;
        for(int i =1 ; i <= n ; i ++)
        {
            if(count[i] == 0)
            ans ++;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3640
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<map>
#define ull unsigned long long
using namespace std;
const int MAXN=100000+5;
struct Edge
{
	int flow,to,nxt;
}e[MAXN*20];
namespace Flow
{
	int dep[MAXN],tot,fir[MAXN],str,T,cur[MAXN];
	queue<int>q;
	void add(int x,int y,int w)
	{
		tot++;
		e[tot]=(Edge){w,y,fir[x]};
		fir[x]=tot;
		
		tot++;
		e[tot]=(Edge){0,x,fir[y]};
		fir[y]=tot;
	}
	void clr(int n)
	{
		T=n+1;str=0;
		memset(fir,0,sizeof(fir));
		tot=1;
	}
	bool bfs()
	{
		memset(dep,0,sizeof(dep));
		dep[str]=1;
		q.push(str);
		while(q.size())
		{
			int x=q.front();q.pop();
			for(int i=fir[x];i;i=e[i].nxt)
			{
				int v=e[i].to;
				if(e[i].flow==0||dep[v]) continue;
				dep[v]=dep[x]+1;
				q.push(v);
			}
		}
		return dep[T];
	}
	int dfs(int x,int flow)
	{
		if(x==T) return flow;
		int res=0,cnt;
		for(int &i=cur[x];i;i=e[i].nxt)
		{
			int v=e[i].to;
			if(dep[v]!=dep[x]+1||e[i].flow==0) continue;
			cnt=dfs(v,min(flow,e[i].flow));
			if(cnt)
			{
				e[i].flow-=cnt;
				e[i^1].flow+=cnt;
				res+=cnt;
				flow-=cnt;
			}
			if(!flow) return res;
		}
		return res;
	}
	int maxflow()
	{
		int res=0;
		while(bfs())
		{
			for(int i=str;i<=T;i++) cur[i]=fir[i];
			res+=dfs(str,1<<30);
		}
		return res;
	}
}
int n;
struct Node
{
	int p[MAXN],cnt,bel[MAXN];
}A,B;
int main()
{
//	freopen("1.in","r",stdin);
//	freopen("name.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&A.p[i]),A.p[i]++;
	for(int i=1;i<=n;i++) scanf("%d",&B.p[i]),B.p[i]++;
	for(int i=1;i<=n;i++)
	if(!A.bel[i])
	{
		A.bel[i]=++A.cnt;
		for(int j=A.p[i];!A.bel[j];j=A.p[j])
			A.bel[j]=A.cnt;
	}
	for(int i=1;i<=n;i++)
	if(!B.bel[i])
	{
		B.bel[i]=++B.cnt;B.bel[i]=B.cnt+A.cnt;
		for(int j=B.p[i];!B.bel[j];j=B.p[j])
			B.bel[j]=B.cnt+A.cnt;
	}
	Flow::clr(A.cnt+B.cnt);
	int Ans=n;
	for(int i=1;i<=n;i++)
	if(A.p[i]!=i||B.p[i]!=i)
	{
		if(A.p[i]==i)
		{
			Flow::add(B.bel[i],Flow::T,1);
			continue;
		}
		if(B.p[i]==i)
		{
			Flow::add(0,A.bel[i],1);
			continue;
		}
		if(A.p[i]==B.p[i])
		{
			Flow::add(A.bel[i],B.bel[i],1);
			Flow::add(B.bel[i],A.bel[i],1);
			continue;
		}
		Flow::add(B.bel[i],A.bel[i],1);
	}
	else Ans--;
	printf("%d\n",Ans-Flow::maxflow());
	return 0;
}
	

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
int par[10000], rank[10000];

void init(int n) {
  for (int i=0; i<n; i++) {
    par[i]=i;
    rank[i]=0;
  }
}
int find(int val) {
  if (val==par[val]) {
    return val;
  } else {
    par[val]=find(par[val]);
    return par[val];
  }
}
void unite(int x,int y) {
  x=find(par[x]);
  y=find(par[y]);
  if (x==y) {
    return;
  }
  if (rank[x]<rank[y]) {
    par[x]=y;
  } else {
    par[y]=x;
    if (rank[x]==rank[y]) {
      rank[x]++;
    }
  }
}
bool same(int x,int y) {
  x=find(x);
  y=find(y);
  return x==y;
}
int main() {
  int n, q;
  cin >> n >> q;
  init(n);
  for (int i=0; i<q; i++) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com==0) {
      unite(x,y);
    } else {
      printf("%d\n",same(x,y));
    }
  }
  return 0;
}

Measured memory_bytes: 3284
#include<stdio.h>

int main(void)
{
	int a,b,c,x,ans=0,i,j,k;
	scanf("%d%d%d%d",&a,&b,&c,&x);
	for(i=0;i<=a;i++){
		for(j=0;j<=b;j++){
			for(k=0;k<=c;k++){
				if(x==500*i+100*j+50*k)
					ans++;
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
using namespace std::chrono;

#define ll long long
#define ld long double
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#ifdef LL
const ll inf = 1e9;
#else 
const ll inf = 1e18;
#endif

const int mod = 1e9 + 7;
const int mod2 = 998244353;

typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

high_resolution_clock::time_point curTime() { return high_resolution_clock::now(); }
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);} //Just add this as a third argument to sort() while sorting an array of pairs; NO NEED FOR ANY ARGUMENTS;
template <typename T>
T fact(T a, T mod){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=mod;} return res; }
template <typename T>
ll powmod(T a,T b,ll m){ ll ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
ll power(T a, T b){ ll ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}
template <typename T>
T gcd(T a,T b){ return (b?__gcd(a,b):a); }
template <typename T>
T lcm(T a, T b){ return (a*(b/gcd(a,b))); }
template <typename T>
T cl(T a, T b){ return (a+b-1)/b; }
template <typename T>
T set_bits(T a)
{ return __builtin_popcount(a); }
template <typename T>
T add_self(T& a, T b, T mod){ a+=b; if(a>=mod){ a-=mod; } }
template <typename T>
T to_upper(T s){ transform(s.begin(), s.end(), s.begin(), ::toupper); return s; }
template <typename T>
T to_lower(T s){ transform(s.begin(), s.end(), s.begin(), ::tolower); return s; }



int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    auto startTime = curTime();

    int n;
    cin>>n;
    vi h(n);
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }

    vi dp(n+1);
    dp[2] = abs(h[1] - h[0]);
    dp[3] = min(dp[2] + abs(h[2]-h[1]), abs(h[2]-h[0]));
    for(int i=4;i<=n;i++)
    {
        dp[i] = min(dp[i-2] + abs(h[i-1]-h[i-3]), dp[i-1] + abs(h[i-1]-h[i-2]));
    }

    cout<<dp[n]<<endl;

    auto stopTime = curTime();
    auto duration = duration_cast<microseconds>(stopTime - startTime);
    //cout<<"Program ran for "<<(ld)duration.count()/1e6<<" "<<"seconds"<<endl;
}


Measured memory_bytes: 4748
#include<bits/stdc++.h>
#define LL long long
#define M 1000005 
using namespace std;
const int P=1e9+7; 
struct node{
	int x,k,step;
};
int dis[M][3],n,m,s,t;
bool mark[M][3];
vector<int>edge[M];
queue<node>Q;
int BFS(){
	node tmp=(node){s,0,0};
	mark[s][0]=1;
	Q.push(tmp);
	while(!Q.empty()){
		node p=Q.front();Q.pop();
		for(int i=0;i<edge[p.x].size();i++){
			int y=edge[p.x][i];
			int k1=(p.k+1)%3;
			int step=p.step+1;
			if(!mark[y][k1]){
				mark[y][k1]=1;
				if(y==t&&k1==0)return step/3;
				Q.push((node){y,k1,step});
			}
		}
	}
	return -1;
}
int main(){ 
	cin>>n>>m;
	int a,b;
	for(int i=1;i<=m;i++){
		scanf("%d %d",&a,&b);
		edge[a].push_back(b);
	}
	cin>>s>>t;
	cout<<BFS()<<endl;
	return 0;
}

Measured memory_bytes: 29952
#include <iostream>

using namespace std;

int main(){
    string S;
    cin >> S;
    int K;
    cin >> K;

    long dp[S.length()][5][2];
    for(int i=0; i<S.length(); i++){
        for(int j=0; j<4; j++){
            for(int k=0; k<2; k++){
                dp[i][j][k] = 0;
            }
        }
    }
    dp[0][1][0] = 1;
    dp[0][1][1] = S[0]-'0'-1;
    dp[0][0][1] = 1;
    // 0: t
    // 1: >t
    for(int i=1; i<S.length(); i++){
        for(int j=0; j<4; j++){
            if(S[i]=='0'){
                dp[i][j][0] = dp[i-1][j][0];
            }else{
                dp[i][j+1][0] = dp[i-1][j][0];
                dp[i][j+1][1] += dp[i-1][j][0]*(S[i]-'0'-1);
                dp[i][j][1] += dp[i-1][j][0];
            }

            dp[i][j+1][1] += dp[i-1][j][1]*9;
            dp[i][j][1] += dp[i-1][j][1];
        }
    }

    cout << dp[S.length()-1][K][0] + dp[S.length()-1][K][1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;

const int MAX_N=50000;
const int MAX_M=20;

int d[MAX_M];
int dp[MAX_M+1][MAX_N+1];
int n,m;

void solve(){
	for(int i=0;i<=m;i++){
		for(int j=0;j<=n;j++){
                      if(j==0){
                            dp[i][j]=0;
                              }
                      else if(i==0){
                    	  dp[i][j]=10000;
                      }
                      else if(j<d[i-1]){
				dp[i][j]=dp[i-1][j];
			}
			else{
				dp[i][j]=min(dp[i-1][j],dp[i][j-d[i-1]]+1);
			}
		}

	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d",&d[i]);
	}

	solve();

	printf("%d\n",dp[m][n]);
	return 0;
}

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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li pow_[200200];
li p[200200];

inline li inverse(li a) {
	li m = MOD;
	li b = m, u = 1, v = 0;
	while (b) {
		li t = a / b;
		swap(a -= t * b, b);
		swap(u -= t * v, v);
	}
	return (u % m + m) % m;
}

inline li ncr(li n, li r) {
	return (((pow_[n] * inverse(pow_[n - r])) % MOD) * inverse(pow_[r])) % MOD;
}

int main() {
	li h, w;
	cin >> h >> w;

	pow_[0] = 1;
	repp(i, 1, h + w + 1) {
		pow_[i] = pow_[i - 1] * i % MOD;
	}

	li a, b;
	cin >> a >> b;

	// ooooo
	// PPPPP
	// xxxoo
	// xxxoo
	// Pのところの組み合わせ（生き方）を求める
	rep(i, w) {
		li tate = h - 1 - a, yoko = i;
		p[i] = ncr(tate + yoko, min(tate, yoko));
	}

	li res = 0;
	repp(j, b, w) {
		li tate = a - 1, yoko = w - 1 - j;
		res = (res + ncr(tate + yoko, min(tate, yoko)) * p[j]) % MOD;
	}
	cout << res << endl;



	return 0;
}

Measured memory_bytes: 2560
import java.util.*

fun main(args: Array<String>) {
    val argList = Scanner(System.`in`)

    val line = argList.nextLine().split(" ")
    val k = line[0].toInt()
    val x = line[1].toInt()

    val e = OneClue()
    println(e.execute(k, x).joinToString(" "))

}

class OneClue {
    fun execute(k: Int, x: Int): List<Int> {
        val min = x - (k - 1)
        val max = x + (k - 1)

        return (min..max).toList()
    }
}

Measured memory_bytes: 36084
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner s = new Scanner(System.in);
		long x = Math.abs(s.nextLong());
		long k = s.nextLong();
		long d = s.nextLong();
		
		long ans = x/d;
		if(ans>k) {
			System.out.println(x-k*d);
		}
		else {
			k-=ans;
			if(k%2==0) {
				System.out.println(x-ans*d);
			}
			else {
				System.out.println(Math.abs(x-ans*d-d));
			}
		}
		
		
	}
}


Measured memory_bytes: 35712
#include "bits/stdc++.h"
    #define ALL(obj) (obj).begin(),(obj).end()
    #define RALL(obj) (obj).rbegin(),(obj).rend()
    #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 FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
    using namespace std;
    typedef long long ll;
    const int MOD = 1e9 + 7;
    const int INF = 1e9 + 6;
    const ll LLINF = 4e18;
     
    int c(int n, const vector<int> &G, const vector<int> &cost, vector<int> &ans) {
        if (ans[n] != -1) return ans[n];
        if (n == 0) {
            return ans[0] = cost[0];
        }
        else {
            return ans[n] = cost[n] + c(G[n], G, cost, ans);
        }
    }
     
    int main() {
        int n, q; cin >> n >> q;
        vector<int> G(n);
        vector<int> cost(n,0);
        vector<int> ans(n, -1);
        REP(i, n - 1) {
            int a, b;
            cin >> a >> b;
            G[b-1] = a - 1;
        }
        REP(i, q) {
            int p, x;
            cin >> p >> x;
            cost[p-1] += x;
        }
        REP(i, n) {
            cout << c(i,G,cost,ans) << " ";
        }
        cout << endl;
        getchar(); getchar();
    }

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

/*
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <ctype.h>
*/


using namespace std;

typedef pair<int , int > pii;
typedef pair<long , long> pll;
typedef pair<pii , int > piii;
typedef pair<pll , long > plll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector <pii> vii;
typedef vector<pll> vll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef unsigned long long int ulli;
typedef long long int lli;
typedef double d;
typedef float f;
typedef string s;
typedef char ch;
typedef pair<int,ll> pill;

#define loop(n) for(int i = 0; i < (n); i++)
#define lp(x , s , e) for(int x = (s); x < (e); x++)
#define lpe(x , s , e) for(int x = (s); x <= (e); x++)
#define readline(s) getline(cin,s)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;
#define MP make_pair
#define PB push_back
#define all(a) a.begin(),a.end()
#define clr(x , val) memset((x) , (val) , sizeof(x))
#define endl '\n'

ll power(ll a, ll b)
{
    ll res = 1;
    for(int i = 0; i<b; i++)
       res *= a;

    return res;
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
	ll n , x;
	cin >> n >> x;
	ll c[n];
	//ll mindis = LLONG_MAX;
	loop(n)
	{
		cin >> c[i];
		c[i] = abs(c[i] - x);
	}
	if (n == 1)
	{
		cout << c[0] << endl;
		return 0;
	}
	sort (c , c + n);
	ll d = c[0];
	loop(n)
	{
		for(int j = d; j >= 1; j--)
		{
			if (d % j == 0 && c[i] % j == 0)
			{
				d = j;
				break;
			}
		}
	}
	cout << d << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream> 
#include <string> 
#include <map>
using namespace std; 
map<string,int> table; 
int main() {
  string word,frequent,longest; 
  size_t N=0;
  while (cin >> word) {
  table[word] += 1;
  if (table[word] > N){
    N = table[word];
    frequent = word;
  }
  if (word.size() > longest.size())
    longest = word;
  }
  cout << frequent << " " << longest << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = 1000000007;

const int MAX_N = 100000 + 10;
int A[MAX_N];

int main2() {
  int N = nextInt();
  REP(i, N) A[i] = nextInt();
  ll ans = 1;

  map<int,ll> count;
  count[-1] = 3;
  REP(i, N) {
    ans *= count[ A[i]-1 ];
    ans %= MOD;
    --count[ A[i] - 1 ];
    ++count[A[i]];
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 6912
//============================================================================
// Name        : c.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
using namespace std;

int main() {
	long long n;cin>>n;
	vector<long long> v;
	for(long long i=1;i*i<=n;i++){
		if(n%i==0)v.push_back(i);
	}
	cout<<v.back()+n/v.back()-2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

int n;
int a[N];

int main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
	}
	int cnt=0;
	sort(a+1,a+1+n);
	for(int i=1;i<=n;++i){
		for(int j=i+1;j<=n;++j){
			for(int k=j+1;k<=n;++k){
				if(a[i]+a[j]>a[k] && a[i]!=a[j] && a[i]!=a[k] && a[j]!=a[k]) cnt++;
			}
		}
	}

	printf("%d\n",cnt);

    return 0;
}

Measured memory_bytes: 3836
N = int(input())
h = input()

h_n = [int(x) for x in h.split()]
now = []
for i in range(N):
    now.append(0)

count = 0
while True:
    add_range = [0, N]

    for i in range(0,N):
        if (now[i] < h_n[i]):
            add_range[0] = i
            break
    else:
        break
    for i in range(add_range[0]+1,N):
        if (now[i] >= h_n[i]):
            add_range[1] = i
            break
    for i in range(add_range[0], add_range[1]):
        now[i] += 1
    count += 1
print(count)

Measured memory_bytes: 3064
def main():
    n, k = map(int, input().split())
    rsp = list(map(int, input().split()))
    ts = list(input())

    points = [0] * n
    for i, t in enumerate(ts):
        prev_idx = i - k
        if prev_idx >= 0:
            prev_t = ts[prev_idx]
            if prev_t == t:
                if points[prev_idx] == t:
                    pass
                else:
                    points[i] = t
                    continue
        if t == 'r':
            point = rsp[2]
        elif t == 's':
            point = rsp[0]
        else:
            point = rsp[1]
        points[i] = point

    ans = 0
    for p in points:
        if type(p) == int:
            ans += p
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4792
import numpy as np

n,d=map(int,input().split())
X=[]
for i in range(n):
  x=np.array(list(map(int,input().split())))
  X.append(x)
count=0
for i in range(n-1):
  for j in range(i+1,n):
    d = ((X[i]-X[j])**2).sum()**.5
    if d==int(d):count+=1
print(count)

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

int main() {
  int A, B;
  string S;

  cin >> A >> B >> S;

  bool flag = true;
  for (int i = 0; i < (A + B + 1); i++) {
    if (i < A) {
      if (!isdigit(S[i])) flag = false;
    } else if (i == A) {
      if (S[i] != '-') flag = false;
    } else {
      if (!isdigit(S[i])) flag = false;
    }
  }

  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
      

  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int main(int argc, char const* argv[])
{
    std::string in_str;
    std::cin >> in_str;

    auto result = 700;
    for(auto c: in_str)
    {
        if(c == 'o')
        {
            result += 100;
        }
    }
    std::cout << result << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,min=10000,k,i;
	for(i=0; i<3; i++)
	{
		scanf("%d", &a);
		if(min>a)
		min=a;
	}
	scanf("%d %d", &a, &b);
	if(a>b)
	a=b;
	k=min+a-50;
	printf("%d\n", k);
	
	return 0;
}


Measured memory_bytes: 2056
from collections import deque

while True:
    w, h = map(int, input().split())
    if w == 0 and h == 0:
        break
    v_wall = [[0] * w for _ in range(h)]
    h_wall = [[0] * w for _ in range(h)]
    for i in range(2 * h - 1):
        walls = map(int, input().split())
        for j, obstacle in enumerate(walls):
            if i % 2 == 0:
                v_wall[i // 2][j] = obstacle
            else:
                h_wall[i // 2][j] = obstacle
    d = [[False] * w for _ in range(h)]
    que = deque()
    sx, sy = 0, 0
    gx, gy = w-1, h-1
    que.append((sx, sy))
    d[sy][sx] = 0

    while que:
        x, y = que.popleft()
        for dx, dy in [[-1, 0], [1, 0], [0, 1], [0, -1]]:
            nx, ny = x + dx, y + dy
            # 0 index
            if 0 <= nx < w and 0 <= ny < h and d[ny][nx] is False:
                if dy == 1:
                    if h_wall[y][x] == 0:
                        d[ny][nx] = d[y][x] + 1
                        que.append((nx, ny))
                elif dy == -1:
                    if h_wall[ny][nx] == 0:
                        d[ny][nx] = d[y][x] + 1
                        que.append((nx, ny))
                elif dx == 1:
                    if v_wall[y][x] == 0:
                        d[ny][nx] = d[y][x] + 1
                        que.append((nx, ny))
                elif dx == -1:
                    if v_wall[ny][nx] == 0:
                        d[ny][nx] = d[y][x] + 1
                        que.append((nx, ny))
    if d[gy][gx] is False:
        print(0)
    else:
        print(d[gy][gx] + 1)



Measured memory_bytes: 6020
#include <stdio.h>
int main(){
		int a,b,c,d;
		char op;
		while(true){
			scanf("%d %c %d",&a, &op, &b);
			if (op == '+' ){
		c = a+b;
		printf("%d\n",c);
	}
			else if(op == '-' ){
		c = a-b;
		printf("%d\n",c);
	}
			else if(op == '*' ){
		c = a*b;
		printf("%d\n",c);
			}
			else if(op == '/' ){
		c = 10*a/b;
		d = c-(c%10);
		d = d/10;
		c = d;
		printf("%d\n",c);
	}


			else {
		break;
	}

		};

	    return 0;
}

Measured memory_bytes: 1028
n, a, b = map(int, input().split())

if (b-a) % 2 == 0:
    print((b-a)//2)
else:
    tmp_a = a - (a - 1)
    tmp_b = b - (a - 1)
    ans = a - 1
    ans = ans + 1
    ans1 = ans + (tmp_b - tmp_a)//2
    
    tmp_a = a + (n - b)
    tmp_b = b + (n - b)
    ans = (n - b)
    ans = ans + 1
    tmp_a += 1
    ans2 = ans + (tmp_b - tmp_a)//2
    print(min(ans1, ans2))

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

int main(){
    string s;
    cin >> s;
    int num = 0;
    vector<int> t;
    string ans = "No";

    for (auto i = 1; i < 4; i++)
    {
        if(s[0]==s[i]){
            num += 1;
            continue;
        }

        t.push_back(i);
    }

    if(num == 1){
        if(s[t[0]] == s[t[1]]){
            ans = "Yes";
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
//orz yht
using namespace std;
string s;
int x;
bool flag=true;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>s;
	while(x<=s.size()-1){
		if(s.substr(x,7)=="dreamer" && s.substr(x+5,5)!="erase")
		x+=7;
		else if(s.substr(x,6)=="eraser")
		x+=6;
		else if(s.substr(x,5)=="dream")
		x+=5;
		else if(s.substr(x,5)=="erase")
		x+=5;
		else{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
	//system("pause");
	return 0;
} 

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int a,b;
	cin >> a >> b;
	cout << max({a+b,a-b,a*b}) << endl;
	

}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    ll a,b,x;
    cin >> a >> b >> x;
 
    if( a%x != 0 ) a = (a/x+1)*x ;
    if( b%x != 0 ) b = (b/x)*x;
    
    if( a > b )
    {
        cout << 0 << endl;
        return 0;
    }
    ll ans = (b-a)/x;
    //最初
    if( a%x == 0 || b%x ==0 ) ans++;
    
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();

        int[] m = new int[w];
        int a;
        int b;
        int temp;
        String c;

        for(int i = 0; i < w; i++){
            m[i] = i + 1;
        }

        for(int i = 0; i < n; i++){
            c = sc.next();
            String[] num = c.split(",", 0);
            a = Integer.parseInt(num[0]);
            b = Integer.parseInt(num[1]);

            temp = m[a - 1];
            m[a - 1] = m[b - 1];
            m[b - 1] = temp;
        }

        for(int i = 0; i < w; i++){
            System.out.println(m[i]);
        }

        sc.close();
    }
}


Measured memory_bytes: 26188
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <climits>
#include <math.h>

using namespace std;

typedef long long ll;
#define REP(i, x) for (int i = 0; i < (int)(x); i++)



int N;
int main()
{
  cin >> N;
  vector<int> l(N * 2);
  REP(i, N * 2) cin >> l[i];

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

  int ans = 0;
  for (int i = 0; i < l.size(); i+= 2) {
    ans += min(l[i], l[i + 1]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n;
	long long c=0,d=65500000;
	cin>>n; 
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int b=0;b<=100;b++)
	{
		for(int i=0;i<n;i++)
		{
			c=(a[i]-b)*(a[i]-b)+c;
		}
		if(d>c)
		{
			d=c;
		}
		c=0;
	}
	cout<<d;
}

Measured memory_bytes: 256
// 2015/08/05 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		unsigned sum = 0;
		for(int i=0; i<n; i++){
			int p;
			cin >> p;

			sum += (unsigned)p;
		}

		int j[65000];
		for(int i=0; i<n-1; i++){
			cin >> j[i];
		}

		sort(j, j+(n-1));

		unsigned sal_max = (unsigned)n*sum;

		for(int i=n-1; i>=1; i--){
			sum += (unsigned)j[i-1];

			sal_max = max(sal_max, (unsigned)i*sum);
		}

		cout << sal_max << endl;
	}

	return 0;
}

Measured memory_bytes: 1424
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <vector>

using namespace std;

int main(int argc, const char *argv[]) {
  int H, A;
  int count = 1;
  int d;

  cin >> H >> A;
  H -= A;
  while (H > 0) {
    H -= A;
    count++;
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 888
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n-1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}



int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N,M;
  cin>>N>>M;
  vector<l_l> pairs(M);
  vector<ll>A(N);
  rep(i,N) cin>>A[i];
  sort all(A);
  rep(i,M){
        ll a;
        ll b;
        cin >> a >> b;
        pairs[i] = make_pair(b, a);
    }
  sort all(pairs);
  vector<ll>D(N);
  int cnt=0;
  repr(i,M){
    rep(j,pairs[i].second){
      if(cnt==N)
        break;
      else{
        D.push_back(pairs[i].first);
        cnt++;
      }
    }
    if(cnt==N)
      break;
  }
  ll ans=0;
  sort all(D);
  reverse all(D);
  rep(i,N){
    ans+=max(A[i],D[i]);
  }
  cout<<ans<<endl;
  
  
}
  
  


Measured memory_bytes: 4224
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, w, h, x, y, s, t, count, max, i, j, k, l;
    boolean[][] f;

    for(;;){
      n = sc.nextInt(); if(n == 0)break;
      w = sc.nextInt(); h = sc.nextInt();
      f = new boolean[w][h];
      for(;n-- > 0;){
        x = sc.nextInt(); y = sc.nextInt(); f[x - 1][y - 1] = true;
      }
      s = sc.nextInt(); t = sc.nextInt();
      max = 0;
      for(i = 0;i < w + 1 - s;i++)for(j = 0;j < h + 1 - t;j++){
        count = 0;
        for(k = 0;k < s;k++)for(l = 0;l < t;l++)if(f[i + k][j + l])count++;
        if(max < count)max = count;
      }
      out.println(max);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 35564
/*
[dp] T - Permutation
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 3000;
const ll MOD = 1e9 + 7;

int N;
string s;
ll dp[MAX_N][MAX_N];

ll solve() {
    for (int j = 0; j < N; j++) {
        dp[0][j] = 1;
    }
    for (int i = 1; i < N; i++) {
        for (int j = 0; j <= N - i; j++) {
            if (s[i - 1] == '<') {
                (dp[i][j] += dp[i - 1][j]) %= MOD;
                (dp[i][N - i] += MOD - dp[i - 1][j]) %= MOD;
            } else {
                (dp[i][0] += dp[i - 1][j]) %= MOD;
                (dp[i][j] += MOD - dp[i - 1][j]) %= MOD;
            }
        }
        for (int j = 1; j <= N - i; j++) {
            (dp[i][j] += dp[i][j - 1]) %= MOD;
        }
    }
    return dp[N - 1][0];
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 70016
#include<iostream>
#include<string>
using namespace std;
int main(){
    
    //入力部
    string S;
    string T = "2019/04/30"; //平成最後の日
    cin >> S;

    //出力部
    for(int i=0;i<=9;i++){
        if(S[i] < T[i])break; //n文字目が`RE_WA`の方が大きいならループを抜ける
        if(S[i] > T[i]){
            cout << "TBD" << endl;
            return 0;
        } //n文字目が`RE_WA`の方が小さいなら"TBD"を返して処理を終了
    }
    cout << "Heisei" << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()

v = 'abcdefghijklmnopqrstuvwxyz'
ans = 1000
for i in range(26):
  t = s
  a = t.split(v[i])
  if len(a) == 1:
    continue
  b = 0
  for j in a:
    b = max(len(j),b)
  ans = min(b,ans)
print (ans)


Measured memory_bytes: 9044
N, T = map(int, input().split())
c_t = []
for _ in range(N):
    _c, _t = map(int, input().split())
    c_t.append((_c, _t))

for a in sorted(c_t):
    if a[1] <= T:
        print(a[0])
        break
else:
    print("TLE")


Measured memory_bytes: 3060
n = int(input())

def divisor(n):
    d = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            d.append(i)
            if i != n//i:
                d.append(n//i)
    #d.sort()
    return d



ls = divisor(n-1)
ls2 = divisor(n)
a1 = len(ls)-1
a2 = 0
for num in ls2:
    cnt = 1
    s = n
    if num ==1:
        continue
    while True:
        if s % num ==0:
            s = s//num
        else:
            if s % num ==1:
                a2 +=1
            break
print(a1+a2)


Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100005;
int n;
int a[N];
int cnt[N],num[N],tot;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	if(a[1]==a[n]&&a[1]==0)
	{
		printf("Yes");
		return 0;
	}
	a[0]=-1;
	for(int i=1;i<=n;i++)
	{
		if(a[i]!=a[i-1]) tot++,num[tot]=a[i],cnt[tot]=1;
		else cnt[tot]++;
		if(tot>3)
		{
			printf("No");
			return 0;
		}
	}
	if(n%3!=0)
	{
		printf("No");
		return 0;
	}
	if(tot==3)
	{
		if((num[1]^num[2]^num[3])==0&&cnt[1]==cnt[2]&&cnt[2]==cnt[3]) printf("Yes");
		else printf("No");
	}
	else if(tot==2)
	{
		if(a[1]==0&&cnt[1]==n/3) printf("Yes");
		else printf("No");
	}
	else printf("No");
	return 0;
}

Measured memory_bytes: 4120
use proconio::input;

use std::io::Write;

pub trait Echo {
    fn echo(&self);
    fn echo_b(&self, out: &mut std::io::Stdout) -> Result<(), std::io::Error>;
}

macro_rules! impl_echo {
    ($($t:ty),*) => {
        $(
            impl Echo for $t {
                fn echo(&self){
                    self.echo_b(&mut std::io::stdout()).unwrap();
                }

                fn echo_b(&self, out: &mut std::io::Stdout) -> Result<(), std::io::Error>{
                    writeln!(out,"{}", &self)?;
                    Ok(())
                }
            }
        )*
    };
}

macro_rules! impl_echo_f {
    ($($t:ty),*) => {
        $(
            impl Echo for $t {
                fn echo(&self){
                    self.echo_b(&mut std::io::stdout()).unwrap();
                }

                fn echo_b(&self, out: &mut std::io::Stdout) -> Result<(), std::io::Error>{
                    writeln!(out,"{:.12}", &self)?;
                    Ok(())
                }
            }
        )*
    };
}

impl_echo!(u8, u16, u32, u64, u128, usize);
impl_echo!(i8, i16, i32, i64, i128, isize);
impl_echo!(&str, String, char);
impl_echo_f!(f32, f64);

impl<T: Echo> Echo for Vec<T> {
    fn echo(&self) {
        self.echo_b(&mut std::io::stdout()).unwrap();
    }
    fn echo_b(&self, out: &mut std::io::Stdout) -> Result<(), std::io::Error> {
        for i in self {
            i.echo_b(out).unwrap();
        }
        Ok(())
    }
}

fn main() {
    input! {
        a: u32
    };
    let res = a + a.pow(2) + a.pow(3);
    res.echo();
}


Measured memory_bytes: 2092
#include<iostream>

int main(){
    int i,j,n,m;
    
    std::cin>>n>>m;

    int a[n][m],b[m],c[n];

    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            std::cin>>a[i][j];
        }
    }

    for(j=0;j<m;j++){
        std::cin>>b[j];
    }

    for(i=0;i<n;i++){
        c[i]=0;
    }

    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            c[i]+=a[i][j]*b[j];
        }
        std::cout<<c[i]<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 3120