akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#define MAXN 2010

int n,m,q;
int a[MAXN][MAXN];
int s1[MAXN][MAXN],s2[MAXN][MAXN],s3[MAXN][MAXN];

int getS1(int x1,int y1,int x2,int y2){ return s1[x2][y2]-s1[x1-1][y2]-s1[x2][y1-1]+s1[x1-1][y1-1]; }
int getS2(int x1,int y1,int x2,int y2){ return s2[x2][y2]-s2[x1-1][y2]-s2[x2][y1-1]+s2[x1-1][y1-1]; }
int getS3(int x1,int y1,int x2,int y2){ return s3[x2][y2]-s3[x1-1][y2]-s3[x2][y1-1]+s3[x1-1][y1-1]; }

int main(){
#ifdef DEBUG
	freopen("C.in","r",stdin);
#endif
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++){
		static char str[MAXN];
		scanf("%s",str+1);
		for(int j=1;j<=m;j++)
			a[i][j]=str[j]-'0';
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			s1[i][j]=a[i][j];
			if(a[i][j] && a[i][j+1]) s2[i][j]=1;
			if(a[i][j] && a[i+1][j]) s3[i][j]=1;
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			s1[i][j]+=s1[i-1][j]+s1[i][j-1]-s1[i-1][j-1];
			s2[i][j]+=s2[i-1][j]+s2[i][j-1]-s2[i-1][j-1];
			s3[i][j]+=s3[i-1][j]+s3[i][j-1]-s3[i-1][j-1];
		}
	while(q--){
		int x1,y1,x2,y2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		printf("%d\n",getS1(x1,y1,x2,y2)-getS2(x1,y1,x2,y2-1)-getS3(x1,y1,x2-1,y2));
	}
	return 0;
}


Measured memory_bytes: 64768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m,a[1000005];
int main(){
	cin>>n>>m;
	repn(i,m){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+m+1);
	vector<int>vec;
	for(int i=2;i<=m;i++) vec.pb(a[i]-a[i-1]);
	SORT(vec);
	int need = max(0,m-n);
	int ans = 0;
	for(int i=0;i<need;i++){
		ans+=vec[i];
		}cout<<ans<<endl;
		}

Measured memory_bytes: 1276
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>

using namespace std;

typedef pair<int,int> PII;

char m[100][100];

int main(){

    int N,M;

    while(1){

    cin >> N >> M;

    if(N==0 && M==0)break;

    for(int i=0;i<N;++i)
        for(int j=0;j<M;++j)
            cin >> m[i][j];

    int cnt=0;

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

            if(m[i][j]!=0){

                char c = m[i][j];

                queue<PII> q;

                q.push(make_pair(i,j));

                m[i][j]=0;

                while(!q.empty()){

                    PII p = q.front(); q.pop();

                    const int d[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};

                    for(int k=0;k<4;++k){

                        int x = p.first+d[k][0];
                        int y = p.second+d[k][1];

                        if(0<=x && x<N && 0<=y && y<M && m[x][y]==c){

                            m[x][y] = 0;
                            q.push(make_pair(x,y));

                        }

                    }

                }

                ++cnt;
            }

        }
    }

    cout << cnt << endl;

    }

    return 0;

}

Measured memory_bytes: 1224
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vll = V<ll>;
using VVll = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

const double PI = acos(-1);
const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n;
    cin >> n;
    V<Pii> v(n);
    REP(i, n) {
        int x,y;
        cin >> x >> y;
        v[i] = make_pair(x, y);
    }

    double sum = 0;
    int cnt = 0;
    Vi p(n);
    REP(i, n) {
        p[i] = i;
    }
    do {
        REP(i, n-1) {
            double x = v[p[i]].first - v[p[i+1]].first;
            double y = v[p[i]].second - v[p[i+1]].second;
            sum += sqrt(x*x + y*y);
        }
        cnt++;
    } while( next_permutation(ALL(p)) );
    printf("%.7f\n", sum/cnt);

    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#pragma GCC optimize("03")
#define ll long long
#define ld long double
#define fi first
#define se second

using namespace std;

int main() {
//	ifstream cin("tst.in");
//	ofstream out("tst.out");
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	string s;
	cin >> s;
	if (s.size() == 2)
		cout << s;
	else {
		reverse(s.begin(), s.end());
		cout << s;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const ll MOD=1e9+7;
struct Point
{
	int x,y;
}a[100005];
int n,m,x[100005],y[100005],sa[100005];
ll c[100005];
bool cmp(int x,int y)
{
	return a[x].y<a[y].y;
}
bool cmp2(Point a,Point b)
{
	return a.x<b.x||(a.x==b.x&&a.y>b.y);
}
void add(int p,ll v)
{
	while(p<=m)
	{
		c[p]=(c[p]+v)%MOD;
		p+=p^(p&(p-1));
	}
}
ll sum(int p)
{
	ll ans=0;
	while(p)
	{
		ans+=c[p];
		p&=p-1;
	}
	return ans%MOD;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&x[i]);
	for(int i=1;i<=m;i++)scanf("%d",&y[i]);
	while(n&&x[n]>y[m])n--;
	int st=1;
	while(st<=n&&x[st]<y[1])st++;
	for(int i=1;st+i-1<=n;i++)x[i]=x[st+i-1];
	n-=st-1;
	int now=1;
	for(int i=1;i<=n;i++)
	{
		while(y[now]<x[i])now++;
		a[i].x=x[i]-y[now-1];
		a[i].y=y[now]-x[i];
		sa[i]=i;
	}
	sort(a+1,a+n+1,cmp2);
	sort(sa+1,sa+n+1,cmp);
	m=now=0;
	for(int i=1;i<=n;i++)
	{
		if(a[sa[i]].y!=now)m++;
		now=a[sa[i]].y,a[sa[i]].y=m;
	}
	m++;
	add(1,1);
	for(int i=1;i<=n;i++)
	{
		if(a[i].x==a[i-1].x&&a[i].y==a[i-1].y)continue;
		add(a[i].y+1,sum(a[i].y));
	}
	printf("%lld\n",sum(m));
	return 0;
}

Measured memory_bytes: 2560
// 2020.4.15

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

int main() {
    int K, S;
    int ans = 0;

    cin >> K >> S;

    // 全探索は2500の３乗で、ギリギリ間に合わない。

    // 以下はトリッキーな回答。C++だとギリギリセーフ。
    // for (int i = 0; i <= K; i++) {
    //     for (int j = i; j <= K; j++) {
    //         for (int k = j; k <= K; k++) {
    //             if (i + j + k == S) {
    //                 if (i == j and j == k) {
    //                     ans += 1;
    //                 } else if (i == j or j == k) {
    //                     ans += 3;
    //                 } else {
    //                     ans += 6;
    //                 }                    
    //             }
    //         }
    //     }
    // }

    // 正しくは（解説は）下記。
    // k = S - i - jとして、kが<=Kの範囲に収まってるかを調べる。
    for (int i = 0; i <= K; i++) {
        for (int j = 0; j <= K; j++) {
            int k = S - i - j;
            if (0 <= k and k <= K) {
                ans += 1;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {

  int v, i, j, n, a[1001];
  
  // input n
  scanf("%d", &n);
  //input a[]
  for(i = 0;i < n; i++) scanf("%d", &a[i]);

  for(i = 1;i <= n;i++) {
    for(j = 0;j < n; j++) {
      // output
      printf("%d",a[j]);
      if(j + 1 != n) printf(" ");
    }
    printf("\n");
    // insert a[j] into the sorted sequence a[1,...,j-1]
    v = a[i];
    j = i - 1;
    while(j >= 0 && a[j] > v) {
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
  }

  return 0;
}

Measured memory_bytes: 604
#pragma GCC optimize ("-O3")
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
ll NUM = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define zer ll(0)
 

int main()
{

    ll a,b;
    cin>>a>>b;
    ll ans ;
    if(a>2*b)
    {
        ans = a-2*b;
    }
    else
    {
        ans = 0;
    }
    
    cout<<ans;
    
    return 0;
}

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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

int main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vector<ll>arr(n);
    ll f=0,a;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a%2==0){
            if(a%3==0 || a%5==0){

            }
            else{
                f=1;
            }
        }
    }

    if(f){
        cout<<"DENIED";
    }
    else{
        cout<<"APPROVED";
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>

#define roop(i, n) for(int i=0;i<n;i++)

using namespace std;
using ll = long long int;
using ull = unsigned long long;

constexpr ull mod = 1e9+7;
constexpr int N = 13;
ull dp[100010][N];

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	string s;
	cin >> s;
	int i = 0, j = s.size() - 1, ans=0;
	if (s.size() == 1) {
    	cout << 0 << endl;
		return 0;
    }
	if (s.size() % 2 == 0) {
		while(true) {
			if (s[i] != s[j]) {
					ans++;
			}
			i++;
			j--;
			if (j < (s.size() / 2)) {
				break;
			}
		}
	} else {
		while(true) {
			if (s[i] != s[j]) {
					ans++;
			}
			i++;
			j--;
			if ((j < (s.size() / 2) + 1)) {
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

const int mod = 1e9 + 7;
int32_t main() {

    fast

    int s;
    cin >> s;

    //vector<vector<int>>dp(s + 1, vector<int>(s + 1, 0));
    vector<int>dp(s+1,0);
    dp[0]=1;
    for(int i = 3; i <= s; i++) {
        for(int j = 3; j <= i; j++) {
            dp[i] += dp[i - j];
            dp[i] %= mod;
        }
    }
    cout << dp[s];

    return 0;
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
using namespace std;
void max_self(ll &a,ll b){
	a=max(a,b);
}
int main(){ IOS;
	int n,W;
	cin>>n>>W;
	vector<ll>dp(W+1);//dp[i] is the max value of exactly weight i
	for(int i=0;i<n;i++){
		ll w,v;
		cin>>w>>v;
		for(ll weight_already=W-w;weight_already>=0;weight_already--){
			max_self(dp[w+weight_already],dp[weight_already]+v);
	}
	} 
	ll ans=0;
	for(int i=0;i<=W;i++){
		max_self(ans,dp[i]);
	}
	cout<<ans;
}

Measured memory_bytes: 1024
#include <vector>
#include <cassert>
#include <algorithm>
#ifdef _WIN32
inline unsigned int __builtin_clz(unsigned int x) {
	unsigned long r;
	_BitScanReverse(&r, x);
	return 31 - r;
}
#endif

template<class Type>
class SparseTable {
private:
	std::vector<std::vector<Type> > st;
public:
	void init(std::vector<Type> v) {
		int b = 0;
		for (; (1 << b) <= v.size(); b++);
		st.assign(b, std::vector<Type>(1 << b));
		for (int i = 0; i < v.size(); i++) st[0][i] = v[i];
		for (int i = 1; i < b; i++) {
			for (int j = 0; j + (1 << i) <= (1 << b); j++) {
				st[i][j] = std::min(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]);
			}
		}
	}
	Type query(int l, int r) {
		assert(l < r);
		int b = 32 - __builtin_clz(r - l) - 1;
		return std::min(st[b][l], st[b][r - (1 << b)]);
	}
	SparseTable() {}
	SparseTable(std::vector<Type> v) { init(v); }
};
#include <iostream>
#include <algorithm>
using namespace std;
int n; vector<int> a;
int main() {
	cin >> n; a.resize(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<int> b(a);
	reverse(b.begin(), b.end());
	SparseTable<int> st(a), st2(b);
	vector<int> p(n), q(n);
	for (int i = 0; i < n; i++) {
		int l = 0, r = i + 1;
		while (r - l > 1) {
			int m = (l + r) / 2;
			if (st.query(m, i + 1) != a[i]) l = m;
			else r = m;
		}
		if(st.query(l, i + 1) == a[i]) p[i] = l;
		else p[i] = r;
	}
	for (int i = 0; i < n; i++) {
		int l = 0, r = i + 1;
		while (r - l > 1) {
			int m = (l + r) / 2;
			if (st2.query(m, i + 1) != b[i]) l = m;
			else r = m;
		}
		if (st2.query(l, i + 1) == b[i]) q[n - i - 1] = n - l;
		else q[n - i - 1] = n - r;
	}
	long long ret = 0;
	for (int i = 0; i < n; i++) ret += 1LL * (i - p[i] + 1) * (q[i] - i) * a[i];
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 41436
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main(int argc, char *argv[]) {
	int n, a, ans = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		ans += (i % 2 == 0) && (a % 2 != 0);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
from itertools import product

N = int(input())

mod = 10 ** 9 + 7

dp = [[[[0] * 4 for _ in range(4)] for _ in range(4)] for _ in range(N + 1)]
dp[0][3][3][3] = 1

for i, l1, l2, l3 in product(range(N), range(4), range(4), range(4)):
    if dp[i][l1][l2][l3] == 0:
        continue

    for a in range(4):
        if (0, 1, 2) == (l2, l1, a):
            continue
        if (1, 0, 2) == (l2, l1, a):
            continue
        if (0, 2, 1) == (l2, l1, a):
            continue
        if (0, 1, 2) == (l3, l1, a):
            continue
        if (0, 1, 2) == (l3, l2, a):
            continue

        dp[i + 1][a][l1][l2] += dp[i][l1][l2][l3]
        dp[i + 1][a][l1][l2] %= mod

ans = 0
for l1, l2, l3 in product(range(4), range(4), range(4)):
    ans += dp[N][l1][l2][l3]
    ans %= mod
print(ans)


Measured memory_bytes: 3444
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int INF = 1e9 + 7;

int solve(vector<int> &v){
  int low = v[0], ans = -INF;
  for(int i = 1; i < v.size(); ++i){
    ans = max(ans, v[i] - low);
    low = min(low, v[i]);
  }
  return ans;
}
 
int main() {
  int N; cin >>N;
  vector<int> v(N);
  REP(i, N) cin >>v[i];
  cout <<solve(v) <<endl;
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define TRACE
#ifdef TRACE
#define tr(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define tr(...)
#endif

#define ll long long
#define ld long double 
#define endl "\n"
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (ll)(a.size())
#define all(a) a.begin(), a.end() 
#define fr(i,n) for(i=1;i<=n;i++)
#define rp(i,n) for(i=0;i<n;i++)
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)
typedef pair<ll, ll> ii;
typedef vector<ll> vl;
const ll N = 200010;
ll mod=1e9+7;

ll ffmod(ll x, ll y, ll mod)
{
    ll rt=1;
    while(y)
    {
        if(y&1ll) rt=(rt*x)%mod;
        x=(x*x)%mod, y/=2ll;
    }
    return rt;
}

ll dp[N], h[N];

int main()
{
    FIO;
    ll n,i;
    cin>>n;
    fr(i,n) cin>>h[i];
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    for(i=3;i<=n;i++)
        dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    _ = readline()
    As = map(int, readline().split())

    for A in As:
        if A % 2 == 0:
            if (A % 3 != 0) and (A % 5 != 0):
                print('DENIED')
                return
    print('APPROVED')


if __name__ == '__main__':
    main()


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

using namespace std;

using int64 = long long;

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

  int n;
  cin >> n;
  vector<int> ps(n);
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;
    p--;
    ps[p] = i;
  }

  vector<int> xs(n);
  vector<int> ys(n);
  for (int i = 1; i < n; i++) {
    int d = ps[i] - ps[i - 1];
    if (d > 0) {
      ys[i] = ys[i - 1] - 1;
      xs[i] = xs[i - 1] + d + 1;
    } else {
      ys[i] = ys[i - 1] + d - 1;
      xs[i] = xs[i - 1] + 1;
    }
  }

  int x_base = 1;
  int y_base = -ys[n - 1] + 1;
  for (int i = 0; i < n; i++) {
    xs[i] += x_base;
    ys[i] += y_base;
  }

  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << xs[i];
  }
  cout << endl;
  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << ys[i];
  }
  cout << endl;
}


Measured memory_bytes: 896
"use strict";
function Main(input) {
  input = input.split("\n");
  const person = input[1].split(" ");
  const boxes = [];
  
  for(let i=0; i < 9; i++){
      boxes[i] = 0;
  }
    
  for(let personCount=0; personCount < person.length; personCount++){
      const inputValue = parseInt(person[personCount], 10);
      if(inputValue < 400){
          boxes[0] = true;
      }
      else if(inputValue < 800){
          boxes[1] = true;
      }
      else if(inputValue < 1200){
          boxes[2] = true;
	  }
	  else if(inputValue < 1600){
	      boxes[3] = true;
	  }
	  else if(inputValue < 2000){
	      boxes[4] = true;
	  }
	  else if(inputValue < 2400){
	      boxes[5] = true;
	  }
	  else if(inputValue < 2800){
	      boxes[6] = true;
	  }
	  else if(inputValue < 3200){
	      boxes[7] = true;
	  }
	  else if(inputValue <= 4800){
	      boxes[8] += 1;
	  }
  }
  
  let  color = 0;
  for(let colorCount=0; colorCount < 8; colorCount++){
      color += boxes[colorCount];
  }
  
  const max = color + boxes[8];
  let min = color;
  
  if(color === 0 && boxes[8] > 0){
      min = 1;
  }
  console.log(min,max);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<stdio.h>
#include<math.h>

int main(void)
{
  int a,b,c,s,m;
  scanf("%d %d %d",&a,&b,&c);
  s = (a+b+c)/2;

  m = pow(s*(s-a)*(s-b)*(s-c),0.5);

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

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
bool IsUpper (char c)
{
	return (c>64 && c<97);
}
int main()
{
	string x;
	getline(cin,x);
	int len = x.length();
	if (IsUpper(x[0]))
	{
		cout<<x[0];
	}
	for(int i = 1; i<len ;++i)
	{
		if(IsUpper(x[i]) && x[i-1] ==' ')
		cout<<x[i];
	}
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <cstdio>
#include <cstdint>
#define READINT(X) if(ci-cn+16>cm){while((ct=readchar())>='0')(X)=(X)*10+ct-'0';}else{while((ct=*ci++)>='0')(X)=(X)*10+ct-'0';}

using namespace std;
typedef int_fast64_t ll;

unsigned int M = 0, i = 0;
ll d, c, sd = 0, sc = 0;
const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;

inline char readchar() {
    if(ci-cn==cm){fread_unlocked(cn,1,cm,stdin); ci=cn; }
    return *ci++;
}

int main() {
    READINT(M);
    while(i++ != M) {
        d = c = 0;
        READINT(d);
        READINT(c);
        sc += c;
        sd += d * c;
    }
    printf("%lld\n", --sc + --sd / 9);
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.array, std.conv, std.algorithm;

void main() {
    int n = readln.chomp.to!int;
    int[] l = readln.chomp.split.to!(int[]);
    sort(l);
    int sum = 0;
    foreach (i; 0 .. n-2) {
        foreach (j; i+1 .. n-1) {
            sum += count!("a < b")(l[j+1..$], l[i]+l[j]);
        }
    }
    sum.writeln;
}

Measured memory_bytes: 2300
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

  ll x, y;
  cin >> x >> y;

  ll rsl = 0;

  while(true) {
    if(x * powl(2, rsl) > y) {
      cout << rsl << endl;
      return 0;
    }
    ++rsl;
  }
}


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

int main()
{
    float a;
    float b,c;
    int d;
    cin>>b>>c;
    a=(c/2)+(b/2);
    d=a;
    if(a-d<0.5){
        cout<<d;
    }
    else{
        cout<<d+1;
    }

}


Measured memory_bytes: 3688
#include<iostream>

using namespace std;

int main(void){
	int n,S[10003],q,T[503],c=0;
	
	cin>>n;
	for(int i=0;i<n;i++)cin>>S[i];
	
	cin>>q;
	for(int i=0;i<q;i++)cin>>T[i];
	
	for(int i=0;i<q;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(T[i]==S[j]){
				c++;
				break;
			}
		}
	}
	
	cout<<c<<endl;
	
	return 0;
}


Measured memory_bytes: 3108
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int val1 = sc.nextInt();
        int val2 = sc.nextInt();
        
        System.out.println((val1 * val2) + " " + ((val1 * 2) + (val2 * 2)));
    }
}


Measured memory_bytes: 26152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define SORT(i) sort((i).begin(), (i).end())
#define INF 2000000000
constexpr ll mod = 1e9 + 7;
 
int main(){
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int>a(N);
    vector<int>b(M);
    for (int i = 0; i < N;++i){
        cin >> a[i];
    }
    for (int i = 0; i < M;++i){
        cin >> b[i];
    }
    int ma = -1000, mi = INF;
    for (int i = 0; i < N;++i){
        ma = max(ma, a[i]);
    }
    for (int i = 0; i < M;++i){
        mi = min(mi, b[i]);
    }
    if(ma < mi && ma < Y && X < mi){
        cout << "No War" <<"\n";
    }
    else {
        cout << "War" <<"\n";
    }

        return 0;
}

Measured memory_bytes: 256
#include<iostream>
long n,k,a=0,i,j,m=1e9+7,v[2<<20];main(){std::cin>>n>>k;for(i=0;i<n;i++)std::cin>>v[i];for(i=0;i<n;i++)for(j=0;j<n;j++){if(i==j)continue;if(v[i]>v[j]){if(i<j)a+=k;(a+=k*(k-1)/2)%=m;}}std::cout<<a<<'\n';}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const ll mod = 1000000007;

ll n, m;

// 素因数分解
unordered_map<ll, ll> prime_factor(ll n) {
    unordered_map<ll, ll> mp;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }
    if (n != 1) mp[n]++;
    return mp;
}

typedef long long ll;
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(ll n, ll k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

void solve() {
    unordered_map<ll, ll> mp = prime_factor(m);
    ll ans = 1;
    COMinit();
    each(m, mp) {
        ans *= COM(n - 1 + m.second, m.second);
        ans %= mod;
    }
    cout << ans << endl;
}

int main() {
    cin >> n >> m;
    solve();
    return 0;
}

Measured memory_bytes: 12160
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int ans=0;
		for(int i=0;i!=4;i++){
			int b=a%10;
			a/=10;
			if(b==2) {ans++;}
		}
		System.out.println(ans);
    }
}

Measured memory_bytes: 23124
n, x, y = map(int, input().split())
lis = [0]*(n-1)
for i in range(1, n):
    for j in range(i+1, n+1):
        lis[min([j-i, abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j)])-1] += 1
for i in range(n-1):
    print(lis[i])

Measured memory_bytes: 3444
K,N=map(int,input().split())
A = list(map(int, input().split()))
han=0
for a in range(len(A)):
    if abs(A[a]-A[a-1])>K/2:
        han=abs(A[a]+K-A[a-1])

    elif abs(A[a]-A[a-1])>han:
        han=abs(A[a]-A[a-1])
print(K-han)
        

Measured memory_bytes: 33244
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

#define maxn 1005
typedef long long ll;
const ll mod = 1e9 + 7;
ll ans;
int n, k;
char s[maxn];
int f[maxn];
ll c[maxn][maxn], fac[maxn], inv[maxn];

ll quickpow(ll p, ll k)
{
	ll res = 1;
	while (k)
	{
		if (k & 1)
			res = (res * p) % mod;
		p = (p * p) % mod;
		k >>= 1;
	}
	return res;
}
void check(int len, int low)
{
	int cnt1 = 0, cnt2 = 0, temp1 = 0, temp2 = 0;
	for (int i = 1; i <= k; i++)
	{
		if (s[i] == 'r' && cnt1 < len)
		{
			cnt1++;
			temp1 += (f[cnt1] != 1);
		}
		else if (s[i] == 'b' && temp1)
		{
			temp1--;
			cnt2++;
			temp2 += (f[cnt2] - 2);
		}
		else if (temp2)
			temp2--;
	}

	if (cnt1 < len || temp1 || temp2) return;


	ll res = fac[len];
	for (int i = 1; i <= len; i++)
	{
		int j = i;
		while (f[j + 1] == f[i] && j < len) j++;
		res = (res * inv[j - i + 1]) % mod;
		i = j;
	}
	ll sz = len + 1;
	for (int i = 1; i <= len; i++) sz += (f[i] * 2 - 1);

	ans += (res * c[n - low + sz - 1][sz - 1]) % mod;
	ans %= mod;
}
void dfs(int now, int len, int low)
{
	if (low > n) return;
	check(len - 1, low);
	for (int i = now; i >= 1; i--)
	{
		f[len] = i;
		dfs(i, len + 1, low + (max(2 * i - 3, 1)) + (len != 1));
	}
}
int main()
{
	scanf("%d%d%s", &n, &k, s + 1);
	for (int i = 0; i <= 300; i++)
	{
		c[i][0] = c[i][i] = 1;
		for (int j = 1; j <= i - 1; j++)
			c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
	}
	inv[0] = fac[0] = 1;
	for (int i = 1; i <= 300; i++)
		fac[i] = (fac[i - 1] * i) % mod, inv[i] = (quickpow(fac[i], mod - 2));
	dfs(70, 1, 0);
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

/*
αとβについて全探索を掛ける
αとβの組ごとにアルファベットの置換表を作る
与えられた文字列を置換表を下に下の文章に直す
*/

int n;
string inp;
map<char, char> m;

int main()
{
	cin >> n;
	getline(cin, inp);

	while (n--)
	{
		getline(cin, inp);
		//cout << inp << endl;
		bool exit = false;

		for (int alpha=0; alpha<=100; alpha++)
		{
			for (int beta=0; beta<=100; beta++)
			{
				m.clear();
				
				m[' '] = ' ';
				for (int pre='a'; pre<='z'; pre++)
				{
					int y = pre - 'a';
					int fy = (alpha * y + beta) % 26;
					char post = fy + 'a';
					m[post] = pre;
				}
	
				//暗号文を原文に置換する
				string genbun = "";
				for (int i=0; i<inp.length(); i++)
				{
					genbun += m[inp[i]];
				}

				if ((genbun.find("that", 0) != string::npos) || genbun.find("this", 0) != string::npos)
				{
					exit = true;
					cout << genbun << endl;
					break;
				}
			}

			if (exit) break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1216
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0206

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    while True:
        L = int(input())
        if L == 0:
            break
        ans = 'NA'
        for i in range(1, 12+1):
            M, N = map(int, input().split())
            if ans == 'NA':
                L -= (M - N)
                if L <= 0:
                    ans = i
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7744
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    new Main().run();
  }

  void run() {
    int n = ni();
    int a = ni();
    int b = ni();
    String str = sc.next();

    int x = 0;
    int y = 0;
    for (char c : str.toCharArray()) {
      if (c == 'a') {
        // kokunai
        if (x + y < a + b) {
          System.out.println("Yes");
          ++x;
        } else {
          System.out.println("No");
        }
      } else if(c == 'b') {
        // kaigai
        if (x + y < a + b && y < b) {
          System.out.println("Yes");
          ++y;
        } else {
          System.out.println("No");
        }
      } else {
        System.out.println("No");
      }
    }
  }

  int ni() {
    return Integer.parseInt(sc.next());
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

Measured memory_bytes: 24052
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define double long double
#define Sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T> inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<int,int> P;
const int MOD=1000000007;


void solve(long long M, long long D){
    ll d,d10,cnt=0;
    for (int i = 1; i <= M; i++)
    {
        for (int j = 1; j <= D; j++)
        {
            d = j%10;
            d10 = j/10;
            if ( d>=2 && d10>=2 && d*d10==i)
            {
                cnt++;
            }
        }
    }
    std::cout << cnt << std::endl;    
}

int main(){
    long long M;
    scanf("%lld",&M);
    long long D;
    scanf("%lld",&D);
    solve(M, D);
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		int d = sc.nextInt();
		int t = sc.nextInt();
		int s = sc.nextInt();
		
		int r = s*t - d;

		System.out.println( r>=0 ? "Yes": "No");
	}
}


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

int main() {
  int n;
  cin >> n;
  int a[n * 3];
  for (int i = 0; i < n * 3; i++) {
    cin >> a[i];
  }
  sort(a, a + n * 3);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a[3 * n - 2 - 2 * i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
char grid[2001][2001];
int lft[2001][2001], rgt[2001][2001], up[2001][2001], down[2001][2001];
int main() {
  int n,m,ans = 0;
  scanf ("%d %d",&n,&m);
  for (int x = 0; x < n; x++) {
    getchar();
    for (int y = 0; y < m; y++) {
      grid[x][y] = getchar();
      if (grid[x][y] == '#') lft[x][y] = -1;
      else if (!y) lft[x][y] = 0;
      else lft[x][y] = lft[x][y-1]+1;
    }
  }
  for (int x = 0; x < n; x++) {
    for (int y = m-1; y >= 0; y--) {
      if (grid[x][y] == '#') rgt[x][y] = -1;
      else if (y == m-1) rgt[x][y] = 0;
      else rgt[x][y] = rgt[x][y+1]+1;
    }
  }
  for (int y = 0; y < m; y++) {
    for (int x = 0; x < n; x++) {
      if (grid[x][y] == '#') up[x][y] = -1;
      else if (!x) up[x][y] = 0;
      else up[x][y] = up[x-1][y]+1;
    }
  }
  for (int y = 0; y < m; y++) {
    for (int x = n-1; x >= 0; x--) {
      if (grid[x][y] == '#') down[x][y] = -1;
      else if (x == n-1) down[x][y] = 0;
      else down[x][y] = down[x+1][y]+1;
    }
  }
  for (int x = 0; x < n; x++) {
    for (int y = 0; y < m; y++) {
      ans = max(ans,lft[x][y]+rgt[x][y]+up[x][y]+down[x][y]+1);
    }
  }
  printf ("%d\n",ans);
  return 0;
}


Measured memory_bytes: 66688
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final long N = sc.nextLong();
			
			long answer = N - 1;
			
			for(int p = 1; p <= Math.sqrt(N); p++) {
				if((N % p) != 0){ continue; }
				
				answer = Math.min(answer, (p - 1) + ((N / p) - 1));
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

int main(){
  string S;
  cin >> S;
  if(S.at(0)==S.at(1)&&S.at(1)==S.at(2)&&S.at(2)==S.at(0))
    cout << "No";
  else
    cout << "Yes";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in insert
#define mp make_pair
#define F first
#define pb push_back
#define pf push_front
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}

int main(){
    ll k,n; cin>>k>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    if(a[0]==0){
        ll ans=0;
        ll gap=a[1]-a[0];
    for(ll i=1;i<n-1;i++){
        ll tp=a[i+1]-a[i];
        if(tp>gap)
            gap=tp;
            
    }
        ans=max(k-a[n-1],gap);
        cout<<k-ans;
    }
    else{
        ll gap=0;
        ll ans=0;
        for(ll i=0;i<n-1;i++){
               ll tp=a[i+1]-a[i];
               if(tp>gap)
                   gap=tp;
                   
           }
        ans=max(gap,k-a[n-1]+a[0]);
        cout<<k-ans;
    }
    
    
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
int n,c,k,t[100010];
int main(){
	cin>>n>>c>>k;
	for(int i=0;i<n;i++)cin>>t[i];
	sort(t,t+n);
	int ans=1,s=t[0];
	int i=1,cnt=1;
	while(i<n){
		if(t[i]>s+k||cnt==c){
			ans++;
			cnt=0;
			s=t[i];
		}
		cnt++,i++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
import math

n, m = map(int, input().split())
mm = m // n
res = []
for k in range(1, int(math.sqrt(m)) + 1):
    if m % k == 0:
        if k > mm:
            break
        if m // k <= mm:
            k = m // k
        res.append(k)
print(max(res))

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
 
int n, a[200000];
 
int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
        {
		cin >> a[i];
		a[i] = a[i] - i - 1;
	}
	sort(a, a + n);
	int b = a[n / 2];
	long long ans = 0;
	for (int i = 0; i < n; i++) 
        {
		ans += abs(a[i] - b);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void calc_prime_factors(ll N, map<ll, ll> &m) {
    m[1] = 1;
    for (int i = 2; i * i <= N; i++) {
        while (N % i == 0) {
            m[i]++;
            N /= i;
        }
    }
}

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

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

    ll num_five1 = 0;
    {
        ll acc = 2 * 5;
        while (acc <= N) {
            num_five1 += N / acc;
            acc *= 5;
        }
    }

    // map<ll, ll> m;
    // calc_prime_factors(N, m);
    // ll num_five2 = m[5];

    cout << num_five1 << endl;

    return 0;
}


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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e16;

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

  string ans;
  int A, B;
  cin >> A >> B;

  if (A == B) {
    ans = "Draw";
  } else if (A > B) {
    if (B == 1) {
      ans = "Bob";
    } else {
      ans = "Alice";
    }
  } else {
    if (A == 1) {
      ans = "Alice";
    } else {
      ans = "Bob";
    }
  }

  cout << ans << '\n';

  return 0;
}

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

long total[4005];

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

	int n, id, p, q, cnt;
	cin >> n;
	while (n != 0) {
		for (int i = 0; i < 4005; i++) {
			total[i] = 0;
		}
		cnt = 1;
		for (int i = 0; i < n; i++) {
			cin >> id >> p >> q;
			long before = total[id];
			total[id] += p * q;
			if (before < GOOD && total[id] >= GOOD) {
				cout << id << endl;
				cnt = 0;
			}
		}
		if  (cnt) {
			cout << "NA" << endl;
		}
		cin >> n;
	}
}


Measured memory_bytes: 3084
import Data.Array

makeDpTable :: (Array Int Int) -> Int -> Int -> Int -> [Int] -> [Int]
makeDpTable a b c k ans
 | b == 0    = makeDpTable a (b + 1) c k (0:ans)
 | b == c    = ans
 | otherwise = makeDpTable a (b + 1) c k newAns
  where newVal = minimum $ map (\x -> ((ans !! x) + abs((a ! b) - (a ! (b - (x + 1)))))) [0..(min (k - 1) (b - 1))]
        newAns = newVal:ans
 
main = do
 [n,k] <- map read . words <$> getLine :: IO [Int]
 hList <- map read . words <$> getLine :: IO [Int]
 print $ head $ makeDpTable (listArray (0, n - 1) hList) 0 n k []

Measured memory_bytes: 148108
from collections import deque

MOD = 10 ** 9 + 7
h, w = map(int, input().split())
grid = '#' * (w + 2)
for _ in range(h):
    grid += '#' + input() + '#'
grid += '#' * (w + 2)
D = [0] * len(grid)
start = w + 3
goal = -(w + 4)
D[start] = 1
for i in range(start + 1, len(grid)):
    if grid[i] == '#':
        continue
    D[i] = (D[i - 1] + D[i - (w + 2)]) % MOD
print(D[goal])

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

typedef long long ll;
const int len = 3e5+5, mod = 998244353;
int fac[len];

int add(int a, int b){
    return (a+b)%mod;
}

int mul(int a, int b){
    return (a*1LL*b)%mod;
}

int po(int a, int b){
    if (b == 0) return 1;
    if (b%2 == 0) return po(mul(a, a), b/2);
    return mul(a, po(mul(a, a), b/2));
}

int f(int n, int k){
    int p = fac[n], q = mul(fac[k], fac[n-k]);
    return mul(p, po(q, mod-2));
}

int main(){
    int n, ans = 0;
    ll a, b, k;
    scanf("%d %lld %lld %lld", &n, &a, &b, &k);

    fac[0] = 1;
    for (int i = 1; i <= n; i++)
        fac[i] = mul(fac[i-1], i);

    for (int i = 0; i <= n; i++)
        if (i*a <= k && (k - i*a)%b == 0 && (k - i*a)/b <= n)
            ans = add(ans, mul(f(n, i), f(n, (k - i*a)/b)));

    printf("%d\n", ans);
    return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> p(n, k-q);
  rep(i, q) {
    int a;
    cin >> a;
    --a;
    ++p[a];
  }
  rep(i, n) {
    if(p[i] <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;


int N,K;
int A[222];

signed main(){
    cin>>N>>K;
    rep(i,N)cin>>A[i];
    sort(A,A+N);
    map<vint,vpint>ei;

    for(int i=0;i<=60;i++){
        vint v(N);
        rep(j,N)v[j]=A[j]%(1ll<<i);
        sort(all(v));

        vpint lis;
        if(i<=K)lis.pb({0,K-i});
        for(int j=0;j+1<v.size();j++){
            if(v[j+1]==v[j])continue;
            int cnt=0;
            for(int k=60;k>=0;k--){
                if(v[j+1]>>k&1)cnt++;
                if((v[j+1]>>k&1)!=(v[j]>>k&1))break;
            }
            if(cnt+i>K)continue;
            lis.pb({v[j]+1,K-cnt-i});
        }

        for(auto p:lis){
            vint a(N);
            rep(j,N)a[j]=(A[j]-p.fi)>>i;
            vint d(N-1);
            rep(j,N-1)d[j]=a[j+1]-a[j];
            ei[d].pb({max(0ll,a[0]-p.se),a[0]+1});
        }
    }

    int ans=0;
    for(auto &p:ei){
        vpint v=p.se;

        sort(all(v));
        vpint u;
        for(auto &q:v){
            if(u.size()==0||u.back().se<q.fi)u.pb(q);
            else u.back().se=q.se;
        }
        for(auto &q:u)ans=(ans+q.se-q.fi)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 18176
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	int n, x;
	while (1){
		cin >> n >> x;
		int count = 0;
		if (!n and !x) break;
		for (int i = 1; i <= n; i++){
			for (int j = i + 1; j <= n; j++){
				for (int k = j + 1; k <= n; k++){
					if (i + j + k == x) count++;
				}
			}
		}

		cout << count << endl;
	}

}



Measured memory_bytes: 3104
import java.lang.reflect.Array;
import java.util.*;

public class Main {

    static int MOD = 1000000007;


    public static void main(String[] args) {

        //int ans=Integer.MAX_VALUE;
        Scanner sc = new Scanner(System.in);
        int h=sc.nextInt();
        int a =sc.nextInt();
        int ans;
        if(h%a==0)ans=h/a;
        else ans=h/a+1;

        System.out.println(ans);






    }


}


Measured memory_bytes: 23760
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;
typedef long long ll;

int main() {
    ll A;
    string B;
    cin >> A >> B;
    ll B100 = (B.at(0) - '0') * 100 + (B.at(2) - '0')*10 + (B.at(3) - '0');
    ll ans = A * B100 / 100;
    cout << ans << endl;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    int n;
    cin >> n;

    vector<vector<int>> count(n,vector<int>(26));
    rep(i,0,n){
        string S;
        cin >> S;
        for(char c:S) ++count[i][c-'a'];
    }

    string ans;
    rep(i,0,26){
        int mn=inf;
        rep(j,0,n) mn=min(mn,count[j][i]);
        ans+=string(mn,i+'a');
    }
    sort(ans.begin(),ans.end());
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long int n,i,wa=0;
  cin>>n;
  long long int a[n],b[n+1];
  for(i=0;i<n;i++){
    cin>>a[i];    
    b[i+1]=0;
  }
  for(i=0;i<n;i++){    
    b[a[i]]++;
  }
  for(i=0;i<n;i++){
    wa+=b[i+1]*(b[i+1]-1)/2;
  }
  for(i=0;i<n;i++){
    cout<<wa-b[a[i]]+1<<endl;
  }
}


Measured memory_bytes: 5760