akhauriyash/Code-Regression huggingface dataset:
function Main(input) {
    input = input.trim().split("\n");
    var N = parseInt(input[0], 10);
    var x = [];
    var y = [];
    for (var i = 0; i < N; i++){
        var tmp = input[i+1].split(" ");
        x[i] = parseInt(tmp[0], 10);
        y[i] = parseInt(tmp[1], 10);
    }

    var a = [];
    var k = 0;
    for (var i = 0; i < N; i++){
        for (var j = 0; j < N; j++){
            if (i != j) {
                var p = x[j] - x[i];
                var q = y[j] - y[i];
                a[k] = p+","+q;
                    k++;
            }
        }
    }

    if (a.length == 0) {
        console.log(N);
    }
    else {
        var maxA = a[0];
        var maxCount = 0;
        for (var i = 0; i < a.length-1; i++) {
            var count = 0;
            for (var j = i+1; j < a.length; j++){
                if (a[i] == a[j]) {
                    count++;
                }
            }
            if (count > maxCount) {
                maxCount = count;
                maxA = a[i];
            }
        }
        var tmp = maxA.split(",");
        var p = parseInt(tmp[0], 10);
        var q = parseInt(tmp[1], 10);

        var cost = [];
        for (var i = 0; i < N; i++){
            cost[i] = 1;
        }
        for (var i = 0; i < N; i++){
            for (var j = 0; j < N; j++){
                if (i != j) {
                    if ((y[j] - y[i]) == q && (x[j] - x[i]) == p) {
                        cost[j] = 0;
                    }
                }
            }
        }

        var sumCost = 0;
        for (var i = 0; i < N; i++){
            sumCost += cost[i];
        }
        console.log(sumCost);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
int main() {
	llong width, height;
	int x, y;
	cin >> width >> height >>x>>y;
	llong rect = width * height;
	int can_multi = 0;
	if (x == width / 2.0 && y == height / 2.0) {
		can_multi = 1;
	}
	cout << rect / 2.0 << " " << can_multi << endl;
	return 0;
}

Measured memory_bytes: 256
local s = io.read()
local all9 = true
for i = 2, #s do
  if s:sub(i, i) ~= "9" then
    all9 = false
  end
end
local n = tonumber(s:sub(1, 1))
n = n + 9 * (#s - 1)
if not all9 then n = n - 1 end
print(n)


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int n,m;cin>>n>>m;
    vector<ll> cost(m),item(m);
    for(int i=0;i<m;i++){
        cin>>cost[i];
        int b;cin>>b;
        item[i]=0;
        while(b--){
            int x;cin>>x;
            x--;
            item[i]|=((1ll)<<x);
        }
    }
    vector<ll> dp((1ll)<<n,1e6);
    dp[0]=0;
    for(int i=0;i<m;i++){
        for(int j=0;j<((1ll)<<n);j++){
            dp[j|item[i]]=min(dp[j|item[i]],dp[j]+cost[i]);
        }
    }
    if(dp[((1ll)<<n)-1]==1e6)dp[((1ll)<<n)-1]=-1;
    cout<<dp[((1ll)<<n)-1];
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

int main() {
  ll K, ans = 0;
  cin >> K;

  for (ll i = 1; i <= K; ++i) {
    for (ll j = 1; j <= K; ++j) {
      for (ll k = 1; k <= K; ++k) {
        ans += gcd(i, gcd(j, k));
      }
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
import sys
import math
import bisect

def solve(A, d, x):
    B = [0] * d
    for i in range(d):
        for a in A:
            if i % a == 0:
                B[i] += 1
    return sum(B) + x

def main():
    n = int(input())
    d, x = map(int, input().split())
    A = []
    for i in range(n):
        A.append(int(input()))
    print(solve(A, d, x))

if __name__ == "__main__":
    main()


Measured memory_bytes: 38640
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<cctype>
#include<set>
#include<queue>
#include<vector>
#include<map>
#define Root 0, n, 1
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
using namespace std;
typedef long long LL;

inline int read() {
	int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f;
}

const int N = 200005;
int T[N << 2], b[N];
vector<int> vec[N];

bool cmp(int x,int y) { return x > y; }
void update(int l,int r,int rt,int p,int v) {
	if (l == r) { T[rt] = min(T[rt], v); return ; }
	int mid = (l + r) >> 1;
	if (p <= mid) update(lson, p, v);
	else update(rson, p, v);
	T[rt] = min(T[rt << 1], T[rt << 1 | 1]);	
}
int query(int l,int r,int rt,int L,int R) {
	if (L <= l && r <= R) return T[rt];
	int mid = (l + r) >> 1, res = 1e9;
	if (L <= mid) res = min(res, query(lson, L, R));
	if (R > mid) res = min(res, query(rson, L, R));
	return res;
}
int main() {
	int n = read(), sum = 0;
	for (int i = 1; i <= n; ++i) {
		b[i] = read(); sum += (b[i] == 0);
	}
	int m = read();
	for (int i = 1; i <= m; ++i) {
		int l = read(), r = read(); vec[l].push_back(r);
	}
	for (int i = 1; i <= n; ++i) sort(vec[i].begin(), vec[i].end(), cmp);
	memset(T, 0x3f, sizeof(T));
	update(Root, 0, 0);
	for (int i = 1; i <= n; ++i) {
		for (int sz = vec[i].size(), j = 0; j < sz; ++j) {
			int t = query(Root, i - 1, vec[i][j]);
			update(Root, vec[i][j], t);
		}
		int t = query(Root, i - 1, i - 1);
		update(Root, i, t + (b[i] ? 1 : -1));
	}
	cout << sum + query(Root, n, n);
	return 0;
}
/*

5
0 1 0 1 0
1
1 5

*/

Measured memory_bytes: 12800
#include <iostream>
using namespace std;
int main(void){
    
    int N;
    int buil[4][3][10] = {};
    
    cin >> N;
    for(int i = 0; i < N; i++){
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        
        // 配列の要素の場所を1つ減らす
        b--; f--; r--;
        buil[b][f][r] += v;
    }
    
    for(int i = 0; i < 4; i++){
        
        // 壁を作る
        if(i != 0) cout << "####################" << endl;
        
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 10; k++){
                // 各部屋の人数の判定
                if(buil[i][j][k] < 0) cout <<" 0";
                if(buil[i][j][k] > 9) cout <<" 9";
                else cout << " " << buil[i][j][k];
                
            }cout << endl;
        }
    }
    
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i, a) for (ll i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  int ct = 0;
  rep(i,n){
    cin >> a[i];
    if(a[i] % 2 != 0){
      ct++;
    }
  }
  if(ct%2==0){
    cout << "YES" << endl;
    return 0;
  }else{
    cout << "NO" << endl;
    return 0;
  }
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,k;
string s;

signed main() {
    cin >> n >> s >> k;
    rep(i,n) {
        if (s[i] != s[k-1]) cout << "*";
        else cout << s[i];
    }
    cout << endl;
}












Measured memory_bytes: 768
N,M=list(map(int,input().split()))
a=[]
for i in range(M):
  A=int(input())
  a.append(A)

dp = [0]*(N+1)
for j in a:
  dp[j]=-1

dp[0]=1
if dp[1] != -1:
  dp[1]=1
elif dp[1] == -1:
  dp[1]=0

for i in range(2,N+1):
  if dp[i] != -1:
    dp[i] = dp[i-1]+dp[i-2]
  elif dp[i] == -1:
    dp[i]=0

print(dp[N]%(10**9+7))

Measured memory_bytes: 465792
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#define fi first
#define se second
#define L(i,u) for (int i=head[u]; i!=0; i=nxt[i])
#define rep(i,a,b) for (int i=a; i<=b; i++)
#define per(i,a,b) for (int i=a; i>=b; i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x) {
	x=0; char c=getchar(); int f=1;
	while (c<'0'||c>'9') {if (c=='-') f=-1; c=getchar();}
	while (c>='0'&&c<='9') {x=10*x+c-'0'; c=getchar();} x*=f;
}
inline int f(int n, int k) {
	if (n%k==0) return n/k;
	int mul=(n%k)/(n/k+1); if (!mul) return f(n-n/k-1,k);
	return f(n-mul*(n/k+1),k);
}

int main() {
//	printf("%d",f(100000000,23));
	int n,ans=0; read(n);
	rep(i,1,n) {
		int a,k;read(a); read(k);ans^=f(a,k);
	}
	printf("%s",ans?"Takahashi":"Aoki");
	return 0;
}

Measured memory_bytes: 256
#include <atcoder/mincostflow>
#include <iostream>
#include <vector>
using ll = long long;
#define rep(i, j, n) for (int i = 0; i < n; ++i)
using namespace std;

int n, k;
ll a;

int main() {
  cin >> n >> k;
  int s = n * 2;
  int t = n * 2 + 1;
  atcoder::mcf_graph<int, ll> mcf(n * 2 + 2);

  ll base = 1000000010;
  rep(i, 0, n) rep(j, 0, n) {
    cin >> a;
    mcf.add_edge(i, n + j, 1, base - a);
  }

  rep(i, 0, n) {
    mcf.add_edge(s, i, k, 0);
    mcf.add_edge(n + i, t, k, 0);
  }
  mcf.add_edge(s, t, n * k, base);

  auto [_, c] = mcf.flow(s, t, n * k);

  vector<string> g(n, string(n, '.'));
  for (auto e : mcf.edges()) {
    if (e.flow == 1) {
      if (e.from == s || e.to == t) continue;
      g[e.from][e.to - n] = 'X';
    }
  }
  cout << base * n * k - c << '\n';
  rep(i, 0, n) cout << g[i] << '\n';
  return 0;
}

Measured memory_bytes: 3476
#include <iostream>
#include <algorithm>
using namespace std;

int fukuri(double riritu, int tesu, int year, int money){
	for(int i = 0; i < year; i++){
		money += ((int)((double)money * riritu) - tesu);
	}
	return money;
}

int tannri(double riritu, int tesu, int year, int money){
	int risi = 0;
	for(int i = 0; i < year; i++){
		risi += (int)((double)money * riritu);
		money -= tesu;
	}
	return money + risi;
}

int main(){
	int m;
	int money;
	int year, n;
	cin >> m;
	for(int i = 0; i < m; i++){
		int result = -1;
		cin >> money >> year >> n;
		for(int j = 0; j < n; j++){
			double riritu;
			int si;
			int tesu;
			cin >> si >> riritu >> tesu;
			if(si){
				result = max(result, fukuri(riritu, tesu, year, money));
			}else{
				result = max(result, tannri(riritu, tesu, year, money));
			}
		}
		cout << result << endl;
	}
	return 0;
}

Measured memory_bytes: 0
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)
#define elif(c) else if(c)

#define emb emplace_back
#define pub push_back
#define pob pop_back
#define me min_element
#define Me max_element
#define mp make_pair
#define fi first
#define se second
#define siz(xs) ((int)(xs).size())
#define all(xs) xs.begin(),xs.end()
#define lla(xs) xs.rbegin(),xs.rend()
#define sortup(xs) sort(all(xs))
#define sortdown(xs) sort(lla(xs))
template<class C>void mini(C &a,C b){a=min(a,b);}
template<class C>void maxi(C &a,C b){a=max(a,b);}
#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__)
#define out(...) _cout(__VA_ARGS__);
void _cin(){}template<class Head,class...Tail>void _cin(Head&&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
void _cout(){}template<class Head,class...Tail>void _cout(Head&&head,Tail&&...tail){cout<<head<<endl;_cout(forward<Tail>(tail)...);}
template<class Type>void _cinvec(Type t,int n){}template<class Type,class Head,class...Tail>void _cinvec(Type t,int n,Head&&head,Tail&&...tail){rep(n){cin>>t;head.eb(t);}_cinvec(t,n,forward<Tail>(tail)...);}

#define VI vector<int>
#define VD vector<double>
#define VS vector<string>
#define VVI vector<VI>
#define VVD vector<VD>
#define VVS vector<VS>

// #define int int64_t
// #define double long double

// map
// 横並びcout




signed main(){
  in(int,N);
  in(string,S);
  VI cost(N);
  fou(i,1,N){
    if(S[i]=='.') cost[0]++;
  }
  fou(i,0,N-1){
    int d=0;
    if(S[i]=='#') d++;
    if(S[i+1]=='.') d--;
    cost[i+1] = cost[i] + d;
  }
  int ans=cost[0];
  fou(i,1,N){
    mini(ans,cost[i]);
  }
  out(ans);
}

Measured memory_bytes: 1412
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;


int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  map<ll, ll> s;
  rep(i, 1, 100000) s.emplace((i*(i+1))/2, i);
  auto itr = s.lower_bound(n);
  ll k = (*itr).second;
  for(int i=1;i<=k;i++){
    if(i==(*itr).first-n) continue;
    std::cout << i << '\n';
  }
}


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

class Program {
    static void Main(string[] args) {
        string[] s = Console.ReadLine().Split(' ');
        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);
        int c = int.Parse(s[2]);
        for (int i = 0; i < b; i++) {
            if (a * i % b == c) {
                Console.WriteLine("YES");
                return;
            }
        }
        Console.WriteLine("NO");
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <string.h>

char s[10];
char t[10];

int main()
{
	char u[10]{NULL};
	int a, b;
	scanf("%s %s", &s, &t);
	scanf("%d %d", &a, &b);
	scanf("%s", &u);

	if (!strcmp(s, u))
	{
		a--;
	}
	else {
		b--;
	}
	printf("%d %d", a, b);
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;

double EPS=1e-9;
int INF=1000000005;
long long INFF=1000000000000000005ll;
double PI=acos(-1);
int dirx[8]={ -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8]={ 0, 1, -1, 0, -1, 1, -1, 1 };
const ll MOD = 1000000007;

ll sum() { return 0; }
template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }

#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define OUT(x) cout << x << endl
#define OUTH(x) cout << x << " "
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define READ(x) for(auto &(z):x) cin >> z;
#define FOR(a, b, c) for (int(a)=(b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a)=(b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a)=(b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a)=(b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a)=(b); (a) <= (c); ++(a))
#define EACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define MAX(a, b) a=max(a, b)
#define MIN(a, b) a=min(a, b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define TC(t) while (t--)
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define what_is(x) cerr << #x << " is " << x << endl;

void solve() {
	
}

int main()
{
    FAST_INP;
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt","r", stdin);
//    freopen("output.txt","w", stdout);
//    #endif

//    int tc; cin >> tc;
//    TC(tc) solve();
	int x;
	cin >> x;
	if(x==0) OUT(1);
	else OUT(0);

    return 0;
}

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

using namespace std;
int N, M, i, j, a[101][101], I, J;
char c;
bool ok, Ok;
int main()
{
    scanf("%d %d", &N, &M);
    for(i = 1; i <= N; i++) {
        for(j = 1; j <= M; j++) {
            cin >> c;
            if(c == '.') a[i][j] = 1;
            else a[i][j] = 0;
        }
    }
    do {
        ok = 0;
        if(N > 1 && M > 1) {
        for(i = 1; i <= N; i++) {
                Ok = 1;
            for(j = 1; j < M && Ok == 1; j++)
                if(a[i][j] != a[i][j + 1] || a[i][j] != 1 && j > 1) Ok = 0;
            if(Ok == 1) {
                for(I = i; I < N; I++)
                    for(J = 1; J <= M; J++) a[I][J] = a[I + 1][J];
                N--;
                ok = 1;
                if(N == 1) ok = 0;
                break;
            }
        }
        }
    }
    while(ok == 1);
    if(N == 1 || M == 1) {
        if(N == 1) {
            for(i = 1; i <= M; i++) if(a[1][i] == 0) printf("#");
        }
        else if(M == 1)
            for(i = 1; i <= N; i++) if(a[i][1] == 0) printf("#");
            return 0;
    }
    do {
        ok = 0;
        if(N > 1 && M > 1) {
        for(j = 1; j <= M && ok == 0; j++) {
            Ok = 1;
            for(i = 1; i < N && Ok == 1 && ok == 0; i++)
                if(a[i][j] != a[i + 1][j] || a[i][j] != 1) Ok = 0;
            if(Ok == 1) {
                for(J = j; J < M; J++)
                    for(I = 1; I <= N; I++) a[I][J] = a[I][J + 1];
                ok = 1;
                M--;
                if(M == 1) ok = 0;
                break;
            }
        }
        }
    }
    while(ok == 1);
    for(i = 1; i <= N; i++) {
        for(j = 1; j <= M; j++) {
                if(a[i][j] == 1) printf(".");
                else printf("#");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

constexpr int MOD = 1000000007;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

int H, W, N;
int h[101010], w[101010];

int main() {
    cin >> H >> W >> N;
    for (int j = 0; j < N; ++j) {
        cin >> h[j] >> w[j];
    }

    set<P> points;
    for (int j = 0; j < N; ++j) {
        points.insert(make_pair(h[j],w[j]));
    }

    LL numSquares[10] = {0,0,0,0,0,0,0,0,0,0};
    for (int j = 0; j < N; ++j) {
        for (int lh = max(1,h[j]-2); lh <= min(h[j], H-2); ++lh) {
            for (int lw = max(1,w[j]-2); lw <= min(w[j],W-2); ++lw) {
                int count = 0;
                for (int dh = 0; dh < 3; ++dh) {
                    for (int dw = 0; dw < 3; ++dw) {
                        if (points.find(make_pair(lh+dh,lw+dw)) != end(points)) {
                            ++count;
                        }
                    }
                }
                ++numSquares[count];
            }
        }
    }
    for (int j = 1; j <= 9; ++j) {
        numSquares[j] /= j;
    }
    LL sumExcept0 = 0;
    for (int j = 1; j <= 9; ++j) { sumExcept0 += numSquares[j]; }

    numSquares[0] = ((LL)H - 2) * ((LL)W - 2) - sumExcept0;

    for (int j = 0; j < 10; ++j) {
        cout << numSquares[j] << endl;
    }

    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()

typedef pair<ll,ll> P;

int main() {
  string s; cin >> s;
  ll n = s.size();
  vector<P> a;
  ll l=0;
  ll r=0;
  ll pos = 0;
  while(pos<n){
    if(s[pos]=='R'){
      r++;
      pos++;
    }else{
      while(pos<n && s[pos] == 'L'){
        l++;
        pos++;
      }
      a.push_back({r,l});
      r=0;
      l=0;
    }
  }
  vector<ll> ans(n,0);
  ll cur = -1;
  REP(i,a.size()){
    ll r = a[i].first;
    ll l = a[i].second;
    cur += r;
    ans[cur] = r/2 + l/2 + (r%2);
    cur++;
    ans[cur] = r/2 + l/2 + (l%2);
    cur += l-1;
  }
  REP(i,n){
    cout << ans[i];
    if(i==n-1) cout << endl;
    else cout << " ";
  }
}


Measured memory_bytes: 2292
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    private static FastScanner sc = new FastScanner();
    private static boolean DEBUG_FLG = false;

    public static void main(String[] args) {
    	int N = sc.nextInt();
    	int M = sc.nextInt();
    	int maxL = -1;
    	int minR = N;
    	for(int i=0; i<M; i++) {
    		int L = sc.nextInt();
    		int R = sc.nextInt();
    		if(L > maxL) maxL = L;
    		if(R < minR) minR = R;
    	}
    	if(minR >= maxL) {
    		System.out.println(minR - maxL + 1);
    	} else {
    		System.out.println(0);
    	}
    }

    static void debug(long... args) {
    	if(!DEBUG_FLG) return;
    	boolean flg = false;
    	for(long s : args) {
    		if(flg) System.out.print(" ");
    		flg = true;
    		System.out.print(s);
    	}
    	System.out.println();
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 39228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n,a;
	vector<pair<int,int>>v;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		v.push_back(make_pair(a,i));
	}
	sort(v.begin(),v.end());
	cout<<v[0].second;
	for(int i=1;i<n;i++)
	{
		cout<<" "<<v[i].second;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1780
#include "bits/stdc++.h"
using namespace std;

int main(){
    int N; cin >> N;
    int F[N][10];
    for(int i=0; i<N; i++){
        for(int j=0; j<10; j++){
            cin >> F[i][j];
        }
    }
    int P[N][11];
    for(int i=0; i<N; i++){
        for(int j=0; j<11; j++){
            cin >> P[i][j];
        }
    }
    long long int cur, mx=-10000000000;

    for(int bit = 1; bit < (1<<10); bit++){
        cur = 0;
        for(int i = 0; i < N; i++){
            int open = 0;
            for(int j=0; j<10; j++){
                if(((bit>>j)&1) & F[i][j]) open++;
            }
            cur += P[i][open];
        }
        if(mx<cur) mx=cur;
    }
    cout << mx << endl;
    return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int f(int a) {
  return (a * a + 4) / 8;
}

ll memo[1000];
ll fib(ll n) {
  if(n == 0) return 2;
  else if(n == 1) return 1;
  else if(memo[n]) return memo[n];
  else return memo[n] = fib(n-1) + fib(n-2);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int x; cin >> x;

  int ma = 1;
  for(int i=2;i*i<=x;++i) {
    int now = 1;
    while(now <= x) {
      now *= i;
    }
    now /= i;
    ma = max(ma, now);
  }
  cout << ma << endl;

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		StringTokenizer st = new StringTokenizer(str, " ");
		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());

		if(a < b ) {
			System.out.println("a < b");
		} else if(a > b) {
			System.out.println("a > b");
		} else if(a==b) {
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 24104
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> a(n);
  for(int & v : a) cin >> v;
  sort(a.begin(), a.end());
  a[n - 1] /= 2;
  cout << accumulate(a.begin(), a.end(), 0) << endl;
  return 0;
}


Measured memory_bytes: 256
S = gets.chomp
res = 0
num = 0
flag = false
S.split('').each do |s|
    if s == 'A' || s == 'C' || s == 'G' || s == 'T' then
        if flag then
            num += 1
        else
            flag = true
            num = 1
        end
    else
        res = num if res < num
        flag = false
    end
end
res = num if flag && res < num
puts res

Measured memory_bytes: 1916
#include<stdio.h>

int partition(int A[], int left, int right) {
  int r = right - 1;
  int j = left;
  for ( int i = left; i < r; i++ ) {
    if ( A[i] <= A[r] ) {
      int t = A[i]; A[i] = A[j]; A[j] = t;
      j++;
    }
  }
  int t = A[j]; A[j] = A[r]; A[r] = t;
  return j;
}

int main() {
  int n, A[100000];

  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);

  int m = partition(A, 0, n);

  for ( int i = 0; i < n; i++ ) {
    if (i) printf(" ");
    if (i == m) printf("[%d]", A[i]);
    else printf("%d", A[i]);
  }

  printf("\n");

  return 0;
}



Measured memory_bytes: 2952
def solve():
    for i in range(N):
        if xyh[i][2] > 0:
            x,y,h = xyh[i][0], xyh[i][1], xyh[i][2]
            break

    for i in range(101):
        for j in range(101):
            H = h + abs(x-i) + abs(y-j)
            a = 0
            for k in range(N):
                if xyh[k][2] == max(H-abs(xyh[k][0]-i) - abs(xyh[k][1]-j), 0):
                    continue
                else:
                    a = 1
                    break
            if a == 0:
                print(i,j,H, sep=" ")
                break
        else:
            continue


if __name__ == "__main__":
    N = int(input())
    xyh = [list(map(int, input().split())) for _ in range(N)]
    solve()


Measured memory_bytes: 8956
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=tf-8
#

"""
"""

from collections import defaultdict
import bisect

import sys
input = sys.stdin.readline

def solve(s):
    ss = sum(map(int,s))
    if ss % 9 == 0:
        print('Yes')
    else:
        print('No')

            

def main():
    s = list(input().rstrip())
    solve(s)


if __name__ == "__main__":
    main()

Measured memory_bytes: 77652
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    ll a[5] = {}, n;
    cin >> n;
    for (int i = 0; i < 5; i++) cin >> a[i];
    cout << (n - 1) / min({a[0], a[1], a[2], a[3], a[4]}) + 5;
    return 0;
    int T;
    cin >> T;
    for (int U = 1; U <= T; U++) {
        cout << "Case #" << U << ": ";
        
    }
}


Measured memory_bytes: 256
#input
#N = 4
#H = [6, 5, 6, 8]
N = int(input())
H = list(map(int,input().split()))
tmp = H[0]
ans = 0
for i in range(N):
    if H[i] >= tmp:
        ans += 1
        tmp = H[i]
print(ans)



Measured memory_bytes: 2940
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        var n = long.Parse(Console.ReadLine());
        var ans = 0L;

        long[] table = num_divisors_table(n);
        for (long i = n; i > 0; i--)
        {
            ans += i * table[i];
        }

        // 出力
        Console.WriteLine(ans);
    }

    //約数の個数をまとめたテーブルを作成
    public static long[] num_divisors_table(long n)
    {
        long[] res = new long[n + 1];
        for (int i = 1; i < n + 1; i++)
        {
            for (int j = i; j < n+1; j += i)
            {
                res[j] += 1;
            }
        }
        return res;
    }
}

Measured memory_bytes: 105740
#include <bits/stdc++.h>
#define R register
#define ll long long
#define mp make_pair
#define pii pair<int, int>
using namespace std;

template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = ch == '-', ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}

int main() {
    int n, m;
    read(n), read(m);
    if (n >= 10 || m >= 10) printf("-1\n");
    else printf("%d\n", n * m);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, H;
	cin >> N >> H;

	vector<vector<Int>> ab(N,vector<Int>(2,0));
	vector<vector<Int>> ba(N,vector<Int>(2,0));

	Int a, b;
	for (Int i = 0; i < N; i++) {
		cin >> a >> b;
		ab[i][0] = a;
		ab[i][1] = b;
		ba[i][0] = b;
		ba[i][1] = a;
	}

	sort(ab.begin(), ab.end());
	sort(ba.begin(), ba.end());

	Int tempa = ab[N - 1][0];

	Int i = N - 1;
	Int sum = 0;
	Int cnt = 0;
	while (sum<H && i >= 0 && ba[i][0]>tempa) {
		sum += ba[i][0];
		cnt++;
		i--;
	}

	if (sum < H) {
		cnt += (H - sum + tempa - 1) / tempa;
	}
	
	cout << cnt << "\n";
}

Measured memory_bytes: 11264
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(n==0&&s[i]=='C')n=1;
        if(n==1&&s[i]=='F'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


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


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

	int swap = 0;
	bool rev = false;
	for (int i = 1; i <= N; i++) {
		int p;
		cin >> p;
		if (p == i) {
			if (!rev) {
				rev = true;
				swap++;
			} else {
				rev = false;
			}
		} else {
			rev = false;
		}
	}

	cout << swap << endl;

	return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = LI()

    t = [[0]*n for _ in range(n)]
    for i in range(n):
        t[i][i] = a[i]

    for i in range(n-2,-1,-1):
        z = t[i]
        y = t[i+1]
        for j in range(i+1,n):
            r = a[j] - z[j-1]
            u = a[i] - y[j]
            if r < u:
                r = u
            z[j] = r

    return t[0][-1]


print(main())


Measured memory_bytes: 236708
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
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> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  string S, T;
  cin >> S >> T;
  if (S.length() + 1 != T.length()) {
    cout << "No" << endl;
    return 0;
  }
  REP(i, 0, S.length()) {
    if (S[i] != T[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 3600
from collections import Counter, deque


def bfs(d, s, N):
    dist = [-1]*N
    q = deque()
    q.append(s)
    dist[i] = 0
    while len(q) != 0:
        From = q.popleft()
        for To in d[From]:
            if dist[To-1] == -1:
                q.append(To)
                dist[To-1] = dist[From-1]+1
    return dist


N, X, Y = map(int, input().split())
d = [[] for _ in range(N+1)]
d[X].append(Y)
d[Y].append(X)
for i in range(1, N):
    d[i].append(i+1)
    d[i+1].append(i)

ans = [0]*(N+1)

for i in range(N):
    s = i+1
    c = Counter(bfs(d, i+1, N))
    for i, m in c.items():
        ans[i] += m

for i in range(1, N):
    print(ans[i]//2)

Measured memory_bytes: 70620
from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10


def main():
    N = int(input())
    p_list = list(map(int, input().split()))
    ans = 0
    i = 0
    while i < N:
        if p_list[i] == i + 1:
            ans += 1
            i += 2
        else:
            i += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14196
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    string s;
    cin >> s;

    int p = -100, d = 0;

    for(char &c : s) {
        if(c == '?') c = 'D';
    }

    cout << s << endl;

    return 0;
}

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

ll MOD=1e9+7;

int main() {
    ll n, m, ans=0;
    cin >> n >> m;
    if(n*2<=m) {
        ans+=n;
        m-=n*2;
        n=0;

        //まだできる
        ans += m/4;
    } else {
        ans+=m/2;
        n-=m/2;
        m%=2;

        //もうできない
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
N, Q = map(int, input().split())
S = ['0'] + list(input())
C = [0] * len(S)
c = 0
for i in range(1, len(S)):
    if S[i-1] == "A" and S[i] == "C":
        c += 1
    C[i] = c
for _ in range(Q):
    l, r = map(int, input().split())
    print(C[r] - C[l])


Measured memory_bytes: 12088
use std::io::Read;

const MOD: i64 = 1_000_000_007;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n = iter.next().unwrap().parse().unwrap();
    let x: usize = iter.next().unwrap().parse().unwrap();
    let y: usize = iter.next().unwrap().parse().unwrap();
    let z: usize = iter.next().unwrap().parse().unwrap();

    let mut dp = (0..n + 1)
        .map(|_| vec![0; 1 << 18])
        .collect::<Vec<Vec<_>>>();
    let mut next = (0..18).map(|_| vec![0; 11]).collect::<Vec<Vec<usize>>>();
    for state in 0..18 {
        for num in 1..11 {
            next[state][num] = if state < 5 {
                if num + state < x {
                    num + state
                } else if num + state == x {
                    5
                } else {
                    0
                }
            } else if state < 12 {
                let y_num = state - 5;
                if num + y_num < y {
                    num + state
                } else if num + y_num == y {
                    12
                } else {
                    0
                }
            } else if state < 17 {
                let z_num = state - 12;
                if num + z_num < z {
                    num + state
                } else if num + z_num == z {
                    17
                } else {
                    0
                }
            } else {
                state
            };
            //            dbg!(state, num, next[state][num]);
        }
    }

    let mut next_masks = (0..1 << 18).map(|_| vec![0; 11]).collect::<Vec<Vec<_>>>();
    for mask in 0..(1 << 18) {
        for num in 1..11 {
            let mut next_mask = 0;
            for j in 0..18 {
                if (mask & (1 << j)) > 0 {
                    next_mask |= 1 << next[j][num];
                }
            }
            next_masks[mask][num] = next_mask | 1;
        }
    }

    dp[0][1] = 1;
    for i in 0..n {
        for mask in 0..(1 << 18) {
            if dp[i][mask] == 0 {
                continue;
            }
            //            println!("{} {:#b}", i, mask);

            for j in 1..11 {
                let next_mask = next_masks[mask][j];
                //                if next_mask & (1 << 17) > 0 {
                //                    dbg!(i, j, dp[i][mask]);
                //                }
                dp[i + 1][next_mask] += dp[i][mask];
                dp[i + 1][next_mask] %= MOD;
            }
        }
    }

    let mut res = 0;
    for mask in (1 << 17)..(1 << 18) {
        res += dp[n][mask];
        res %= MOD;
    }
    println!("{}", res);
}


Measured memory_bytes: 119036
// Coordinate compression

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
 
#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;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
 
//#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)



int solve()
{

int x;
cin>>x;

int ans=x/500;
ans*=1000;
x%=500;
ans+=(x/5)*5;
cout<<ans<<endl;


  return 0;
}


 
signed main()
{  int t=1;

 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
  
   cin.exceptions(cin.failbit);                                                                    
                                 
 
  clock_t time_req;
                                                                                                                   
//cin>>t;
 
    int k=1;
     
   while(t--)
     {
      solve();
     }
        exit(0);
 
 
         time_req = clock() - time_req;
    cout <<endl<< "Processor time taken is "
      << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;
 
    return 0;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 200001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
ll gcd(ll a, ll b) { if(a < b) swap(a, b); if(b <= 0) return a; return gcd(b, a % b); }

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    ll N, M; cin >> N >> M;
    ll gccd = 1;
    vector<ll> factors;
    for(ll i = 1; i * i <= M; i++)
    {
        if(M % i != 0) continue;
        factors.push_back(i);
        if(i * i != M)
            factors.push_back(M / i);
    }
    
    for(auto factor : factors)
    {
        if(M >= N * factor)
            gccd = max(gccd, factor);
    }
   
    cout << gccd << endl;
    return 0;
}



/*
 
 
 */


Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
l=list(map(int,input().split()))
c=0
li=[]
for x in l:
    c+=1
    tmp=[]
    tmp.append(abs(a-t+x*0.006))
    tmp.append(c)
    li.append(tmp)
print(sorted(li)[0][1])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

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

    int n;
    cin >> n;
    int h[n], dp[n];
    fill(dp, dp + n, 1e9);
    dp[0] = 0;
    rep(i, n) cin >> h[i];
    rep(i, n) FOR(j, i + 1, i + 3) if(j < n)
        chmin(dp[j], dp[i] + abs(h[i] - h[j]));
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1024