akhauriyash/Code-Regression huggingface dataset:
#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;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define lli long long int
#define pii pair<int,int>
#define vii vector<pii>
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v)  v.begin(),v.end()
#define mod 1000000007
#define vi vector<int>
#define vl vector<lli>
#define vll vector<pair<lli,lli>>
#define pll pair<lli,lli>
#define vvi vector<vector<int>>
#define vvl vector<vector<lli>>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define tk(args...) take(args);
#define posLSB(X) __builtin_ctz(X)
#define num1bit(X) __builtin_popcount(X)
#define numlead0(X) __builtin_clz(X)
#define umreserve(X) X.reserve(32768); X.max_load_factor(0.25);
void err(istream_iterator<string> it) {} template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cout << *it << " = " << a << "\n"; err(++it, args...);}
void take() {} template<typename T, typename... Args> void take( T & a, Args & ... args ) { cin>>a; take(args...); }
template<class T>
void printvec(vector<T> &a){
	for(T &x:a){
		cout<<x<<" ";
	}
	cout<<endl;
}
template<class T>
void printarr(T a[],lli n){
	for(lli i=0;i<n;i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};

#define endl "\n"

lli add(lli a, lli b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

lli mul(lli a, lli b) {
	return a * 1ll * b % mod;
}

inline bool setmin(lli &x, lli y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(lli &x, lli y) { return (y > x) ? x = y, 1 : 0; }

lli power_mod(lli a,lli x){if(x==0) return 1;lli y=power_mod(a,x/2);lli ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
lli inv(lli a){return power_mod(a,mod-2);}
lli power(lli a, lli x){ if(x==0) return 1; lli y= power(a,x/2); lli ans=(y*y); if(x%2) ans*=a; return ans;}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b;
	cin>>a>>b;
	if(a>b){
		for(int i=0;i<a;i++){
			cout<<b;
		}
		cout<<endl;
	}
	else{
		for(int i=0;i<b;i++)cout<<a;
		cout<<endl;
	}
}

Measured memory_bytes: 256
s=input()
ans1=''
ans2=''
for i in range(len(s)):
    if i%2==0:
        ans1+='1'
        ans2+='0'
    else:
        ans1+='0'
        ans2+='1'
tmp1=0
tmp2=0
for i in range(len(s)):
    if s[i]!=ans1[i]:
        tmp1+=1
    if s[i]!=ans2[i]:
        tmp2+=1
print(min(tmp1,tmp2))

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 1000000000000



int main() {
	
	long long N;
	cin>>N;
	
	set<long long> ans;
	
	for(long long i=1;i*i<=N-1;i++){
		if((N-1)%i==0){
			ans.insert(i);
			ans.insert((N-1)/i);
		}
	}
	
	for(long long i=1;i*i<=N;i++){
		if(N%i==0){
			long long t = N;
			if(i!=1){
				while(t%i==0)t/=i;
				if(t%i==1){
					ans.insert(i);
				}
			}
			if(N/i!=1){
				t = N;
				while(t%(N/i)==0)t/=(N/i);
				if(t%(N/i)==1){
					ans.insert(N/i);
				}
			}
		}
	}
	
	//for(auto a:ans)cout<<a<<endl;
	
	cout<<ans.size()-1<<endl;
	
    return 0;
}


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

int calc(int x, int y, int cx, int cy){
    return - abs(x-cx) - abs(y-cy);
}

int main(void){
    int N;
    cin >> N;
    int x[101], y[101], h[101];
    int p;
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i]) p=i;
    }
    bool check = true;
    for(int i = 0; i < 101; i++){
        for(int j = 0; j < 101; j++){
            int top = h[p] - calc(x[p], y[p], i,j);
            check = true;
            for(int k = 0; k < N; k++){
                if(max(0,top + calc(x[k],y[k],i,j)) != h[k])check=false;
            }
            if(check){
                cout << i << " " << j << " " << top << endl;
                break;
            }
        }
        if(check)break;
    }
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    val to = Array<MutableList<Int>>(N, { mutableListOf() } )
    repeat(M) {
        val (u, v) = listOfInt()
        to[u - 1].add(v - 1)
    }
    val (S, T) = listOfInt()
    val INF = 1001001001
    var dist = Array<Array<Int>>(100005) { Array<Int>(3, { INF }) }

    var q = Queue<Pair<Int, Int>>()
    q.enqueue(Pair(S - 1, 0))
    dist[S - 1][0] = 0
    while (!q.isEmpty()) {
        val e = q.dequeue()!!
        val v = e.first
        val l = e.second
        to[v].forEach {
            val nl = (l + 1) % 3
            if (dist[it][nl] == INF) {
                dist[it][nl] = dist[v][l] + 1
                q.enqueue(Pair(it, nl))
            }
        }
    }
    var ans = dist[T - 1][0]
    if (ans == INF) ans = -1 else ans /= 3
    println(ans)
}

class Queue<T> {
    val elements: MutableList<T> = mutableListOf()
    fun isEmpty() = elements.isEmpty()
    fun count() = elements.size
    fun enqueue(item: T) = elements.add(item)
    fun dequeue() = if (!isEmpty()) elements.removeAt(0) else null
    fun peek() = if (!isEmpty()) elements[0] else null
    override fun toString(): String = elements.toString()
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


Measured memory_bytes: 99864
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int r;
    cin >>r;
    cout <<3 * r * r;
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    x=II()
    a=100
    for i in range(10**7):
        a=a*101//100
        if a>=x:
            print(i+1)
            break

main()

Measured memory_bytes: 9228
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
#define MAX 100002
#define BIG 1000000007
int min(int a,int b){
    if(a>b) return b;
    else return a;
}
int main(){
    int N;
    scanf("%d",&N);
    int DP[MAX];
    memset(DP,BIG,sizeof(DP));
    DP[0] = 0;
    for(int i=1;i<=N;i++){
        if(i<6)
            DP[i] = DP[i-1] + 1;
        else if(i<9)
            DP[i] = min(DP[i-1]+1,DP[i-6]+1);
        else{
            int six_tmp=6,nine_tmp=9;
            while(six_tmp<=i){
                DP[i] = min(DP[i],DP[i-six_tmp]+1);
                six_tmp *= 6;
            }
            while(nine_tmp<=i){
                DP[i] = min(DP[i],DP[i-nine_tmp]+1);
                nine_tmp *= 9;
            }
        }
    }
    printf("%d",DP[N]);

}


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

const int INF = 1000000000;

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;

		if(n==0 && m==0)
			break;

		int C[100][100];
		int T[100][100];
		for(int i=0; i<m; i++){
			for(int j=0; j<m; j++){
				if(i==j){
					C[i][j] = T[i][j] = 0;
				}
				else{
					C[i][j] = T[i][j] = INF;
				}
			}
		}

		for(int i=0; i<n; i++){
			int a, b, c, t;
			cin >> a >> b >> c >> t;

			C[a-1][b-1] = C[b-1][a-1] = c;
			T[a-1][b-1] = T[b-1][a-1] = t;
		}
		for(int k=0;k<m;k++){
			for(int i=0;i<m;i++){
				for(int j=0;j<m;j++){
					if(C[i][j]>C[i][k]+C[k][j]){
						C[i][j]=C[i][k]+C[k][j];
					}
				}
			}
		}
		for(int k=0;k<m;k++){
			for(int i=0;i<m;i++){
				for(int j=0;j<m;j++){
					if(T[i][j]>T[i][k]+T[k][j]){
						T[i][j]=T[i][k]+T[k][j];
					}
				}
			}
		}
		int k;
		cin>>k;
		for(int i=0;i<k;i++){
			int p,q,r;
			cin>>p>>q>>r;
			if(r==0)
				cout<<C[p-1][q-1]<<endl;
			if(r==1)
				cout<<T[p-1][q-1]<<endl;
		}
		}
	return 0;
}

Measured memory_bytes: 1236
require "matrix"
  iN,iM,iL=$stdin.gets.split.map(&:to_i)
  arrA=[]
  iN.times do |n|
    arrA<<$stdin.gets.split.map(&:to_i)
  end
  arrB=[]
  iM.times do |n|
    arrB<<$stdin.gets.split.map(&:to_i)
  end

  mxA=Matrix.rows(arrA)
  mxB=Matrix.rows(arrB)
  mxC=mxA*mxB
  mxC.to_a.each do |r|
    puts r.join " "
  end


Measured memory_bytes: 9144
#include <iostream>
#include <string>
 
using namespace std;
 
int main()
{
  int n, k, c; string s; cin >> n >> k >> c >> s;
  
  int a[200000]; int b[200000];
  for (int i = 0, idx = 0; i < n; ++i) if (s[i] == 'o') {a[idx++] = i; i += c;}
  for (int i = n-1, idx = k-1; i >= 0; --i) if (s[i] == 'o') {b[idx--] = i; i -= c;}
  
  for (int i = 0; i < k; ++i) if (a[i] == b[i]) cout << a[i]+1 << endl;
  return 0;
}


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

int n;

//int *A;

int A[20];

bool solve(int i, int m){
  if(m == 0){
    return 1;
  }
  else if(i >= n){
    return 0;
  }

  return solve(i + 1, m) || solve(i + 1, m - A[i]);
}

int main(){

  int q, m;

  cin >> n;

  //A = new int[n];

  //string *ans = new string[q];

  int ans[200];


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

  cin >> q;

  for(int i = 0; i < q; i++){
    cin >> m;
    if(solve(0, m) == 1){
      ans[i] = 1;
    }
    else{
      ans[i] = 0;
    }
  }

  for(int i = 0; i < q; i++){
    if(ans[i]){
      cout << "yes" << endl;
    }
    else{
      cout << "no" << endl;
    }
  }


  return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<lint> A(N);
  vector<lint> B(N);
  bool flg = false;
  REP(i, N) {
    cin >> A[i] >> B[i];
    if(A[i] != B[i]) flg = true;
  }
  if(!flg) {
    cout << 0 << endl;
    return 0;
  }
  lint sum = 0;
  lint min = INF;
  REP(i, N) {
    sum += A[i];
    if(A[i] > B[i] && B[i] < min) min = B[i];
  }
  cout << sum-min << endl;

}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
	int a;
	while(scanf("%d",&a),~a){
		int rev=1150;
		if(a>=30)rev+=(a-30)*160+1400+1250;
		else if(a>=20)rev+=(a-20)*140+1250;
		else if(a>=10)rev+=(a-10)*125;
		printf("%d\n",4280-rev);
	}
}

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  vector<int> times(N,0);
  for (int i=0; i<N; i++){
    cin >> A[i];
    times[A[i]-1] ++;
  }
  sort(times.begin(), times.end(), greater<int>());
  

  
  int ans =0;
  for (int j=K; j<N; j++){
    ans += times[j];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(int i=0;i<N;i++)
typedef long long ll;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin>>N>>M;
    vector<int> height(N);
    for(int i=0;i<N;i++){
        cin>>height[i];
    }
    vector<int> highest_neighbor(N);
    int A,B;
    for(int i=0;i<M;i++){
        cin>>A>>B;
        A--;B--;
        highest_neighbor[A]=max(highest_neighbor[A],height[B]);
        highest_neighbor[B]=max(highest_neighbor[B],height[A]);
    }
    int count=0;
    for(int i=0;i<N;i++){
        if(height[i]>highest_neighbor[i])count++;
    }
    cout<<count<<endl;

}

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

using namespace std;
const int INF=1e9+5;
typedef long long ll;
const int MOD=1e9+7;
int main(){
	int n,k;
	cin>>n>>k;
	unordered_set<int> us;
	int d,hh;
	while(k--){
		cin>>d;
		while(d--){
			cin>>hh;
			us.insert(hh);
		}
	}
	int ans=n-us.size();
	cout<<ans<<endl;

}


Measured memory_bytes: 3628
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    a = II()
    print(a + a ** 2 + a ** 3)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 81332
#include <stdio.h>
 
int main(void) {
	
	int a,b,c,d,e,f,g,h;
	scanf("%d%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f,&g,&h);
	a=a+b+c+d;
	e=e+f+g+h;
	if(a>e)
	{
		printf("%d\n",a);
	}
	if(e>a)
	{
		printf("%d\n",e);
	}
	if(a==e)
	{
		printf("%d\n",a);
	}
    return 0;
}



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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long 
#define db double
#define pii pair <int, int> 
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T& a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T& a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T& a) { return 1ll * a * a; }
template <class T> void compress(vector <T> &a){
  sort(all(a));
  a.resize(unique(all(a)) - a.begin());
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 1e9;
const int MOD = 1e9+7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

int main()
{
  fastio;
  string s, t; cin >> s >> t;
  t.pop_back();
  cout << (s == t ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
ll i, a, b, c, k, ans;

int main() {
    scanf(" %lld %lld %lld %lld", &a, &b, &c, &k);
    ll sum = 0;
    if (a > k) {
        sum += k;
    } else {
        sum += a;
    }
    k -= a;
    k -= b;
    if (k > 0) {
        sum -= k;
    }
    
    printf("%lld\n", sum);
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N, M, A, B, C;
    string str1, str2;
    cin >> str1;
    if(str1[0] == '7' || str1[1] == '7' || str1[2] == '7')cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
    int to;
    ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

int main() {
    COME_LET_THE_GAMES_BEGIN();
    int w, a, b;
    cin >> w >> a >> b;
    if (a + w < b) {
        cout << b - a - w << endl;
    } else if (a > b + w) {
        cout << a - b - w << endl;
    } else {
        cout << 0 << endl;
    }
}

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

using namespace std;

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

    string week[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

    for (int i = 0; i < 7; i++) {
        if (week[i] == today) {
            cout << 7-i << endl;
            break;
        }
    }
    
    return(0);
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {

    int N, K;
    scanf("%d%d", &N, &K);
    int arr[N];
    for(int i=0;i<N;i++){
        scanf("%d", &arr[i]);
    }

    for(int j=0;j<N-K;j++){
        if(arr[j]<arr[j+K]){
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }

    return 0;
}

Measured memory_bytes: 2396
#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<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

std::vector<int> primeNumbers;
std::vector<bool> isPrime;

void eratosthenes(int n){
    int i, j;
    int s = 4;

    primeNumbers.clear();
    primeNumbers = {2, 3};

    isPrime.assign(std::max(n + 1, 2), true);
    isPrime[0] = false;
    isPrime[1] = false;

    for(i = 4 ; i <= n ; i += 2){
        isPrime[i] = false;
    }
    for(i = 9 ; i <= n ; i += 6){
        isPrime[i] = false;
    }

    for(i = 5 ; i * i <= n ; i += s){
        if(isPrime[i]){
            primeNumbers.emplace_back(i);
            for(j = i * i ; j <= n ; j += i){
                isPrime[j] = false;
            }
        }
        s ^= 6;
    }
    for( ; i <= n ; i += s){
        if(isPrime[i]){
            primeNumbers.emplace_back(i);
        }
        s ^= 6;
    }

    return;
}

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

    constexpr int N = 1120;
    constexpr int K = 14;

    eratosthenes(N + 1);

    const int m = (int)primeNumbers.size();

    vector< vector< vector<int> > > dp(m + 1, vector< vector<int> >(N + 1, vector<int>(K + 1, 0)));
    dp[0][0][0] = 1;

    rep(i, m){
        rep(j, N + 1){
            rep(l, K + 1){
                dp[i + 1][j][l] += dp[i][j][l];
                if(j + primeNumbers[i] <= N && l + 1 <= K){
                    dp[i + 1][j + primeNumbers[i]][l + 1] += dp[i][j][l];
                }
            }
        }
    }

    int n, k;
    while(cin >> n >> k, n){
        cout << dp[m][n][k] << endl;
    }

    cout << flush;

    return 0;
}


Measured memory_bytes: 24632
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

const int INF=1001001001;
const int di[]={-1,0,1,0};
const int dj[]={0,-1,0,1};


int main(){
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  for(int i=0;i<h;++i){
    cin >> s[i];
  }
  int ans=0;
  for(int si=0;si<h;++si){
    for(int sj=0;sj<w;++sj){
      if(s[si][sj]=='#') continue;
      vector<vector<int>> dist(h,vector<int>(w,INF));
      queue<P> q;
      auto update = [&](int i,int j,int x){
        if(dist[i][j]!=INF) return;
        dist[i][j]=x;
        q.push(P(i,j));
      };
      update(si,sj,0);
      while(!q.empty()){
        int i=q.front().first;
        int j=q.front().second;
        q.pop();
        for(int dir=0;dir<4;++dir){
          int ni=i+di[dir];
          int nj=j+dj[dir];
          if(ni<0 || ni>=h || nj<0 || nj>=w) continue;
          if(s[ni][nj]=='#')continue;
          update(ni,nj,dist[i][j]+1);
        }
      }
      for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
          if(dist[i][j]==INF) continue;
          ans=max(ans,dist[i][j]);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto K = readln.chomp.to!long;
    long r = 1, k;
    foreach (_; 0..10^^7+1) {
        k = (k*10+7) % K;
        if (k == 0) {
            writeln(r);
            return;
        }
        ++r;
    }
    writeln(-1);
}

Measured memory_bytes: 2716
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {
    // 入力
    ll N,M,X;
    cin >> N >> M >> X;
    vector<ll> C(N);
    vector<vector<ll>> A(N,vector<ll>(M));
    rep(i,N){
        cin >> C[i];
        rep(j,M){
            cin >> A[i][j];
        }
    }
    // bit 全探索
    ll out = -1;
    for (ll bit = 0; bit < (1 << N); ++bit) {
        ll S[M];
        ll sum = 0;
        rep(i,M) S[i] = 0;
        rep(i,N){
            if (bit & (1 << i)){
                sum += C[i];
                rep(j,M){
                    S[j] += A[i][j];
                }
            }
        }
        // 判定
        bool isMatch = true;
        
        rep(i,M){
            if(S[i]<X) isMatch = false;
        }
        if(isMatch){
            if(out==-1) out = sum;
            else if(sum<out) out = sum;
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    int valid = true;
    for (int i = 0; i+1 < n; ++i) {
        if(v[i] >= v[i+1]) valid = false;
    }
    if(valid) {
        puts("1");
        return 0;
    }
    int ng = 1, ok = n;
    while(ok-ng > 1){
        int mid = (ok+ng)/2;
        deque<pair<int, int>> s;
        s.emplace_back(0, -INF<int>);
        for (int i = 1; i < n; ++i) {
            if(v[i-1] < v[i]) continue;
            while(s.back().first > v[i]) s.pop_back();
            if(s.back().first == v[i]){
                s.back().second++;
            }else {
                s.emplace_back(v[i], 1);
            }
            while(s.back().second == mid){
                int x = s.back().first;
                s.pop_back();
                if(s.back().first == x-1){
                    s.back().second++;
                }else {
                    s.emplace_back(x-1, 1);
                }
            }
        }
        if(s.front().second == -INF<int>) ok = mid;
        else ng = mid;
    }
    cout << ok << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first) {
        return a.first < b.first;
    } else {
        return a.second < b.second;
    }
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> ve(N);
    rep(i, 0, N) { cin >> ve[i].first >> ve[i].second; }
    sort(ve.begin(), ve.end(), compare_by_a);
    // rep(i, 0, N) { cout << ve[i].first << "," << ve[i].second << endl; }
    priority_queue<int> q;
    int r = 0;
    long long ans = 0;
    rep(i, 0, M + 1) {
        rep(t, r, N) {
            if(ve[t].first <= i) {
                q.push(ve[t].second);
                // cout << "day:" << i << "canwork:" << ve[t].second << endl;
                r++;
            } else {
                break;
            }
        }
        if(q.size() != 0) {
            //      cout << "day:" << i << "work:" << q.top() << endl;
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof(a))
#define IN freopen("in.txt","r",stdin);
#define OUT freopen("out.txt","w",stdout);
#define sc scanf
#define itn int
#define STR clock_t startTime = clock();
#define END clock_t endTime = clock();cout << double(endTime - startTime) / CLOCKS_PER_SEC *1000<< "ms" << endl;
using namespace std;
const int N=1e6+5;
const int mod=1e9+7;
const int p=998244353;
const int oo=0x7fffffff;
const int sup=0x80000000;
typedef long long ll;
typedef unsigned long long ull;
template <typename it>void db(it *begin,it *end){while(begin!=end)cout<<(*begin++)<<" ";puts("");}
template <typename it>
string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}
template <typename it>int o(it a){cout<<a<<endl;return 0;}
inline ll mul_64(ll x,ll y,ll c){return (x*y-(ll)((long double)x/c*y)*c+c)%c;}
inline ll ksm(ll a,ll b,ll c){ll ans=1;for(;b;b>>=1,a=a*a%c)if(b&1)ans=ans*a%c;return ans;}
inline void exgcd(ll a,ll b,ll &x,ll &y){if(!b)x=1,y=0;else exgcd(b,a%b,y,x),y-=x*(a/b);}
int n,a[N],f[N]={0};
short int mu[N];
ll inv[N],w[N];
int main(){
    mu[1]=1;inv[1]=1;
    for(int i=2;i<N;i++)inv[i]=(p-p/i)*inv[p%i]%p;
    for(int i=1;i<N;i++)
    for(int j=i+i;j<N;j+=i)mu[j]-=mu[i];
    for(int i=1;i<N;i++)
    for(int j=i;j<N;j+=i)w[j]+=mu[j/i]*inv[i],w[j]=(w[j]%p+p)%p;
    cin>>n;
    for(int i=1;i<=n;i++)sc("%d",&a[i]),f[a[i]]++;
    ll ans=0;
    for(int d=1;d<N;d++){
        ll res=0,ret=0;
        for(int i=d;i<N;i+=d){
            if(f[i]){
                for(int j=0;j<f[i];j++)ret+=res*i%p,res+=i,ret%=p,res%=p;
            }
        }
        ans+=w[d]*ret%p;
        ans%=p;
    }
    o(ans);
}

Measured memory_bytes: 22784
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <utility>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)

typedef long long ll;

using namespace std;

typedef pair<int, int> pint;

int main(){
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    pint v12 = {x2 - x1, y2 - y1};
    pint v23 = {y1 - y2, x2 - x1};
    pint p3 = {v23.first + x2, v23.second + y2};
    pint p4 = {v23.first + x1, v23.second + y1};

    printf("%d %d %d %d", p3.first, p3.second, p4.first, p4.second);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 100002;

int n;
long long a[maxn];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];

	long long sum = 0;
	for (int i = 1; i < n; i += 2)
		sum += a[i+1] - a[i];

	long long x = (a[n] - sum) / 2;
	cout << x * 2;
	for (int i = 2; i <= n; ++i) {
		x = a[i-1] - x;
		cout << " " << x * 2;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll a,w;cin>>a>>w;
    ll b,v;cin>>b>>v;
    ll t;cin>>t;

    if(v>=w)return cout<<"NO" , 0;

    ll vel = w-v;
    ll dist = abs(b-a);

    cout<<(dist<=vel*t?"YES":"NO");
}


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

int main(){
  long a1=1,a2=2,num;
  int n;

  cin>>n;
  if(n==1) num=1;
  else
  {
    for(int i=1;i<n;i++)
    {
      num=a1+a2;
      a2=a1;
      a1=num;
    }
  }

  cout<<num<<endl;
}

Measured memory_bytes: 256
// #define bhartiya
#ifndef bhartiya
    // #pragma GCC optimize("Ofast")
    // #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

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

typedef long long ll;
typedef pair<ll, ll> pll;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#ifdef bhartiya
#define endl '\n'
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
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...);
}
#else
#define trace(...)
#endif


#define pb push_back
#define bitc  __builtin_popcountl
#define mp make_pair
#define ff first
#define ss second

#define swap(a,b) {a=a^b;b=a^b;a=a^b;}
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define inf 200000000000000ll
// #define inf 10000000000ll
#define mod 1000000007ll
// #define mod 998244353ll
#define eps 1e-7

ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }

const ll maxn = 3005;
double dp[maxn][maxn];
bool vis[maxn][maxn];
double a[maxn];

int main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.precision(10);
    // cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
        ll n,m;
        cin>>n;
        fr(i,1,n){
            cin>>a[i];
        }
        dp[0][0] = 1;
        fr(i,1,n){
            dp[i][0] = dp[i-1][0]*(1-a[i]);
            fr(j,1,n){
                dp[i][j] = dp[i-1][j]*(1-a[i]) + dp[i-1][j-1]*a[i];
            }
        }
        double ans = 0;
        fr(i,(n+1)/2,n){
            ans += dp[n][i];
        }
        cout<<ans;
    }
}


Measured memory_bytes: 71424
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(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)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>>pr(n),pb(n);
	int a, b,ans=0;
	vector<bool>flagr(n),flagb(n);
	repp(i, 0, n) {
		flagr[i] = true;
		flagb[i]= true;
	}
	repp(i, 0, n) {
		cin >> a >> b;
		pr[i] = make_pair(b,a);
	}
	repp(i, 0, n) {
		cin >> a >> b;
		pb[i] = make_pair(a, b);
	}
	sort(pr.begin(), pr.end()); reverse(pr.begin(), pr.end());
	sort(pb.begin(), pb.end());
	repp(i, 0, n)swap(pr[i].first, pr[i].second);
	repp(i, 0, n)repp(j, 0, n) {
		if (pr[i].first < pb[j].first && pr[i].second < pb[j].second && flagr[i] == true && flagb[j] == true) {
			++ans;
			flagr[i] = false; flagb[j] = false;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// header {{{
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <boost/foreach.hpp>
#include <vector>
#include <algorithm>
using namespace std;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}

template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
// }}}

// init {{{
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------
template<typename T> void combSort(vector<T>& v) {
	size_t h = (v.size() * 10) / 13;
	bool is_sorted = false;
	while (!is_sorted) {
		if (h == 1)is_sorted = true;
		for (size_t i = 0; i < v.size() - h; ++i) {
			if (v[i] > v[i + h]) {
				swap(v[i], v[i + h]);
				if (is_sorted)is_sorted = false;
			}
		}
		if (h > 1) h = (h * 10) / 13;
		if (h == 0) h = 1;
	}
}
signed main() {
	int N;

	cin >> N;

	vector<int> v(N);

	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}

	vector<int> v_comb = v;
	combSort(v_comb);

	v_comb.erase(std::unique(v_comb.begin(), v_comb.end()), v_comb.end());
	string ans;
	if (v_comb.size() < N)
	{
		ans = "NO";
	}
	else
	{
		ans = "YES";
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
int mod = 998244353;
// int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int n;
  cin >> n;
  map<int, int> mp;
  rep3(i, 1, n) {
    int a;
    cin >> a;
    a--;
    mp[a]++;
  }
  rep(i, n) cout << mp[i] << endl;
}


Measured memory_bytes: 13028
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

/*aのb進数時の桁数*/
ll digits(ll a, ll b){return a/b?1+digits(a/b,b):1;}
/*nをa進数にしたときの、i桁目の数*/
ll a_base2(ll n, ll a, ll i){return i==1?n%a:a_base2(n/a,a,i-1);}

ll n;

ll dfs(ll a, ll dig){
    if(a>n) return 0;
    if(digits(n,10)==dig) return 1;
    ll ans=1,one=a%10;
    rep(i,0,10){
        ans+=dfs(a*10-9*one+10*i,dig+1);
    }
    return ans;
}

int main(void){
    ll ans=0;
    // char ;
    scanf("%lld",&n);
    // ll [n];
    rep(i,1,10){
        rep(j,i,10){
            ll a=0,b=0;
            if(i==j){
                if(i>n) continue;
                a++;
                a+=dfs(10*i+j,2);
                ans+=a*a;
                b=a;
            }else{
                a+=dfs(10*i+j,2);
                b+=dfs(10*j+i,2);
                ans+=a*b*2;
            }
            // printf("%lld %lld ||",a,b);
            // ans+=a*b;
        }
        // PN;
    }

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


Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast","-funroll-loops","-fdelete-null-pointer-checks")
#pragma GCC target("ssse3","sse3","sse2","sse","avx2","avx")
using namespace std;

int h, w, k, g[15][1005], make_cut[15];
int main() {
  scanf ("%d%d", &h, &w);
  cin >> k;
  for (int i = 1; i <= h; ++i) {
    string t;
    cin >> t;
    for (int j = 1; j <= w; ++j)
        g[i][j] = t[j - 1] == '1';
  }
  int ans = 0x3f3f3f3f;
  for (int st = 0; st < (1 << (h - 1)); ++st) {
    vector <int> tp(__builtin_popcount(st) + 1);
    for (int i = 1; i <= h-1; ++i)
      make_cut[i] = (st >> (i - 1) & 1);
    make_cut[h] = 1;
    int cutt = __builtin_popcount(st);
    for (int j = 1; j <= w; ++j) {
      int cnt = 0;
      vector <int> ts;
      for (int i = 1; i <= h; ++i) {
        cnt += g[i][j];
        if (make_cut[i]) ts.push_back(cnt), cnt = 0;
      }

      for (int i = 0; i < ts.size(); ++i) if (ts[i] > k) goto end;
      bool f = 0;
      for (int i = 0; i < ts.size(); ++i) f |= (tp[i] + ts[i] > k);
      if (f == 0) {
        for (int i = 0; i < ts.size(); ++i) tp[i] += ts[i];
      } else tp = ts, ++cutt;
    }

    ans = min(ans, cutt);

    end:;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sum = sc.nextInt();
		int broken_sum = sc.nextInt();
		int[] array = new int[broken_sum + 1];

		for (int i=0; i<broken_sum; i++) {
			array[i] = sc.nextInt();
		}
		array[broken_sum] = sum + 1;

		long result = (fibonatch(array[0]))% 1000000007;

		for (int i=1; i<broken_sum+1; i++) {
			if (array[i] -  array[i-1] == 1) {
				result = 0;
				break;
			}
			result = (result * fibonatch(array[i] -  array[i-1] - 1) % 1000000007) % 1000000007;
		}


		System.out.println(result % 1000000007);
	}

	static long fibonatch(int num) {
		long tmp1 = 1;
		long tmp2 = 1;


		if (num < 3) {
			return 1;
		} else {
			long n = 0;
			for (long i = 3; i <= num; i ++) {
				n = (tmp1 + tmp2) % 1000000007;
				tmp1 = tmp2 % 1000000007;
				tmp2 = n % 1000000007;
			}
			return n;
		}

	}

}


Measured memory_bytes: 48148
N=int(input())
h=list(map(int,input().split()))
dp=[0]*(N+1)
dp[0]=0
dp[1]=abs(h[1]-h[0])
for n in range(2,N):
    dp[n]=min(dp[n-2]+abs(h[n-2]-h[n]),dp[n-1]+abs(h[n-1]-h[n]))
print(dp[N-1])

Measured memory_bytes: 13980
using System;
public class CC {
    public static void Main() {
        long N = long.Parse(Console.ReadLine());
        string[] readSome = new string[N];
        readSome = Console.ReadLine().Split(' ');
        long[] A = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = long.Parse(readSome[i]);
        }
        Array.Sort(A);
        long count = 0;
        long test;
        bool[] OK = new bool[N];
        for (int i = 0; i < N; i++) {
            if (i != 0) {
                if (A[i] == A[i - 1]) {
                    if (OK[i - 1]) {
                        OK[i] = true;
                        count++;
                    } else {
                        OK[i] = false;
                    }
                } else {
                    test = A[i];
                    for (int j = 0; j < N; j++) {
                        if (i != j) {
                            if (2 * test < A[j]) {
                                break;
                            } else {
                                test += A[j];
                            }
                        }
                        if (j == N - 1) {
                            count++;
                            OK[i] = true;
                        }
                    }
                }
            } else {
                test = A[i];
                for (int j = 0; j < N; j++) {
                    if (i != j) {
                        if (2 * test < A[j]) {
                            break;
                        } else {
                            test += A[j];
                        }
                    }
                    if (j == N - 1) {
                        count++;
                        OK[i] = true;
                    }
                }
            }
            if (count == 1) {
                count = N - i;
                break;
            }
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 26588
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
const double pi = 3.141592653589793;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;//nは偶数
    vector<int64_t> a(n);
    vector<bitset<30>> c(n);
    vector<bitset<30>> ans(n);
    rep(i,n){
        cin>>a[i];
        c[i] = a[i];
        //cout<<c[i]<<endl;
    }
    rep(j,30){
        int count=0;
        rep(i,n){
            if(c[i].test(j)){
                count++;
            }
        }
        if(count%2==0){
            rep(i,n){
                ans[i].set(j,c[i][j]);
            }
        }
        else{
            rep(i,n){
                ans[i].set(j,!c[i][j]);
            }
        }
    }
    rep(i,n){
        cout<<ans[i].to_ullong()<<" ";
    }
    cout<<endl;
}

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

using ll = long long;
using ld = long double;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int r, g, b;
    cin >> r >> g >> b;
    cout << ((g * 10 + b) % 4 == 0 ? "YES" : "NO") << EOL;

}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int N, M;
	cin >> N >> M;
	int L = 0;
	int R = 100001;
	REP(i, M) {
		int l, r;
		cin >> l >> r;
		L = max(L, l);
		R = min(R, r);
	}
	cout << max(0, R - L + 1) << endl;

	return 0;
}


Measured memory_bytes: 256
N = gets.chomp.to_i
D = gets.chomp.split.map(&:to_i)

D.sort!

# p D

def solve
  if (N % 2) == 1
    p 0
    return     
  end
  
  l = D[N/2-1]
  r = D[N/2]
  if r == l
    p 0
    return
  end
  
  p r - l
end
  
solve

Measured memory_bytes: 9472
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

vector<long long> a;
long long dp[401][401] = {};

long long solve(int l, int r) {
	if (l == r) return 0;
	if (dp[l][r]) return dp[l][r];
	long long ans = 1e18;
	for (int i = l; i < r; ++i)
		ans = min(ans, solve(l, i) + solve(i + 1, r) + a[r] - a[l - 1]);
	return dp[l][r] = ans;
}

int main() {
	int n; cin >> n;
	a.resize(n + 1);
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		a[i] += a[i - 1];
	}
	cout << solve(1, n) << endl;

	return 0;
}

Measured memory_bytes: 1664