akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define For1(i, n) for(int i = 1; i <= (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;
#include <set>

int main(void){
    Cin(int, n, x);
    if(x == 2){
        Cout("Yes");
        For(i, n) Cout(2*n-1 - 2*i);
        For(i, n-1) Cout(2*i + 2);
        return 0;
    }
    if(x == 1 || x == 2*n-1){
        Cout("No");
        return 0;
    }
    Cout("Yes");
    vc<int> a;
    For1(i, 2*n-1) if(!(x-2 <= i && i <= x+1)) a.push_back(i);
    For(i, n-2) Cout(a[i]);
    Cout(x-2); Cout(x); Cout(x+1); Cout(x-1);
    For(i, n-3) Cout(a[i+n-2]);
}




Measured memory_bytes: 2420
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int m;
  cin>>m;
  int i;
  int arr[m],sum=0;
  for(i=0;i<m;i++)
    cin>>arr[i],sum=sum+arr[i];
  if(n>=sum)
    cout<<n-sum;
  else
    cout<<-1;
  return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <numeric>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#include <cassert>
using namespace std;

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)x)<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define EREP(i,a,b) for(int i=a;i<=b;i++)
#define erep(i,n) EREP(i,0,n)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

int euler[1000002];
ll ans[1000002];

void euler_phi2(){
  for(int i=0;i<1000001;i++) euler[i] = i;
  for(int i=2;i<1000001;i++){
    if(euler[i] == i){
      for(int j=i;j<1000001;j+=i) euler[j] = euler[j] / i * (i - 1);
    }
  }
}

int main(void){
  euler_phi2();
  for(int i=1;i<=1000000;i++){
    ans[i] = ans[i-1] + (ll)euler[i];
  }

  int T;
  cin>>T;

  while(T--){
    int n;
    cin>>n;
    cout<<ans[n]+1<<endl;
  }
}

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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type / Class / Struct Definitions:
using ll = long long;
using ull = unsigned long long;

//Constants:
const int INF = (1ll << 30) - 1;  //nearly 1.07e9
const ll INFLL = 1ll << 60;       //nearly 1.15e18
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

//================ Main Loop ================
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) {
        cin >> h[i];
    }
    vector<int> dp(n, INF);
    dp[0] = 0;

    for(int i = 1; i < n; i++) {
        for(int j = 1; j <= k && i - j >= 0; j++) {
            chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }

    cout << dp[n - 1] << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    vector<string> s(n), t(n);
    for (int i = 0; i < n; i++)
      cin >> s[i];
    for (int i = 0; i < n; i++) {
      bool f = true;
      for (int j = 0; j < s[i].size(); j++) {
        if (s[i][j] == '.')
          t[i].push_back(' ');
        else {
          if (f) {
            f = false;
            t[i].push_back('+');
          }
          t[i].push_back(s[i][j]);
        }
      }
    }
    for (int i = 0; i < n; i++)
      t[i] = t[i].substr(1, t[i].size());
    for (int i = n - 1; i >= 0; i--) {
      for (int j = 0; j < t[i].size() - 1; j++) {
        if (t[i][j] == '+') {
          for (int k = i - 1; k >= 0; k--) {
            if (t[k][j] == ' ')
              t[k][j] = '|';
            else
              break;
          }
          break;
        }
      }
    }
    for (auto &a : t)
      cout << a << endl;
  }
  return 0;
}


Measured memory_bytes: 4520
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int main() {
	int h, w; std::cin >> h >> w;
	int n; std::cin >> n;
	int a; std::cin >> a;
	int color = 1;
	std::vector<std::vector<int>> state(h, std::vector<int>(w, 0));
	for (auto i = 0; i < h; ++i) {
		for (auto j = 0; j < w; ++j) {
			if (a == 0) {
				std::cin >> a;
				++color;
			}
			if (i % 2 == 0) state[i][j] = color;
			else state[i][w - j - 1] = color;
			--a;
		}
	}
	for (const auto& line : state) {
		for (auto i = 0; i < line.size(); ++i) {
			if (i != 0) std::cout << ' ';
			std::cout << line[i];
		}
		std::cout << '\n';
	}
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

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

    int ans = 0;

    for (int i = 0; i < 3; ++i) {
        if (s[i] == t[i]) ++ans;
    }

    cout << ans << endl;
}

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

using namespace std;

using ll = long long;

struct Item {
  ll v, w, m;
  Item(){}
  explicit Item(ll v, ll w, ll m):v(v), w(w), m(m){}
  bool operator < (const Item& item) const {
    return v*item.w < item.v*w;
  }
};

constexpr ll MAX_N = 50;
constexpr ll MAX_V = 50;
constexpr ll LIMIT = MAX_N*MAX_N*MAX_V;

ll N, W;
ll dp[LIMIT+1];

int main() {

  cin >> N >> W;

  vector<Item> items;
  for(ll i = 0; i < N; ++i) {
    ll v, w, m;
    cin >> v >> w >> m;
    items.emplace_back(v, w, m);
  }
  sort(items.rbegin(), items.rend());

  // knapsack dp
  fill(dp, dp+LIMIT+1, LLONG_MAX/2);
  dp[0] = 0;
  for(ll i = 0; i < N; ++i) {
    ll v = items[i].v;
    ll w = items[i].w;
    ll m = min(items[i].m, MAX_V);
    for(ll k = 0; m > 0; ++k) {
      ll use = min(m, 1LL<<k);
      for(ll j = LIMIT-v*use; j >= 0; --j) {
	dp[j+v*use] = min(dp[j+v*use], dp[j]+w*use);
      }
      m -= use;
    }
  }

  // greedy
  ll ans = 0;
  for(ll i = 0; i <= LIMIT; ++i) {
    ll sum = i;
    ll cap = W-dp[i];
    if(cap < 0) continue;
    for(Item item : items) {
      if(item.m < MAX_V) continue;
      ll use = min(cap/item.w, item.m-MAX_V);
      sum += use*item.v;
      cap -= use*item.w;
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4084
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
vector<vector<int> > edge(1000);
vector<int> x(1000);

int memo[1000];
int dfs(int par, int ver) {
  vector<int> child;
  int sz = 0;
  for (int c : edge[ver]) if (c != par) {
    if (dfs(ver, c) == INF) return INF;
    child.push_back(c);
    ++sz;
  }
  vector<vector<int> > dp(sz+1, vector<int>(x[ver]+1, INF));
  dp[0][0] = 0;
  REP(i, sz) REP(j, x[ver]+1) {
    if (j - memo[child[i]] >= 0) dp[i+1][j] = min(dp[i+1][j], dp[i][j-memo[child[i]]] + x[child[i]]);
    if (j - x[child[i]] >= 0) dp[i+1][j] = min(dp[i+1][j], dp[i][j-x[child[i]]] + memo[child[i]]);
  }
  int ans = INF;
  REP(i, x[ver]+1) ans = min(ans, dp[sz][i]);
  memo[ver] = ans;
  return memo[ver];
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  if (n == 1) {
    cout << "POSSIBLE" << '\n';
    return 0;
  }
  REP(i, n-1) {
    int p; cin >> p;
    --p;
    edge[p].push_back(i+1);
    edge[i+1].push_back(p );
  }
  REP(i, n) cin >> x[i];
  cout << (dfs(-1, 0) == INF? "IMPOSSIBLE" : "POSSIBLE") << '\n';
  return 0;
}


Measured memory_bytes: 1364
r, c = list(map(int, input().split()))
t = [[int(x) for x in input().split()] for _ in range(r)]
for i in t:
    i.append(sum(i))
u = list(map(list, zip(*t)))
for i in u:
    i.append(sum(i))
for i in list(map(list, zip(*u))):
    print(' '.join(map(str, i)))



Measured memory_bytes: 5900
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 100050
int fa[N],a[N],n,m,ans;
int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}
int main() {
	int i;
	scanf("%d%d",&n,&m);
	int x,y;
	for(i=1;i<=n;i++) scanf("%d",&a[i]),fa[i]=i;
	for(i=1;i<=m;i++) {
		scanf("%d%d",&x,&y);
		int dx=find(x),dy=find(y);
		if(dx!=dy) fa[dx]=dy;
	}
	for(i=1;i<=n;i++) if(find(a[i])==find(i)) ans++;
	printf("%d\n",ans);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;
  cout<<(N-1)/2<<endl;
  return 0;
}


Measured memory_bytes: 764
N=int(input())
w=[None]*N
a=1
for i in range(N):
    w[i]=input()
for i in range(1,N):
    if w[i-1][-1]==w[i][0]:
        for j in range(0,i-1):
            if w[j]==w[i]:
                a=0
                break
    else:
        a=0
    if a==0:
        break
if a==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
S = int(input())
list = [S]
cnt = 2

def solve(n):
	if n % 2 == 0:
		return n // 2
	else:
		return 3 * n + 1

while True:
	n = solve(S)
	if not (n in list):
		list.append(n)
		S = n
		cnt += 1
	else:
		print(cnt)
		exit()

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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N; cin >> N;
    ll a[N]; for(int i=0;i<N;i++) cin >> a[i];
    map<ll,ll> ma;
    ll sum=0;
    for(int i=0;i<N;i++){
        ma[a[i]]++;
        sum+=a[i];
    }
    int q; cin >> q;
    while(q--){
        ll b,c; cin >> b >> c;
        sum-=b*ma[b];
        sum+=c*ma[b];
        ma[c]+=ma[b];
        ma[b]=0;
        cout << sum << endl;
    }

}


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

#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL)
// #define int long long
#define endl '\n'

using namespace std;

const int N = 2e5 + 77;
int A[N];
string s;

int32_t main()
{
    int n  ; cin >> n ;
    for(int i = 0; i < n ; ++i) cin >> A[i+1];
    int ans = 1e8;
    for(int p = 1 ; p <= 100 ; ++p){
        int sum = 0;
        for(int i = 1 ; i <= n ; ++i){
            sum += (A[i]-p) * (A[i]-p);
        }
        ans = min(ans,sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a, b;
    cin >> a >> b;
    char res = 'x';
    if (a + b == 15) {
        res = '+';
    } else if (a * b == 15) {
        res = '*';
    }
    cout << res << '\n';
 
    return 0;
}

Measured memory_bytes: 892
//include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#define LL long long
#define rep(i,x,y) for (int i=x;i<=y;++i)

using namespace std;
const int N  =  2e5+233;

void read(int &x)
{
	int f=1;
	x=0;
	char ch=getchar();
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return ;
}
int n,a[N],b[N],c[N];
LL ans;

int main()
{
	read(n);
	rep(i,1,n) read(a[i]),b[i]=b[i-1]+a[i],c[i]=c[i-1]^a[i];
	rep(i,1,n)
	{
		int l=i,mid,r=n,tmp=0;
		while (l<=r)
		{
			mid=l+r>>1;
			if (b[mid]-b[i-1]==(c[mid]^c[i-1])) tmp=mid,l=mid+1;
			else r=mid-1;
		}
		int len=tmp-i+1;
		ans+=len;
	}
	printf("%lld",ans);
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    int n, w;
    cin >> n >> w;
    vector<int> value(n), weight(n);
    ll total_value_sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> weight[i] >> value[i];
        total_value_sum += value[i];
    }
    vector<ll> dp(total_value_sum + 1, 1e18L+5);
    dp[0]=0;
    for (int item = 0; item < n; item++)
    {
        for(ll value_curr=total_value_sum;value_curr>=value[item];value_curr--)
        {
            dp[value_curr]=min(dp[value_curr],weight[item]+dp[value_curr-value[item]]);
        }
    }
    ll ans=INT_MIN;
    for(ll i=0;i<=total_value_sum;i++)
    {
        if(dp[i]<=w)
            ans=max(ans,i);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
int c[10000];
int i,n,max,min;
long long sum;
scanf("%d",&n);
scanf("%d",&c[0]);
sum=c[0];
max=c[0];
min=c[0];

for(i=1;i<n;i++){
scanf("%d",&c[i]);
sum+=c[i];
if(max<c[i]) max=c[i];
if(min>c[i]) min=c[i];
}

printf("%d %d %lld\n",min,max,sum);

return 0;
}


Measured memory_bytes: 2140
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        sc.close();
        double sum = 0;
        for (int i = 1; i <= n; i++) {
            if (i >= k) {
                sum += 1;
                continue;
            }
            int cnt = 1;
            while (k > i * Math.pow(2, cnt)) {
                cnt++;
            }
            sum += Math.pow(0.5, cnt);
        }
        sum /= n;
        System.out.println(sum);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int a,b,c,k,j;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>a>>b>>c;
while(b<a){
   k=0;
    k++;
    j++;
    b+=k;
}
if(c>j)cout<<c-j;
else cout<<0;
return 0;}



Measured memory_bytes: 3616
firstMountainHeight  = 0
secondMountainHeight = 0
thirdMountainHeight  = 0
while 1:
	try :
		i = int(raw_input())
		if firstMountainHeight<i:
			thirdMountainHeight=secondMountainHeight
			secondMountainHeight=firstMountainHeight
			firstMountainHeight=i
		elif secondMountainHeight<i:
			thirdMountainHeight=secondMountainHeight
			secondMountainHeight=i
		elif thirdMountainHeight<i:
			thirdMountainHeight=i
    	except:
	    	print"%d" % (firstMountainHeight)
	    	print"%d" % (secondMountainHeight)
	    	print"%d" % (thirdMountainHeight)
	    	break

Measured memory_bytes: 4208
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,m) = get!(usize, usize);
    let a = get!(usize; m);
    let mut pos = vec![true;n+1];
    for e in a {
        pos[e] = false;
    }
    let mut dp = vec![0; n+1];
    dp[0] = 1;
    if pos[1] {
        dp[1] = 1;
    }
    let mo = 1_000_000_007;
    for i in 0..n-1 {
        if pos[i+2] {
            dp[i+2] = dp[i+1] + dp[i];
            dp[i+2] %= mo;
        }
    }
    println!("{}", dp[n]);
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

#include <bits/stdc++.h>

using namespace std;

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

	ll a, b, k;
	cin >> a >> b >> k;
	cout << max(0LL, a - k) << " " << max(0LL, b - (max(0LL, k - a))) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  in x;
  cin>>x;
  in sum=100;
  for(int i=0;;){
    i++;
    sum+=(sum/100);
    if(sum>=x){
      cout<<i<<endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3632
using System;
using System.Linq;

namespace Volume0
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            while((s = Console.ReadLine()) != null)
            {
                double[] i = s.Split(' ')
                              .Select(e => double.Parse(e))
                              .ToArray();
                var x = (i[2] * i[4] - i[1] * i[5]) / (i[0] * i[4] - i[1] * i[3]);
                var y = (i[5] * i[0] - i[2] * i[3]) / (i[0] * i[4] - i[3] * i[1]);
                Console.WriteLine("{0:F3} {1:F3}", x, y);
            }
        }
    }
}

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

int n, m ;

int main(){
    #define NAME "abc112d"
    //freopen(NAME".inp", "r", stdin) ; freopen(NAME".out", "w", stdout) ;

    ios_base :: sync_with_stdio(false) ;

    cin >> n >> m ;

    int ans = -1 ;

    for (int i = 1; i * i <= m; ++ i){
        if(m % i) continue ;
        if(m / i >= n) ans = max(ans, i) ;
        if(i >= n) ans = max(ans, m / i) ;
    }

    cout << ans << endl ;

    return 0 ;
}

Measured memory_bytes: 256
//noob
#include<bits/stdc++.h>
using namespace std;
#define fori(x) for(int i=0;i<x;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long int 
#define ld long double
#define ull unsigned long long int
#define pi acos(-1)
#define test() int T,t=1;cin>>T;
#define size 2e9
typedef vector<int> VI;
typedef pair<int,int> PII;


void solve()
{
   //freopen("input.txt","r",stdin);
	ll n,b=0,sum=0;cin>>n;
	fori(n){
		ll a;cin>>a;
		if(a>b) b=a;
		else sum+=b-a;
	}
	cout<<sum<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);

solve();


	return 0;
}

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

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

    ll N, M;
    cin >> N >> M;

    if(N == 1 && M == 1) {
        cout << 1 << endl;
        return 0;
    }

    if(N == 1 || M == 1) {
        cout << N * M - 2LL << endl;
        return 0;
    }

    cout << N * M - 2LL * (N + M) + 4LL << endl;
}

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

int main()
{
	while ( true )
	{
		int m,n; cin>>m>>n;
		if ( m==0 && n==0 )
			break;
		vector<int> C(n);		//	Ô
		for ( int i=0; i<n; i++ )
			cin>>C[i];
		vector<int> U(m,-1);	//	ã
		vector<int> D(m,-1);	//	º
		vector<int> S;			//	ÔÒ¿
		vector<int> ans;		//	¦

		for ( int t=0; (int)ans.size()<n; t++ )
		{
			//	oÉ
			for ( int i=0; i<m; i++ )
			{
				if ( D[i]>=0 )
					if ( --C[D[i]]<=0 )
						ans.push_back(D[i]),
						D[i] = -1;
				if ( U[i]>=0 )
					if ( --C[U[i]]<=0 && D[i]==-1 )
						ans.push_back(U[i]),
						U[i] = -1;
			}

			//	üÉ
			if ( t%10==0 && t/10<n )
				S.push_back( t/10 );
			if ( S.size()>0 )
			{
				bool f = false;
				for ( int i=0; i<m && !f; i++ )
					if ( U[i]==-1 && D[i]==-1 )
						U[i] = S[0],
						f = true;
				if ( !f )
				{
					int mn=99999999;
					int mi;
					for ( int i=0; i<m; i++ )
						if ( D[i] == -1 )
						if ( C[U[i]] >= C[S[0]] )
							if ( C[U[i]]-C[S[0]] < mn )
								mn = C[U[i]]-C[S[0]],
								mi = i;
					if ( mn<99999999 )
						D[mi] = S[0],
						f = true;
				}
				if ( !f )
				{
					int mn=99999999;
					int mi;
					for ( int i=0; i<m; i++ )
						if ( D[i]==-1 )
							if ( C[S[0]]-C[U[i]] < mn )
								mn = C[S[0]]-C[U[i]],
								mi = i;
					if ( mn<99999999 )
						D[mi] = S[0],
						f = true;
				}

				if ( f )
					S.erase(S.begin());
			}
		}

		for ( int i=0; i<(int)ans.size(); i++ )
			cout << (i>0?" ":"") << ans[i]+1;
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
from math import inf


n = int(input())
A = list(map(int, input().split()))

dp = [[-inf] * 3  for _ in range(n + 1)]
k = 1 + n % 2
dp[0][0] = 0
for i in range(n):
    for j in range(k + 1):
        if j < k:
            dp[i + 1][j + 1] = dp[i][j]
        now = dp[i][j]
        if (i + j) % 2 == 0:
            now += A[i]
        dp[i + 1][j] = max(dp[i + 1][j], now)
print(dp[n][k])


Measured memory_bytes: 58476
// 2017/11/20 Tazoe

#include <iostream>
#include <queue>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

class SP{
public:
	string p;
	int n;		// ?????°

	bool is_over(string q)		// ????????????
	{
		return p==q;
	}

	int find0()		// 0?????¢???
	{
		for(int i=0; i<8; i++){
			if(p[i]=='0')
				return i;
		}

		return -1;
	}

	void swp1()		// ???????????????
	{
		int i0 = find0();

		if(4<=i0 && i0<=7){
			swap(p[i0], p[i0-4]);
		}
	}

	void swp2()		// ???????????????
	{
		int i0 = find0();

		if(0<=i0 && i0<=3){
			swap(p[i0], p[i0+4]);
		}
	}

	void swp3()		// ???????????????
	{
		int i0 = find0();

		if(i0!=0 && i0!=4){
			swap(p[i0], p[i0-1]);
		}
	}

	void swp4()		// ???????????????
	{
		int i0 = find0();

		if(i0!=3 && i0!=7){
			swap(p[i0], p[i0+1]);
		}
	}
};


int main()
{
	map<string, int> memo2;

	while(true){
		string c;
		cin >> c;

		if(cin.eof())
			break;

		string q = c;

		for(int i=1; i<8; i++){
			cin >> c;

			q += c;
		}

		if(memo2.find(q)!=memo2.end()){
			cout << memo2[q] << endl;
			continue;
		}

		queue<SP> que;			// ?????\???
		map<string, bool> memo;		// ?????¢

		SP now;
		now.p = "01234567";
		now.n = 0;
		que.push(now);
		memo[now.p] = true;

		while(!que.empty()){		// ?????\???????????????????????§
			now = que.front();
			que.pop();
			if(memo2.find(now.p)==memo2.end()){
				memo2[now.p] = now.n;
			}

			if(now.is_over(q)){
				cout << now.n << endl;
				break;
			}

			SP nex1 = now;  nex1.swp1();  nex1.n++;
			if(memo.find(nex1.p)==memo.end()){
				que.push(nex1);
				memo[nex1.p] = true;
			}

			SP nex2 = now;  nex2.swp2();  nex2.n++;
			if(memo.find(nex2.p)==memo.end()){
				que.push(nex2);
				memo[nex2.p] = true;
			}

			SP nex3 = now;  nex3.swp3();  nex3.n++;
			if(memo.find(nex3.p)==memo.end()){
				que.push(nex3);
				memo[nex3.p] = true;
			}

			SP nex4 = now;  nex4.swp4();  nex4.n++;
			if(memo.find(nex4.p)==memo.end()){
				que.push(nex4);
				memo[nex4.p] = true;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 7652
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int N = S.size();
    //    cout << N << endl;
    string arr1 = S.substr(0, (N - 1) / 2);
    string rev1 = S.substr(0, (N - 1) / 2);
    reverse(rev1.begin(), rev1.end());
    string arr2 = S.substr((N + 3) / 2 - 1);
    string rev2 = S.substr((N + 3) / 2 - 1);
    reverse(rev2.begin(), rev2.end());

    //    cout << arr1 << endl;

    //    cout << arr2 << endl;

    if (arr1 == rev1 && arr1 == rev2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())

s = []
for i in range(N):
    s.append(int(input()))


ans = sum(s)
s.sort()

if ans % 10 == 0:
    for i in range(len(s)):
        if ans % 10 != 0:
            break
        else:
            tmp = s[i]
            if (ans - s[i]) % 10 == 0:
                continue
            else:
                ans -= s[i]
                break

if ans % 10 == 0:
    print(0)
else:
    print(ans)

Measured memory_bytes: 3064
N, K = map(int, input().split())

num = [0]*K
for n in range(1, N+1):
  num[n%K] += 1
  
res = 0

for a in range(K):
  b = (K - a) % K
  c = (K - a) % K
  if (b+c) % K != 0:
    continue
  res += num[a] * num[b] * num[c]
  
print(res)

Measured memory_bytes: 4596
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll x, y;
    cin >> x >> y;

    for (ll i = 0; i <= x; i++)
    {
        if ((2 * i + 4 * (x - i)) == y)
        {
            cout << "Yes" << endl;
            exit(0);
        }
    }
    


    cout << "No" << endl;

}

Measured memory_bytes: 3636
#include<stdio.h>

int main(){
  int array[200][200];
  
  int number;
  scanf("%d",&number);
  

  int i;
  int j;

  
  int me;
  int count;
  int u;

 for(i=0;i<number;i++){
    for(j=0;j<number;j++){
      array[i][j]=0;
    }
  }

  
  for(i=0;i<number;i++){
    scanf("%d",&me);
    scanf("%d",&count);

    for(j=0;j<count;j++){
      scanf("%d",&u);


      array[me][u]=1;

    
    }
  }


  for(i=0;i<number;i++){
    for(j=0;j<number;j++){
      if(j==number-1){printf("%d",array[i+1][j+1]);}
      else{ printf("%d ",array[i+1][j+1]);}
    }
    printf("\n");
  }

  
  
  return 0;}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define Pct puts("------ Yes ------");
#define rep(a, b, c) for(int a = (b); a <= (c); ++ a)
#define per(a, b, c) for(int a = (b); a >= (c); -- a)
#define fir first
#define sec second
#define ls son[u][0]
#define rs son[u][1]
#define eps 1e-8
#define PI acos(-1.0)
using namespace std;
template <class T> void rd(T &x){ x = 0; int f = 1; char ch = getchar(); while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); } while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar(); x *= f; }

typedef long long ll;
const int N = 4e3 + 5;
const int mod = 998244353;
int n;
ll f[N][N], fac[N], fin[N];
char s[N];

void add(ll &a, ll b){ a = (a + b) % mod; }

ll Inv(ll x){ return x <= 1 ? 1 : Inv(mod % x) * (mod - mod / x) % mod; }

ll C(ll n, ll m){ return fac[n] * fin[m] % mod * fin[n - m] % mod; }

int main(){
	scanf("%s", s + 1);
	n = strlen(s + 1);

	fac[0] = 1; rep(i, 1, n) fac[i] = fac[i - 1] * i % mod;
	fin[n] = Inv(fac[n]);
	per(i, n, 1) fin[i - 1] = fin[i] * i % mod;
	
	f[0][0] = 1;
	rep(i, 1, n){
		rep(j, 0, i - 1){
			int r = j, b = i - 1 - j;
			if(s[i] == '0'){
				add(f[i][r + 1], f[i - 1][r]);
				if(b) add(f[i][r + 2], f[i - 1][r]);
			}
			else if(s[i] == '1'){
				add(f[i][r], f[i - 1][r]);
				add(f[i][r + 1], f[i - 1][r]);
			}
			else{
				if(r) add(f[i][r - 1], f[i - 1][r]);
				add(f[i][r], f[i - 1][r]);
			}
		}
	}
	
	ll ans = 0;
	rep(i, 0, n) add(ans, C(n, i) * f[n][i] % mod);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 60672
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n,i,s=0;
cin>>n;
for(i=1; i<=n; i++){
        if(i%3 != 0 && i%5 != 0){
    s=s+i;}

}
cout<<s<<endl;
return 0;}


Measured memory_bytes: 3652
n = int(input())
s = list(map(int,input().split()))
 
maxans = 0
minans = 0
 
color = [0]*8
red = 0
 
for i in s:
    if i>=3200:
        red += 1
    else:
        color[i//400] = 1
        
x = sum(color)
 
if x == 0:
    print(1,red)
else:
    print(x,x+red)

Measured memory_bytes: 9180
def readints(): return map(int,input().split())

N, T = readints()
a = list(readints())

mdiff = 0
mi = 1145141919
for x in a:
    mi = min(mi, x)
    mdiff = max(mdiff, x - mi)

mi = 1145141919
ans = 0
for x in a:
    mi = min(mi, x)
    ans += (x - mi == mdiff)

print(ans)

Measured memory_bytes: 14252
import sys
# input = sys.stdin.readline
inf = 10 ** 18

N, K = map(int, input().split())

targets = [0] * N
for i in range(N):
    tmp = i + 1
    for j in range(64):
        if (tmp << j) >= K: break
    targets[i] = j

ans = 0
for i in range(N):
    ans += (0.5 ** targets[i])
ans = ans / N

print(ans)

Measured memory_bytes: 3828
import numpy as np

h, w = tuple(map(int, input().split()))
matrix = np.zeros((h, w), dtype=bool)
for i in range(h):
    row = np.array(list(input()))
    matrix[i, :] = row == "."

for i in range(h)[::-1]:
    if np.all(matrix[i, :]):
        matrix = np.delete(matrix, i, 0)

for i in range(w)[::-1]:
    if np.all(matrix[:, i]):
        matrix = np.delete(matrix, i, 1)

matrix = np.where(matrix, ".", "#")
for row in matrix:
    for e in row:
        print(e, end="")
    print()


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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	int m,d;
	cin>>m>>d;
	int ans = 0;
	for(int i=2;i<=9;i++){
		for(int j=2;j<=9;j++){
			int cur = i + j*10;
			if(cur > d)continue;
			if(i * j <= m)ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define rep(a) for(int i=0;i<a;i++)
#define nrep(a,b) for(int i=a;i<b;i++)
#define mrep(a) for(int i=a;i>=0;i--)
#define ll long long
#define INF 1145141919
using namespace std;

int main(){
	ll n, m; cin >> n >> m;
	ll ans_x=0, ans_y=0, x, y, ans;
	ll mod = 1000000007;
	rep(n){
		cin >> x;
		ans_x += (x*(i - (n - 1 - i)));
		ans_x %= mod;
	}
	rep(m){
		cin >> y;
		ans_y += (y*(i - (m - 1 - i)));
		ans_y %= mod;
	}
	ans = (ans_x*ans_y) % mod;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

int f[105][5][2];

ll p[105][11];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 5; j++) {
            for (int k = 0; k < 2; k++) {
                cin >> f[i][j][k];
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= 10; j++) {
            cin >> p[i][j];
        }
    }

    ll ans = -1145141919;
    for (int i = 1; i < 1024; i++) {
        ll tmp = 0;
        for (int j = 0; j < n; j++) {
            int cnt = 0;
            for (int k = 0; k < 10; k++) {
                if (i & (f[j][k / 2][k % 2] << k)) {
                    cnt++;
                }
            }
            tmp += p[j][cnt];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef pair<int,int> P;

int a[15];
int b[15];
int dp[16][10001]; //[????????°][????????°]->??????
set<P> S;

int main(){
    int N,M,K;
    cin>>N>>M>>K;
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    for(int i=0;i<N;i++){
        cin>>b[i];
    }

    for(int i=1;i<=N;i++){
        int ai=a[i-1],bi=b[i-1];
        for(int k=i;k>0;k--){
            S.clear();
            for(int n=0;n<bi;n++) S.insert(P(dp[k-1][10000-n]+n*ai,10000-n));
            for(int m=10000;m>=0;m--){
                S.erase(P(dp[k-1][m+1]+(10000-m-1)*ai,m+1));
                if(m-bi>=0) S.insert(P(dp[k-1][m-bi]+(10000-m+bi)*ai,m-bi));
                int maximum=(*S.rbegin()).first-(10000-((*S.rbegin()).second))*ai+(m-(*S.rbegin()).second)*ai;
                dp[k][m]=max(dp[k][m],maximum);
            }
        }
    }
    int ans=0;
    for(int m=0;m<=M;m++) ans=max(ans,dp[K][m]+M-m);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2248
import Control.Applicative ((<$>))
import Data.Bool (bool)
import Data.List (sort)

main :: IO ()
main = solve <$> sort <$> map read <$> words <$> getLine >>= putStrLn

solve :: [Int] -> String
solve [e1, e2, e3, e4] = bool "no" "yes" $ e1 == e2 && e3 == e4



Measured memory_bytes: 3664
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextString() string {
	sc.Scan()
	i := sc.Text()
	return i
}

//not sort
func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	s := make([][]int, 4)
	for i := 0; i < 4; i++ {
		s[i] = make([]int, 13)
	}
	for i := 0; i < n; i++ {
		a, b := nextString(), nextInt()
		if a == "S" {
			s[0][b-1] = 1
		} else if a == "H" {
			s[1][b-1] = 1
		} else if a == "C" {
			s[2][b-1] = 1
		} else if a == "D" {
			s[3][b-1] = 1
		}
	}
	for i := 0; i < 4; i++ {
		for j := 0; j < 13; j++ {
			if s[i][j] == 0 {
				if i == 0 {
					fmt.Printf("S %d\n", j+1)
				} else if i == 1 {
					fmt.Printf("H %d\n", j+1)
				} else if i == 2 {
					fmt.Printf("C %d\n", j+1)
				} else if i == 3 {
					fmt.Printf("D %d\n", j+1)
				}
			}
		}
	}

}



Measured memory_bytes: 1060
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
p = [list(map(int, input().split()+[i])) for i in range(m)]

p.sort()
cnt = 0
pre = -1

for city in p:
    if city[0] == pre:
        cnt = cnt + 1
    else:
        pre = city[0]
        cnt = 1

    city.append("{:0>6}{:0>6}".format(city[0], cnt))

p.sort(key = lambda x: x[2])

for city in p:
    print(city[3])

Measured memory_bytes: 38808
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

string s;
int N;

void sanity()
{
    if (s[0] == '0' || s.back() == '1') cout << -1 << endl, exit(0);
    REP(i, N - 1) if (s[i] != s[N - i - 2]) cout << -1 << endl, exit(0);
    return;
}

int main()
{
    cin >> s;
    N = s.length();
    sanity();

    if (N == 2)
    {
        cout << "1 2" << endl;
        return 0;
    }
    if (N == 3)
    {
        cout << "1 2" << endl;
        cout << "2 3" << endl;
        return 0;
    }

    FOR(i, 2, N / 2) cout << 1 << " " << i << endl;

    int head = 1;
    FOR(i, N / 2, N + 1)
    {
        cout << head << " " << i << endl;
        if (s[i - 2] == '1') head = i;
    }
}


Measured memory_bytes: 1488
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
          if(n/i==i)
            c++;
          else
            c+=2;
        }

    }

    
    return  c;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   
   int n;
   cin>>n;
   vector<int> v;
   while(n--)
   {
    int h;
    cin>>h;
    v.push_back(h);
   }
   sort(v.begin(),v.end());
   cout<<v[v.size()-1]-v[0];




 return 0;
}








Measured memory_bytes: 3644
# -*- coding: utf-8 -*-
import sys
from itertools import combinations
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    n=int(input())
    A=list(map(int,input().split()))
    s=set()
    for i in range(2**n):
        tmp=0
        for j in range(n):
            if (i>>j)&1:
                tmp+=A[j]
        s.add(tmp)
    q=int(input())
    m=list(map(int,input().split()))
    for x in m:
        print('yes' if x in s else 'no')
        


if __name__ == '__main__':
    main()



Measured memory_bytes: 5696
<?php
  function gcd($a, $b) {
    if ($a % $b == 0) {
      return $b;
    } else {
      return gcd($b, $a % $b);
    }
  }
  
  function lcm($a, $b) {
    return $a * $b / gcd($a,$b);
  }

  fscanf(STDIN, "%d %d", $a, $b);
  echo lcm($a, $b) . "\n";
?>

Measured memory_bytes: 4604
#include<stdio.h>
int main(void)
{
	int x,a,b,c,d;
	scanf("%d%d%d",&x,&a,&b);
	if(x<a) c=a-x;
	else c=x-a;
	if(x<b) d=b-x;
	else d=x-b;
	if(c<d) printf("A\n");
	else printf("B\n");
	return 0;
}

Measured memory_bytes: 128
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int h, w;
    cin >> h >> w;
    auto a = initVec2<bool>(h, w, true);
    rep(i, h) rep(j, w){
        char c;
        cin >> c;
        if(c == '#'){
            a[i][j] = false;
        }
    }

    auto x = initVec2<int>(h, w);
    rep(i, w){
        int pos = -1;
        int cnt = 0;
        rep(j, h){
            if(not a[j][i]){
                if(pos == -1){
                    continue;
                }
                for(int k = pos; k < j; k++){
                    x[k][i] = cnt;
                }
                cnt = 0;
                pos = -1;
                continue;
            }
            if(pos == -1){
                pos = j;
            }
            cnt++;
        }
        if(pos != -1){
            for(int k = pos; k < h; k++){
                x[k][i] = cnt;
            }
        }
    }

    auto y = initVec2<int>(h, w);
    rep(i, h){
        int pos = -1;
        int cnt = 0;
        rep(j, w){
            if(not a[i][j]){
                if(pos == -1){
                    continue;
                }
                for(int k = pos; k < j; k++){
                    y[i][k] = cnt;
                }
                cnt = 0;
                pos = -1;
                continue;
            }
            if(pos == -1){
                pos = j;
            }
            cnt++;
        }
        if(pos != -1){
            for(int k = pos; k < w; k++){
                y[i][k] = cnt;
            }
        }
    }

    int ans = 0;
    rep(i, h) rep(j, w){
        ans = max(ans, x[i][j] + y[i][j] - 1);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 63488
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = next()
    var s = 0
    n.forEach {
        s += it.toString().toInt()
    }

    println(if (n.toInt() % s == 0) "Yes" else "No")
}

fun next() = readLine()!!

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 33692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main() {
    vector<int> V(3);
    cin >> V[0] >> V[1] >> V[2];

    sort(V.begin(), V.end());
    int count = 0;
    count += V[2] - V[1];
    V[1] += count; V[0] += count;

    if((V[2] - V[0]) % 2 == 0 ) count += (V[2] - V[0]) / 2;
    else count += (V[2] - V[0]) / 2 + 2;
    cout << count << endl;
}

Measured memory_bytes: 3548
def resolve():
    N, K = map(int, input().split())
    h = [int(i) for i in input().split()]

    dp = [0, abs(h[1] - h[0])]
    for i in range(2, N):
        dp.append(
            min(dp[i - j] + abs(h[i] - h[i - j]) for j in range(1, min(K + 1, i + 1)))
        )
    print(dp[N - 1])


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 58848
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
  long long n,p;
  cin >> n >> p;
  if (n==1){
    cout << p << endl;
  }
  else{
    long long ans;
    ans=1;
    for (int i = 1; pow(i,n)<=p ; i++) {
      long long tmp;
      tmp=pow(i,n);
      if ( p % tmp ==0){
        ans=i;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256