akhauriyash/Code-Regression huggingface dataset:
N,P = map(int,input().split(" "))
A = list(map(lambda x:int(x)%2,input().split(" ")))
f = [1,1]

def frac(x):
    l = len(f)
    if not(l > x) :
        for i in range(x-l+1):
            f.append(f[-1]*(l+i))
    return f[x]

even = A.count(0)
odd = A.count(1)

a = 0
while P <= odd:
    a += frac(odd) // frac(P) // frac(odd-P)
    P += 2
print(a * 2 ** even)

Measured memory_bytes: 3064
mod = 10**9 +7
n, a, b = map(int, input().split())

nb = str(bin(n))[2:]
nblis = []
for k in range(len(nb)):
  if nb[-k-1] == '1':
    nblis.append(k)

two = [2]
for k in range(len(nb)-1):
  two.append(two[-1]*two[-1]%mod)


ans = 1
for item in nblis:
  ans = ans * two[item] %mod



bi = str(bin(mod-2))[2:]
blis = []
for k in range(len(bi)):
  if bi[-k-1] == '1':
    blis.append(k)


def modinv(N):
  if N == 1:
    return 1
  else:
    res = 1
    li = []
    for _ in range(len(bi)):
      li.append(N%mod)
      N = N*N%mod
    for item in blis:
      res = res * li[item] %mod
    return res

ans_a = 1
for k in range(n-a+1, n+1):
  ans_a = ans_a*k%mod
amother = 1
for k in range(2, a+1):
  amother = amother * k % mod
ans_a = ans_a*modinv(amother)%mod


ans_b = 1
for k in range(n-b+1, n+1):
  ans_b = ans_b*k%mod
bmother = 1
for k in range(2, b+1):
  bmother = bmother * k % mod  
ans_b = ans_b*modinv(bmother)%mod

print((ans-ans_a-ans_b-1)%mod)

Measured memory_bytes: 65344
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var L = cin.ReadInt;
            var R = cin.ReadInt;
            var mL = L % 2019;
            var mR = R % 2019;
            int ans;
            if (R - L >= 2019 || mL > mR)
            {
                ans = 0;
            }
            else
            {
                ans = 2019;
                for (int l = mL; l < mR; l++)
                {
                    for (int r = l + 1; r <= mR; r++)
                    {
                        var m = l * r % 2019;
                        if (m < ans)
                        {
                            ans = m;
                        }
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

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

int H, W;
int grid[101][101];
bool visited[101][101];

// r, l, u, d
int dx[4] = { 1, -1, 0, 0 };
int dy[4] = { 0, 0, -1, 1 };

int main() {
  char ch;
  while (cin >> H >> W, H+W) {
    // grid, visited初期化
    rep(i, 0, H) {
      rep(j, 0, W) {
        cin >> ch;
        if (ch == '#') {
          grid[i][j] = 0;
        } else if (ch == '*') {
          grid[i][j] = 1;
        } else {
          grid[i][j] = 2;
        }
        visited[i][j] = false;
      }
    }

    // bfs
    int ans = 0;
    rep(i, 0, H*W) {
      int row = i / W;
      int col = i % W;
      if (visited[row][col]) {
        continue;
      }

      int type = grid[row][col];
      ans += 1;
      queue<int> q;
      q.push(i);
      while (!q.empty()) {
        int v = q.front(); q.pop();
        int y = v / W;
        int x = v % W;
        if (visited[y][x]) continue;
        visited[y][x] = true;


        rep(j, 0, 4) {
          int ny = y+dy[j];
          int nx = x+dx[j];
          if (0 <= nx && nx < W && 0 <= ny && ny < H) {
            if (!visited[ny][nx] && grid[ny][nx] == type) {
              int n = ny * W + nx;
              q.push(n);
            }
          }
        }
      }
    }

    // print ans
    cout << ans << endl;
  }

  return 0;
};



Measured memory_bytes: 3148
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
    int n,m;
    int sum=0;
    scanf("%d %d",&n,&m);
    while(n!=0)
    {
        n=n/m;
        sum++;
    }
    printf("%d\n",sum);
    return 0;
}


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

int n,v,c,sum,arr[21];

int main(){
	cin>>n;
	for(int i = 1;i <= n; i++){
		cin>>v;
		arr[i] = v;
	}for(int i = 1;i <= n; i++){
		cin>>c;
		if(arr[i] - c > 0){
			sum = sum + arr[i] - c;
		}
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,m,k,ans,n,a,b,g;
    	cin>>n>>k;
    	ll h[n];
    	rep(i,0,n)
    	{
    		cin>>h[i];
		}
		sort(h,h+n); ans=0;
		if(k>=n)
    	cout<<0;
    	else
    	{
    		rep(i,0,n-k)
    		ans+=h[i];
    		cout<<ans;
		}
//    	cout<<ans;
    } 
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll k; cin >> k;
    vector <ll> as_plus;
    vector <ll> as_minus;
    REP(i, n){
        ll a; cin >> a;
        if (a >= 0) {
            as_plus.push_back(a);
        } else {
            as_minus.push_back(a*-1);
        }
    }
    sort(as_plus.begin(), as_plus.end());
    sort(as_minus.begin(), as_minus.end());
    ll ok = 1e18;
    ll ng = -1e18 - 1;
    //ll ok = 100;
    //ll ng = -101;
    while (ok - ng > 1){
        ll mid = (ok + ng)/2;
        ll ord = 0;
        if (mid < 0){
            for(auto a: as_minus){
                ll plus;
                plus = as_plus.end() - lower_bound(as_plus.begin(), as_plus.end(), (mid*-1 + a-1)/a);
                ord += plus;
            }
        } else {
            for(auto ap=as_minus.begin(); ap!=as_minus.end(); ++ap){
                ll plus;
                ll a = *ap;
                if (a == 0){
                    plus = ap - as_minus.begin();
                } else {
                    plus = upper_bound(as_minus.begin(), ap, mid/a) - as_minus.begin();
                }
                ord += plus;
            }
            for(auto ap=as_plus.begin(); ap!=as_plus.end(); ++ap){
                ll plus;
                ll a = *ap;
                if (a == 0){
                    plus = ap - as_plus.begin();
                } else {
                    plus = upper_bound(as_plus.begin(), ap, mid/a) - as_plus.begin();
                }
                ord += plus;
            }
            ord += as_minus.size() * as_plus.size();
        }
        dump(mid)
        dump(ord)
        dumpline
        if (ord > k-1){
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok << endl;
    return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a >= 13){
        cout << b << endl;
    }else if(a >= 6 && a <= 12){
        cout << b/2 << endl;
    }else if(a <= 5){
        cout << "0" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
#define rep(i, n) for (int i=0; i<(int) (n);i++)
using ll = long long;
using P = pair<int, int>;

void solve_1() {//14m
	int a, b;
	cin >> a >> b;
	int total;
	int n = 0;
	while (!((a-1)*n + 1 >= b)) {
		n++;
	}
	cout << n << endl;

}

void solve_2() {//30m
	int n;
	cin >> n;
	vector<int> x;
	int total = 0;
	rep(i, n) {
		int tmp;
		cin >> tmp;
		x.push_back(tmp);
		total += tmp;
	}
	int p1 = (double(total)/double(n)*2 - 1.0) / 2;
	int p2 = (double(total)/double(n)*2 - 1.0) / 2 + 1;
	int point_sum1 = 0, point_sum2= 0;
	rep(i, n) {
		point_sum1 += pow(x[i] - p1, 2);
		point_sum2 += pow(x[i] - p2, 2);
	}
	cout << min(point_sum1, point_sum2) << endl;

}

void solve_2re() {
	int n;
	cin >> n;
	vector<int> x(n);
	int total = 0;
	rep(i, n) {
		cin >> x[i];
		total += x[i];
	}
	int p1 = total / n;
	int p2 = total / n + 1;
	int point_sum1 = 0, point_sum2 = 0;
	rep(i, n) {
		point_sum1 += pow(x[i] - p1, 2);
		point_sum2 += pow(x[i] - p2, 2);
	}
	cout << min(point_sum1, point_sum2) << endl;
}

void solve_3() {//17m
	int n, a, b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	int sum = a + b;
	rep(i, n) {
		if (s[i] == 'a') {
			cout << (sum > 0 ? "Yes" : "No") << endl;
			if (sum>0) {
				sum--;
			}
		}
		else if (s[i] == 'b') {
			cout << (sum > 0 && b > 0 ? "Yes" : "No") << endl;
			if (sum > 0 && b > 0) {
				if (b>0) {
					sum--;
					b--;
				}
				else {
					sum--;
				}
			}
		}
		else if (s[i] == 'c') {
			cout << "No" << endl;
		}
	}
}

void solve_4() {
	int n;
	cin >> n;
	rep(i, 50000) {
		if (int(i*1.08) == n) {
			cout << i;
			return;
		}
	}
	cout << ":(";
}

void solve_5() {

}

void solve_6() {

}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//solve_1();
	//solve_2();
	//solve_2re();
	//solve_3();
	solve_4();
	//solve_5();
	//solve_6();
	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 ll 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 << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

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

  int n, k; cin >> n >> k;
  vi h(n);
  for(int i=0;i<n;++i) {
    cin >> h[i];
  }
  sort(h.rbegin(), h.rend());

  ll cnt = 0;
  for(int i=k;i<n;++i) {
    cnt += h[i];
  }
  cout << cnt << endl;




}


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

int main(){
  	bool end=false;
	int N;
 	cin >> N ;
  	int A[N];
  	int count=0;
  	for(int i=0;i<N;i++){
  		cin >> A[i];
  	}
  	while(1){
  		for(int i=0;i<N;i++){
  			if(A[i]%2!=0){
  			end=true;
    		break;
  		}
    	else{
    		A[i]/=2;
    	}
  	}	
   	if(end) {break;}
    else {count += 1;}
  	}
  	cout<<count<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int dx[]={1,0,-1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
int ceil(int a,int b){
    return (a+b-1)/b;
}
int main(void){
    int n;
    cin>>n;
    int flg=0;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==n) {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

using namespace std;
typedef set<int> si;

int N,M;
si neigh[200005];


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

        for (int i=0; i<N; i++) {
                if (neigh[i].count(0) > 0 && neigh[i].count(N-1)) {
                        cout << "POSSIBLE\n";
                        return 0;
                }
        }

        cout << "IMPOSSIBLE\n";
        return 0;
}

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

typedef long long ll;

int N;
int a[105];

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%d", a+i);

	int cnt = 1, tot = 0;
	for (int i = 0; i < N; ++i) {
		if (a[i] ^ a[i+1]) {
			tot += cnt / 2;
			cnt = 1;
		} else cnt++;
	}

	printf("%d\n", tot);
}

Measured memory_bytes: 256
/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-03-06(Fri)
   note
**********************************************************************/

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> L(M), R(M);
  for (int i = 0; i < M; i++) {
    cin >> L[i] >> R[i];
  }
  int maxL = 1;
  int minR = N;
  for (int i = 0; i < M; i++) { //
    maxL = max(maxL, L[i]);
    minR = min(minR, R[i]);
  }
  int ans = minR- maxL + 1;
  ans = max(ans, 0);

  cout << ans << endl;
}


Measured memory_bytes: 1024
from collections import deque


def main():
    s = input()
    d = deque(s)
    q = int(input())
    reverse = False
    for _ in range(q):
        line = input().split()
        if line[0] == "1":
            reverse = reverse ^ True
        else:
            if (not reverse and line[1] == "1") or (reverse and line[1] == "2"):
                d.appendleft(line[2])
            else:
                d.append(line[2])
    print("".join(list(d)) if not reverse else "".join(list(reversed(d))))


if __name__ == "__main__":
    main()


Measured memory_bytes: 14304
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;
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; }

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

llong memo[410][410];  // memo[l][r] = min[l, r)
llong slime[410] = {0};
llong sumSlime[410] = {0};

llong search(llong left, llong right) {
    if(left + 1 == right) {
        return slime[left];
    }
    if(left == right) {
        return 0;
    }
    if(memo[left][right] >= 0) {
        return memo[left][right];
    }

    llong ret = INF;
    FORS(middle, left + 1, right) {
        ret = min(ret, search(left, middle) + search(middle, right));
    }
    ret += sumSlime[right] - sumSlime[left];
    memo[left][right] = ret;
    return ret;
}

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

    llong N;
    cin >> N;

    FOR(i, N) {
        cin >> slime[i];
        sumSlime[i + 1] = sumSlime[i] + slime[i];
    }

    FOR(l, N + 1) {
        FOR(r, N + 1) {
            memo[l][r] = -1;
        }
    }

    llong ans = search(0, N) - sumSlime[N];
    cout << ans << endl;

    return 0;
}

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

int partition(int *A, int p, int r) {
  int x = A[r];
  int tmp;
  int i = p - 1;
  for (int j = p; j < r; j++) {
    if (A[j] <= x) {
      i++;
      tmp = A[i]; A[i] = A[j]; A[j] = tmp;
    }
  }
  i++;
  tmp = A[i]; A[i] = A[r]; A[r] = tmp;
  return i;
}

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

  int n, q;
  cin >> n;

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

  q = partition(A, 0, n - 1);


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

  return 0;
}

Measured memory_bytes: 3504
#include <bits/stdc++.h>
#define rep(i,a,b) for(auto i=(a);i<(b);i++)
#define per(i,a,b) for(auto i=(a);i>=(b);i--)
#define Min(a,b) ((a) < (b) ? (a) : (b))
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define int_inf 0x3f3f3f3f
#define int_max 2147483647
#define ll_max 9223372036854775807
#define ull_max 18446744073709551615
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lowbit(x) (x)&(-x)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define eps 1e-8
#define all(v) (v.begin(),v.end())
#define db double
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const double pi=acos(-1.0);
const double inf = 1e100;
template<class T>
inline T read()
{
	T x=0,f=1;char s=getchar();
	while(s<'0'||s>'9') {if(s=='-')f=-1;s=getchar();};
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+s-48;s=getchar();};
	return x*f;
}
template<typename T>
inline void wri(T x)
{
	if(x<0){x=-x;putchar('-');};
	if(x/10) wri(x/10);
	putchar(x%10+48);
}
template<typename T>
inline void print(T x,char s)
{
	wri(x);
	putchar(s);
}
template<typename T>
T gcd(T a,T b)
{
	return b==0?a:gcd(b,a%b);
}
//关闭流同步就不能手写读入优化啦
int vis[10001000];
ll p[10001000];
ll ans[10001000];
void init(){
	for(int i=1;i<=10000000;i++) p[i]=1;
	for(int i=2;i<=10000000;i++){
		if(vis[i]) continue;
		p[i]=2;
		for(int j=2*i;j<=10000000;j+=i){
			ll r=1;
			int k=j;
			int cnt=0;
			while(k%i==0){
				cnt++;
				k/=i;
			}
			p[j]*=(cnt+1);
			vis[j]=1;
		}
	}
	for(int i=1;i<=10000000;i++){
		p[i]=p[i-1]+1ll*p[i]*i;
		//cout<<i<<" "<<ans[i]<<endl;
	}
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int n;
    cin>>n;
    init();
	cout<<p[n]<<endl;
    return 0;
}



Measured memory_bytes: 120824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	ll n, in ,sum=0,ans=0;
	map<ll, int> m;
	cin >> n;
	m[0] = 1;
	rep(i, n) {
		cin >> in;
		sum += in;
		if (m.find(sum)!=m.end())  m[sum] += 1;
		else m[sum] = 1;
	}
	for (auto itr = m.begin(); itr != m.end(); itr++) {
		ll t = itr->second;
		ans += t*(t-1)/2;
	}
	cout << ans<<endl;

}

Measured memory_bytes: 12800
import std.stdio, std.string, std.string;

void main()
{
  long h, w;
  readf("%d %d\n", &h, &w);
  string[] s;
  foreach (_; 0..h) {
    s ~= readln.strip();
  }
  foreach (y; 0..h) {
    foreach (x; 0..w) {
      if (s[y][x] == '.') {
        continue;
      }
      auto dx = [0, -1, 1, 0];
      auto dy = [-1, 0, 0, 1];

      bool flag = false;
      foreach (i; 0..4) {
        auto x2 = x + dx[i], y2 = y + dy[i];
        if (x2 < 0 || y2 < 0 || w <= x2 || h <= y2) {
          continue;
        }
        if (s[y2][x2] == '#') {
          flag = true;
          break;
        }
      }

      if (!flag) {
        writeln("No");
        return;
      }

    }
  }
  writeln("Yes");
}


Measured memory_bytes: 380
def main():
    N = int(input())
    A = list(map(int, input().split()))

    money = 1000
    trading = []
    buy = True

    for i in range(1, len(A)):
        if buy:
            if A[i] <= A[i-1]:
                continue
            else:
                trading.append(A[i-1])
                if i == len(A)-1:
                    trading.append(A[i])
                buy = False
        else:
            if A[i] >= A[i-1]:
                if i == len(A)-1:
                    trading.append(A[i])
                continue
            else:
                trading.append(A[i-1])
                buy = True
    
    if len(trading) % 2 == 1:
        trading.pop(-1)
    

    stock = 0
    
    for i in range(len(trading)):
        if i % 2 == 0:
            stock = money // trading[i]
            money -= stock * trading[i]
        else:
            money += stock * trading[i]
            stock = 0
    
    print(money)


if __name__ == '__main__':
    main()

Measured memory_bytes: 61988
#include <stdio.h>
#include <stdlib.h>

int puz[3][3];
int tmp[3][3];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

void empty(int *x,int *y) {
  int i,j;
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      if(!puz[i][j]){
        *x=j;
        *y=i;
        return;
      }
    }
  }
}

void swap(int *a, int *b) {
  int tmp;
  tmp= *a;
  *a= *b;
  *b=tmp;
}

int cal() {
  int i,a;
  int sum=0;
  for(i=0;i<9;i ++){
    a=puz[i/3][i%3];
    if(a){
      a--;
      sum+=abs(i/3-a/3)+abs(i%3-a%3);
    }
  }
  return sum;
}

int dfs(int x, int y, int p, int dep, const int lim) {
  int i,h,nx,ny,res;
  h=cal();
  if(h==0){
    return dep;
  }
  if(dep+h>lim){
    return -1;
  }
  for(i=0;i<4;i++){
    nx=x+dx[i];
    ny=y+dy[i];
    if(~p&&i==(p+2)%4) continue;
    if(!(0<=nx&&nx<3&&0<=ny&&ny<3)) continue;
    swap(&puz[y][x],&puz[ny][nx]);
    res=dfs(nx,ny,i,dep+1,lim);
    if(~res){
      return res;
    }
    swap(&puz[y][x],&puz[ny][nx]);
    }
  return -1;
}

int main() {
  int i,j,ans,x,y,l;
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      scanf("%d",&puz[i][j]);
    }
  }
  empty(&x,&y);
  for(l=0;l<100;l++){
    for(i=0;i<3;i++){
      for(j =0;j<3;j++){
        tmp[i][j] = puz[i][j];
      }
    }
    ans=dfs(x,y,-1,0,l);
    if(ans!=-1){
      printf("%d\n",ans);
      break;
    }
    for(i=0;i<3;i++){
      for(j=0;j<3;j++){
        puz[i][j]=tmp[i][j];
      }
    }
    ans= -1;
    if(l==99){
      printf("%d\n",ans);
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
  
int main(){
    char number[1001];
    int i, sum;
    while(1){
        scanf("%s", number);
        if(number[0]=='0')break;
        sum=0;
        for(i=0;number[i]!='\0';i++){
            sum+=number[i]-'0';
        }
        printf("%d\n", sum);
    }

    return 0;
}


Measured memory_bytes: 2044
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int64_t N, D, A;
  cin >> N >> D >> A;
  vector<pair<int64_t, int64_t>> XH(N);
  rep(i, N) {
    int64_t x, h;
    cin >> x >> h;
    XH[i].first = x;
    XH[i].second = (h + A - 1) / A;
  }
  sort(XH.begin(), XH.end());

  int64_t answer = 0;
  int64_t damage = 0;
  queue<pair<int64_t, int64_t>> que;
  rep(i, N) {
    while (!que.empty() && que.front().first < XH[i].first) {
      damage -= que.front().second;
      que.pop();
    }
    if (damage < XH[i].second) {
      int64_t diff = (XH[i].second - damage);
      answer += diff;
      damage += diff;
      que.emplace(XH[i].first + 2 * D, diff);
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 4992
n=int(input())
c=[[0]*10 for i in range(10)]
for a in range(1,n+1):
  a=str(a)
  c[int(a[-1])][int(a[0])]+=1
ans=0
for i in range(1,10):
  for j in range(1,10):
    ans+=c[i][j]*c[j][i]
print(ans)



Measured memory_bytes: 9132
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

bool compare(pair<int, int> a, pair<int, int> b) {
  if (a.second != b.second) return a.second < b.second;
  else                      return a.first < b.first;
}

bool accessible(const vector<bool>& blocked, int start, int end) {
  for (int i = start; i < end; ++i) {
    if (blocked[i]) return false;
  }
  return true;
}

int main() {
  int N, M; cin >> N >> M;
  vector<pair<int, int>> ps(M);
  vector<bool> blocked(N-1, false);
  for (int i = 0; i < M; ++i) {
    int a, b; cin >> a >> b;
    ps[i] = {a, b};
  }

  sort(ps.begin(), ps.end(), compare);

  int cnt = 0;
  for (auto p : ps) {
    int start = p.first;
    int end = p.second;
    if (accessible(blocked, start, end)) {
      ++cnt;
      blocked[end-1] = true;
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 1024
(N,M) = (int(i) for i in input().split(" "))
S = input()
T = [S[0]]
for i in range(1,len(S)):
	if T[-1][-1] != S[i]:
		T.append(S[i])
	else:
		T[-1]+=S[i]
mp = [len(t) for t in T]
ans = len(S) - len(mp) + M*2
print(min(ans,len(S)-1))

Measured memory_bytes: 5484
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
using namespace std;

int main () {
	string s;
	cin >> s;
	if(s == "SUN") cout << 7;
	else if(s == "MON") cout << 6;
	else  if(s == "TUE") cout << 5;
	else if(s == "WED") cout << 4;
	else if(s == "THU") cout << 3;
	else if(s == "FRI") cout << 2;
	else cout << 1;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
L=[0]+list(map(int,input().split()))
for i in range(len(L)):
    L[i]-=i

D={}
for i in range(1,len(L)):
    if L[i] not in D:
        D[L[i]]=1
    else:
        D[L[i]]+=1

ans=0
for i in range(1,len(L)):
    if -2*i-L[i] in D:
        ans+=D[-2*i-L[i]]
print(ans)

Measured memory_bytes: 112912
#define  _USE_MATH_DEFINES

#define  rep(i, n) for(int i = 0; i < n; i++)
#define  repx(i, a, n) for(int i = a; i < n; i++)
#define  loop while(1)
#define  lli long long int
#define  aryout(ary) rep(i, ary.size()) cout << ary[i] << (i < ary.size() - 1 ? " " : "\n");
#define  arysort(v) sort(v.begin(), v.end())
#define  aryreverse(v) reverse(v.begin(),v.end())
#define  arysum(v) accumulate(v.begin(), v.end(), 0)
 
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <utility>
#include <set>

using namespace std;

int main() {

  int n, m;
  cin >> n >> m;

  vector<vector<int>> v(m, vector<int>(n, 0));
  
  rep(i, m) {
    int k, tmp;
    cin >> k;
    rep(j, k) {
      cin >> tmp;
      v[i][tmp - 1] = 1;
    }
  }
  
  vector<int> p(m);
  rep(i, m) cin >> p[i];

  int ans = 0;

  for(int bit = 0; bit < (1 << n); bit++) {
    vector<int> sw(n);
    rep(i, n) sw[i] = (bit & (1 << i) ? 1 : 0);

    int cnt0 = 0;
    rep(i, m) {
      int cnt1 = 0;
      rep(j, n) {
        cnt1 += v[i][j] * sw[j];
      }
      if (cnt1 % 2 == p[i]) cnt0 += 1;
    }
    if (cnt0 == m) ans += 1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"\Case #"<<x<<"\:"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}


void virus(){
        
        ll tot, num;
        cin>>tot>>num;
        ll minn = tot * 2;
        ll maxx = tot * 4;

        if((num%2 == 0) and(num >= (minn)) and (num <= (maxx))) cout<<"Yes";
        else cout<<"No";
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t=1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 3648
//////////////////////
        	//******************//
			//**  OM THUMMAR  **//
			//**  DA-IICT     **//
			//**  201901070   **//
			//**  I'D=Aom2608 **//
			//******************//
			/////////////////////

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;


#define PI 3.141592653589793
#define MOD 1000000007



int main()
{
	IOS;
	ll n,m,count=0;
	cin>>n>>m;
	ll h[n+1];
	ll i;
	for(i=1;i<=n;i++)  cin>>h[i];
	map<ll,ll>   M;
	vll v[n+1];
	for(i=1;i<=m;i++)
	{
		ll x,y;
		cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}
	for(i=1;i<=n;i++)
	{
		bool flag=0;
		for(ll j=0;j<v[i].size();j++)
		{
			if(h[i]<=h[v[i][j]])
			{
				flag=1;
				break;
			}

		}
		if(!flag)
		{
			count++;
		}
	}
	cout<<count;
}





Measured memory_bytes: 10276
N, K = map(int,input().split())
R, S, P = map(int,input().split())
T = input()

#kT = [''] * K
kT = {}
points = {'r': P, 's': R, 'p': S}

for i in range(N):
  #kT[i % K] += T[i]
  if i % K not in kT.keys():
    kT[i % K] = list(T[i])
  else:
    kT[i % K].append(T[i])
    
ans = 0
  
for i in kT.keys():
  for j in range(len(kT[i])):
    if j == 0:
      ans += points[kT[i][j]]
    else:
      if kT[i][j-1] == kT[i][j]:
        kT[i][j] = 'X'
      else:
        ans += points[kT[i][j]]
        
print(ans)

Measured memory_bytes: 24612
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.*;
import java.math.*;
import java.util.*;
class Main{

    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String S = br.readLine();
        String t = br.readLine();
        int min = Integer.MAX_VALUE;
        for(int i = 0; i < S.length() - t.length() + 1; i++){

            String s = S.substring(i, i + t.length());

            int count = 0;
            for(int j = 0; j < t.length(); j++){
                if(t.charAt(j) != s.charAt(j)){
                    count++;
                }
                if(count >= min){
                    break;
                }
                
            }
            min = Math.min(min, count);

        }
        System.out.print(min);
    }  

}

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

int main() {
    int christmas;

    cin >> christmas;

    if(christmas == 24){
        cout << "Christmas Eve";
    
    }else if(christmas == 23){
        cout << "Christmas Eve Eve";
    
    }else if(christmas == 22){
        cout << "Christmas Eve Eve Eve";
    
    }else {
        cout << "Christmas";
    }
   
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int D[100001], n, tmp, a, b;
int main(){
    cin>>tmp>>n;
    memset(D,0,sizeof(D));
    for(int i = 0; i < n; i++){
        int t1;
        string t2;
        cin>>t1>>t2;
        if(D[t1] == 1000000) continue;
        if(t2 == "AC"){
            b+=abs(D[t1]);
            D[t1] = 1000000;
            a++;
        }
        if(t2 == "WA") D[t1]--;
    }
    cout<<a<<" "<<b;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{

    public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        int a=0;
        int b=0;
        int c=0;
        int d=0;
        int score=0;
        a=sc.nextInt();
        String s=String.valueOf(a);
        if(s.endsWith("2")||s.endsWith("4")||s.endsWith("5")||s.endsWith("7")||s.endsWith("9")){
            System.out.print("hon");
        }



        if(s.endsWith("0")||s.endsWith("1")||s.endsWith("6")||s.endsWith("8")){
            System.out.print("pon");
        }
        if(s.endsWith("3")){
            System.out.print("bon");
        }





    }

}





Measured memory_bytes: 35720
N, K = map(int,input().split()) # 複数の数字を変数に格納

red = N - K
blue = K
division = 10 ** 9 + 7

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under % division
  
for i in range(K):
    if i > red:
        print("0")
    else:
        tmp_blue = cmb(blue-1,i) % division
        tmp_red = cmb(red+1,red-i)
        result = int(tmp_blue * tmp_red % division)
        print("{}".format(result))



Measured memory_bytes: 3940
from collections import defaultdict

N,A = map(int, raw_input().split())
cards = map(int, raw_input().split())

class CardSet:
  def __init__(self, n):
    self.cards = []
    self.combis = [defaultdict(lambda:0) for i in range(n+1)]

  def add_card(self, card):
    self.cards.append(card)
    for n in range(len(self.cards)-1,0,-1):
      for k, v in self.combis[n].items():
        self.combis[n+1][k+card] += v
    self.combis[1][card] += 1

  def avg_count(self, average):
    count = 0
    for n in range(1,len(self.cards)+1):
      count += self.combis[n][n*average]
    return count

  def __str__(self):
    return '\n'.join([str(cs) for cs in self.combis])

cardset = CardSet(N)
for card in cards:
  cardset.add_card(card)
print cardset.avg_count(A)

Measured memory_bytes: 5624
#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for (int x=y; x<=z; x++)
#define downrep(x,y,z) for (int x=y; x>=z; x--)
#define ms(x,y,z) memset(x,y,sizeof(z))
#define LL long long
#define repedge(x,y) for (int x=hed[y]; ~x; x=edge[x].nex)
inline int read(){
	int x=0; int w=0; char ch=0;
	while (ch<'0' || ch>'9') w|=ch=='-',ch=getchar();
	while (ch>='0' && ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w? -x:x;
}
const int maxn=505;
const int maxm=505;
struct node{ int x1,y1,x2,y2,kd; }ans[maxn*maxm],ANS[maxn*maxm];
int a[maxn][maxm],n,m,tot,sum;
void move_left(int i){
		while (ans[i].y1>ans[i].y2) { ANS[++sum].x1=ans[i].x1; ANS[sum].y1=ans[i].y1;
		ANS[sum].x2=ans[i].x1; ANS[sum].y2=--ans[i].y1; }
}
void move_right(int i){
		while (ans[i].y1<ans[i].y2) { ANS[++sum].x1=ans[i].x1; ANS[sum].y1=ans[i].y1;
		ANS[sum].x2=ans[i].x1; ANS[sum].y2=++ans[i].y1; }
}
void move_down(int i){
	while (ans[i].x1<ans[i].x2) { ANS[++sum].x1=ans[i].x1; ANS[sum].y1=ans[i].y1;
		ANS[sum].x2=++ans[i].x1; ANS[sum].y2=ans[i].y1; }
}
int main(){
    n=read(); m=read();
    rep(i,1,n) rep(j,1,m) a[i][j]=read();
    int cnt=0; int t=1;
    rep(i,1,n) {
    	if (t==1) 
    		rep(j,1,m) if (a[i][j]&1) {
    			++cnt; if (cnt&1) { ans[++tot].x1=i; ans[tot].y1=j; }
			    if (!(cnt&1)) { ans[tot].x2=i; ans[tot].y2=j; }
			}
		    
		if (t==2) 
			downrep(j,m,1) if (a[i][j]&1) {
				++cnt; if (cnt&1) { ans[++tot].x1=i; ans[tot].y1=j; }
				if (!(cnt&1)) { ans[tot].x2=i; ans[tot].y2=j; }
			}
		
		if (t==1) t=2; else t=1; if ((cnt&1)&&(!ans[tot].kd)) ans[tot].kd=t;  
	}
	if (!ans[tot].x2) tot--;
	rep(i,1,tot) {
		if (ans[i].kd==1){
			move_left(i);
			move_down(i);
			move_right(i);
		}
		if (ans[i].kd==2){
			move_right(i);
			move_down(i);
			move_left(i);
		}
		if (!ans[i].kd){
			move_left(i);
			move_right(i);
		}
	}
    printf("%d\n",sum);
    rep(i,1,sum) printf("%d %d %d %d\n",ANS[i].x1,ANS[i].y1,ANS[i].x2,ANS[i].y2);
    return 0;
}

Measured memory_bytes: 12288
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void output(vector<int> A)
{
    for(int i = 0; i < A.size(); ++i){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
}
int count;
vector<int> insertionSort(vector<int>& A, int g)
{
    for(int i = g; i < A.size(); ++i){
        // output(A);
        int v = A[i];
        int j = i - g;
        while(j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j -= g;
            ::count++;
        }
        A[j+g] = v;
    }
    // output(A);
    return A;
}
vector<int> GetG(int n)
{
    int h = 1;
    vector<int> G;
    while(h <= n){
        G.push_back(h);
        h = 3 * h + 1;
    }
    reverse(G.begin(), G.end());
    return G;
}
vector<int> shellSort(vector<int>& A)
{
    vector<int> G = GetG(A.size());
    for(int i = 0; i < G.size(); i++){
        insertionSort(A, G[i]);
    }
    return G;
}
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }
    vector<int> G = shellSort(A);
    cout << G.size() << endl;
    output(G);
    cout << ::count << endl;
    for(int i = 0; i < A.size(); ++i){
        cout << A[i] << endl;;
    }
    
    
    return 0;
}

Measured memory_bytes: 10720
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

int main(){
    int n; cin >> n;
    string s; cin >> s;
    
    int res = 0;
    
    for(int i=1 ; i<n ; i++){
        int cc = 0;
        for(char c ='a' ; c<='z' ; c++){
            bool left=0, right = 0;
            
            for(int j=0;j<i ; j++){
                if(s[j] == c) left = 1;
            }
            
            for(int j=i ; j<n ; j++){
                if(s[j] == c) right = 1;
            }
            
            if(left and right) cc++;
        }
        
        res = max(res,cc);
    }
    cout << res << endl;
}







Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  int64_t a, b, c, k;
  cin >> a >> b >> c >> k;

  if (k % 2 == 0) cout << a-b << endl;
  if (k % 2 == 1) cout << b-a << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter, defaultdict

h, w, n = map(int, input().split())
dic = defaultdict(int)
for _ in range(n):
    a, b = map(int, input().split())
    for y in range(a - 2, a + 1):
        for x in range(b - 2, b + 1):
            if 1 <= y <= h - 2 and 1 <= x <= w - 2:
                dic[(x, y)] += 1
counter = Counter(dic.values())
cntSum = (w - 2) * (h - 2)
counter[0] = cntSum - sum(counter.values())
for k in range(10):
    print(counter[k])

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

static const int N = 200;

int main(){
    int n, p[N+1],m[N+1][N+1];
    cin >> n;
    for(int i=1; i<=n;i++){
        cin >> p[i-1] >> p[i];
    }

    for(int i=1;i<=n;i++)m[i][i] = 0;
    
    for(int l = 2;l<=n;l++){
        for(int i=1;i<=n;i++){
            int j = i+l-1;
            m[i][j] = (1<<21);
            for(int k=i;k<=j-1;k++){
                m[i][j] = min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
            }
         }
    }
    cout << m[1][n] << endl;

    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll n;
    cin>>n;
    vector <tuple<string,ll,ll>> a;
    for (ll i = 1; i <= n; i++){
        string s;
        ll p;
        cin>>s>>p;
        p = -p;
        a.push_back(tie(s,p,i));
    }
    sort(a.begin(), a.end());
    
    for (ll i =0; i < n; i++){
        cout << get<2>(a[i]) <<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int min = 1000;
		for (int i=0;i<s.length()-2;i++) {
			String temp = s.substring(i,i+3);
			int a= Integer.parseInt(temp);
			if (Math.abs(a-753)<min) {
				min = Math.abs(a-753);
			}
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 35624