akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define _USE_MATH_DEFINES
//BIAR MANTAB LAH YA
#define Willy using
#define Indrayana namespace
#define Komara std
 
Willy Indrayana Komara;

using ll = long long int;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    map<int, int> boss;
    for (int i = 1; i < n; i++)
    {
        int input;
        cin >> input;
        boss[input]++;
    }
    for (int i = 1; i <= n; i++)
    {
        cout << boss[i] << '\n';
    }
}

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

int main()
{
	int a, b, c;
	int k;
	int n;

	scanf("%d%d%d", &a, &b, &c);
	n = 0;
	for (k = a; k <= b; k++) {
		if (c % k == 0) n++;
	}
	printf("%d\n", n);
	return 0;
}



Measured memory_bytes: 2104
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <queue>
using namespace std;

int main(){
  long long int A, B, C, D, ans = 0, primer = 0, maker = 0, setG = 0 ;
  cin >> A >> B >> C >> D ;
  ans = max(A * C,B * D) ;
  ans = max(ans,A*D) ;
  ans = max(ans,B*C) ;
  cout << ans << endl ;
  return 0 ;
}  

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

int main(){
  int dy,a,b,c,d;
  int ans,mini;
  cin >> dy >> a >> b >> c >> d;
  if(a % c == 0) mini = a / c;
  else mini = a / c + 1;
  if(b % d == 0) mini = max(mini,b/d);
  else mini = max(mini,b/d+1);
  cout << dy - mini << endl;
}

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

int main()
{
    int a[1000];
    int c,b,t;
    a[1]= 1;
    for(int i=2; i<=999; i++)
        a[i] = a[i-1]+ i;

    cin>>c>>b;
    t= b-c;
    t = a[t]-b;
    cout<<t<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0); 
int h,w,k;
int ret;
int ans;
char board[6][6];

int hasBit(int s, int num){
    return (s >> num) & 1;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> h >> w >> k;
    rep1(i,0,h)
        rep1(j,0,w)
            cin >> board[i][j];

    for(int r = 0; r < (1 << h); r++){
        for(int c = 0; c < (1 << w); c++){
            ret = 0;
            for(int i = 0; i < h; i++){
                for(int j = 0; j < w; j++){
                    if(hasBit(r,i) && hasBit(c,j) && board[i][j] == '#') ret++;
                }
            }
            if(ret == k) ans++;
        }
    }
    cout << ans;
    return 0;  
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n + 1);
    a[0] = 0;
    rep(i, n) cin >> a[i + 1];
    vector<int> ans(n + 1);
    ans[0] = 0;
    for(int i = n; i > 0; i--){
        if(i > n / 2) {
            ans[i] = a[i];
            continue;
        }
        int s = 0;
        for(int j = i; j < n + 1; j += i){
            if(ans[j])s++;
        }
        if(s % 2 == 0){
            if(a[i] == 0) ans[i] = 0;
            else ans[i] = 1;
        }else{
            if(a[i] == 1) ans[i] = 0;
            else ans[i] = 1;
        }
    }
    int memo = 0;
    rep(i, n + 1){
        if(ans[i]) memo++;
    }
    cout << memo << endl;
    rep(i, n + 1){
        if(ans[i]) cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 2432
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<array>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


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


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };
int dx2[2] = { 1,0 };
int dy2[2] = { 0,1 };

/******************************************************************************************/
typedef tuple<int,int,int> tpl;

template <typename T> bool next_combination(const T first, const T last, int k) {
    const T subset = first + k;
    // empty container | k = 0 | k == n 
    if (first == last || first == subset || last == subset) {
        return false;
    }
    T src = subset;
    while (first != src) {
        src--;
        if (*src < *(last - 1)) {
            T dest = subset;
            while (*src >= *dest) {
                dest++;
            }
            iter_swap(src, dest);
            rotate(src + 1, dest + 1, last);
            rotate(subset, subset + (last - dest) - 1, last);
            return true;
        }
    }
    // restore
    rotate(first, subset, last);
    return false;
}

int main() {

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

	int N;
	cin >> N;
	ll sum = 0;
	for(int i = 1;i <= N;i++){

		if(i%3==0 && i%5==0){

		}else if(i%3==0){

		}else if(i%5==0){

		}else{
			sum += i;
		}

	}
	cout << sum << endl;


	return 0;
}






Measured memory_bytes: 3600
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <cmath>
#include <unordered_map>

#define MaxN 200010

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

int n, c[MaxN];
vector<int> edges[MaxN];
bool vis[MaxN];
int dfn[MaxN], en[MaxN], ti, siz[MaxN];
stack<int> col_stack[MaxN];
ll ans[MaxN];

void dfs(int now) {
    dfn[now] = ++ti;
    vis[now] = true;
    siz[now] = 1;
    for (const auto& it : edges[now]) {
        if (!vis[it]) {
            dfs(it);
            siz[now] += siz[it];
            int t = siz[it];
            while (!col_stack[c[now]].empty() && dfn[col_stack[c[now]].top()] > dfn[now]) {
                int top = col_stack[c[now]].top();
                t -= siz[top];
                col_stack[c[now]].pop();
            }

            ans[c[now]] += (ll)t * (t + 1) / 2LL;
        }
    }
    col_stack[c[now]].push(now);
    en[now] = ++ti;
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &c[i]);
    }
    for (int i = 1; i < n; ++i) {
        int a, b;
        scanf("%d%d", &a, &b);
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    dfn[0] = 0;
    dfs(1);
    for (int i = 1; i <= n; ++i) {
        int t = n;
        while (!col_stack[i].empty()) {
            int top = col_stack[i].top();
            t -= siz[top];
            col_stack[i].pop();
        }
        ans[i] += (ll)t * (t + 1) / 2LL;
        ans[i] = (ll)n * (n + 1) / 2LL - ans[i];
        printf("%lld\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 169624
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <queue>
#include <vector>
using namespace std;

char str[100];
int H, W = 0;
int grid[50][50];

vector< vector<int> > score(50, vector<int> (50, 0));

bool visited[50][50];
const int dh[] = {1, -1, 0, 0};
const int dw[] = {0, 0, 1, -1};

// 幅優先探索
void bfs(int i, int j) {
    queue<pair<int,int> > Q;
    score[i][j] = 0;            /* スタート地点 */
    Q.push(make_pair(i, j));    /* キューにpush */
    /* キューが空になるまで処理を実行 */
    while(!Q.empty()) {
        /* 探索の起点となる座標を記憶してからポップ */
        pair<int,int> q = Q.front();
        Q.pop();
        int h = q.first;
        int w = q.second;
        /* 起点を元に座標を移動 */
        for (int k = 0; k < 4; k++) {
            int nh = h + dh[k];
            int nw = w + dw[k];
            /* 移動先が迷路の範囲外なら処理をスキップ */
            if (nh < 0 || nh >= H || nw < 0 || nw >= W) {
                continue;
            }
            /* 移動先が壁か訪問済みなら処理をスキップ */
            if (grid[nh][nw] == '#' || visited[nh][nw]) {
                continue;
            }
            /* 移動先のスコアを起点のスコア+1にする */
            score[nh][nw] = score[h][w] + 1;
            /* 移動先の座標を訪問済みにする */
            visited[nh][nw] = true;
            /* 訪問先の座標をキューにプッシュ */
            Q.push(make_pair(nh, nw));
        }
    }
}

void getInput(char *pstr)
{
    fgets(pstr, sizeof(str), stdin);
}

int main() {
    char *pstr = &str[0];
    int result = 0;
    
    /* 標準入力の処理 */
    getInput(pstr);
    H = atoi(strtok(pstr, " "));
    W = atoi(strtok(NULL, " "));
    
    for (int i = 0; i < H; i++) {
        getInput(pstr);
        for (int j = 0; j < W; j++) {
            grid[i][j] = *pstr;
            pstr++;
        }
    }
    
    /* 幅優先探索の実行 */
    bfs(0, 0);
    
    /* 黒の数をカウント */
    int blackCount = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (grid[i][j] == '#') {
                blackCount++;
            }
        }
    }
    
    /* ゴールにたどり着けなかった場合は-1を入れる */
    if (score[H - 1][W - 1] == 0) {
        result = -1;
    } else {
        /* 格子の数 - 黒の数 - 経路 */
        result = H * W - blackCount -(score[H - 1][W - 1] + 1);
    }
    
    /* 結果の出力 */
    printf("%d\n", result);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu


const ll INF=1e9+7;
const ll N = 101;
string s;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>s;
	ll k=0;
	if(s[0]=='o')k++;
	if(s[1]=='o')k++;
	if(s[2]=='o')k++;
	cout<<700+k*100<<endl;
	return 0;
}

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

ll mod=1e9+7;
int inf = 1e6;

int n;
int a,b,c;
vector<int> l(8);

int dfs(int j, int ta, int tb, int tc) {
    if (j==n) {
        if (ta>0 && tb>0 && tc>0) return abs(a-ta)+abs(b-tb)+abs(c-tc)-30;
        else return inf;
    }
    int resa=dfs(j+1,ta+l[j],tb,tc)+10;
    int resb=dfs(j+1,ta,tb+l[j],tc)+10;
    int resc=dfs(j+1,ta,tb,tc+l[j])+10;
    int res=dfs(j+1,ta,tb,tc);
    return min(min(resa,resb),min(resc,res));
}

int main() { 
    cin >> n >> a >> b >> c;
    for (int i=0;i<n;i++) cin >> l[i];
    cout << dfs(0,0,0,0) << endl;
}

Measured memory_bytes: 256
def fib(n):
    if n == 0 or n == 1:
        return 1
    else:
        a = [1, 1]
        for i in range(2, n + 1):
            a.append(a[i - 1] + a[i - 2])
        return a[n]

if __name__ == '__main__':
    n = int(input())
    print(fib(n))



Measured memory_bytes: 5600
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char dn[1300000], * di = dn;
int keta1 = 1, keta2;
char C1[10] = { '1', '0', '0', '0', '0', '0' };
char C2[10] = { '0', '0', '0', '0', '0', '0' };

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


	int N, M;
	scanf("%d %d", &N, &M);

	if (N % 2) {
		int n = N - 1;
		keta2 = 0;
		while (n) {
			*(C2 + keta2) = '0' + n % 10;
			n /= 10;
			keta2++;
		}

		rep1(i, M) {
			for (int i = keta1 - 1; i >= 0; i--)* di++ = (*(C1 + i));
			*di++ = ' ';
			for (int i = keta2 - 1; i >= 0; i--)* di++ = (*(C2 + i));
			*di++ = '\n';

			C1[0]++;
			int tmp = 0;
			while (C1[tmp] > '9') {
				C1[tmp++] -= 10;
				C1[tmp]++;
				if (C1[keta1] != '0') keta1++;
			}
			C2[0]--;
			tmp = 0;
			while (C2[tmp] < '0') {
				C2[tmp++] += 10;
				C2[tmp]--;
				if (C2[keta2 - 1] == '0') keta2--;
			}
		}
	}
	else {
		int n = N;
		keta2 = 0;
		while (n) {
			*(C2 + keta2) = '0' + n % 10;
			n /= 10;
			keta2++;
		}
		rep1(i, (M + 1) / 2) {
			for (int i = keta1 - 1; i >= 0; i--)* di++ = (*(C1 + i));
			*di++ = ' ';
			for (int i = keta2 - 1; i >= 0; i--)* di++ = (*(C2 + i));
			*di++ = '\n';

			C1[0]++;
			int tmp = 0;
			while (C1[tmp] > '9') {
				C1[tmp++] -= 10;
				C1[tmp]++;
				if (C1[keta1] != '0') keta1++;
			}
			C2[0]--;
			tmp = 0;
			while (C2[tmp] < '0') {
				C2[tmp++] += 10;
				C2[tmp]--;
				if (C2[keta2 - 1] == '0') keta2--;
			}
		}
		C2[0]--;
		int tmp = 0;
		while (C2[tmp] < '0') {
			C2[tmp++] += 10;
			C2[tmp]--;
			if (C2[keta2 - 1] == '0') keta2--;
		}
		for (int i = (M + 1) / 2 + 1; i <= M; i++) {
			for (int i = keta1 - 1; i >= 0; i--)* di++ = (*(C1 + i));
			*di++ = ' ';
			for (int i = keta2 - 1; i >= 0; i--)* di++ = (*(C2 + i));
			*di++ = '\n';

			C1[0]++;
			int tmp = 0;
			while (C1[tmp] > '9') {
				C1[tmp++] -= 10;
				C1[tmp]++;
				if (C1[keta1] != '0') keta1++;
			}
			C2[0]--;
			tmp = 0;
			while (C2[tmp] < '0') {
				C2[tmp++] += 10;
				C2[tmp]--;
				if (C2[keta2 - 1] == '0') keta2--;
			}
		}
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 2724
#include<bits/stdc++.h>
using namespace std;
int main(){
int A,B;
  cin>>A>>B;
  if((A+B)%3==0||A%3==0||B%3==0){
  cout<<"Possible"<<endl;
  }
  else{
  cout<<"Impossible"<<endl;
  
  }
}


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

/**
 * Created by jaga on 9/6/16.
 * dpで解けるかな?
 * 入力の数字を -Aしておき、組み合わせで0が何通り作れるかを考える
 * dp[j][k] = j番目(0-indexed)までの文字をつかってkが何回作れるか  j < N , - N*50 < k < N*50 + 1
 * kの値は k + N*50　としておく(負の値の処理のため)
 * dp[j][k] = dp[j - 1][k] + dp[j-1][k - x[j]]
 * j-1番目までの数で作ってj番目は使わない + j - 1番目までの数でk-x[j]をつくってjを使う
 * これに+してx[j]がkのときはdp[j-1][k] = 0でも1足すことになる（コーナーケース）
 */
public class Main {
    public static void main (String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String text[] = line.split(" ");

        int N,A;
        N = Integer.parseInt(text[0]);
        A = Integer.parseInt(text[1]);

        line = br.readLine();
        text = line.split(" ");

        int [] x = new int[N];

        for(int i = 0; i < N ; i++){
            x[i]  = Integer.parseInt(text[i]) - A;
//            System.out.println(x[i]);
        }

        long dp[][] = new long [N][N * 50 * 2 + 1];
        int dpl = 50 * N;

        dp[0][x[0] + dpl] = 1;

        for(int j = 1; j < N; j++){

            for(int k  = -1 * N * 50; k < N * 50 + 1; k++){
//                System.out.println(k + dpl - x[j]);
                if(k + dpl - x[j] >= 0 && k + dpl - x[j] <= 50*N*2){
//                if(k + dpl - x[j] >= 0 ){
                    dp[j][k + dpl] = dp[j-1][k + dpl] + dp[j-1][k + dpl - x[j]];
                }else {
                    dp[j][k + dpl] = dp[j - 1][k + dpl];
                }
                if(x[j] == k) dp[j][k + dpl] ++;

//                System.out.println("dp[" + j + "][" + k + "] = " + dp[j][k + dpl]);
            }
        }


        System.out.println(dp[N - 1 ][dpl]);
    }
}


Measured memory_bytes: 10324
S = input()
given = ['dream', 'dreamer', 'erase', 'eraser']


while True:
    if len(S) == 0:
        break
    judge = [S.endswith(i) for i in given]
    if True in judge:
        index = judge.index(True)
        length = len(given[index])
        S = S[:-length]
    else:
        print('NO')
        quit()

print('YES')


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

#define pi 3.141592653589
#define MOD 1000000007
#define to() int t; cin>>t; while(t--)
#define pb push_back
#define in insert
#define mp make_pair
#define ff first
#define ss second
#define si(s) s.size()
#define fori(it,v) for(it=v.begin();it!=v.end(); it++)
#define for1(low,high,k) for(int i=low;i<high;i+=k)
#define for11(low,high,k) for(int j=low;j<high;j+=k)
#define for2(low,high,k) for(int i=low;i<=high;i+=k)
#define rev(high,low,k)  for(int i=high;i>=low ;i-=k)
#define all(x) x.begin(), x.end()
#define fil(x,i) memset(x,i,sizeof(x));
#define setbits(x) __builtin_popcount(x)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;

void i_o() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin) ;
	freopen("output.txt", "w", stdout) ;
#endif
}

int main()
{
	boost; i_o();
	int n; cin >> n;
	std::vector<pair<int, int> > v(n);
	for1(0, n, 1) cin >> v[i].ff >> v[i].ss;
	bool f = false;
	for1(0, n - 2, 1) {
		if (v[i].ff == v[i].ss && v[i + 1].ff == v[i + 1].ss && v[i + 2].ff == v[i + 2].ss) f = true;
	}
	if (f) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3600
import itertools
N = int(input())
place = [list(map(int,input().split())) for _ in range(N)]
d_sum = 0
perm_len = 0
for p in itertools.permutations(list(range(N))):
    perm_len += 1
    for i in range(1,N):
        d_sum += ((place[p[i-1]][0]-place[p[i]][0])**2 + (place[p[i-1]][1]-place[p[i]][1])**2)**(1/2)
print(d_sum/perm_len)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // 102B - Maximum Difference

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] a = new int[n];
        int max = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            if (i > 0) {
                for (int j = 0; j < i; j++) {
                    int sa = Math.abs(a[i] - a[j]);
                    if (max < sa) max = sa;
                }
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

int main() {
	string S, T;
	cin >> S >> T;

	int cnt = 0;
	for (int i = 0; i < S.length(); ++i) {
		if (S[i] != T[i]) cnt += 1;
	}

	cout << cnt;
	return 0;
}

Measured memory_bytes: 3900
N = int(input())
A = list(map(int,input().split()))
D = {}
for i in range(N) :
    for j in range(-1,2) :
        a = A[i]+j
        if a not in D :
            D[a] = 1
        else :
            D[a] += 1
L = sorted(list(D.values()))
print(L[-1])


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

typedef pair<int, int> P;

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

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

signed main(){
    int N; cin >> N;
    vector<int> plus, minus;
    REP( i, N ){
        int t; cin >> t;
        if( t >= 0 ) plus.push_back( t );
        else         minus.push_back( t );
    }

    sort( ALL( plus ), greater<int>() );
    sort( ALL( minus ) );

    if( plus.empty() ){
        plus.push_back( minus.back() );
        minus.pop_back();
    }
    if( minus.empty() ){
        minus.push_back( plus.back() );
        plus.pop_back();
    }

    vector<P> ans;
    int cur = minus[0];
    REP( i, plus.size() - 1 ){
        ans.emplace_back( cur, plus[i] );
        cur -= plus[i];
    }

    ans.emplace_back( plus.back(), cur );
    cur = plus.back() - cur;

    FOR( i, 1, minus.size() ){
        ans.emplace_back( cur, minus[i] );
        cur -= minus[i];
    }

    cout << cur << endl;
    for( auto p : ans ) cout << p.first << " " << p.second << endl;

}


Measured memory_bytes: 5104
#include<iostream>
#include<map>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, n;
    map<int, bool>m;
    cin>>n;
    for(int i=0; i<n; i++)
    {
    	cin>>a;
    	if(m[a])
    		m.erase(a);
    	else
    		m[a]=true;
    }
    cout<<m.size();
}

Measured memory_bytes: 8260
#include <iostream>
using namespace std;
int main( void )
{
  int n,a[10],b[10],c[10],p,q;
  cin >> n;
  for( int i=0; i<n; i++ ){
    for( int j=0; j<10; j++ ) cin >> a[j];
    bool flag;
    for( int j=0; j<1024; j++ ){
      p=0; q=0; flag=true;
      for( int k=0; k<10; k++ ){
        if( j & (1<<k) ) b[p++] = a[k];
        else c[q++] = a[k];
      }
      for( int k=1; k<p; k++ )
        if( b[k-1] > b[k] ){ flag = false; break; }
      for( int k=1; k<q; k++ )
        if( c[k-1] > c[k] ){ flag = false; break; }
      if( flag ) break;
    }
    if( flag ) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

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

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


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

string solve(int N) {
  if (N == 0) return "0";
  if (N == 1) return "1";
  if (N % 2 == 0) {
    return solve(N / -2) + "0";
  } else {
    return solve((N-1)/-2) + "1";
  }
}

int main2() {
  int N = nextInt();
  string ans = solve(N);
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int d[n];
    for (int i = 0; i < n; i++) cin >> d[i];

    int bucket[101] = {0};
    for (int i = 0; i < n; i++) bucket[d[i]]++;

    int cnt = 0;
    for (int i = 1; i <= 100; i++) {
        if (bucket[i]) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
s = gets.chomp

a = s.count("a")
b = s.count("b")
c = s.count("c")
n = (s.length - 1) / 3

if [a, b, c].all? { |c| [n, n + 1].include?(c) }
  puts "YES"
else
  puts "NO"
end


Measured memory_bytes: 1916
import std.stdio;
import std.string;

/+
const int LEFT  = 0;
const int RIGHT = 1;
const int UP    = 2;
const int DOWN  = 3;
+/
enum {
    LEFT,
    RIGHT,
    UP,
    DOWN
}


void main()
{
    string[9] kabe;
    int x, y;
    int direction;

    foreach (i; 0..9) {
        kabe[i] = readln().chomp;
        kabe[i].length = 18;
    }
    x = 0;
    y = 0;
    direction = RIGHT;
    move(&x, &y, direction);
    while (x != 0 || y != 0) {
        if (isKabe(kabe, x, y, getLeft(direction)))
            direction = getLeft(direction);
        else if (isKabe(kabe, x, y, direction))
            {}
        else if (isKabe(kabe, x, y, getRight(direction)))
            direction = getRight(direction);
        else
            direction = getRight(getRight(direction));
        move(&x, &y, direction);
    }
    writeln();
}


bool isKabe(string[9] kabe, int x, int y, int dir)
{
    final switch (dir) {
    case LEFT:
        if (x <= 0) return false;
        return (kabe[y*2][x-1] == '1');
        break;
    case RIGHT:
        if (x >= 4) return false;
        return (kabe[y*2][x] == '1');
        break;
    case UP:
        if (y <= 0) return false;
        return (kabe[y*2-1][x] == '1');
        break;
    case DOWN:
        if (y >= 4) return false;
        return (kabe[y*2+1][x] == '1');
        break;
    }
    return false;
}


int getLeft(int dir)
{
    final switch (dir) {
    case LEFT: return DOWN; break;
    case RIGHT: return UP; break;
    case UP: return LEFT; break;
    case DOWN: return RIGHT; break;
    }
    return 0;
}


int getRight(int dir)
{
    final switch (dir) {
    case LEFT: return UP; break;
    case RIGHT: return DOWN; break;
    case UP: return RIGHT; break;
    case DOWN: return LEFT; break;
    }
    return 0;
}

void move(int* x, int* y, int dir)
{
    final switch (dir) {
    case LEFT:
        (*x)--;
        write("L");
        break;
    case RIGHT:
        (*x)++;
        write("R");
        break;
    case UP:
        (*y)--;
        write("U");
        break;
    case DOWN:
        (*y)++;
        write("D");
        break;
    }
}

Measured memory_bytes: 1040
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i,init , n) for (int i = init; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = 2 * pow(10, 9) + 1;//+1しないとREになるかも(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };

ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }


const ll MOD = pow(10, 9) + 7;
// a+b mod p
ll add_modp(ll a, ll b, ll p) {return (a % p + b % p) % p;}


// a-b mod p
ll sub_modp(ll a, ll b, ll p) {
	ll res = add_modp(a, -b, p);
	if (res < 0) return  res + MOD;
	return res;
}

// a*b mod p
ll mul_modp(ll a, ll b, ll p) {return ((a % p) * (b % p)) % p;}

// a^n mod p
ll pow_modp(ll a, ll n, ll p) {
	
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = mul_modp(res, a, p);
		a = mul_modp(a, a, p);
		n >>= 1;
	}
	return res;
}

//  a/b mod p
ll div_modp(ll a, ll b, ll p) { return  a * (pow_modp(b, MOD - 2, MOD)); }// a/b(mod p)   =  a * b^(MOD-2)   (mod MOD)





int main(void) {

	ll n, a, b;
	cin >> n >> a >> b;

	//ll ans = pow(2, n) - 1;

	ll ans = pow_modp(2, n, MOD) - 1;
	//cout << "yah1   " << ans << endl;
	ll nCa = 1, nCb = 1;

	for (int i = 0; i < a; i++) {//nCa =   {n (n-1) (n-2)  ... (n-a+1) }   /   { a (a-1) (a-2) ... (a-a+1)}
		//nCa *= n - i;
		//nCa /= a - i;
		nCa = mul_modp(nCa, n - i, MOD);
		nCa = div_modp(nCa, a - i, MOD);
	}
	for (int i = 0; i < b; i++) {//nCb =   {n (n-1) (n-2)  ... (n-b+1) }   /   { b (b-1) (b-2) ... (b-b+1)}
		//nCb *= n - i;
		//nCb /= b - i;
		nCb = mul_modp(nCb, n - i, MOD);
		//nCb = nCb * (pow_modp(b - i, MOD - 2, MOD));
		nCb = div_modp(nCb, b - i, MOD);
	}

	//cout << "yah2   " << n << "C" << a << " = " << nCa << endl;
	//cout << "yah3   " << n << "C" << b << " = " << nCb << endl;

	//ans = ans - nCa - nCb;
	ans = sub_modp(ans, nCa, MOD);
	ans = sub_modp(ans, nCb, MOD);
	cout << ans << endl;

}


Measured memory_bytes: 256
/*
[diverta2019] B - RGB Boxes
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

int R, G, B, N;

ll solve() {
    int ans = 0;
    for (int r = 0; r <= N; r++) {
        for (int g = 0; g <= N; g++) {
            int bB = N - r * R - g * G;
            if (bB >= 0 && bB % B == 0) {
                ans++;
            }
        }
    }

    return ans;
}

int main() {
    cin >> R >> G >> B >> N;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<iostream>
#include<algorithm>
#include <string>
#include <stdexcept>
using namespace std; 
int main(){
  int a,b,c,d,e;
 	cin >>a>>b;
if(a==0&&b==100) 
  cout <<b+1; else if(a==0)cout <<b;
  if(a==1&&b==100)cout <<b*100+100;
  else if(a==1) cout <<b*100;
  if(a==2&&b==100)cout <<b*10000+10000;
  else if(a==2) cout <<b*10000;
  	
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

using P = pair<int, int>;

bool istwo(int a, int b, int c) {
    return ((a < b && b < c) || (c < b && b < a));
}

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p.at(i);
    }
    int cnt = 0;
    for (int i = 1; i < n - 1; i++) {
        cnt += istwo(p[i - 1], p[i], p[i + 1]);
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int n, d;
  std::cin >> n >> d;

  int check = d * 2 + 1;
  int hito = n / check;
  if ((n % check) != 0) {
    hito += 1;
  }

  std::cout << hito << std::endl;
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    long long ans = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3640
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int L=sc.nextInt();
		int R=sc.nextInt();
		long min=0;
		if(L%2019==0||R%2019==0||L/2019<R/2019){
			System.out.println(0);
			return;
		}

		for(long i=L;i<=R;i++){
			for(long j=i+1;j<=R;j++){
				long a=(i*j)%2019;
				if((i==L&&j==L+1)||min>a){min=a;}
			}
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 21716
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define F first
#define S second
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;
ll vis[N],res[N];

int solve() 
{
	//happy coding

	int n;
	cin>>n;
	string s;
	cin>>s;

	Unique(s);
	cout<<s.size()<<endl;
	
	return 0;
}
int main(){
	int test = 1;
  	//scanf("%d", &test);
  	while (test--)solve();return 0;
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

struct date {
  int y, m, d;

  date() {}
  date(int y, int m, int d) : y(y), m(m), d(d) {}

  bool operator<(date a) {
    if (y == a.y) {
      if (m == a.m) {
        return d < a.d;
      }
      return m < a.m;
    }
    return y < a.y;
  }
};

bool izryt(date &a, date &b) {
  if (a.m == b.m) {
    return a.d < b.d;
  }
  return a.m < b.m;
}

istream &operator>>(istream &is, date &a) {
  is >> a.y >> a.m >> a.d;
  return is;
}

signed main(int argc, char *argv[]) {
  date a, b;
  cin >> a >> b;

  if (b < a) swap(a, b);

  cout << b.y - a.y + izryt(a, b) << endl;
}



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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  ll k;
  cin >> k;

  for (ll i = 0; i < s.size(); ++i) {
    if (s[i] == 'a') continue;
    ll n = 'z' - s[i] + 1;
    if (n <= k) {
      s[i] = 'a';
      k -= n;
    }
  }

  if (k > 0) {
    auto ch = s[s.size()-1];
    ch += k % 26;
    if ('z'-ch < 0) ch = 'a' + abs('z'-ch)-1;
    s[s.size()-1] = ch;
  }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 512
/*
    coded by - PATHAKCODES ~~Revamped
    AIT PUNE , INDIA 
     
    "The Key is not will to win ......everybody has that "
    "It is will to prepare that is important"  
     
*/
     
#include <bits/stdc++.h>
 
using namespace std ;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
const ll n  = 1e6 +5;


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

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

    int max = 0  ;
    for(int i = 0 ; i < s.size()-t.size()+1; i++){
        int temp = 0;
        for(int j = 0 ; j < t.size(); j++){

            if(s[j+i] == t[j])
                temp++;
        }
       // cout << temp << endl;
        if(temp > max)
            max = temp;

    }

    cout << t.size()- max <<endl ;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

signed main(){
   IOS;
   int k; cin >> k;
   string s; cin >> s;
   if(s.size() <= k) cout << s << "\n";
   else{
      rep(i,0,k) cout << s[i];
      cout << "...\n";
   }  
}

Measured memory_bytes: 3640
from heapq import heappush, heappop
import sys
def main():
    readline = sys.stdin.readline
    write = sys.stdout.write
    L2 = 1 << 16
    bc = [0]*L2
    for i in range(1, L2):
        bc[i] = bc[i ^ (i & -i)] + 1
    INF = 10**18
    def solve():
        N, M, L, s, T = map(int, readline().split())
        if N == M == 0:
            return False
        G = [[] for i in range(N)]
        for i in range(M):
            a, b, c = map(int, readline().split()); a -= 1; b -= 1
            G[a].append((b, c))
            G[b].append((a, c))
        def dijkstra(s):
            dist = [INF]*N
            dist[s] = 0
            que = [(0, s)]
            while que:
                cost, v = heappop(que)
                if dist[v] < cost:
                    continue
                for w, d in G[v]:
                    if cost + d < dist[w]:
                        dist[w] = cost + d
                        heappush(que, (cost + d, w))
            return dist

        G0 = [[] for i in range(L)]
        RS = []
        BS = [0]*L
        for i in range(L):
            j, e = map(int, readline().split()); j -= 1
            d0 = dijkstra(j)
            for k, p in enumerate(RS):
                v = d0[p]
                if v+BS[k] <= T:
                    G0[i].append((k, v+BS[k], 1 << k))
                if v+e <= T:
                    G0[k].append((i, v+e, 1 << i))
            RS.append(j)
            BS[i] = e

        ans = 0
        ds = dijkstra(s-1)
        que = []
        Q = [[{} for j in range(L)] for i in range(L+1)]
        L2 = 1 << L
        dw = [0]*L
        for i in range(L):
            d = ds[RS[i]]
            r = d + BS[i]
            dw[i] = T - d + 1
            if r < dw[i]:
                Q[1][i][1 << i] = r
                ans = 1
        for k in range(1, L):
            qs = Q[k]
            qs1 = Q[k+1]
            if any(qs):
                ans = k
            for v in range(L):
                qsv = qs[v]
                for w, d, b in G0[v]:
                    dww = dw[w]
                    qs1w = qs1[w]
                    for state, cost in qsv.items():
                        if state & b:
                            continue
                        r = cost + d
                        if r < qs1w.get(state | b, dww):
                            qs1w[state | b] = r
        if any(Q[L]):
            ans = L
        write("%d\n" % ans)
        return True
    while solve():
        ...
main()


Measured memory_bytes: 55144
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int s_s,t_s;
  s_s = s.size();
  t_s = t.size();
  int dp[s_s+1][t_s+1];
  for(int i = 0;i <= s_s;i++)dp[i][0] = 0;
  for(int i = 0;i <= t_s;i++)dp[0][i] = 0;
  for(int i = 1;i <= s_s;i++){
    for(int j = 1;j <= t_s;j++){
      if(s[i-1] == t[j-1])dp[i][j] = dp[i-1][j-1] + 1;
      else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
    }
  }
  //cout << dp[s_s][t_s] << endl;
  int i = s_s;
  int j = t_s;
  string ans = "";
  while(dp[i][j] != 0){
    if(dp[i][j] == dp[i][j-1])j--;
    else if(dp[i][j] == dp[i-1][j])i--;
    else{
      //cout << i << s[i-1] << endl;
      ans += s[i-1];
      i--;
      j--;
    }
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;
}

Measured memory_bytes: 35456
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

f=factorization(int(input())) 
ans=0
for list in f:
  if list[0]==1:
    continue
  m=list[1]
  n=int((2*m)**(1/2))
  while True:
    if n*(1+n)>2*m:
      n-=1
      break
    n+=1

  ans+=n
print(ans)
    
  




Measured memory_bytes: 63380
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int K = sc.nextInt();
		sc.nextLine();
		
		if (N == K) {
			System.out.println(0);
			return;
		}
		
		//O(N)
		int type = 0;
		boolean[] flag = new boolean[200_001];
		int[] map = new int[200_001];
		for(int i = 0; i < N; i++) {
			int num = sc.nextInt();
			if (!flag[num]) {
				flag[num] = true;
				type++;
			}
			map[num] += 1;
		}
		
		Arrays.sort(map);
		type -= K;
		if (type <= 0) {
			System.out.println(0);
			return;
		}
		
		int ans = 0;
		for (int i = 0; i < map.length; i++) {
			if (map[i] == 0)
				continue;
			
			ans += map[i];
			type--;
			if (type == 0)
				break;
		}
		
		System.out.println(ans);
	}
	
}

Measured memory_bytes: 82284
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int D = sc.nextInt();
        int X = sc.nextInt();
        int[] a = new int[N];
        for (int i=0; i<N; i++) {
            a[i] = sc.nextInt();
        }

        int ans = solve(N, D, X, a);
        System.out.println(ans);
    }

    private static int solve(int N, int D, int X, int[] a) {
        int total = X;

        for (int i=0; i<N; i++) {
//            System.err.print((D-1)/a[i] + " ");
            total += 1 + (D-1)/a[i];
        }

        return total;
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	int N,i;
	cin>>N;
	vector<LL> A(N+1),B(N);
	int SumA=0;
	for (i=1;i<=N;i++){
		cin>>A[i];
		B[i-1]=A[i]-i;
	}
	sort(B.begin(),B.end());
	LL b=(B[(N-1)/2]+B[N/2])/2;
	LL Sum=0;
	for (i=1;i<=N;i++){
		LL x=(A[i]-(b+i));
		if (x<0){
			x=-x;
		}
		Sum+=x;
	}
	cout<<Sum<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

// 入力
ll n, Q;
// BIT
ll bit0[200001], bit1[200001];

ll sum(ll *b, int i) { 
	ll s = 0;
	while (i > 0) {
		s += b[i];
		i -= i & -i; 
	}
	return s; 
}
void add(ll *b, int i, ll v){
	while (i <= n) {
		b[i] += v;
		i += i & -i; 
	}
}

int main() {
	ll d,a;cin>>n>>d>>a;
	vector<P> A(n + 1);
	vector<ll> B(n + 1);
	for(int i = 1; i <= n; i++) {
		ll x,y;cin>>x>>y;
		A[i] = mp(x,y);
		B[i] = x;
	}
	sort(A.begin() + 1,A.end());
	sort(B.begin() + 1,B.end());

	// for(int i = 1; i <= n; i++) {
	// 	cout << A[i].sc << endl;
	// }

	for (int i = 1; i <= n; i++) { 
		add(bit0, i, A[i].sc);
	}

	ll count = 0LL;
	for (int i = 1; i <= n; i++) {
		ll res = 0;
		res += sum(bit0, i) + sum(bit1, i) * i;
		res -= sum(bit0, i - 1) + sum(bit1, i - 1) * (i - 1); 
		// cout << res << endl;

		if (res > 0){//爆撃(i ~ i + 2D)
			ll bomb = (res + a - 1)/ a;
			count += bomb;
			auto index = upper_bound(B.begin() + 1,B.end(),B[i]+ 2 * d);
			ll r = index - B.begin() - 1;
			// cout << "r" << r << endl;
			add(bit0, i, bomb * a * (i - 1)); 
			add(bit1, i, -1 * bomb * a);
			add(bit0, r+ 1, -1 * bomb * a  * r); 
			add(bit1, r + 1, bomb * a);
		} 
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 8064
X = int(input())

if X <= 599:
    print("8")
elif X <=799:
    print("7")
elif X <= 999:
    print("6")
elif X <= 1199:
    print("5")
elif X <= 1399:
    print("4")
elif X <= 1599:
    print("3")
elif X <= 1799:
    print("2")
else:
    print("1")

Measured memory_bytes: 61792
# 最小値が端点でないと、隣接とswapして矛盾。
# 最小値は端点としてよい。
# 端点のどれでもよい。
# あとは帰納的に

N = int(input())
score = 0

edge = [set() for _ in range(N+1)]
for _ in range(N-1):
  a,b = map(int,input().split())
  edge[a].add(b)
  edge[b].add(a)

C = [int(x) for x in input().split()]
deg = [len(x) for x in edge]

# degree1の頂点全体
deg_1 = [i for i,x in enumerate(deg) if x == 1]

D = [None]*(N+1)
C.sort(reverse = True)
M = sum(C) - C[0] # score
  
while deg_1:
  v = deg_1.pop()
  if not deg_1:
    D[v] = C.pop()
    break
  w = edge[v].pop()
  edge[w].remove(v)
  deg[w] -= 1
  if deg[w] == 1:
    deg_1.append(w)
  D[v] = C.pop()

  
print(M)
print(' '.join(map(str,D[1:])))

Measured memory_bytes: 7276
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,k=mii()
arra=limii()
arr=[]
s=[0]
chk=0
for i in range(n):
    arri=arra[i]
    arr.append((arri*(arri+1)//2)/arri)
    

for i in arr:s.append(s[-1]+i)

for i in range(n-k+1):
    chk=max(chk,s[i+k]-s[i])

print(chk)


Measured memory_bytes: 102320