akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const int MAX_N = 100000;
int n;
ll a[MAX_N];

int main(){
  cin >> n;
  REP(i, n) cin >> a[i];
  ll ans = 0;
  bool carry = false;
  REP(i, n) {
    if(a[i] == 0) {
      carry = false;
    } else {
      ans += (a[i] + carry) / 2;
      carry = (a[i] + carry) % 2 == 1;
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, a[202020], b[202020], k[202020];
bool used[202020], used2[202020];
P p[202020];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> k[i] >> a[i] >> b[i];
		k[i]--;
		p[i] = P(abs(b[i]-a[i]), i);
	}
	sort(p, p+n, greater<P>());
	
	fill(used,used+n,0);
	fill(used2,used2+n,0);
	int l = 0, r = n-1;
	i64 cnt = 0;
	for(int i = 0; i < n; i++){
		int j = p[i].second;
		if(a[j] > b[j]){
			if(l > k[j]) cnt += b[j];
			else{
				cnt += a[j];
				int pos = k[j];
				while(used[pos]) pos--;
				used[pos] = 1;
				while(used[l]) l++;
			}
		}
		else{
			if(r <= k[j]) cnt += a[j];
			else{
				cnt += b[j];
				int pos = k[j]+1;
				while(used2[pos]) pos++;
				used2[pos] = 1;
				while(used2[r]) r--;
			}
		}
	}
	cout << cnt << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 9492
#include<vector>
#include <iostream>
#include<string>

using namespace std;
int main() {
    string a,b,c;
    cin>>a>>b>>c;
    if((a[a.size()-1]==b[0])&&(b[b.size()-1]==c[0])){
        cout<<"YES"<<endl;
      }else{
        cout<<"NO"<<endl;
    }
    
    
    
    
}

Measured memory_bytes: 256
N = int(input())
T = 1
A = 1
for i in range(N):
    ti, ai = map(int, input().split())
    if T <= A:
        if T % ti == 0:
            TT = T
        else:
            TT = ti - (T % ti) + T
        if A <= (TT // ti) * ai:
            T = TT
            A = (TT // ti) * ai
        else:
            if A % ai != 0:
                A = ai - (A % ai) + A
            T = (A // ai) * ti
    else:
        if A % ai == 0:
            AA = A
        else:
            AA = ai - (A % ai) + A
        if T <= (AA // ai) * ti:
            A = AA
            T = (AA // ai) * ti
        else:
            if T % ti != 0:
                T = ti - (T % ti) + T
            A = (T // ti) * ai
        
print(T+A)
        
    

Measured memory_bytes: 73220
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<time.h>
#include<vector>
#include<bitset>
#include<memory>
#include<utility>
#include<fstream>
#include<stdio.h>
#include<sstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
char c[1005][1005];
int flag=0;
void dfs(int n,int m,int a,int b)
{
    int i,j;
    if (n%2==1)
    {
        for (i=m%2;i+1<m;i+=2)
        {
            if (a<=0) break;
            c[n-1][i]='<';
            c[n-1][i+1]='>';
            a--;
        }
    }
    if (m%2==1)
    {
        for (i=0;i+1<n;i+=2)
        {
            if (b<=0) break;
            c[i][m-1]='^';
            c[i+1][m-1]='v';
            b--;
        }
    }
    
    {
        if ((a%2==1)&&(b%2==1)&&(n%2==1)&&(m%2==1)&&(n>1)&&(m>1))
        {
            c[n-3][0]='<';
            c[n-3][1]='>';
            c[n-2][0]='^';
            c[n-1][0]='v';
            a--;
            b--;
        }
        for (i=0;i+1<n;i+=2)
        {
            for (j=0;j+1<m;j+=2)
            {
                if (c[i][j]!='.') continue;
                if (a!=0)
                {
                    c[i][j]='<';
                    c[i][j+1]='>';
                    a--;
                    if (a!=0)
                    {
                        c[i+1][j]='<';
                        c[i+1][j+1]='>';
                        a--;
                    }
                }
                else
                {
                    if (b!=0)
                    {
                        c[i][j]='^';
                        c[i+1][j]='v';
                        b--;
                        if (b!=0)
                        {
                            c[i][j+1]='^';
                            c[i+1][j+1]='v';
                            b--;
                        }
                        if (b==0) return;
                    }
                }
            }
        }
        if ((a==0)&&(b==0)) return;
        puts("NO");
        flag=-1;
    }
}
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n,m,a,b;
    scanf("%d%d%d%d",&n,&m,&a,&b);
    memset(c,'.',sizeof(c));
    dfs(n,m,a,b);
    if (flag==-1) return 0;
    puts("YES");
    int i;
    for (i=0;i<n;i++)
    {
        c[i][m]='\0';
        printf("%s\n",c[i]);
    }
    return 0;
} 


Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

using Graph = vector<vector<ll>>;

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

#define MAX_N 2010

const long long INF = 1LL << 60;

//境界値に注意！！！

int main() {
    ll a,b,c,k,ans=0,m;
    cin >> a >> b >> c >> k;
    ans=a+b+c;
    m=max(max(a,b),max(b,c));
    ll m2=m;
    for (ll i=0;i<k;i++){
        m*=2;
    }
    m-=m2;
    ans+=m;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;
#define MAX_L 2005
pair<long long, long long> a[55]; 
int main() {
	int n, kk;
	long long ans = 9223372036854775807;
	cin >> n >> kk;
	for(int i = 1; i <= n; i++)
		cin >> a[i].first >> a[i].second;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			for(int k = 1; k <= n; k++)
				for(int l = 1; l <= n; l++) {
					long long xi = a[i].first, xj = a[j].first, yi = a[k].second, yj = a[l].second;
					if(xi < xj)
						swap(xi, xj);
					if(yi < yj)
						swap(yi, yj);
					int count = 0;
					for(int p = 1; p <= n; p++)
						if(a[p].first <= xi && a[p].first >= xj && a[p].second <= yi && a[p].second >= yj)
							count ++;
					if(count == kk)
						ans = min((xi - xj) * (yi - yj), ans);
				}	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import collections
from collections import deque
import numpy as np

N = int(input())
A = list(map(int, input().split()))

ca = collections.Counter(A)
cakeys = list(ca.keys())
cavalues = np.array(list(ca.values()))

#print(cakeys)
#print(np.array(list(ca.values())))

cavaluesmax = cavalues*(cavalues-1)//2
valuesum = np.sum(cavaluesmax)
#cavaluesmin = (cavalues-1)*(cavalues-2)//2


for a in A:
    #print(cakeys[index])
    v = ca[a]
    ans = valuesum - v + 1
    #ans = cavaluesmin[index].sum() + cavaluesmax[:index].sum() + cavaluesmax[index+1:].sum()
    print(ans)


Measured memory_bytes: 34152
#include<iostream>
#define ll long long int
using namespace std;
#include<math.h>
#include<bits/stdc++.h>
ll min(ll a,ll b)
{
  return a < b ? a : b;
}
int main()
{
  ll n,k;
  cin >> n >> k;
  ll a[n];
  for(ll i = 0;i < n;i++)
   	cin >> a[i];
  ll ans[n];
  ans[0] = 0;
  ans[1] = abs(a[0] - a[1]);
  for(int i = 2;i < n;i++)
  {
  	ans[i] = INT_MAX;
  	if(i <= k)
    {
        for(int j = 0;j < i;j++)
        {
            ans[i] = min(ans[i],abs(a[i] - a[j]) + ans[j]);
        }
    }
    else
    {
        for(int j = i - k;j < i;j++)
        {
            ans[i] = min(ans[i],abs(a[i] - a[j]) + ans[j]);
        }
    }
  }

cout << ans[n-1];

 	return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S; bool check = false;	vector<ll> v;



int main() {
	//Code Line
	cin >> n;
	for (int i = 1; i <= n; i++) {
		a = i * 1.08;
		if (a == n) { check = true; b = i; }
	}
	if (check)cout << b << endl;
	else cout << ":(" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
 int n,i,j,t,c=0;
 scanf("%d",&n);
 int l[n*2];
 for(i=0;i<n*2;i++){
  scanf("%d",&l[i]);
  for(j=i;j>0;j--){
   if(l[j]<l[j-1]){
    t=l[j];
    l[j]=l[j-1];
    l[j-1]=t;
   }
  }
 }
 for(i=0;i<n*2;i+=2){
  c+=l[i];
 }
 printf("%d",c);
 return 0;
}
 


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll INF=1000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}

//a,b x
int main(){
    ll N; cin>>N;
    vector<ll> x(N);
    vector<ll> y(N);
    vector<ll> h(N);
	rep(i,N) cin>>x[i]>>y[i]>>h[i];
    ll H;

    rep(cx,101)rep(cy,101){
        bool ans=true;
        rep(i,N){
            if(h[i]!=0){
                H=h[i]+abs(cx-x[i])+abs(cy-y[i]);
                break;
            }
        }
        rep(i,N){
            if(H-abs(x[i]-cx)-abs(y[i]-cy)<=0){
                if(h[i]!=0) ans=false;
            }
            else if(H-abs(x[i]-cx)-abs(y[i]-cy)!=h[i]) ans=false;
        }
        if(ans){
            printf("%lld %lld %lld",cx,cy,H);
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};


bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll Q,H,S,D,N,Q8,H4,S2,res=0;
  cin >> Q >> H >> S >> D >> N;
  N *= 4;
  Q8 = Q*8;
  H4 = H*4;
  S2 = S*2;
  vector<ll> v(0);
  v.push_back(Q8);
  v.push_back(H4);
  v.push_back(S2);
  v.push_back(D);
  sort(v.begin(),v.end());
  res += v[0]*(N/8);
  N %= 8;
  
  ll Q4 = Q*4;
  ll H2 = H*2;
  vector<ll> g(0);
  g.push_back(Q4);
  g.push_back(H2);
  g.push_back(S);
  sort(g.begin(),g.end());
  res += g[0]*(N/4);
  
  N %= 4;

  ll Q2 = Q*2;
  vector<ll> t(0);
  t.push_back(Q2);
  t.push_back(H);
  sort(t.begin(),t.end());
  res += t[0]*(N/2);
  N %= 2;

  res += Q*N;

  cout << res << endl;;
  
 
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


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

int n;
int map[100][100];

int pilehigh(int w){
  int i;
  for(i=0;i<n;i++)if(!map[w][i])break;
  return i;
}

void takeoff(int pickw ,int pickh){
  int i,j;

  for(i=n-1;i>pickh;i--){
    if(map[pickw][i]){
      for(j=0;j<n;j++){
	if(!map[j][0]){
	  map[j][0] = map[pickw][i];
	  map[pickw][i] = 0;
	  break;
	}
      }
    }
  }
}

void puton(int pickw,int pickh,int putw,int puth){
  map[putw][puth+1] = map[pickw][pickh];
  map[pickw][pickh] = 0;
}

void pileup(int pick , int put){
  int flag;
  int pickw,pickh;
  int putw,puth;

  if(pick == put)return;
    

  flag = 0;
  for(pickw=0;pickw<n;pickw++){
    for(pickh=0;pickh<n;pickh++){
      if(map[pickw][pickh] == pick){
	flag = 1;
	break;
      }
    }
    if(flag)break;
  }

  flag = 0;
  for(putw=0;putw<n;putw++){
    for(puth=0;puth<n;puth++){
      if(map[putw][puth] == put){
	flag = 1;
	break;
      }
    }
    if(flag)break;
  }

  if(put == 0){
    if(pickh == 0)return;
    else{
      takeoff(pickw,pickh-1);
      return;
    }
  }
 
  if(pickw == putw){
    if(pickh > puth)return;
    else{
      takeoff(pickw,pickh);
      flag = 0;
      for(putw=0;putw<n;putw++){
	for(puth=0;puth<n;puth++){
	  if(map[putw][puth] == put){
	    flag = 1;
	    break;
	  }
	}
	if(flag)break;
      }
      puton(pickw,pickh,putw,puth);
      return;
    }
  }else{
    takeoff(pickw,pickh);
    puton(pickw,pickh,putw,pilehigh(putw)-1);
    return;
  }
}

int main(void){
  int i,j;
  int pick,put;
  int high[100];
  int tmp,count;

  while(1){
    scanf(" %d ",&n);
    if(!n)break;
    
    for(i=0;i<n;i++)map[i][0] = i+1;
    for(i=0;i<n;i++){
      for(j=1;j<n;j++){
	map[i][j] = 0;
      }
    }

    while(1){
      scanf(" %d %d ",&pick,&put);
      if(!pick && !put)break;

      pileup(pick,put);
    }


    count = 0;
    for(i=0;i<n;i++){
      tmp = pilehigh(i);
      if(tmp){
	high[count] = tmp;
	count++;
      }
    }
    
    for(i=0;i<count;i++){
      for(j=i+1;j<count;j++){
	if(high[i] > high[j]){
	  tmp = high[i];
	  high[i] = high[j];
	  high[j] = tmp;
	}
      }
    }

    for(i=0;i<count;i++)printf("%d\n",high[i]);
    printf("end\n");
    
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>

using namespace std;

int main(){

	int A[10];
	int i;

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


	sort(A, A+10);

	cout << A[9] << endl;
	cout << A[8] << endl;
	cout << A[7] << endl;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

void solve() {
	int N;
	cin >> N;
	int res = 0;
	rep(i, 0, N) {
		int a; cin >> a;
		if(i % 2 == 0 && a % 2) res++;
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}




Measured memory_bytes: 3796
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
using namespace std;

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

	int n;
	cin >> n;
	vector<long> v(n);
	REP(i, n) cin >> v.at(i);
	long minv = v.at(0), maxv = -123456789012;
	FOR(i, 1, n) {
		maxv = max(maxv, v.at(i)-minv);
		minv = min(minv, v.at(i));
	}
	cout << maxv << endl;
}


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

const int mod = 1e9+7;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  vector<vector<int>> dp(h, vector<int>(w));
  dp[0][0] = 1;
  rep(i,h) rep(j,w) {
    if(i+1 < h && s[i+1][j] == '.') dp[i+1][j] += dp[i][j] % mod;
    if(j+1 < w && s[i][j+1] == '.') dp[i][j+1] += dp[i][j] % mod;
  }
  int ans = dp[h-1][w-1] % mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9452
n = int(input())

l = [0] * 5
for i in range(n):
    s = list(input())
    if s[0] == 'M':
        l[0] += 1
    elif s[0] == 'A':
        l[1] += 1
    elif s[0] == 'R':
        l[2] += 1
    elif s[0] == 'C':
        l[3] += 1
    elif s[0] == 'H':
        l[4] += 1

ans = 0
for i in range(3):
    for j in range(i + 1, 4):
        for k in range(j + 1, 5):
            ans += (l[i] * l[j] * l[k])

print(ans)

Measured memory_bytes: 9156
#include "bits/stdc++.h"

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>

void print(T x)
{
	std::cout << x << '\n';
}


int main() {
	int N,M;
	cin >> N>>M;
	vector<int>l, r;
	int xx, yy;
	
	rep(i, M) {
		cin >> xx>>yy;
		l.pb(xx);
		r.pb(yy);
	}
	
	std::vector<int>::iterator maxIt = std::max_element(l.begin(), l.end());
	std::vector<int>::iterator minIt = std::min_element(r.begin(), r.end());
	size_t minIndex = std::distance(r.begin(), minIt);
	size_t maxIndex = std::distance(l.begin(), maxIt);
	
	int ans = r[minIndex] - l[maxIndex]+1;
	if (ans < 0)print(0);
	else printf("%d", ans);
	
}

Measured memory_bytes: 1276
#include<iostream>
using namespace std;
#define int long long
signed main(){
  int n,k;
  cin>>n>>k;
  int w[n];
  for(int i=0;i<n;i++) cin>>w[i];
  int sum=0;
  for(int i=0;i<n;i++) sum+=w[i];
  int l=0,r=sum;
  while(l+1<r){
    int m=(l+r)/2;
    int t=0,tmp=0;
    bool f=0;
    for(int i=0;i<n;i++){
      f|=w[i]>m;
      if(tmp+w[i]>m){
	tmp=w[i];
	t++;
      }else tmp+=w[i];
    }
    if(tmp) t++;
    if(!f&&t<=k) r=m;
    else l=m;
  }
  cout<<r<<endl;
  return 0;
}


Measured memory_bytes: 3900
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);

    string s;
    cin >> s;
    if (s == "Sunny"){
        cout << "Cloudy" << endl;
    } else if (s == "Cloudy"){
        cout << "Rainy" << endl;
    } else {
        cout << "Sunny" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(m);   (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------

int main(void){
  ll N;cin>>N;
  ll A[N],aA[N];REP(i,N){cin>>A[i];aA[i]=A[i];}
  sort(ALL(A,N));
  ll nc[200001];REP(i,200001)nc[i]=0;
  ll ans=0;
  ll tmp=A[0];ll count=0;
  REP(i,N){
    if(tmp==A[i]){
      count++;
      if(i==N-1)goto label;
    }
    else{
      label:
      nc[A[i-1]]=count;
      if(count>=2){
        //cout<<"i:"<<i<<" ";
        ans+=count*(count-1)/2;
      }
      count=1;
      tmp=A[i];
    }
  }
  //cout<<ans<<"\n";
  REP(i,N){
    //cout<<"nc[aA[i]]:"<<nc[aA[i]]<<"\n";
    ll d=nc[aA[i]]*(nc[aA[i]]-1)/2-(nc[aA[i]]-2)*(nc[aA[i]]-1)/2;
    if(d<0)d=0;
    //cout<<d<<" ";
  	cout<<ans-d<<endl;
  }
  return 0;
}


Measured memory_bytes: 7424
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 510;
const int maxm = 210000;

int n,m;
struct edge{int x,y;}a[maxm];
bitset<maxn>S[maxn];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) scanf("%d%d",&a[i].x,&a[i].y);
	
	for(int i=1;i<=n;i++)
	{
		S[i][i]=1;
		for(int j=m;j>=1;j--)
		{
			int x=a[j].x,y=a[j].y;
			if(S[i][x]&&S[i][y]) { S[i].set(); break; }
			if(!S[i][x]&&!S[i][y]) continue;
			if(S[i][x]) S[i][y]=1;
			else S[i][x]=1;
		}
	}
	
	int ans=0;
	for(int i=1;i<n;i++) for(int j=i+1;j<=n;j++) if((S[i]&S[j]).count()==0)
		ans++;
	printf("%d\n",ans);
	
	return 0;
}


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

int solve(int *arr,int n,int *dp)
{
if(n <0) return INT_MAX;
if(n==1) return arr[0];
if(n==2) return abs(arr[1]-arr[0]);
if(n==3) 
{
    int f=abs(arr[0]-arr[1])+abs(arr[1]-arr[2]);
    int s=abs(arr[0]-arr[2]);
    return min(f,s);
}
if(dp[n]==-1)
{
int first=abs(arr[n-1]-arr[n-2])+solve(arr,n-1,dp);
int second=abs(arr[n-1]-arr[n-3])+solve(arr,n-2,dp);

dp[n]= min(first,second);
}
return dp[n];

}

int main()
{
    int n; cin>>n;
    int arr[n];
    int dp[n+1];
    for(int i=0;i<=n;i++) dp[i]=-1;
    for(int i=0;i<n;i++) cin>>arr[i];

    int ans=solve(arr,n,dp);
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 8832
import java.util.*;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		int q = sc.nextInt();
		int r = sc.nextInt();

		int time[] = new int[3];
		time[0] = p + q;
		time[1] = r + q;
		time[2] = p + r;

		Arrays.sort(time);

		System.out.println(time[0]);
	}
}


Measured memory_bytes: 21204
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

A, B, H, M = parseMap(split(readline()))


h = 30H + 0.5M

m = 6M

r = abs(h - m)
ans = sqrt(A^2 + B^2 - (2 * A * B * cosd(r)))

println(ans)

Measured memory_bytes: 199580
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;


const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


// mod. m での a の逆元 a^{-1} を計算する
ll modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}



map<ll, ll> prime_factors(ll n) {
  map<ll, ll> res;
  if (n == 1) { // n=1 の素因数分解は n^1
    res[n] = 1;
    return res;
  }
  for (ll i = 2, _n = n; i * i <= _n; ++i) {
    while (n % i == 0) {
      ++res[i]; // 素数i^{res[i]}
      n /= i;
    }
  }
  if (n != 1) res[n] = 1;
  return res;
}



int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  cin >> a;

  vector<vector<bool>> bit(n, vector<bool>(21, false));

  for (int i = 0; i < n; i++) {

    for (int j = 0; j < 20; j++) {
      if (a[i] & (1 << j) ) {
        bit[i][j] = true;
      }
    }
  }


  ll ans = 0;


  //しゃくとり法
  int front = 0;
  int back = 0;
  vector<ll> tmp(20, 0);

  for (int i = 0; i < n; i++) {



    bool conflict = false;
    front = i;
    for (int j = 0; j < 20; j++) {
      if (bit[i][j] == true) {
        tmp[j]++;
      }
    }

    for (int j = 0; j < 20; j++) {
      if (tmp[j] >= 2)conflict = true;
    }

    // for (int i = 0; i < 5; i++) {
    //   cerr << tmp[i] << ",";
    // } cerr << endl;


    if (conflict == true) {
      for (int k = back; k < front; k++) {
        back = k + 1;
        for (int j = 0; j < 20; j++) {
          if (bit[k][j] == true) {
            tmp[j]--;
          }
        }

        conflict = false;
        for (int j = 0; j < 20; j++) {
          if (tmp[j] >= 2)conflict = true;
        }
        if (conflict == false)break;
        
      }
    }

    // for (int i = 0; i < 5; i++) {
    //   cerr << tmp[i] << ",";
    // } cerr << endl;
    //追加
    ans += front - back + 1;
    // cerr << front << " front - back " << back << endl;
  }



  cout << ans << endl;
}




















Measured memory_bytes: 15872
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Map.Entry;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int[] a = new int[n];
			HashSet<String> set = new HashSet<String>();
			int count = 0;
			for (int i = 0; i < n; i++) {
				int rate = in.nextInt();
				if (rate <= 399) {
					set.add("灰");
				} else if (rate <= 799) {
					set.add("茶");
				} else if (rate <= 1199) {
					set.add("緑");
				} else if (rate <= 1599) {
					set.add("水");
				} else if (rate <= 1999) {
					set.add("青");
				} else if (rate <= 2399) {
					set.add("黄");
				} else if (rate <= 2799) {
					set.add("橙");
				} else if (rate <= 3199) {
					set.add("赤");
				} else {
					count++;
				}
			}
			if (set.size() + count > 12) {
				out.println(set.size() + " " + (set.size() + count));
			} else {
				if (set.size() == 0) {
					out.println(1 + " " + (set.size() + count));
				} else {
					out.println(set.size() + " " + (set.size() + count));
				}

			}
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

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

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

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

	}
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-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;
}

int main(){
    ll n,m;cin >> n >>m;
    vvl g(n);
    rep(i,m){
        ll x,y;cin >> x >> y;x--;y--;
        g[x].pb(y);
        g[y].pb(x);
    }
    set<ll> use;
    use.ins(0);use.ins(g[0][0]);
    deque<ll> que;
    que.pb(0);que.pb(g[0][0]);
    while(true){
        //cout << que.size() <<endl;
        bool fir=true;
        bool las=true;
        for(auto p:g[que.front()]){
            if(!use.count(p))fir=false;
        }
        for(auto p:g[que.back()]){
            if(!use.count(p))las=false;
        }
        if(fir&&las)break;
        if(!las){
            for(auto p:g[que.back()]){
                if(!use.count(p)){
                    que.pb(p);
                    use.ins(p);
                    break;
                }
            }
            continue;
        }
        if(!fir){
            for(auto p:g[que.front()]){
                if(!use.count(p)){
                    que.push_front(p);
                    use.ins(p);
                    break;
                }
            }
            continue;
        }
    }
    cout << que.size() <<endl;
    while(!que.empty()){
        cout << que.front()+1 <<" ";
        que.pop_front();
    }
    cout << endl;
}

Measured memory_bytes: 11904
def stl1(x):
    if a == e:
        y = b
    else:
        y = (f-b)*(x-a)/(e-a) +b

    return(y)

def stl2(x):
    if c == e:
        y = f
    else:
        y = (d-f)*(x-e)/(c-e) +f

    return(y)

def stl3(x):
    if c == a:
        y = b
    else:
        y = (d-b)*(x-a)/(c-a) +b
        
    return(y)

while True:
    try:
        lst = list(map(float, input().split()))
        point1 = [lst[0], lst[1]]
        point2 = [lst[2], lst[3]]
        point3 = [lst[4], lst[5]]
        xp, yp = lst[6], lst[7]

        pointlst = [point1, point2, point3]
        pointlst.sort()
        a, b, e, f, c, d = pointlst[0][0], pointlst[0][1], pointlst[1][0], pointlst[1][1], pointlst[2][0], pointlst[2][1]

        if a <= xp and xp <= e:
            bdr1 = stl1(xp)
            bdr3 = stl3(xp)

            if min(bdr1, bdr3) <= yp and yp <= max(bdr1, bdr3):
                print("YES")

            else:
                print("NO")
        
        elif e < xp and xp <= c:
            bdr2 = stl2(xp)
            bdr3 = stl3(xp)

            if min(bdr2, bdr3) <= yp and yp <= max(bdr2, bdr3):
                print("YES")
            
            else:
                print("NO")

        else:
            print("NO")

    except EOFError:
        break


Measured memory_bytes: 5592
#include<stdio.h>
 
long max(long a,long b){
	if(a>b){
    	return a;
    }else{
    	return b;
    }
}
 
long min(long a,long b){
	if(a<b){
    	return a;
    }else{
    	return b;
    }
}
 
int f(long a,long b){
  long c=max(a,b);
  int keta=1;
  for(int i=0;i<10;i++){
  	if(c/10>0){
    	keta++;
      	c/=10;
    }
  }
  return keta;
}
 
 
 
int main(void){
  
  long N;
  int minnum=11;
  scanf("%ld",&N);
  
  for(long a=1;a*a<=N;a++){
    long b=0;
  	if(N%a == 0){
      b=N/a;
      int res=f(a,b);
      minnum=min(res,minnum);
    }
  }
  
  printf("%ld",minnum);
  
 
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i< (n); i++)
using namespace std;
 
int main() {
  int N, count, next;
  cin >> N;
  
  vector<int> a(N);
  //vector<int> count(N + 1, 0);
  
  for (int i = 0; i<N; i++){
  	cin>>a[i];
  }
  
  next = a[0];
  for(int i = 0; i<N; i++){
    count++;
  	if (next == 2){
      cout<<count<<endl;
      break;
    }
    else{
      next = a[next - 1];
    }
    
    if (count == N){
    	cout<<-1<<endl;
    }
  }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fl(i, a, b) for(int i = a; i < b; i++)
#define rfl(i, a, b) for(int i = a; i > b; i--)
#define fll(i, a, b) for(ll i = a; i < b; i++)
#define rfll(i, a, b) for(ll i = a; i > b; i--)
#define geta(A, n) fl(i, 0, n) cin >> A[i]
#define pb push_back
#define ff first
#define ss second
#define maxv(a, b) *max_element(a, b)
#define minv(a, b) *min_element(a, b)
#define sortv(v) sort(v.begin(), v.end())
#define getv(vp, n) fl(i, 0, n) {int x; cin >> x; vp.pb(x)}
#define fastaf ios::sync_with_stdio(false), cin.tie(0) , cout.tie(0)
#define cases() ll t; cin >> t; while (t--)
const ll mod = 1e9+7;
const ll MOD = 1e18+7;
int main() {
        int n;
        cin >> n;
        int h[n + 1], dp[n + 1];
        fl(i, 1, n + 1){
                cin >> h[i];
                dp[i] = 0;
        }
        dp[n - 1] = abs(h[n] - h[n - 1]);
        rfl(i, n - 2, 0) dp[i] = min(abs(h[i] - h[i + 1]) + dp[i + 1], abs(h[i] - h[i + 2]) + dp[i + 2]);
        cout << dp[1];
        return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
using ll = long long;

const int MOD = 1e9 + 7;

ll fpow(ll a, int b) {
	ll ret = 1;
	while (b) {
		if (b & 1) {
			ret = (ret * a) % MOD;
		}
		a = (a * a) % MOD;
		b /= 2;
	}
	return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    ll ans = fpow(10, n) - fpow(9, n) + MOD;
    ans = (ans - fpow(9, n) + MOD) % MOD;
    ans = (ans + fpow(8, n)) % MOD;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3608
a,b,c=map(int,input().split())
k=int(input())

for ai in range(k):
  for bi in range(k):
    if ai + bi > k:
      continue
    ci = k - (ai+bi)
    tmpa = a * (2 ** ai)
    tmpb = b * (2 ** bi)
    tmpc = c * (2 ** ci)
    if tmpa < tmpb and tmpb < tmpc:
      print('Yes')
      exit(0)
print('No')

Measured memory_bytes: 9184
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll N;
	cin >> N;

	vector<ll> X(N);
	for (ll i = 0; i < N; ++i) cin >> X[i];

	ll min_x = INF;
	ll max_x = -INF;
	for (const auto x : X)
	{
		min_x = min(min_x, x);
		max_x = max(max_x, x);
	}

	ll ans = min_x;
	ll min_cost = INF;
	for (ll p = min_x; p <= max_x; ++p)
	{
		ll cost = 0;
		for (const auto x : X)
		{
			cost += pow(x - p, 2);
		}

		if (cost <= min_cost)
		{
			min_cost = cost;
			ans = p;
		}
	}

	cout << min_cost << endl;

	//system("pause");
}


Measured memory_bytes: 256
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] strs = str.split(" ");
        int a = Integer.parseInt(strs[0]);
        int b = Integer.parseInt(strs[1]);
        int c = Integer.parseInt(strs[2]);
        int[] ans = {a, b, c};
        for(int i = 0; i < ans.length; i++){
            for(int x = i; x < ans.length; x++){
                if(ans[x] < ans[i]){
                    int w = ans[x];
                    ans[x] = ans[i];
                    ans[i] = w;
                }//if
            }//for
        }//for
        System.out.println(ans[0] + " " + ans[1] + " " + ans[2]);
        br.close();
    }
}

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

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

int s[maxn];

void solve(){
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",s+i);
    }
    int cnt = 0;
    for(int i=1;i<=n;i++){
        if(s[i] >= k) ++cnt;
    }
    printf("%d\n",cnt );
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
   // freopen("in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
   // printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

Measured memory_bytes: 640
import java.io.*;

class Main
{
	public static void main (String[] args) throws IOException
	{
		int x;
		String xx; 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		xx = br.readLine();
		x = Integer.parseInt(xx);
		System.out.println(x * x * x);
	}
}

Measured memory_bytes: 17000
#include <iostream>
using namespace std;
#define INF 1000000
int p[1000];
int d[100];
int n,m;
class edge{
    public:
    int from,to,cost;
};
edge e[1000];

void blf(int s){
    for(int i=0;i<n;i++)d[i]=INF;
    d[s]=0;
    int l[n];
    for(int i=0;i<n;i++)l[i]=-1;
    while(1){
        bool update=false;
        for(int i=0;i<m;i++){
            if(d[e[i].from]<INF&&d[e[i].from]+e[i].cost<d[e[i].to]){
                d[e[i].to]=d[e[i].from]+e[i].cost;
                l[e[i].to]=i;
                update=true;
            }
            if(d[e[i].to]<INF&&d[e[i].to]+e[i].cost<d[e[i].from]){
                d[e[i].from]=d[e[i].to]+e[i].cost;
                l[e[i].from]=i;
                update=true;
            }
        }
        if(update==false)break;
    }
    for(int i=0;i<n;i++){
        if(l[i]>=0)p[l[i]]=1;
    }
    
}
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>e[i].from>>e[i].to>>e[i].cost;
        e[i].from--;
        e[i].to--;
    }
    for(int i=0;i<n;i++){
        blf(i);
    }
    int ans=0;
    for(int i=0;i<m;i++){
        if(p[i]==0)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
n = gets.chop.to_i
p = gets.split(" ").join.to_i
q = gets.split(" ").join.to_i

a = 0
b = 0

arr = [*1..n]
list = arr.permutation(n).map {|v| v.join.to_i}

list.each_with_index do |v, i|
  a = i+1 if v == p
  b = i+1 if v == q
end

res = 0
if a > b
  res = a - b
else
  res = b - a
end

puts res

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

using namespace std;

typedef long long ll;

int n;
int k;

vector<int> a;

int dp[5010][5010];


bool c(int num)
{
	for(int i = 0;i < 5010;i++)
	{
		for(int j = 0;j < 5010;j++)
		{
			dp[i][j] = 0;
		}
	}

	dp[0][0] = 1;

	
	for(int i = 1;i <= n;i++)
	{
		for(int j = 0;j <= k;j++)
		{
			dp[i][j] = dp[i - 1][j];
			if(j - a[i] >= 0 && i != num)
			{
				dp[i][j] = max(dp[i][j],dp[i - 1][j - a[i]]);

			}
			//cout << i << " " << j << "=" << dp[i][j] << endl;
			
			if(dp[i][j] == 1 && k - a[num] <= j && j < k)
			{
				return true;
			}
		}
	}
	return false;
}

int binary()
{
	int ng = 0,ok = n + 1;

	while(abs(ng - ok) > 1)
	{
		int mid = (ng + ok) / 2;

		if(c(mid))
		{
			ok = mid;
		}
		else
		{
			ng = mid;
		}
	}

	return ng;
}

int main()
{
	cin >> n >> k;
	a.resize(n + 1);
	for(int i = 1;i <= n;i++)
	{
		cin >> a[i];
	}

	sort(a.begin(),a.end());
	cout << binary() << endl;
	return 0;
}




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

typedef long long int ll;
using ii= pair<ll,ll>;
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define all(o) (o).begin(),(o).end()
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ld long double
#define eps 0.00000000001
#define mod 1000000007

class prioritize{
    public: bool operator() (ii &p1,ii &p2){
        return p1.F<p2.F;
    }
};

ll fact[2020];

ll powerm(ll a,ll b,ll m)
{
	ll ans= 1;
	while(b){

		if(b&1) ans= (ans*a+m)%m;
		a= (a*a+m)%m;
		b>>=1;
	}
	return ans;
}

ll invmod(ll a, ll m){
  //Calculates (1/a)%m,a&m coprime
    return (powerm(a,m-2,m)+m)%m;
}

void fact_mod(ll n,ll m)
{
	//stores fact[i]%m till n
    //declare a global array fact first
    // m-> prime modulo,if nothing given
	// take m= 1e9+7
    fact[0]= 1;
    fr(i,1,n+1){
    	fact[i]= (i*fact[i-1])%m;
    }
}


ll nCr(ll n,ll r,ll m)
{
	// call (powerm,invmod,fact_mod) in template
	// m-> prime modulo,if nothing given
	// take m= 1e9+7
	fact_mod(n,m);
	ll denom= (fact[r]*fact[n-r]+ m)%m;
	denom= invmod(denom,m);
	return (fact[n]*denom+ m)%m;
}

auto start_time= high_resolution_clock::now();
void time()
{
    #ifndef ONLINE_JUDGE
        auto stop_time= high_resolution_clock::now();
        auto duration= duration_cast<milliseconds>(stop_time-start_time);
        cout<<"run time: "<<duration.count()<<" ms"<<"\n";
    #endif
    return;
}


int main()
{
    
    #ifndef ONLINE_JUDGE
        freopen("input1.txt","r", stdin);
        freopen("output1.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);


    ll n;
    cin>>n;
    
    if(n==3){
    	cout<<1<<"\n";
    	return 0;
    }

    ll ans=0;



    for(ll i=1;(n-1-2*i)>0;i++)
    {
    	if((n-1-2*i)<(i-1)) break;
    	ans= (ans+ nCr((n-1-2*i),i-1,mod)+ mod)%mod;
    }

    cout<<ans<<"\n";

    time();
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int
#define nl endl
using namespace std;

void code()
{       
    int n;
    cin>>n;
    cout<<n+(n*n)+(n*n*n);
    
}
signed main()

{

#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
        
        FAST_IO;
        int t = 1;

        // cin>>t;

        while(t--)
        {
                code();
        }
        

#ifndef ONLINE_JUDGE
cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#endif

        return 0;
}


Measured memory_bytes: 3640
// D - FT Robot

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

bool dp1[4000][20000];
bool dp2[4000][20000];

int main() {
	string s;
	int x_goal, y_goal;
	cin >> s >> x_goal >> y_goal;

	vector<int> x;
	vector<int> y;
	bool dir = 0;
	int d = 0;
	for (int i=0; i<s.size(); i++) {
		if (s[i] == 'F') d++;

		if (s[i] == 'T' || i == s.size() - 1) {
			if (dir == 0) {
				//if (d > 0) x.push_back(d);
				x.push_back(d);
				dir = 1;
			} else {
				//if (d > 0) y.push_back(d);
				y.push_back(d);
				dir = 0;
			}
			d = 0;
		}
	}

	dp1[0][10000] = true;
	for (int i=0; i<x.size(); i++) {
		for (int j=0; j < 20000; j++) {
			if (dp1[i][j] == false) continue;

			dp1[i+1][j + x[i]] = true;
			//dp1[i+1][j - x[i]] = true;
			if (i > 0) dp1[i+1][j - x[i]] = true;
		}
	}

	dp2[0][10000] = true;
	for (int i=0; i<y.size(); i++) {
		for (int j=0; j < 20000; j++) {
			if (dp2[i][j] == false) continue;

			dp2[i+1][j + y[i]] = true;
			dp2[i+1][j - y[i]] = true;
		}
	}

	string ans;
	if (dp1[x.size()][10000 + x_goal] && dp2[y.size()][10000 + y_goal]) ans = "Yes";
	else ans = "No";

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 154368
#include<iostream>
#include<cmath>
using namespace std;
int main() {
	long long a = 100;
	int i = 0;
	long long b;
	cin >> b;
	for (;;) {
		i++;
		a *= 1.01;
		if (a >= b) {
			break;
		}
	}
	cout << i;
}


Measured memory_bytes: 3636