akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int n;
Graph G,Grev;

int dfs(int v){
  // Grevの一番奥がparent
  if (Grev[v].size() == 0) return v;
  return dfs(Grev[v][0]);
}

void depths(vector<int> &depth, int v, int rank){
  for (int nv : G[v]){
    depth[nv] = rank + 1;
    depths(depth, nv, rank+1);
  }
}

int main() {
  cin >>n;
  G.assign(n, vector<int>());
  Grev.assign(n, vector<int>());
  rep(i, n){
    int v; cin >>v;
    int k; cin >>k;
    rep(j, k){
      int c; cin >>c; G[v].push_back(c); Grev[c].push_back(v);
    }
  }
  int parent = dfs(0);
  vector<int> depth(n, -1); depth[parent] = 0;
  depths(depth, parent, 0);

  rep(i, n){
    cout <<"node " <<i <<": parent = ";
    if (i == parent) cout <<-1;
    else cout <<Grev[i][0];
    cout <<", depth = " <<depth[i] <<", ";
    if (i == parent) cout <<"root, [";
    else if (G[i].size() == 0) cout <<"leaf, [";
    else cout <<"internal node, [";
    for (int j=0; j<G[i].size(); j++){
      if (j > 0) cout <<", ";
      cout <<G[i][j];
    }
    cout <<"]" <<endl;
  }
}


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

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut x: Vec<i32> = Vec::new();
    let mut y: Vec<i32> = Vec::new();
    for i in 0..n {
        let a: i32 =  iter.next().unwrap().parse().unwrap();
        let b: i32 =  iter.next().unwrap().parse().unwrap();
        x.push(a);
        y.push(b);
    }
    let mut ans: f64 = 0.0;
    for i in 0..n {
        for j in i+1..n {
            let d = ((
           (x[i]-x[j]) * (x[i]-x[j])  +
           (y[i]-y[j]) * (y[i]-y[j]) 
            ) as f64).sqrt();
            ans += d;
        }
    }
    ans /= n as f64;
    println!("{}", ans * 2.0);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
  
using namespace std;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
int n;
ll a[N];
map <int,int> mp;
void solve(){
    cin >> n;
    ll x = 0;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
        x ^= a[i];
    }
    
    for(int i = 1; i <= n; ++i) {
        cout << (x ^ a[i]) << " ";        
    }


}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

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

using namespace std;

int triangle(int x){
  return x * (x+1) / 2;
}

int main(){
  int n;
  cin >> n;
  int max_number = 1;
  while (triangle(max_number) <= n) {
    ++max_number;
  }
  --max_number;
  int need = n - triangle(max_number);
  for(int i=1;i<=max_number;++i){
    if(i<=max_number-need)cout << i << endl;
    else cout << i + 1 << endl;
  }
}


Measured memory_bytes: 3628
N, M = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(M)]
s = [1] * N
a = [0] * N
a[0] = 1
for i in range(M):
    s[x[i][0] - 1] -= 1
    if a[x[i][0] - 1] == 1:
        a[x[i][1] - 1] = 1
        if s[x[i][0] - 1] == 0:
            a[x[i][0] - 1] = 0
    s[x[i][1] - 1] += 1


print(sum(a))

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

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

  int n = s.size();
  int ans = INT_MAX;
  for(int i = 0;i < n-2;i++){
    ans = min(ans, abs(753-((s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0'))));
  }

  cout << ans << endl;

  return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
int n,m=0;
string a,b,c;
cin>>n>>a>>b>>c;
for(int i=0;i<n;i++){
  if(a[i]!=b[i]&&b[i]!=c[i]&&c[i]!=a[i]) m+=2;
  else if(a[i]==b[i]&&b[i]==c[i]) ;
  else m++;
}
cout<<m;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int n, a[100], i, j, count = 0, v;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int min;
	for (i = 0; i < n; i++)
	{
		min = i;
		for (j = i + 1 ; j < n; j++)
		{
			if (a[j] < a[min])min = j;
		}
		if (i != min)
		{
			v = a[i];
			a[i] = a[min];
			a[min] = v;
			count++;
		}
	}
	for (i = 0; i < n; i++)
	{
		if (i)cout << " ";
		cout << a[i];
	}
	cout << endl << count << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
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 btoc[100005];
ll atob[100005];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N ;cin >> N ;
  vector<ll> A,B,C;
  rep(i,N){
    ll inp; cin >> inp;
    A.pb(inp);
  }
  rep(i,N){
    ll inp; cin >> inp;
    B.pb(inp);
  }
  rep(i,N){
    ll inp; cin >> inp;
    C.pb(inp);
  }

  sort(all(A));
  sort(all(B));
  sort(all(C));


  rep(i,B.size())
    btoc[i] = C.size()-(upper_bound(all(C),B[i])-C.begin());

  ll now = 0;
  for(ll i = B.size()-1; i >= 0; i--){
    btoc[i] += now;
    now = btoc[i];
  }


  ll ans = 0;
  rep(i,A.size()){
    ll ind = (upper_bound(all(B), A[i]) - B.begin());
    ans += btoc[ind];
  }
  cout << ans << endl;
  
    
  
  
    
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7
 
int sm[200002];
int tt[200002];
int s[100002],t[100002],c[100002];

int main(){
  int n,C;
  cin>>n>>C;
  REP(i,n)cin>>s[i]>>t[i]>>c[i];

  rep(i,1,C+1){
    REP(j,200002)tt[j]=0;
    REP(j,n)if(c[j]==i)tt[s[j]*2-1]++, tt[t[j]*2]--;
    rep(j,1,200002)tt[j]+=tt[j-1];
    REP(j,200002)if(tt[j]>0)sm[j]++;
  }
  int mx=0;
  REP(j,200002)if(mx<sm[j])mx=sm[j];
  print(mx);
}

Measured memory_bytes: 2944
#include <iostream>
using namespace std;
int n,i,j,a[51],sum;
int main()
{
    cin>>n;
    for (i=1;i<=n;++i)
        cin>>a[i];
    for (i=1;i<=n;++i)
    {
        for (j=i+1;j<=n;++j)
             sum+=a[i]*a[j];
    }
    cout<<sum;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i <= k;++i)
#define repp(i,j,k) for(int i = j;i >= k;--i)
#define rept(i,x) for(int i = linkk[x];i;i = e[i].n)
#define P pair<int,int>
#define Pil pair<int,ll>
#define Pli pair<ll,int>
#define Pll pair<ll,ll>
#define pb push_back 
#define pc putchar
#define mp make_pair
#define file(k) memset(k,0,sizeof(k))
#define ll long long
int rd()
{
    int sum = 0;char c = getchar();bool flag = true;
    while(c < '0' || c > '9') {if(c == '-') flag = false;c = getchar();}
    while(c >= '0' && c <= '9') sum = sum * 10 + c - 48,c = getchar();
    if(flag) return sum;
    else return -sum;
}
int n,m;
int a[110];
int main()
{
    n = rd();m = rd();
    int cnt = 0,pos1,pos2;
    rep(i,1,m)
    {
        a[i] = rd();
        if(a[i]%2 == 1)
        {
            if(!cnt) cnt++,pos1 = i;
            else cnt++,pos2 = i;
        }
    }
    if(cnt > 2) printf("Impossible");
    else
    if(m == 1)
    {
        if(a[1] == 1) printf("%d\n1\n%d",a[1],a[1]);
        else printf("%d\n2\n1 %d\n",a[1],a[1]-1);
    }
    else
    {
        if(cnt>0) swap(a[1],a[pos1]);
        if(cnt>1) swap(a[m],a[pos2]);
        rep(i,1,m) printf("%d ",a[i]);printf("\n");
        a[1]++;a[m]--;
        if(a[m] == 0) m--;
        printf("%d\n",m);
        rep(i,1,m) printf("%d ",a[i]);
    }
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())

#print(N,M)

num=[]
answer=[]
correct=[False] * (N+1)
correctCount = 0
wrongCount = 0
wrong=[0] * (N+1)
for k in range(M):
    n,a=input().split()
    num.append(int(n))
    answer.append(a)
    if a == "AC":
        if correct[int(n)] == False:
            correct[int(n)] = True
            correctCount += 1
            wrongCount += wrong[int(n)]
    else:
        if correct[int(n)] == False:
            wrong[int(n)] += 1



    
#print(num)
#print(answer)
    
'''
preCorrect = False
correctCount=0
wrongCount = 0
temp_wrongCount = 0


for i in range(M):
    if i > 0 and num[i] != num[i-1]:
        if preCorrect == True:
            preCorrect = False
            temp_wrongCount = 0
        else:
            temp_wrongCount = 0
    
    
    if preCorrect == True:
        continue

    if answer[i] == "AC":
        correctCount += 1
        preCorrect = True
        wrongCount += temp_wrongCount
    if answer[i] == "WA":
        temp_wrongCount += 1
'''
print(correctCount, wrongCount)
    



Measured memory_bytes: 14912
#include <iostream>
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n, m, sum=0;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x;
        cin>>x;
        sum+=x;
    }
    if(sum>n){
        cout<<"-1";
    }
    else{
        cout<<n-sum;
    }
    return 0;
}

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

using namespace std;

int N;
vector<int> G[100005];

int dfs(int v, int prev)
{
	if(prev != -1 && G[v].size() == 1) return 1;
	
	int ret = 0;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == prev) continue;
		ret += dfs(G[v][i], v);
	}
	if(prev == -1) ret -= (int)G[v].size() / 2;
	else ret -= ((int)G[v].size() - 2) / 2;
	return ret;
}

int dfs2(int v, int prev, int bound)
{
	if(bound <= 0) return -1;
	if(prev != -1 && G[v].size() == 1) return 1;
	
	vector<int> vec;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == prev) continue;
		int res = dfs2(G[v][i], v, bound);
		if(res < 0) return -1;
		vec.push_back(res);
	}
	sort(vec.begin(), vec.end());
	
	if(prev == -1){
		int l = 0, r = vec.size()-1;
		bool flag = false;
		while(1){
			if(l >= r) return 1;
			if(vec[l] + vec[r] > bound) break;;
			l++, r--;
		}
	}
	else{
		if(G[v].size() % 2) vec.insert(vec.begin(), 0);
		for(int i = 0; i < vec.size(); i++){
			if(vec[i] + 1 > bound) continue;
			int l = 0, r = vec.size()-1;
			bool flag = false;
			while(1){
				if(l == i) l++;
				if(r == i) r--;
				if(l >= r) return vec[i] + 1;
				if(vec[l] + vec[r] > bound) break;
				l++, r--;
			}
		}
	}
	return -1;
}

int main(void)
{
	cin >> N;
	int a, b;
	for(int i = 1; i <= N-1; i++){
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	int ansA, ansB;
	ansA = dfs(1, -1);
	
	int lb = 0, ub = N, mid;
	while(ub - lb > 1){
		mid = (ub + lb) / 2;
		if(dfs2(1, -1, mid) >= 0) ub = mid;
		else lb = mid;
	}
	ansB = ub;
	
	cout << ansA << " " << ansB << endl;
	return 0;
}

Measured memory_bytes: 16384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll sum[3][30];

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, c, d[500][500], cc[500][500];
  cin >>  n >> c;
  for(int i = 0; i < c; i++) for(int j = 0; j < c; j++) cin >> d[i][j];
  for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin >> cc[i][j], cc[i][j]--;
  ll ans = 1e18;
  for(int k = 0; k < 30; k++) 
  for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) {
    int t = (i + j) % 3;
    sum[t][k] += d[cc[i][j]][k];
  }
  for(int i = 0; i < c; i++) for(int j = 0; j < c; j++) for(int k = 0; k < c; k++) {
    if(i == j) continue;
    if(k == j) continue;
    if(i == k) continue;
    ll res = 
    sum[0][i]+
    sum[1][j]+
    sum[2][k];
    ans = min(ans, res);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1000000007;

signed main(){
    string S;
    cin >> S;
    
    int N = S.length();
    
    string S1 = S.substr(0,(N-1)/2), s1 = S1;
    string S2 = S.substr((N+3)/2-1,N), s2 = S2;
    string re = S;
    reverse(re.begin(),re.end());
    reverse(s1.begin(),s1.end());
    reverse(s2.begin(),s2.end());
    if(S == re && S1 == s1 && S2 == s2) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}



Measured memory_bytes: 256
// ~maqsat~

// #pragma GCC target ("avx2")
// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")

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

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)
#define ever ;;

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 5e5 + 123;
const ll MOD = 1e9 + 7;
const ll INF = 1e15 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
#ifdef ziel
	freopen("input.in", "r", stdin);
#else
	fre("");
#endif
	ACCELERATE;

	int n;
	cin >> n;

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

	ll c, d;
	cin >> c >> d;

	ll delta = abs(a - b);

	for (int i = 0; i < n; i++) {
		ll a1 = i * c, a2 = i * d;
		ll b1 = -(n - 1 - i) * d, b2 = -(n - 1 - i) * c;

		if (a1 + b1 <= delta && delta <= a2 + b2) return !(cout << "YES");
	}
	cout << "NO";

	return 0;
}
/*
 
*/


Measured memory_bytes: 256
N = gets.to_i
answer = 0

if 1 <= N && N < 10 then
    answer = N  
elsif 10 <= N && N < 10**2 then
    answer = 9
elsif 100 <= N && N < 10**3 then
    answer = 9 + (N - 100 + 1)
elsif 10**3 <= N && N < 10**4 then
    answer = 9 + 900
elsif 10**4 <= N && N < 10**5 then
    answer = 9 + 900 + (N - 10000 + 1)
elsif N == 10**5 then
    answer = 9 + 900 + 90000
end

puts answer

Measured memory_bytes: 1788
n = int(raw_input())
a = sorted(map(int, raw_input().split()))

x = []
if n % 2 == 0:
    for i in range(1, n, 2):
        x.extend([i, i])
else:
    x.append(0)
    for i in range(2, n, 2):
        x.extend([i, i])

if a == x:
    if n % 2 == 0:
        print (2 ** (n/2)) % (10 ** 9 + 7)
    else:
        print (2 ** ((n-1)/2)) % (10 ** 9 + 7)
else:
    print 0

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

#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
 
const int Maxn = 1e5 + 10;
const ll Inf = LONG_LONG_MAX >> 2;
const int Log = 20;

int a[Maxn];
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	ll ans = Inf, res;
	for(int i = -100; i <= 100; i++){
		res = 0;
		for(int j = 1; j <= n; j++) res += ((i - a[j]) * (i - a[j]));
		ans = min(ans, res);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    int N;
    ll K;
    cin >> N >> K;
    int P[N];
    ll C[N];
    for (int i = 0; i < N; i++) {
        cin >> P[i];
        P[i]--;
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }

    ll ans = -100000000000000;

    for (int i = 0; i < N; i++) {
        vector<ll> v;
        int p = P[i];
        ll c_sum = C[p];
        ll cnt = 1;
        ans = max(ans, c_sum);
        while (true) {
            p = P[p];
            if (P[i] == p) break;
            cnt++;
            if (cnt > K) break;
            c_sum += C[p];
            ans = max(ans, c_sum);
        }
        ll sum = 0;
        p = P[i];
        if (cnt > K) continue;
        ans = max(ans, c_sum * (K / cnt));
        for (int i = 0; i < cnt; i++) {
            sum += C[p];
            p = P[p];
            ans = max(ans, sum + c_sum * ((K - i - 1)/ cnt));
        }
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3696
#include<iostream>   //AA06( 21/ 06/ 20) If u see my code, Have a Good Day! (^_^)
#define JonSnow ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

using namespace std;

int main()
{
    JonSnow;

    char X;

    cin >> X;

    if(X >= 97 && X <= 122)
        cout << "a" << endl;

    else
        cout << "A" << endl;

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
 
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }
 
    void solve (){
        int n,k;
        cin>>n>>k;
        int total=0;
        for(int i=0;i<n;i++){
            int x;
            cin>>x;
            if(x>=k)
                total++;
        }
        cout<<total;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

Measured memory_bytes: 3612
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <cmath>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector< int > v(n);
    for( auto &i : v )
    {
        cin >> i;
    }
    int ans = 0;
    int cnt = 0;
    for( int i = 1; i < n; ++ i )
    {
        if( v[i] <= v[i - 1] )
            cnt ++;
        else
            cnt = 0;
        ans = max( ans, cnt );
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define ss second
#define ff first
#define INF 300000000000001
#define ll_max 9000000000000000001
#define mod 998244353
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 1000001;
const ll M = 1;

struct point {
    ll x, y;
};

ll fast_exp(ll x, ll n)
{
    if(n == 0) return 1;
    else if(n & 1)
        return fast_exp(x, n - 1) * x % mod;
    else
    {
        ll tmp = fast_exp(x, n >> 1);
        return tmp * tmp % mod;
    }
}

bool c(string s)
{
    ll n = s.size();
    for(int i = 0; i < n / 2; i++)
    {
        if(s[i] != s[n - i - 1]) return false;
    }
    return true;
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m = 0, ans = 0, x, y, k, v;
        string s, s1 = "", s2 = "", t;
        cin >> s;
        ans = c(s);
        n = s.size();
        s = '0' + s;
        s1 = s.substr(1, n / 2);
        s2 = s.substr((n + 3) / 2, n / 2);
        if(ans && c(s1) && c(s2)) cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}


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

int main()
{
    int i, j, k, n, s;
    char c[201], ca[201];

    while (1)
    {
        scanf("%s\n%d", c, &n);
        if (!strcmp(c, "-"))
            break;

        for (i = 0; i < n; i++)
        {
            scanf("%d", &s);
            for (j = s; c[j] != '\0'; j++)
                ca[j - s] = c[j];
            for (k = 0; k < s; k++)
                ca[j - s + k] = c[k];

            for (j = 0; c[j] != '\0'; j++)
                c[j] = ca[j];
        }

        printf("%s\n", c);
    }

    return 0;
}



Measured memory_bytes: 2064
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    String s = next();
    String t = next();

    String[] ss = splitString(s);
    String[] tt = splitString(t);

    int cnt = 0;

    for(int i=0;i<ss.length;i++){
      if(!ss[i].equals(tt[i])){
        cnt++;
      }
    }



    System.out.println(cnt);

  }

  static int lcm(int a,int b){
    return a*b*gcd(a,b);
  }

  static int gcd(int a,int b){
    if(a%b!=0){
      return gcd(b,a%b);
    }
    else{
      return b;
    }
  }

  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


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

	int i, ans = 0, x, y;
	char s[1000], t[1000];
	char end[] = "END_OF_TEXT";

	scanf("%s", s);
	for (i = 0; s[i] != '\0'; i++) {
		if ('A' <= s[i] && s[i] <= 'Z') {
			s[i] += 0x20;
		}
	}

	while (1) {
		scanf("%s", t);
		x = strcmp(end, t);
		if (x != 0) {
			for (i = 0; t[i] != '\0'; i++) {
				if ('A' <= t[i] && t[i] <= 'Z') {
					t[i] += 0x20;
				}
			}
			y = strcmp(s, t);
			if (y == 0) ans++;
		}
		else {
			printf("%d\n", ans);
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 2120
N = gets.strip.to_i
A = Array.new(N)
data = gets.split

i = 0
ma = 0
while i < N
  a = data[i].to_i
  if a > ma
    ma = a
  end
  A[i] = a
  i += 1
end

d = Array.new(ma+1)
e = Array.new(ma/2)
i = 0
while i < ma/2
  d[(i+1)*2] = 2
  e[i] = i * 2 + 3
  i += 1
end

mp = ma ** 0.5 + 1
p = 3

ii = 0
l = e.size
while p <= mp
  d[p] = p
  i = ii+1
  j = i
  while i < l
    x = e[i]
    if x % p == 0
      d[x] = p
    else
      e[j] = x
      j += 1
    end
    i += 1
  end
  l = j
  ii += 1
  p = e[ii]
end

i = ii
while i < l
  d[e[i]] = e[i]
  i += 1
end

pc = true
ip = Array.new(ma+1,-1)
c = Array.new(ma+1,0)
i = 0
mc = 0
sc = false
while (pc || mc == i) && i < N
  aa = A[i]
  while p = d[aa]
    if pc
      if ip[p] >= 0
        if ip[p] != i
          pc = false
        end
      end
      ip[p] = i
    end
    aa /= p while d[aa] == p
    if c[p] == i
      mc = c[p] = i+1
    end
  end
  i += 1
end

sc = mc != N


if pc
  puts "pairwise coprime"
elsif sc
  puts "setwise coprime"
else
  puts "not coprime"
end


Measured memory_bytes: 109964
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
B.sort()
sublist = []
for i in range(max(X-K-1, 0), X):
    for j in range(max(Y - K - 1, 0), Y):
        if (X-i)*(Y-j) <= K:
            sublist.append(A[i]+B[j])

sublist.sort()
# print(sublist)
subanslist = sublist[-K::1]
sbsize = len(subanslist)
anslist = []
C.sort()

for num, i in enumerate(subanslist):
    for j in range(max(Z - K - 1, 0), Z):
        if (sbsize-num)*(Z-j) <= K:
            anslist.append(i+C[j])

anslist.sort()
ans = anslist[:-K-1:-1]
print(*ans, sep="\n")


Measured memory_bytes: 5364
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		char[] s = scanner.next().toCharArray();
		int x = 0;
		int max = x;
		for (char c : s) {
			if ('I' == c) {
				x++;
				if (max < x) {
					max = x;
				}
			} else if ('D' == c) {
				x--;
			}
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 10192
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = scanner.nextInt(), K = scanner.nextInt();
        scanner.nextLine();
        int[][] points = new int[N][N];
        for (int i = 0; i < N; i++) {
            points[i] = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        }

        int[] xs = Arrays.stream(points).mapToInt(x -> x[0]).sorted().toArray();
        int[] ys = Arrays.stream(points).mapToInt(x -> x[1]).sorted().toArray();
        long ans = Long.MAX_VALUE;
        for (int xf = 0; xf < xs.length; xf++) {
            for (int xt = xf + 1; xt < xs.length; xt++) {
                for (int yf = 0; yf < ys.length; yf++) {
                    for (int yt = yf + 1; yt < ys.length; yt++) {
                        int cnt = 0;
                        for (int[] p: points) {
                            if (p[0] >= xs[xf] && p[0] <= xs[xt] && p[1] >= ys[yf] && p[1] <= ys[yt]) {
                                cnt++;
                            }
                        }
                        if (cnt >= K) {
                            ans = Math.min(ans, (xs[xt] - xs[xf]) * (long) (ys[yt] - ys[yf]));
                        }
                    }
                }
            }
        }
        System.out.println(ans);
    }

}

Measured memory_bytes: 29008
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

ll n, U, V;
vvl to;

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

    cin>>n>>U>>V; U--; V--;
    to = vvl(n);
    rep(i, n - 1) {
        ll v1, v2;
        cin>>v1>>v2; v1--; v2--;
        to[v1].push_back(v2);
        to[v2].push_back(v1);
    }
    vl du(n, -1), dv(n, -1);
    queue<LP> qu, qv;
    qu.push(LP(U, 0));
    qv.push(LP(V, 0));
    while (!qu.empty()) {
        LP p = qu.front(); qu.pop();
        ll v = p.fi;
        ll d = p.se;
        if (du[v] != -1) continue;

        du[v] = d;
        for (auto nv : to[v]) {
            qu.push(LP(nv, d + 1));
        }
    }
    while (!qv.empty()) {
        LP p = qv.front(); qv.pop();
        ll v = p.fi;
        ll d = p.se;
        if (dv[v] != -1) continue;

        dv[v] = d;
        for (auto nv : to[v]) {
            qv.push(LP(nv, d + 1));
        }
    }
    ll ans = 0;
    ll m = LINF;
    rep(i, n) {
        if (dv[i] < du[i]) continue;
        if (dv[i] == du[i]) {
            chmin(m, du[i]);
            continue;
        }
        chmax(ans, dv[i] - 1);
    }
    if (m != LINF) chmax(ans, m);
    cout<<ans<<endl;
}

Measured memory_bytes: 8448
/*                                 ___ _____ 
  ___  _ __ ___   ___  __ _  __ _ / _ \___  |
 / _ \| '_ ` _ \ / _ \/ _` |/ _` | | | | / / 
| (_) | | | | | |  __/ (_| | (_| | |_| |/ /  
 \___/|_| |_| |_|\___|\__, |\__,_|\___//_/   
                      |___/            
*/

//https://discord.com/channels/719165954013265971/719829947996176457/720322940771762188
// Getting better at it ! ! !
#include <bits/stdc++.h>
#include <string.h>
#define int long long
#define MAX (int)(1e7+5)
#define MAX2D (int)(1e3+5)
#define itn int
#define inf 5e18
#define MOD (int)(1e9 + 7)
#define pb push_back
#define mk make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define sitr set<int>::iterator
#define mitr map<int, int>::iterator
#define pii pair<int, int>
#define vii vector<pii>
#define vi vector<int>
#define vll vector<unsigned int>
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define fast                       \
    ios_base ::sync_with_stdio(0); \
    cin.tie(NULL);                 \
    cout.tie(NULL)
using namespace std;

// Given a string find the count of all the substrings which are divisible by a number k
// (k is coprime with 10).
// Idea : A substring is suffix[j]-suffix[i].
// eg. 32184718 -> 84 is a substring and it is actually .. 84718 - 718 = 84000.
// Here if the number x is divisible by k, then the number x*10, x*100, x*1000, ... are also
// divisible by k. Unless the number is a multiple of 2 or 5 i.e gcd(k,10) != 1 .. if gcd(k,10) != 1
// then the divisibility might get affected on how many 0s we add, eg. 3 is not divisible by 2 but 30 is.
// Hence for the method gcd(k,10) has to be 1.
// therefore if we have some suff[j]%k == x, and there is another value suff[i]%k == x then we can subtrct
// these 2 to get suff[i]-suff[j]%k = 0. so if we have g values such that suff[i]%k == x
// then the answer is gC2.

signed main()
{
    fast;
    string s;
    cin>>s;
    int k = 2019;
    map<int,int> mp;
    int power = 1, val = 0;
    int n = s.size();
    mp[0]++;
    int ans = 0;
    for(int i=n-1;i>=0;i--) {
        // here we calc suff .. 
        val = (val + ((s[i]-'0')*power))%k;
        power = (power*10)%k;
        mp[val]++;
    }
    for(auto i : mp) {
        int g = i.second;
        ans += (g*(g-1))/2;
        //cout<<g<<" ";         
    }
    cout<<ans;
    return 0;
}


/*
max factors number = 720720 --> 240 factors
max factors number = 1441440 -->288 factors

Beautiful program
Please run for me.
I've tried you in BASIC,
FORTRAN and C.
Beautiful program,
You've errors galore.
And each time I run you,
You're swapped out of core.
*/


Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int sx,sy,tx,ty;
signed main()
{
    sx=read(), sy=read(), tx=read(), ty=read();
    for(ri int i=1;i<=tx-sx;i++) putchar('R');
    for(ri int i=1;i<=ty-sy;i++) putchar('U');
    for(ri int i=1;i<=tx-sx;i++) putchar('L');
    for(ri int i=1;i<=ty-sy;i++) putchar('D');
    putchar('D');
    for(ri int i=1;i<=tx-sx+1;i++) putchar('R');
    for(ri int i=1;i<=ty-sy+1;i++) putchar('U');
    putchar('L');
    putchar('U');
    for(ri int i=1;i<=tx-sx+1;i++) putchar('L');
    for(ri int i=1;i<=ty-sy+1;i++) putchar('D');
    putchar('R');
    puts("");
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int N; cin>>N;
  vector<int>A(N);
  vector<long long>B(N);
  long long ans=0;
  rep(i,N){
    cin>>A[i];
    B[A[i]-1]++;
  }
  rep(i,N)ans+=B[i]*(B[i]-1)/2;
  rep(i,N)cout<<ans-B[A[i]-1]+1 <<endl;
}

Measured memory_bytes: 5612
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#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 all(x)  (x).begin(), (x).end()
#define MAX 10000
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b){
  ll large = max(a, b);
  ll small = min(a, b);
  ll r = large%small;
  if(r != 0){
    return gcd(small, r);
  }
  else{
    return small;
  }
}

ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  return a / g * b;
}

int main(){
  int n;  cin >> n;
  ll ans = 1ll;
  rep(i, 0, n){
    ll tmp;
    cin >> tmp;
    ans = lcm(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

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

    vector<vector<int> > v(n, vector<int>(3));

    for(int i = 0; i < n; ++i)
        for(int j = 0; j < 3; ++j)
            cin >> v[i][j];

    vector<vector<int> > dp(n, vector<int>(3));
    dp[0] = v[0];

    for(int i = 1; i < n; ++i) {
        for(int j = 0; j < 3; ++j) {
            for(int k = 0; k < 3; ++k) {
                if(j == k)
                    continue;
                dp[i][j] = max(dp[i][j], v[i][j] + dp[i - 1][k]);
            }
        }
    }

    cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}) << endl;

    return 0;
}


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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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;
}
///////////////////////////////////////////////
/*🍈( '-'  🍈*/

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

	bool ok = true;
	if (S[0] == S[1]) ok = false;
	if (S[1] == S[2]) ok = false;
	if (S[2] == S[3]) ok = false;
	if (ok) puts("Good");
	else puts("Bad");
	return 0;
}


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

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

int main() {
  ll n, maxd = -1, d;
  cin >> n;
  unordered_map<ll, ll> um;
  vector<int> dv(n);

  rep(i, n) {
    cin >> d;
    um[d]++;
    dv[i] = d;
    maxd = max(maxd, d);
  }

  ll ans;
  bool flg = true;
  for (int i = 0; i <= maxd; ++i)
    if (um[i] < 0) flg = false;
  if (um[0] != 1) flg = false;
  if (!flg) {
    cout << 0 << endl;
    return 0;
  } else {
    ans = 1;
    for (int i = 1; i < n; ++i) {
      ans *= um[dv[i] - 1];
      ans %= MOD;
    }
    cout << ans << endl;
    return 0;
  }
}

Measured memory_bytes: 4772
Scanf.scanf "%d" (fun n ->
    let a = Array.init n (fun _ ->
        Array.init n (fun _ -> Scanf.scanf " %d" (fun i -> i)))
    in
    let nei = Array.make n [] in
    for i = 0 to n - 1 do
        for j = i + 1 to n - 1 do
            let rec loop k =
                if k = n then true else
                    if k = i || k = j then loop (k + 1) else
                        if a.(i).(j) >= a.(i).(k) + a.(k).(j) then false else
                            loop (k + 1)
            in
            if loop 0 then (
                nei.(i) <- (j, a.(i).(j)) :: nei.(i);
                nei.(j) <- (i, a.(i).(j)) :: nei.(j)
            )
        done
    done;
    let mat = Array.make_matrix n n (max_int / 1000) in
    for i = 0 to n - 1 do mat.(i).(i) <- 0 done;
    Array.iteri (fun i l ->
        List.iter (fun (j, len) -> mat.(i).(j) <- len) l) nei;
    for k = 0 to n - 1 do
        for i = 0 to n - 1 do
            for j = 0 to n - 1 do
                mat.(i).(j) <- min mat.(i).(j) (mat.(i).(k) + mat.(k).(j));
            done
        done
    done;
    let rec loop_i i =
        let rec loop_j j =
            if j = n then true else
                if a.(i).(j) <> mat.(i).(j) then false else
                    loop_j (j + 1)
        in
        if i = n then true else
            if loop_j 0 then loop_i (i + 1) else false
    in
    Printf.printf "%d\n" @@ 
        if loop_i 0 then
            let len = Array.fold_left (List.fold_left (fun acc (_, len) -> acc + len)) 0 nei in
            len / 2
        else -1
)

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

using namespace std;

int main()
{
    string text;
    string pattern;

    cin >> text >> pattern;
    for (int i = 0; i < text.length(); i++)
    {
        int j = 0;
        for (j = 0; j < pattern.length(); j++)
        {
            if (pattern[j] != text[((i + j) % text.length())])
            {
                break;
            }
        }
        
        if (j == pattern.length())
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 3196
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	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;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n,  const Monoid &M1) :  M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	ll a, b, c, d, ans;
	cin >> a >> b >> c >> d;
	ans = b - a;
	ans -= b / c - a / c;
	ans -= b / d - a / d;
	ans += b / (c*d / gcd(c, d)) - a / (c*d / gcd(c, d));
	if (a%c != 0 && a%d != 0)
		ans++;
	cout << ans << endl;
}

Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var ab = ReadSplitInt();
            Println(Ceiling((ab[0] + ab[1]) / 2.0));
        }


        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n, a;
  cin >> n >> a;
  vector<int> x(n);
  rep(i, n) cin >> x[i];

  vector<vector<ll>> dp(n + 1, vector<ll>(50 * n + 1, 0));
  rep(i, n) {
    repr(j, i) {
      if (j == 0) dp[1][x[i]]++;
      else {
        repr(k, 50 * j) {
          dp[j + 1][k + x[i]] += dp[j][k];
        }
      }
    }
  }

  ll ans = 0;
  rep(i, n + 1) ans += dp[i][a * i];
  cout << ans << endl;






  
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(void){
  const long k=1e9;
  long s,x,y;
  cin >> s;
  x=(k-s%k)%k;
  y=(s+x)/k;
  cout << "0 0 1000000000 1 " << x << ' ' << y << endl;
  return 0;
}

Measured memory_bytes: 256