akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define  ll   long long int
#define  sz   20010

using namespace std;


ll a[sz];
ll b[sz];

int main()
{


    ll n,m,i,j,x,y,d,k,p,mx=0;

    cin>>n;

    for(i=1; i<=n; i++)
    {
        cin>>a[i];
        a[i]=a[i-1]+a[i];
    }
    for(i=1; i<=n; i++)
    {
        cin>>b[i];
        b[i]=b[i-1]+b[i];
    }

    for(i=1;i<=n;i++)
    {
        x=a[i];
        y=b[n]-b[i-1];
        x=x+y;

        mx=max(mx,x);
    }

    cout<<mx<<endl;


    return 0;
}



Measured memory_bytes: 256
def z_argorithm(s):
    s_len=len(s)
    a=[0]*s_len
    c=0
    for i in range(1,s_len):
        if i+a[i-c] < c+a[c]:
            a[i]=a[i-c]
        else:
            j=max(0,c+a[c]-i)
            while i+j<s_len and s[j]==s[j+i]:
                j += 1
            a[i]=j
            c=i
    return a
def main():
    n=int(input())
    s=input()
    ans = 0
    for i in range(n-1):
        a = z_argorithm(s[i:])
        A=len(a)
        for i in range(A):
            ans=max(ans,min(i,a[i]))
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 48604
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        boolean isBad = false;
        for (int i = a.length() - 1; i >= 1; i--) {
            if (a.charAt(i) == a.charAt(i - 1)) isBad = true;
        }
        
        if (isBad) {
            System.out.println("Bad");
        } else {
            System.out.println("Good");
        }
    }
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n;
	string s,t;
	cin >> n >> s >> t;
	for (int i = n; i >= 1; i--) {
loop:
		for (int j = 0; j < i; j++) {
			if (s[n-i+j] != t[j]) {
				i--;
				goto loop;
			}
		}
		cout << 2*n - i << endl;
		return 0;
	}
	cout << 2*n << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cctype>
#include <cstring>
#include <utility>
#include <cmath>
#include <string>
#define FOR(i,a,n) for(int i=(a);i<(n);i++)
#define INF (1<<21)
using namespace std;


int main(){
    long long int l0=2,l1=1,l2=3,n;
    cin>>n;
    FOR(i,0,n-2){
        long long int tmpl1=l1;
        l1=l2;
        l0=tmpl1;
        l2=l0+l1;
    }
    if(n==1) cout<<1;
    else if(n==2) cout<<3;
    else cout<<l2;
    return 0;
}


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

 using namespace std;
  vector<int> G[101];
  bool V[101];
  bool Vis[101];
  int DP[101];
   int N;
   int Ans = 0;
   int P;
  void DFS(int n,int len){
      Ans = (Ans<=len)? len : Ans;
      DP[n] = (DP[n]<=len)? len : DP[n];
      if(DP[n]==Ans) P = n;
      int S = G[n].size();
      for(int i=0;i<S;i++){
    if(!V[G[n][i]]){
        Vis[G[n][i]]= true;
        V[G[n][i]] = true;
        DFS(G[n][i],len+1);
        V[G[n][i]] = false;
    }
   }
   return;
  }
  int i;
  int main(){
      do{

   for(i=0;i<101;i++){
    G[i].clear();
    V[i] = false;
   Vis[i] = false;
    DP[i] = 0;
   }
   Ans = 0;
   scanf("%d",&N);
   if(N==0)break;
   for(i=0;i<N;i++){
    int A,B;
    scanf("%d%d",&A,&B);
    G[A].push_back(B);
    G[B].push_back(A);
   }

   for(i=1;i<=100;i++){
    if(!Vis[i]){
    Vis[i] =true;
    V[i] = true;
    DFS(i,1);
    V[i] = false;
    }
   }
  if(DP[P]==Ans){
        V[P] = true;
        DFS(P,1);
   }
   printf("%d\n",Ans);
  }while(true);
  }

Measured memory_bytes: 3172
#include <bits/stdc++.h>
const int N=6e5+5;

int n,m=1,k,p,o[N]; char s[N];

int main()
{
	scanf("%d%d%s",&n,&k,s+1); int i;
	for (i=1; i<=n; i++) o[i]=s[i]=='A';
	
	for (i=1; i<=k&&i<=n+n; i++)
		if (o[m]^p) o[m]^=1;
		else p^=1,o[++m+n-1]=p^1;
	if (k<=n+n){for (i=m; i<=n+m-1; i++) putchar((o[i]^p)?'A':'B');}
	else
	{
		if ((n&1)&&(k-n-n&1)) putchar((o[m]^p^1)?'A':'B');
		else putchar((o[m]^p)?'A':'B');
		for (i=m+1; i<=n+m-1; i++) putchar((o[i]^p)?'A':'B');
	} 
	
	return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

typedef long long i64;
typedef pair<i64, i64> pii;

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, d;
  cin >> n >> d;
  int can = 2 * d + 1;
  int ans = 0;
  for (int i = 1; i <= n; i += can) {
    ++ans;
  }
  cout << ans << "\n";
  return 0;
}

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

#define SENTINEL 1000000001

using namespace std;

long long cnt = 0;

void merge(vector<int> &A, int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	vector<int> L(n1 + 1), R(n2 + 1);
	for (int i = 0; i < n1; i++)
	{
		L[i] = A[left + i];
	}
	for (int i = 0; i < n2; i++)
	{
		R[i] = A[mid + i];
	}
	L[n1] = SENTINEL;
	R[n2] = SENTINEL;
	int i = 0;
	int j = 0;
	for (int k = left; k < right; k++)
	{
		if (L[i] <= R[j])
		{
			A[k] = L[i];
			i++;
		}
		else
		{
			A[k] = R[j];
			cnt += n1 - i; // L[]は昇順に整列されているので、i番目以降のL[]の要素(n1 - i)個はすべてR[j]より大きくなる
			j++;
		}
	}
}

void mergeSort(vector<int> &A, int left, int right)
{
	if (left + 1 < right)
	{
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main() {
	int n;
	cin >> n;
	vector<int> S(n);
	for (int i = 0; i < n; i++)
	{
		cin >> S[i];
	}
	mergeSort(S, 0, n);

	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 4364
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(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 Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,ans=0;
    cin >> n;
    vll a(n),tmp(n);
    rep(i,n){
        cin >> a[i];
        tmp[i]=a[i]-i-1;
    }
    sort(all(tmp));
    ll key=tmp[(n-1)/2];
    rep(i,n){
        ans+=abs(a[i]-(key+(i+1)));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//s.order_of_key(), *s.find_by_order()

using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

int32_t main(){
   boost;
   int N; cin>>N;
   vi v(N);
   for(int i=0; i<N; i++) cin>>v[i];
   sort(rall(v));
   int res=0;
   int cnt=N-1;
   for(int i=0; i<N && cnt; i++){
      if(i==0){
         res+=v[i];
         cnt--;}
      else{
         if(cnt==1){
            cnt--;
            res+=v[i];
         }
         else{
            cnt-=2;
            res+=v[i]*2;
         }
      }

   }
   cout << res << endl;


   return 0;
}


Measured memory_bytes: 4756
import java.util.*;


public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        String ans;
        if(a+b > c+d){
            ans = "Left";
        }else if(a+b == c+d){
            ans = "Balanced";
        }else{
            ans = "Right";
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
import math

def main():
    N = int(input())
    rt_N = math.ceil(math.sqrt(N))

    mn_ij = 10**12
    for i in range(1, rt_N+1):
        if N % i == 0:
            j = N // i

            mn_ij = min(mn_ij, i+j)
        
        mn_ij = min(mn_ij, i+j)

    # print(list(map(len,[ st, facs]) ))
    print(int(mn_ij-2))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
/*
     ॐ त्र्यम्बकं यजामहे सुगन्धिं पुष्टिवर्धनम् |
     उर्वारुकमिव बन्धनान्मृत्योर्मुक्षीय माऽमृतात् ||
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define double         long double
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
     int x = 1;
     while (b)
     {
          if (b & 1) x *= a;
          a *= a;
          b >>= 1;
     }
     return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a[N], n, m, k;

void solve()
{
     int cnt = 0, x = 100;
     cin >> n;
     while (x < n)
     {
          x += x / 100;
          cnt++;
     }
     cout << cnt;

}

int32_t main()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

     cout << setprecision(9) << fixed;
     clock_t z = clock();
     solve();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

     return 0;
}

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

#define for_loop_forward(iterator, size) for (int iterator = 0; iterator < size; iterator++)
#define for_loop_backward(iterator,size) for (int iterator = size - 1; iterator >= 0; iterator--) 

typedef unsigned long long int bigint; //big int 

/* 
-------------------------------- 
    declaring dynamic  array: 
    int* ary = new int[size]; 
-------------------------------------- 
 declaring dynamic 2d array: 
    int **ary = new int*[sizeY]; 
    for (int i = 0; i < sizeY; i++) { 
    ary[i] = new int[sizeX]; 

    deleting memory to prevent memory leak 
    for (int i = 0; i < length; ++i) { 
        delete[] grid[i]; 
    } 
    delete[] grid; 
------------------------------------------- 
 */ 

 
int main() 
{ 
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, x;
    cin >> n >> x;
    for(int i = 0; i <= n; i++)
    {
        if(i * 2 + (n - i) * 4 == x)
        {
         cout  << "Yes";
         return 0;
        }
    }
    cout << "No";

     return 0; 

} 

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

int n;
vector<int> G[10010];
int c[10010], p[10010];
int cur;

void dfs(int v){
    p[v] = c[cur--];
    for(int nv:G[v])if(!p[nv]) dfs(nv);
}

int main(){
    scanf("%d", &n);
    rep(i, n-1){
        int a, b;
        scanf("%d%d", &a, &b);
        G[--a].push_back(--b);
        G[b].push_back(a);
    }
    rep(i, n) scanf("%d", &c[i]);
    sort(c, c+n);
    rep(i, n) p[i] = 0;
    cur = n-1;
    dfs(0);
    int ans = 0;
    rep(i, n-1) ans += c[i];
    printf("%d\n%d", ans, p[0]);
    rep(i, n-1) printf(" %d", p[i+1]);
    printf("\n");
}

Measured memory_bytes: 1280
import copy

N = int(input())
p_list = list(map(int, input().split()))
sort_list = copy.copy(p_list)
sort_list.sort()
p_i = -1
for k in range(N):
    if p_list[k] != k+1:
        if p_i < 0:
            p_i = k
        else:
            p_list[p_i], p_list[k] = p_list[k], p_list[p_i]
            break
if p_list == sort_list:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3444
n = int(input())
lis = [int(input()) for i in range(n)]
cou = 0
num = 0
for i in range(n):
  if lis[i] == 0:
    cou += (num // 2)
    num = 0
  else:
    num += lis[i]
cou += (num // 2)
print(cou)

Measured memory_bytes: 7072
words = [" ", "\'", ",", "-", ".", "?"]
words += %{ABCDEFGHIJKLMNOPQRSTUVWXYZ}.split("")
code = %w{101 000000 000011 10010001 010001 000001 100101 10011010 0101 0001 
        110 01001 10011011 010000 0111 10011000 0110 00100 10011001 10011110 
        00101 111 10011111 1000 00110 00111 10011100 10011101 000010 10010010 
        10010011 10010000}
n_code = %w{11010 11110 11100 11101 11011 11111 00000 00001 00010 00011 00100 
          00101 00110 00111 01000 01001 01010 01011 01100 01101 01110 01111 
          10000 10001 10010 10011 10100 10101 10110 10111 11000 11001}
while gets
  s = ""
  $_.chomp.split("").each do |w|
    s += code[words.find_index(w)]
  end
  sz = s.size%5
  s += "0"*((5-sz)%5)
  ret = ""
  (s.size/5).times do |i|
    ret += words[n_code.find_index(s[i*5,5])]
  end
  puts ret
end

Measured memory_bytes: 9960
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (int)(n); (i)++)
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define For(i, a, b)    for(int i = (a); (i) < (int)(b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
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); }

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



/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    ll h; cin >> h;
    ll cnt_1 = 1, cnt_2 = 0;
    while(h > 1){
        h /= 2;
        cnt_2 += cnt_1;
        cnt_1 *= 2;
    }

    cout << cnt_1 + cnt_2 << endl;

return 0;
}

Measured memory_bytes: 3568
(* Vicfred
 * https://atcoder.jp/contests/abc132/tasks/abc132_a
 * implementation
 * *)
Scanf.scanf "%c%c%c%c\n" @@ fun a b c d ->
    print_endline @@
    if a = b && c = d && a != c ||
    a = c && b = d && a != b ||
    a = d && b = c && a != b then "Yes"
    else "No"



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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

signed main(){
	const llong INF = (llong)1e10;
	int n,W; cin >> n >> W;
	vector<llong> w(n),v(n);
	for(int i = 0; i < n; i++)cin >> w[i] >> v[i];
	llong V = 0;
	for(auto e : v)V+= e;
	vector<vector<llong> > dp(2, vector<llong>(V+1,INF));
	vector<llong> &now = dp[0], &prev = dp[1];
	prev[v[0]] = w[0];
	prev[0] = 0;
	for(int i = 1; i < n; i++){
		for(int j = 0; j <= V; j++){
			llong tmp;
			if(j-v[i] < 0)tmp = INF;
			else tmp = prev[j-v[i]]+w[i];
			if(tmp > W)tmp = INF;
			now[j] = min(prev[j], tmp);
		}
		swap(now,prev);
//		for(int i = 0; i <= V; i++)if(prev[i] != INF)cerr << i << ":" << prev[i] << " ";
//		cerr << endl;
//		for(int i = 0; i <= V; i++)if(now[i] != INF)cerr << i << ":" << now[i] << " ";
//		cerr << endl;
//		cerr << "=========" << endl;
	}
	for(int i = V; i >= 0; i--){
		if(prev[i] != INF){
			cout << i << endl;
			break;
		}
	}

	return 0;
}



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

int main() {
  
  int num;
  cin >> num;
  char pebble;
  bool is_Y = false;
  
  for (int i = 0; i < num; i++) {
    cin >> pebble;
    if (pebble == 'Y') {
      is_Y = true;
    }
  }
  
  if (is_Y == true) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
// B - Theater

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	int ans = 0;
	int l, r;
	for (int i=0; i<N; i++) {
		cin >> l >> r;
		ans += (r - l + 1);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vpl vector<pair<long long,long long>>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
long long MOD = 1000000007;
const long double pi = 3.1415926535897932;
#define pb push_back
#define mp make_pair
#define mt make_tuple
using Grid = vector<vector<char>>;
#define vc vector<char>
//(mod m)でのaの逆元を計算する
//a/b(mod m)=a(mod m)*modinv(b,m)
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll N,x;
    cin>>N>>x;
    vl a(N);
    rep(i,N)cin>>a[i];
    sort(all(a));
    ll res=0;
    ll i=0;
    while(x>0){
        x-=a[i];
        i++;
        if(x>=0)res++;
        if(i==N)break;
    }
    if(x>0)res--;
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s, t;
	cin >> s >> t;
	int ans = 0;
	ans += s[0] == t[0];
	ans += s[1] == t[1];
	ans += s[2] == t[2];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

int main() {
    long long sum = 0;
    int N, P;
    long long prevmod = 0;
    long long beki10mod = 1;
    string S;

    cin>>N>>P;
    cin >> S;
    
    vector<long long> M(N);
    vector<long long> modmap(P, 0);

    if(P == 5 || P == 2)
    {        
        REP(i, 0, N){
            M[i] = stoi(S.substr(i, 1)) % P;
        }  
        REP(i, 0, N){
            if(M[i]== 0){
                sum += i+1;
            }
        }
    }else{
        REP(i, 0, N){
            int mod = (beki10mod * stoi(S.substr(N-1-i, 1)) + prevmod) % P;
            modmap[mod]++;
            prevmod = mod;
            beki10mod = (beki10mod * 10) % P;
        }
        REP(i, 0, P){
            sum += modmap[i]*(modmap[i]-1)/2;
        }
        sum += modmap[0];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2180
#include <iostream>

int main(){
  
  using namespace std;
  
  int n, k;
  cin >> n >> k;
    
  bool arr[n] = {false};
  
  for (int i=0; i<n; i++){
    int d;
    cin >> d;
    
    int d_;
    
    for (int j=0; j<d; j++){
      cin >> d_;
      arr[d_-1] = true;
    }
  
  }
  
  int ans = 0;
  for (int i=0; i<n; i++){
    if (!(arr[i])){
      ans = ans +1;
    }
  }
    
  cout << ans;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void){
	
	int i, j;
	
	for(i=1; i<10; i++)
		for(j=1; j<10; j++) 
		{
			printf("%dx%d=%d\n", i,j,i*j);
			// ?????????????????????????????????????????????...
			// if(!(i==9 && j==9)) fputc('\n',stdout);
		}
	return 0;
}
			
			

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
int main()
{
     int n;
     cin>>n;
    string s;
    cin>>s;
     int c=0,k,x=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='W')
        {
            k=i;
            break;
        }
    }
    
    for(int i=k;i<n;i++)
    {
        if(s[i]=='R')
            x++;
    }
    int ans=x;
    int l=0,r=n-1;
    while(l<r)
    {
        if(s[l]=='W' && s[r]=='R')
        {
            c++;
            swap(s[l],s[r]);
        }
        else
        {
            if(s[l]=='R')
                l++;
            if(s[r]=='W')
                r--;
        }
    }
    ans=min(ans,c);
    cout<<ans;
    
    
}

    


Measured memory_bytes: 3704
n, k = map(int, input().split())
a = list(map(int, input().split()))
from collections import Counter
cntr = sorted(Counter(a).items(), key=lambda x: x[1], reverse=True)
#print(cntr)
ans = 0
if len(cntr) > k:
  for i in range(k, len(cntr)):
    ans += cntr[i][1]
print(ans)

Measured memory_bytes: 39348
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;

  int n,m,x;

  cin >> n >> m >> x;

  int cost[n];
  int a[n][m];
  

  for(ii=0;ii<n;ii++){
    cin >> cost[ii];
    for(jj=0;jj<m;jj++){
      cin >> a[ii][jj];
    }
  }

  int buy = pow(2,n);

  int goal[m];
  int sum,min;
  min = 1 << 30;
  //cout << min << endl;
  
  for(ii=0;ii<buy;ii++){
    memset(goal,0,sizeof(goal));
    sum = 0;

    for(jj=0;jj<n;jj++){
      if( ((ii >> jj) & 1 ) == 1){
        //cout << "buy:" << jj;
        sum += cost[jj];
        for(kk=0;kk<m;kk++){
          goal[kk] += a[jj][kk];
        }
      }
    }
    // OK Check
    bool flg = true;
    for(jj=0;jj<m;jj++){
      if(goal[jj] < x){
        flg = false;
      }
    }

    if(flg && sum < min){
      min = sum;
    }
    //cout << endl;
    
  }

  if(min != (1 << 30)){
    cout << min << endl;
  }
  else{
    cout << -1 << endl;
  }
  return 0;
}


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

#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define MOD 1000000007

const int MAX_M = 100000;


int main(){
  ll n, m;
  //string s;
  cin >> n >> m;
  
  ll ans = 0;
  vector<vector<ll>> r(n);
  vector<ll> h(n);
  
  rep(i,0,n){
    cin >> h.at(i);
  }
  
  rep(i,0,m){
    ll a, b;
    cin >> a >> b;
    //cin >> a.at(i) >> b.at(i);
    r.at(a-1).push_back(h.at(b-1));
    r.at(b-1).push_back(h.at(a-1));
  }

  rep(i,0,n){
    ll l = r.at(i).size();
    bool ok = true;
    rep(j,0,l){
      if(r.at(i).at(j) >= h.at(i)){
        ok = false;
        break;
      }
    }
    if(ok)
      ans++;
  }
  
    
  
  //vector<ll> a(n);
  //queue<ll> q;
  //map<string,ll> d{};
  
  
  cout << ans << endl;
}

Measured memory_bytes: 9852
#include<bits/stdc++.h>
    #define vll vector<ll>
    #define vi vector<int>
    #define vpll vector<pair<ll,ll>>
    #define pii pair<int,int>
    #define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
    #define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
    #define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
    #define MOD 1000000007
    #define ALL(v) v.begin(), v.end()
    #define m0(x) memset(x,0,sizeof(x))
    typedef long long ll;
     
    using namespace std;
     
    const int MAX = 1100000;
     
    ll fac[MAX], finv[MAX], inv[MAX];
     
    // テーブルを作る前処理
    void COMinit() {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
     
    // 二項係数計算
    ll COM(int n, int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
     
    int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      ll X,Y;
      cin >> X >> Y;
      if( (Y+X)%3 != 0 ){
        cout << "0";
        return 0;
      }

      ll count = (X+Y)/3; //動かす回数
      
      COMinit();
      cout << COM(count, Y-count);
      return 0;
    }

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

int main(){
    int n, k, distance;
    distance = 0;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        int distB = abs(x - k);  
        if(distB > x){
            distance += x * 2;
        }else{
            distance += distB*2;
        } 
    }
    cout << distance << endl;

}

Measured memory_bytes: 3612
-- Structured Program I - Structured Programming

main :: IO ()
main = do
  n <- readLn
  putStrLn $ " " ++ (unwords $ map show $ filter check [1..n])

check :: Int -> Bool
check x = (mod x 3 == 0) || (include3 $ show x)
  where
    include3 [] = False
    include3 (c : cs)
      | c == '3'  = True
      | otherwise = include3 cs



Measured memory_bytes: 4120
// treap

#include <iostream>
#include <stdio.h>
 
using namespace std;
 
struct Node{
    Node *left;
    Node *right;
    int key;
    int pri;
 
    Node(int k, int p) : key(k), pri(p){
        left = right = NULL;
    }
};
 
Node* rightRotate(Node *t){
    Node* s = t->left;
    t->left = s->right;
    s->right = t;
     
    return s; 
}
 
Node* leftRotate(Node *t){
    Node* s = t->right;
    t->right = s->left;
    s->left = t;
     
    return s; 
}
 
void find(Node *t, int k){
  while(t != NULL && k != t->key){
    if(k < t->key) t = t->left;
    else t = t->right;
  }
 
  if ( t != NULL ) cout << "yes" << endl;
  else cout << "no" << endl;
}
 
Node* insert(Node *t, int key, int pri){
    if(t == NULL){ return new Node(key, pri); }
    if(key == t->key){ return t; }                     
 
    if(key < t->key){                         
        t->left = insert(t->left, key, pri);  
        if(t->pri < t->left->pri){ t = rightRotate(t); }
    } else{
        t->right = insert(t->right, key, pri);
        if(t->pri < t->right->pri){ t = leftRotate(t); }
    }
     
    return t;
}
 
Node* erase(Node *t, int key){
    if(t == NULL){ return NULL; }
     
    if(key == t->key){                         
        if(t->left == NULL && t->right == NULL){ return NULL; }
        else if(t->left == NULL){ t = leftRotate(t); }
        else if(t->right == NULL){ t = rightRotate(t); }
        else{
            if(t->left->pri > t->right->pri){ t = rightRotate(t); }
            else{ t = leftRotate(t); }
        }
        return erase(t, key);
    }
     
    if(key < t->key){ t->left = erase(t->left, key); }
    else{ t->right = erase(t->right, key); }
     
    return t;
}
 
 
void Inorder(Node *t){
  if(t->left != NULL) Inorder(t->left);
  if(t->key != -1) cout << " " << t->key;
  if(t->right != NULL) Inorder(t->right);
}
    
void Preorder(Node *t){
  if(t->key != -1) cout << " " << t->key;
  if(t->left != NULL) Preorder(t->left);
  if(t->right != NULL) Preorder(t->right);
}
 
 
void print(Node *t){
    if(t != NULL) Inorder(t);
      cout <<endl;
      if(t != NULL) Preorder(t);
      cout <<endl;
}
 
int main(){
    int n;
    cin >> n;
    char ope[n];
    int k, p;
 
    Node *t=new Node(-1, -1);
 
    for(int i=0; i<n; i++){
        scanf("%s", ope);
        if(ope[0] == 'p'){ print(t); }
        else if(ope[0] == 'f'){ cin >> k; find(t, k); }
        else if(ope[0] == 'd'){ cin >> k; t = erase(t, k); }
        else if(ope[0] == 'i'){ cin >> k >> p; t = insert(t, k, p); }
    }
 
    return 0;
}


Measured memory_bytes: 9496
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let n: usize = input();
    let a_vec = input_vec();
    let mut ans = 0;
    let mut right = 0;
    let mut sum = 0;
    let mut xor = 0;
    for left in 0..n {
        while right < n && (sum + a_vec[right]) == (xor ^ a_vec[right])  {
            sum += a_vec[right];
            xor ^= a_vec[right];
            right += 1;
        }
        // println!("{}, {}, {} {}", left, right, sum , xor);
        ans += right - left;
        sum -= a_vec[left];
        xor ^= a_vec[left];
    }
    println!("{}", ans);
}


Measured memory_bytes: 5192
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	if(n&1){
		FOR(i,1,m){
			cout<<i<<' '<<m*2-i+1<<'\n';
		}
	}else{
		int last,t=m/2;
		FOR(i,1,t){
			cout<<i<<' '<<t*2+2-i<<'\n';
		}
		last=t*2+2-1;
		FOR(i,1,m-t){
			cout<<last+i<<' '<<m*2+1-i+1<<'\n';
		}
	}
	RE 0;
}




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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 5e5 + 3;
int seg[4*T];
int n,a,b;
char c;
string s;

void build(int node, int i, int j) {
    if(i == j) seg[node] = (1<<(s[i]-'a'));
    else {
        int mid = (i+j)>>1;
        build(2*node,i,mid);
        build(2*node+1,mid+1,j);
        seg[node] = (seg[2*node] | seg[2*node+1]);
    }
}

void update(int node, int i, int j) {
    if(i > b or j < a) return;
    if(i >= a and j <= b) seg[node] = (1<<(c-'a'));
    else {
        int mid = (i+j)>>1;
        update(2*node,i,mid);
        update(2*node+1,mid+1,j);
        seg[node] = (seg[2*node] | seg[2*node+1]);
    }
}

int query(int node, int i, int j) {
    if(i > b or j < a) return 0;
    if(i >= a and j <= b) return seg[node];
    int mid = (i+j)>>1;
    return (query(2*node,i,mid) | query(2*node+1,mid+1,j));
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> s;
    s = "#" + s;
    build(1,1,n);
    int q; cin >> q;
    while(q--) {
        int op;
        cin >> op;
        if(op==1) {
            cin >> a >> c;
            b = a;
            update(1,1,n);
        } else {
            cin >> a >> b;
            cout << __builtin_popcount(query(1,1,n)) << endl;
        }
    }
    return 0;
}


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

unordered_map<string, int> m;

string convertToString(int n) {
  string s = "";
  while (n > 0) {
    int mod = n % 10;
    char cur = '0' + mod;
    s = cur + s;
    n = n / 10;
  }
  return s;
}

int solve(int n, int *a, int *b, int *c, char prev = ' ') {
  if (n == 1) {
    if (prev == ' ') {
      return max(a[0], max(b[0], c[0]));
    } else if (prev == 'a') {
      return max(b[0], c[0]);
    } else if (prev == 'b') {
      return max(a[0], c[0]);
    } else {
      return max(a[0], b[0]);
    }
  }
  string temp = convertToString(n) + prev;
  if (m.count(temp)) {
    return m[temp];
  }
  if (prev == 'a') {
    return m[temp] = max(b[n - 1] + solve(n - 1, a, b, c, 'b'),
                         c[n - 1] + solve(n - 1, a, b, c, 'c'));
  } else if (prev == 'b') {
    return m[temp] = max(a[n - 1] + solve(n - 1, a, b, c, 'a'),
                         c[n - 1] + solve(n - 1, a, b, c, 'c'));
  } else if (prev == 'c') {
    return m[temp] = max(a[n - 1] + solve(n - 1, a, b, c, 'a'),
                         b[n - 1] + solve(n - 1, a, b, c, 'b'));
  } else {
    return m[temp] = max(a[n - 1] + solve(n - 1, a, b, c, 'a'),
                         max(b[n - 1] + solve(n - 1, a, b, c, 'b'),
                             c[n - 1] + solve(n - 1, a, b, c, 'c')));
  }
}

int main() {
  int n;
  cin >> n;
  int *a = new int[n];
  int *b = new int[n];
  int *c = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  cout << solve(n, a, b, c);
}

Measured memory_bytes: 45968
#include<bits/stdc++.h>
#define maxn 10000000000000010
using namespace std;
int n,m;
struct hurtcloud{
    long long x,y;
}
a[55];
hurtcloud b[55];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%lld%lld",&a[i].x,&a[i].y);
    for(int j=1;j<=m;j++)scanf("%lld%lld",&b[j].x,&b[j].y);
    for(int i=1;i<=n;i++)
    {
        long long minx=maxn;
        int bh;
        for(int j=1;j<=m;j++)
          {
              long long sum=abs(a[i].x-b[j].x)+abs(a[i].y-b[j].y);
              if(minx>sum)minx=sum,bh=j;
          }
          printf("%d\n",bh);
    }
    return 0;
}

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

#define pb		push_back
#define eb		emplace_back
#define mk		make_pair
#define fi		first
#define se		second
#define cc(x)	cout << #x << " = " << x << endl
#define ok		cout << "ok" << endl
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

const int N = 1e5 + 10;
int dp[N][5];
int n, swim[N], bugs[N], home[N];

int pog(int at, int id){
	if(at >= n) return 0;

	int &r = dp[at][id];
	if(r != -1) return r;

	if(id == 0){
		return r = max(pog(at+1, 1) + bugs[at+1], pog(at+1, 2) + home[at+1]);
	} else if(id == 1){
		return r = max(pog(at+1, 0) + swim[at+1], pog(at+1, 2) + home[at+1]);
	} else {
		return r = max(pog(at+1, 0) + swim[at+1], pog(at+1, 1) + bugs[at+1]);
	}
}

int main() {
        ios_base::sync_with_stdio(false);

	memset(dp, -1, sizeof dp);
	cin >>n;

	for(int i = 0; i < n; i++){
		cin >>swim[i] >>bugs[i] >>home[i];
	}
	
	int x = pog(0, 0) + swim[0];
	int y = pog(0, 1) + bugs[0];
	int z = pog(0, 2) + home[0];

	cout <<max({x, y, z}) <<endl;
        return 0;
}


Measured memory_bytes: 8064
#include <iostream>
using namespace std;
int main(void){
    
 int a, b, c;
 cin >> a;
 b = a/3600;
 a = a - 3600 * b;
 c = a/60;
 a = a - 60 * c;
 cout << b << ":" << c << ":" << a << endl;
}


Measured memory_bytes: 3108
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <numeric> 
#include <bits/stdc++.h>
typedef long long ll;
typedef std::pair<std::pair<int,int>,int>pi;
using namespace std;

int main() {
    int k,a,b,c; cin >> k;
    a=b=c=1;
    ll sum = 0;
    vector<int>v;
    for(int j = b; j <= k; j++){
        for(int h = c; h <= k; h++){
            if(j == 1 || h == 1){
                v.push_back(1);
                continue;
            }
            int bc = __gcd(h,j);
            v.push_back(bc);
        }
    }
    for(int i = a; i <= k; i++){
        for(auto x: v){
            sum+= __gcd(i, x);
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 3756
import java.util.*;

public class Main {
    static int INF = 1001001009;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt() - 1;
        int y = sc.nextInt() - 1;
        
        // to: 隣接リスト(有向)
        List<int[]>[] to = new List[n];
        for (int i = 0; i < n; i++) {
            to[i] = new ArrayList<int[]>();
        }
        for (int i = 0; i < n - 1; i++) {
            to[i].add(new int[]{i + 1, 1});
            to[i + 1].add(new int[]{i, 1});
        }
        to[x].add(new int[]{y, 1});
        to[y].add(new int[]{x, 1});
        
        int[] ans = new int[n];
        // dist: startからの最短距離
        int[] dist = new int[n];
        for (int i = 0; i < n-1; i++) {
            Arrays.fill(dist, INF);
            dist[i] = 0;
            
            // ダイクストラ法: BFSで距離を配る。
            // (キューの先頭の点はそう来る他最短経路がないので最短距離が確定する)
            PriorityQueue<Point> que = new PriorityQueue<>();
            que.add(new Point(i, 0));
            while (!que.isEmpty()) {
                Point cur = que.poll();
                int p = cur.name;
                int dis = cur.dist;
                
                // distより大きいdisを持つ点からは配らせない
                if (dis > dist[p]) continue;
                
                // 子に「自分の距離 + p→qの距離」を配る
                for (int[] qData : to[p]) {
                    int q = qData[0];
                    int PtoQ = qData[1];
                    
                    // 最短距離が更新される場合だけキューに入れる
                    if (dis + PtoQ < dist[q]) {
                        dist[q] = dis + PtoQ;
                        que.add(new Point(q, dist[q]));
                    }
                }
            }
            
            for (int j = i; j < n; j++) {
                ans[dist[j]]++;
            }
        }
        for (int i = 1; i < n; i++) {
            System.out.println(ans[i]);
        }
    }
}
    
class Point implements Comparable<Point> {
    int name;
    int dist;
     
    Point(int name, int dist) {
        this.name = name;
        this.dist = dist;
    }
    
    @Override
    public int compareTo(Point o) {
        return this.dist - o.dist;    //重みの小さい順
    }
}

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

typedef long long ll;

int main() {
  ll n;
  cin >> n;
  ll c = (ll)pow(2, n);
  vector<ll> a(c);
  for (ll i = 0; i < c; i++) {
    cin >> a[i];
  }
  vector<ll> v;
  while (true) {
    if (a.size() == 1) {
      break;
    }
    for(int i = 0; i < a.size(); i += 2) {
      if (a[i] == a[i + 1]) {
        v.push_back(a[i]);
      }
      else if (a[i] > a[i + 1]) {
        v.push_back(a[i] - a[i + 1]);
      }
      else {
        v.push_back(a[i + 1] - a[i]);
      }
    }
    a.clear();
    for (int i = 0; i < v.size(); i++) {
      a.push_back(v[i]);
    }
    v.clear();
  }
  cout << a[0] << endl;
  return 0;
}

Measured memory_bytes: 3448
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  int n;
  cin >> n;
  vi a(n);
  int ans=INF;
  REP(i,n) {
    int x,cnt=0;
    cin >> x;
    while(x%2==0) {
      x/=2;
      cnt++;
    }
    ans=min(ans,cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>

using namespace std;

string num, reverse_num = "";

int main(){
  cin >> num;
  string buff = num;

  while(!buff.empty()){
    reverse_num.push_back(buff.back());
    buff.pop_back();
  }
  string ans = num == reverse_num ? "Yes" : "No";
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        // 解
        int ans = 0;

        // 入力
        int[] inp1 = CSRD.RI(' ');  //SC数：N, SCを構成する整数Aの数：M, 整数：C
        int n = inp1[0];
        int m = inp1[1];
        int c = inp1[2];
        int[] barr = CSRD.RI(' ');  //整数：B(M個分)
        int[][] aarr = new int[20][];
        for (int i = 0; i < n; i++)
        {
            aarr[i] = CSRD.RI(' ');  //整数：A(N * M個分)
        }
        
        // 処理
        for (int i = 0; i < n; i++)
        {
            int scAns = 0;
            for (int j = 0; j < aarr[i].Length; j++)
            {
                scAns = scAns + (aarr[i][j] * barr[j]);
            }
            scAns = scAns + c;
            if (scAns > 0)
            {
                ans++;
            }
        }
        


        //出力
        CSWT.WS(ans);
    }
}

class CSRD
{
    // 文字列または数値の入力
    public static string RS() { return Console.ReadLine(); }
    public static int RI() { return int.Parse(Console.ReadLine()); }
    public static string[] RS(char sep) { return Console.ReadLine().Split(sep); }
    public static int[] RI(char sep) { return Console.ReadLine().Split(sep).Select(x => int.Parse(x)).ToArray(); }
}

class CSWT
{
    public static void WS(object param) { Console.WriteLine(param); }
}

Measured memory_bytes: 13396
#include <stdio.h>

int main()
{
 int a,b,sum;
 char x;
 while(1)
 {
  scanf("%d %c %d", &a, &x, &b);
 switch (x){
  case '?':
   return 0;
  case '+':
   sum = a+ b;
   break;
  case '-':
   sum = a - b;
   break;
  case '*':
   sum = a* b;
   break;
  case '/':
   sum= a / b;
   break;
  }
  printf("%d\n", sum);
 }
 return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void) {
    vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << v[--K] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void r_shuffle(int n);
void cut(int k, int n);

short c[220];

int main(void)
{
	int n, m;
	int k, i;
	
	scanf("%d %d", &n, &m);
	
	for (i = 0; i < n * 2; i++){
		c[i] = i + 1;
	}
	
	for (i = 0; i < m; i++){
		scanf("%d", &k);
		
		if (k == 0){
			r_shuffle(n);
		}
		else{
			cut(k, n);
		}
	}
	for (i = 0; i < n * 2; i++){
		printf("%d\n", c[i]);
	}
	
	return (0);
}

void r_shuffle(int n)
{
	short tmp[220];
	int i;
	
	for (i = 0; i < n; i++){
		tmp[i * 2] = c[i];
		tmp[i * 2 + 1] = c[n + i];
	}
	for (i = 0; i < 2 * n; i++){
		c[i] = tmp[i];
	}
}

void cut(int k, int n)
{
	short tmp[220];
	int i, j;
	
	for (i = 0; i < 2 * n - k; i++){
		tmp[i] = c[k + i];
	}
	for (j = 0; j < k; j++){
		tmp[i + j] = c[j];
	}
	for (i = 0; i < 2 * n; i++){
		c[i] = tmp[i];
	}
}
		

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int p[200005];
int q[200005];

map<int, int> pt;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
  int n;cin>>n;
  for(int i=0;i<n;i++){
    cin>>p[i];
    p[i]--;
    q[p[i]]=i;
  }
  int mx = 1, t=1;
  for(int i=0;i<n-1;i++){
    if(q[i]<q[i+1]){
      t++;
      mx=max(mx, t);
    }else{
      t=1;
    }
  }
  // cout<<n<<endl;
  // cout<<mx<<endl;
  cout<<n-mx<<endl;
  return 0;
}


Measured memory_bytes: 1792