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

int main(){
    int n, i, j, m = 0;
    long int ans = 0;
    cin >> n;
    int a[n], b[n], c[n];
    for(i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a,a+n);
    for(i=0; i<n; i++){
        cin >> b[i];
    }
    sort(b,b+n);
    for(i=0; i<n; i++){
        cin >> c[i];
    }
    sort(c,c+n);
    for(i=0; i<n; i++){
        ans += (long int)(lower_bound(a, a+n, b[i]) - a) * (long int)((c+n) - upper_bound(c, c+n, b[i]));
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>

using namespace std;

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

	int n;
	cin >> n;
	int a[n];
	int avg = 0;
	for(int i=0; i<n; i++){
		cin >> a[i];
		avg += a[i];
	}
	avg = avg/n;
	int ans1 = 0, ans2 = 0;
	for(int i=0; i<n; i++){
		ans1 += (a[i]-avg)*(a[i]-avg);
		ans2 += (a[i]-avg-1)*(a[i]-avg-1);
	}
	cout << min(ans1, ans2);

	return 0;
}

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

int main(){
   int x;
    cin>>x;
   if(x>=400&&x<=599)cout<<"8\n";
   else if(x>=600&&x<=799)cout<<"7\n";
   else if(x>=800&&x<=999)cout<<"6\n";
   else if(x>=1000&&x<=1199)cout<<"5\n";
   else if(x>=1200&&x<=1399)cout<<"4\n";
   else if(x>=1400&&x<=1599)cout<<"3\n";
   else if(x>=1600&&x<=1799)cout<<"2\n";
   else cout<<"1\n";   
}


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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

  reverse(S.begin(), S.end());
  for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

  bool can = true;
  for (int i = 0; i < S.size();){
    bool can2 = false;
    for (int j = 0; j < 4; ++j) {
      string d = divide[j];
      if (S.substr(i, d.size()) == d){
        can2 = true;
        i += d.size();
      }
    }
    if (!can2){
      can = false;
      break;
    }
  }

  // output
  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n, a;

int main() {
	cin >> n >> a;
	cout << n*n - a << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
k = 0
ans = 0

while True:
    for i in range(n):
        if a[i] % 2 == 0:
            k += 1
    if n == k:
        for i in range(n):
            a[i] /= 2
        ans += 1
        k = 0
    else:
        break
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define LL_MAX LLONG_MAX
#define ULL_MAX ULLONG_MAX
#define ull unsigned long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb(x) push_back(x)
#define re() pop_back()
#define eb(x) emplace_back(x)
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define all(a) a.begin(),a.end()
#define msort(a) sort(a.begin(),a.end())
#define pii pair<int,int>
#define sz(x) int(x.size())
#define mk make_pair
#define endl '\n'

void solve()
{
    int n;
    cin>>n;
    int x=7;
    int count =1;

    while(count<1e8){
        x=x%n;
        if(x==0){
            break;
        }
        count++;
        x=x*10 +7;
    }
    if(count<1e8) cout<<count<<endl;
    else cout<<-1;
}

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

Measured memory_bytes: 3616
//#include <bits/stdc++.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];

    int r=0,sum=0;
    int res=0;
    rep(l,n){
        while(r<n && (sum+a[r])==(sum^a[r])){
            sum+=a[r++];
        }
        res+=r-l;
        if(r==l) r++;
        else sum-=a[l];
    }
    cout<<res<<endl;

}

Measured memory_bytes: 4784
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

void solve(void)
{
  int N;
  cin>>N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  SORT_(vec);
  vector<int> vec_s(N);
  int index_min = 0;
  int index_max = N -1;
  for (int i = 0; i < N; i++)
  {
    if(i%2 == 0)
    {
      vec_s[i] = vec[index_max];
      index_max--;
    }
    else
    {
      vec_s[i] = vec[index_min];
      index_min++;
    }
    
  }
  // DEBUG((vec_s));
  int ANS1 = 0;
  for (int i = 0; i < N-2; i++)
  {
    ANS1 += abs(vec_s[i+1] - vec_s[i]);
  }

  ANS1 += max(abs(vec_s[N-1]-vec_s[N-2]),abs(vec_s[N-1]-vec_s[0]));
  index_min = 0;
 index_max = N -1;

    for (int i = 0; i < N; i++)
  {
    if(i%2 == 1)
    {
      vec_s[i] = vec[index_max];
      index_max--;
    }
    else
    {
      vec_s[i] = vec[index_min];
      index_min++;
    }
    
  }
  // DEBUG((vec_s));
  int ANS2 = 0;
  for (int i = 0; i < N-2; i++)
  {
    ANS2 += abs(vec_s[i+1] - vec_s[i]);
  }

  ANS2 += max(abs(vec_s[N-1]-vec_s[N-2]),abs(vec_s[N-1]-vec_s[0]));
  cout<<max(ANS1,ANS2)<<endl;

  
  
  
  
  
  return;

   
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

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

int main() {
    string S, T;
    cin >> S >> T;
    bool flag = false;
    for(int i = 0; i < S.size(); i++){
        if(S == T){
            flag = true;
            break;
        }
        S = S.back() + S.substr(0, S.size() - 1);
    }
    if(flag) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const ll dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

signed main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	string a, b, c;
	cin >> a >> b >> c;

	cout << "A" << b[0] << "C" << endl;

	return 0;
}

Measured memory_bytes: 256
merry = [4,1,4,1,2,1,2,1]
main = do
  s <- getContents
  mapM_ func $ map words $ lines s
  return ()

func s = do
  let s2 = (map read s)
  let ans = snd $ choice $all_list s2 merry []
  putStrLn $ unwords $ map show ans

rotate (x:xs) = xs ++ (x:[])

score s m = sum $ zipWith f s m
  where f x y = max 0 (y - x)

all_list s m l = 
  let t = ((score s m),m) in
  if (elem t l)
    then l
    else all_list s (rotate m) (t:l)

choice l = 
  foldl f (100,[5,5,5,5,5,5,5,5]) l
f acc t
  | fst acc == fst t && snd acc > snd t = t
  | fst acc > fst t                     = t
  | otherwise                           = acc

Measured memory_bytes: 4084
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	string S;
	cin>>S;
	S.at(3)='8';
	ce(S)
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll k;
  cin >> k;
  queue<string> q;
  FOR(i, 1, 10) { q.push(to_string(i)); }
  ll now = 0;
  while (true) {
    now++;
    string s = q.front();
    q.pop();
    if (now == k) {
      cout << s << endl;
      return 0;
    }
    ll last = stoll(s.substr(SZ(s) - 1, 1));
    if (1 <= last && last <= 8) {
      FOR(i, -1, 2) {
        string t = to_string(last + i);
        q.push(s + t);
      }
    } else if (last == 0) {
      REP(i, 2) {
        string t = to_string(last + i);
        q.push(s + t);
      }
    } else {
      FOR(i, -1, 1) {
        string t = to_string(last + i);
        q.push(s + t);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 12288
n = int(input())
hs = list(map(int, input().split()))

# 足場 i にたどり着くまでのコストの総和の最小値
dp = [1e14] * n

dp[0] = 0
dp[1] = abs(hs[0] - hs[1])

for i in range(2, n):
    dp[i] = min(abs(hs[i] - hs[i - 1]) + dp[i - 1], abs(hs[i] - hs[i - 2]) + dp[i - 2])

print(dp[n - 1])


Measured memory_bytes: 13928
#include<iostream>
#include<cmath>
#include<stdio.h>
#include <ctype.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<deque> //<< fixed << setprecision()
#include<queue> //priority_queue
#include<vector>
typedef long long ll;
using namespace std;
const double pi = (2 * acos(0));


struct point
{
	long double x, y;
};
double area(int x1, int y1, int x2, int y2, int x3, int y3)
{
	double a = (x2*y3) - (x3*y2) - (x1*y3) + (x3*y1) + (x1*y2) - (x2*y1);
	a /= 2;
	return fabs(a);
}

long double anyarea(point p[], int n)
{
	long double sum1 = p[n - 1].x * p[0].y, sum2 = p[n - 1].y * p[0].x;
	for (int i = 0; i < n - 1; i++)
	{
		sum1 += p[i].x * p[i + 1].y;
		sum2 += p[i].y * p[i + 1].x;
	}
	return  fabs((sum1 - sum2) * 0.5);
}

ll fastpow(ll base, ll p, ll m)
{
	if (p == 0)
		return 1;
	ll ans = fastpow(base, p / 2, m);
	ans = ((ans%m)*(ans%m)) % m;
	if (p % 2)
		ans = ((base%m)*ans) % m;
	return ans;
}
ll GCD(ll M, ll m)
{
	if (M%m == 0)
		return m;
	M %= m;
	ll x1 = M, x2 = m;
	m = min(x1, x2);
	M = max(x1, x2);
	return GCD(M, m);


}
ll lcm(ll M, ll m)
{
	return (M*m) / GCD(max(M, m), min(M, m));

}


	
int h, w;
char arr[1002][1002];
map<pair<int, int>, ll>mp;
ll solve(ll i, ll j)
{
	if (arr[i][j] == '#')
		return mp[{i, j}] = 0;
	if (i == h - 1&&j==w-1)
		return 1;
	if (i >= h||j>=w)
		return 0;
	if (mp[{i, j}] != -1)
		return mp[{i, j}];
	return mp[{i, j}] = ((solve(i + 1, j) % (1000000007)) + solve(i, j + 1) % (1000000007)) % (1000000007);
}


int main()
	{
	cin >> h >> w;
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cin >> arr[i][j];
			mp[{i, j}] = -1;
		}
	}
	cout << solve(0,0);
	}

Measured memory_bytes: 64000
#include <iostream>
#include <cstdio> 
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=200010,Mo=1000000007;
bool w[N];
int a[N],f[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') ch=='-'?o=-1:0,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,s=1;
    cin>>n;
    for(int i=1,j=0;i<=n;i++) {
	int x=gi(),y=s;
	if(j!=x) {
	    if(w[x]) s=(s+f[x])%Mo;
	    f[x]=(f[x]+y)%Mo;
	}
	w[x]=1,j=x;
    }
    cout<<s;
    return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string S;
	cin >> S;

	int ans = SZ(S);
	rep(i, 1, SZ(S))
	{
		if (S[i - 1] != S[i])
		{
			chmin(ans, max(i, SZ(S) - i));
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

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

		Scanner scanner = new Scanner(System.in);
		int numOfJoin = scanner.nextInt();
		int dispRating = scanner.nextInt();
		int internalRating;

		if(numOfJoin<10&&numOfJoin>0) {
			internalRating = dispRating + 100*(10-numOfJoin);
		}else {
			internalRating = dispRating ;
		}

		System.out.println(internalRating);

		scanner.close();
	}
}


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

const int N = 100;

int n, k, ans, a[N];

int main(){
    scanf("%d %d", &n, &k);
    for(int i=0; i<n; i++)  scanf("%d", a+i);
    sort(a, a+n);
    ans = 0;
    for(int i=0; i<k; i++){
        ans += a[n-i-1];
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const ll MAX = 1e15 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }



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


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, k, d[111][111];
main() {
    file("rmq");
    //ios;
    cin >> n >> k;
    vector <pii> ans;
    fo(i, 2, n, 1) ans.pb({1, i});
    int cur = (n - 1) * (n - 2) / 2, mi = n - 2;
    if (cur < k) return !(cout << -1);
    k = cur - k;
    fo(i, 2, n, 1) {
        bool flag = 0;
        fo(j, i + 1, n, 1) {
            if (!k) {
                flag = 1;
                break;
            }
            --k;
            ans.pb({i, j});
        }
    }
    cout << ans.size() << "\n";
    fo(i, 1, n, 1) fo(j, 1, n, 1) if (i != j) d[i][j] = mod;
    for (pii it : ans) cout << it.F << " " << it.S << "\n", d[it.F][it.S] = d[it.S][it.F] = 1;
    return 0;
    fo(k, 1, n, 1) {
        fo(i, 1, n, 1) {
            fo(j, 1, n, 1) {
                chmin(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    int cnt = 0;
    cout << "CH\n";
    fo(i, 1, n, 1) fo(j, i + 1, n, 1) if (d[i][j] == 2) cout << i << " " << j << "\n", ++cnt;
    cout << cnt;
    return 0;
}
/**

*/


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(void){
  int low,high;
  int A,B;
  cin >> A >> B;
  low = (int)(8*A/100) - 1;
  high = (int)(9*A/100) + 1;
  int i;
  for(i=0;i<=2000;i++){
    if((int)(8*i/100) == A && (int)(10*i/100) == B)
      break;
  }
  if(i <= 2000){
    cout << i << endl;
    return 0;
  }

  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
 
#define long long long int
 
using namespace std;
 
// @author: pashka
 
int main() {
    ios::sync_with_stdio(false);
 
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = n - 2; i >= 0; i--) {
        if (a[i] > a[i + 1]) {
            a[i]--;
        }
        if (a[i] > a[i + 1]) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
 
    return 0;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
	"math"
)

func main() {
	var x int
	fmt.Scan(&x)

	ans := 1
	for i := 2; i*i <= x; i++ {
		for j := 2; ; j++ {
			e := int(math.Pow(float64(i), float64(j)))
			if e <= x {
				ans = max(ans, e)
			} else {
				break
			}
		}
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 512
//config = {input: 'tmp', newline: '\r\n'}; // win
config = {input: '/dev/stdin', newline: '\n'}; // linux

fs = require('fs');
si = fs.createReadStream(config.input);

rl = require('readline').createInterface({input: si, output: process.stdout});

is_first = true;
n = 0;
k = 0;
w = [];
rl.on('line', function(line) {
  if (is_first) {
    ary = line.split(' ');
    n = parseInt(ary[0], 10);
    k = parseInt(ary[1], 10);
    is_first = false;
  } else {
    w.push(parseInt(line, 10));
    if (w.length === n) {
      rl.close();
      si.destroy();
    }
  }
});

rl.on('close', function() {
  var min, max = 1, mid;
  while (!is_loadable(n, k, w, max)) max *= 2;
  if (max === 1) {
    console.log(1);
    return;
  }
  min = max / 2;
  while (max - min > 1) {
    mid = Math.floor((max + min) / 2);
    if (is_loadable(n, k, w, mid)) max = mid;
    else min = mid;
  }
  console.log(max);
});

function is_loadable(n, k, w, P) {
  var i = 0, j = 0, wi, sum = 0;
  while (i < n) {
    wi = w[i];
    if (wi > P) return false;
    if (sum + wi <= P) {
      sum += wi;
    } else {
      sum = wi;
      j++;
    }
    i++;
  }
  if (sum !== 0) j++;
  return j <= k;
}

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

int main(){
    int N;
    cin >> N;
    int d[110];
    for(int i = 0;i < N;++i) cin >> d[i];

    int num[110] = {0};
    for(int i = 0;i < N;i++){
        num[d[i]]++; 
    }
    int res = 0;
    for (int i = 1;i <= 100;i++){
        if(num[i]) ++res;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
using namespace std;

int main(){
  vector<int> p;
  for(int i=3;i<=1e5;i+=2){
    int n=floor(sqrt(i)),b=1;
    for(int d=2;d<=n;d++){
      int j=(i+1)/2;
      if(i%d==0||j%d==0){
        b=0;
        break;
      }
    }
    if(b) p.push_back(i);
  }

  int Q,l,r; cin>>Q;
  for(int i=0;i<Q;i++){
    cin>>l>>r;
    cout<<upper_bound(ALL(p),r)-lower_bound(ALL(p),l)<<endl;
  }
}

Measured memory_bytes: 3628
/**
 *    author:  tourist
 *    created: 25.11.2019 15:54:03       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(1 << n);
  for (int i = 0; i < (1 << n); i++) {
    cin >> a[i];
    --a[i];
  }
  vector<int> L(1 << n), R(1 << n);
  for (int i = 0; i < (1 << n); i++) {
    if (a[i] == -1) {
      L[i] = 0;
      R[i] = (1 << n) - 1;
    } else {
      L[i] = R[i] = a[i];
    }
  }
  for (int t = 0; t < n; t++) {
    for (int i = 0; i < (1 << n); i++) {
      if (i & (1 << t)) {
        L[i] = max(L[i], L[i ^ (1 << t)] + 1);
        R[i ^ (1 << t)] = min(R[i ^ (1 << t)], R[i] - 1);
      }
    }
  }
  vector<vector<int>> at(1 << n);
  for (int i = 0; i < (1 << n); i++) {
    if (L[i] > R[i]) {
      cout << "NO" << '\n';
      return 0;
    }
    at[L[i]].push_back(i);
  }
  set<pair<int, int>> s;
  for (int i = 0; i < (1 << n); i++) {
    for (int j : at[i]) {
      s.emplace(R[j], j);
    }
    if (s.empty() || s.begin()->first < i) {
      cout << "NO" << '\n';
      return 0;
    }
    a[s.begin()->second] = i;
    s.erase(s.begin());
  }
  cout << "YES" << '\n';
  for (int i = 0; i < (1 << n); i++) {
    int j = 0;
    for (int k = 0; k < n; k++) {
      if (i & (1 << k)) {
        j |= (1 << (n - 1 - k));
      }
    }
    if (i > 0) {
      cout << " ";
    }
    cout << a[j] + 1;
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 23168
k, n = map(int, input().split())
a_list = list(map(int, input().split()))

longest = 0
for i in range(n):
    # if i==0:
    #     continue
    if i==n-1:
        longest = max(longest, k-a_list[i]+a_list[0])
    else:
        distance = a_list[i+1] - a_list[i]
        longest = max(longest, distance)

print(k-longest)

Measured memory_bytes: 32192
// B.

#include <iostream>
#include <sstream>
#include <map>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	map<string, int> a, b;
	int n, m;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		a[s] += 1;
	}
	cin >> m;
	for (int i = 0; i < m; ++i) {
		string s;
		cin >> s;
		b[s] += 1;
	}
	int ans = 0;
	for (const auto kv : a) {
		ans = max(ans, kv.second - b[kv.first]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] NX = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();
            int N = NX[0];
            int X = NX[1];
            List<int> iList = new List<int>();//
            for(int i = 0; i < N; i++)
            {
                iList.Add(int.Parse(Console.ReadLine()));
            }
            int sum = iList.Sum();
            int min = iList.Min();
            int ans = 0;
            X -= sum;
            while (true)
            {
                if (X >= iList.Min())
                {
                    ans++;
                    X -= min;
                }
                else
                {
                    break;
                }
            }
            Console.WriteLine(ans + N);
        }
    }
}
//int i = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();

Measured memory_bytes: 31900
#include<stdio.h>
 #include<iostream>
#include<vector>
 using namespace std ; 
 vector<int> v  ;

 int main() {
  int x , y , z;
  cin >> x >>y >>z ; 
  int mx=max(max(x,y),z) ; 
  int mn=min(min(x,y),z) ; 
  int bet = mx+mn-x-y-z ; 

  int ans= (mx-bet)+(bet-mn) ; 
  cout << ans ; 



 return 0 ; 
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=2; i<=n; i++)
#define all(v) v.begin(), v.end()

int main() {
	int n;
	cin >> n;
	vector<vector<int>> v(n);

	int t;
	rep(i, n) {
		cin >> t;
		v.at(t-1).push_back(i);
	}

	for (auto x : v) {
		std::cout << x.size() << '\n';
	}
}


Measured memory_bytes: 14348
#include<stdio.h>
	#include<stdlib.h>
	#include<iostream>

	using namespace std;
	int N,M;
	struct houseki{
		int x,y;
		int flag;
	};
	struct order{
		char dir;
		int move;
	};

	struct houseki hou[20];
	struct order ord[30];

	int robo_x,robo_y;

	int main(void)
	{
		int i,j,k;

		int maflag;
		char temp[20];
		robo_x = 10;
		robo_y = 10;
		maflag = 0;

		while(1 ) 
		{
			robo_x = 10;
			robo_y = 10;
			for( i=0; i<20; i++ )
			{
				hou[i].flag = 0;
				hou[i].x = 0;
				hou[i].y =0;
			}
			scanf("%d",&N);
			if( N == 0 )
			{
				break;
			}
			for( i=0; i<N; i++ )
			{	
				cin >> hou[i].x >> hou[i].y;
				//scanf("%d %d",&hou[i].x, &hou[i].y);
				hou[i].flag = 0;
			}

			scanf("%d",&M);
			for( i=0; i<M; i++ )
			{
				cin >> ord[i].dir >> ord[i].move;
				/*scanf("%s",temp);
				ord[i].dir = temp[0];
				ord[i].move = atoi( &temp[2] );
				*/
			}
			
			for( i=0; i<M; i++ )
			{
				for( j=0; j<ord[i].move; j++ )
				{
					switch( ord[i].dir )
					{
					case 'N' :
						robo_y++;
						break;
					case 'E' :
						robo_x++;
						break;
					case 'S' :
						robo_y--;
						break;
					case 'W' :
						robo_x--;
						break;
					}
					for( k=0; k<N; k++ )
					{
						if( hou[k].x == robo_x && hou[k].y == robo_y )
						{
							hou[k].flag = 1;
						}
					}
				}
			}

			maflag = 1;

			for( i=0; i<N; i++ )
			{
				if( hou[i].flag == 0 )
				{
					maflag = 0;
				}
			}

			if( maflag == 1 )
			{
				printf("Yes\n");
			}else {
				printf("No\n");
			}

		}

		return 0;

	}

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

int main(){
	int vnum, capacity;
	std::vector<int> vprice;

	while(std::cin >> vnum >> capacity){
		//end
		if(vnum == 0 && capacity == 0) break;

		int tmp,buf = capacity;
		int total = 0;
		std::vector<int> vprice;

		//input
		for(int i = 0; i < vnum; ++i){
			std::cin >> tmp;
			vprice.push_back(tmp);
	}

		//sort
		std::sort(vprice.begin(), vprice.end(), std::greater<int>());

		//sum price
		std::for_each(vprice.begin(),vprice.end(), 
			[&total,buf,&capacity](int x) { capacity != 1 ? (total += x, --capacity) : capacity = buf; } );

		//output
		std::cout << total << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1228
n = int(input())
L = list(map(int, input().split()))
res = 0
temp = 0
for i in range(1,n):
    if L[i-1] >= L[i]:
        temp+=1
    else:
        res = max(temp, res)
        temp = 0
res = max(temp, res)
print(res)

Measured memory_bytes: 15020
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
using namespace std;

int main(){
    string s;
    cin >> s;
    if(s == "BBB" || s == "AAA") cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;

#define fi first
#define se second
typedef long long LL;
typedef long double LD;

int N,a[200010],arr[500010];

int main(){
    cin >> N;

    int i;
    for (i=1; i<=N; i++)
        cin >> a[i];

    int l=200010,r=l,e=r;
    arr[l]=a[1];
    for (i=2; i<=N; i++){
        if (e==l) arr[--l]=a[i],e=r;
        else arr[++r]=a[i],e=l;
    }

    if (e==r){
        for (i=l; i<=r; i++)
            cout << arr[i] << " ";
    }
    else {
        for (i=r; i>=l; i--)
            cout << arr[i] << " ";
    }
    return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define nn 100004
int n,arr[102];
int dp[nn][2];
int solve(int turn,int k){
   // cout<<turn<<" ";
    if(k<0){
        return (turn);
    }
    if(k==0){
        return !turn;
    }
    if(dp[k][turn] == -1){
        int i;
        for(i=0;i<n;i++){
            int a1 = solve(!turn,k-arr[i]);
           // cout<<a1<<" "<<k<<" "<<turn<<endl;
            if(a1== turn){
                dp[k][turn] = turn;
                return turn;
            }
        }
        dp[k][turn] = !turn;
    }
    return dp[k][turn];
}
int main(){
    int k;
    cin>>n>>k;
    int i;
    memset(dp,-1,sizeof(dp));
    for(i=0;i<n;i++){
        cin>>arr[i];
    }
    int ans =solve(0,k);
    if(ans == 0)
        cout<<"First";
    else{
        cout<<"Second";
    }
    return 0;

}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
int a[26];
int main(){
  string s;cin>>s;
  for(int i=0;i<s.size();i++){
    a[s.at(i)-'a']++;
  }
  int sum=0;
  for(int i=0;i<26;i++){
    sum+=a[i]%2;
  }
  cout<<(sum==0?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
x1, y1, x2, y2 = gets.split.map(&:to_i)

x3 = x2+y1-y2
y3 = y2 + x2 - x1
y4 = y1 + x2 - x1
x4 = x1+y1-y2
puts [x3, y3, x4, y4].join(' ')

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <set>

using namespace std;

string rev(string s)
{
  string rs;
  for(unsigned int i=0;i<s.length();i++){
    rs.append(1,s[s.length() - 1 - i]);
  }
  return rs;
}

int main(void)
{
  int a;
  cin >> a;
  string s;
  for(int k=0;k<a;k++){
    cin >> s;
    set<string> v;
    for(unsigned int i=1;i<s.length();i++){
      string s1,s2;
      for(unsigned int j = 0;j < i;j++){
        s1.append(1,s[j]);
      }
      for(unsigned int j = 0;j < s.length() - i;j++){
        s2.append(1,s[j+i]);
      }
      v.insert(s1+s2);
      v.insert(s2+s1);
      v.insert(rev(s1)+s2);
      v.insert(s2+rev(s1));
      v.insert(s1+rev(s2));
      v.insert(rev(s2)+s1);
      v.insert(rev(s1)+rev(s2));
      v.insert(rev(s2)+rev(s1));
    }

    cout << v.size() << endl;
  }

  return 0;
}

Measured memory_bytes: 1312
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pii pair<int,int>

map <string,int> mp;
string ans[200005],s[200005];
int n,c,cnt;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s[i];
		mp[s[i]]++;
		c=max(c,mp[s[i]]);
	}
	for(int i=1;i<=n;i++)if(mp[s[i]]==c){
		ans[++cnt]=s[i];
		mp[s[i]]=0;
	}
	sort(ans+1,ans+cnt+1);
	for(int i=1;i<=cnt;i++)cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 28288
#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define rp(i,e) for(int i=0; i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long ll;
const int INF=1000000;
const int MOD=998244353;


int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll k;
    int n;
    cin >> k;
    cin >> n;
    vector<int> a(n);
    rp(i,n) cin >> a[i];
    vector<int> b(n);
    fr(i,0,n-1){
        b[i]=a[i+1]-a[i];
    }
    b[n-1]=k-a[n-1]+a[0];
    sort(all(b));
    cout << k-b[n-1] << "\n";
}   

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x;
	cin >> x;
	if(x>=400 && x<=599)cout << "8" << endl;
	else if(x>=600 && x<=799)cout << "7" << endl;
	else if(x>=800 && x<=999)cout << "6" << endl;
	else if(x>=1000 && x<=1199)cout << "5" << endl;
	else if(x>=1200 && x<=1399)cout << "4" << endl;
	else if(x>=1400 && x<=1599)cout << "3" << endl;
	else if(x>=1600 && x<=1799)cout << "2" << endl;
	else if(x>=1800 && x<=1999)cout << "1" << endl;
} 

Measured memory_bytes: 3628
#include <stdio.h>
int main(void){
    // Your code here!
    int W,a,b;
    
    scanf("%d%d%d",&W,&a,&b);
    
    if(a > b){ //a < b
        int tmp = a;
        a = b;
        b = tmp;
    }
    
    if(a+W >= b){
        printf("0\n");
    }
    else{
        printf("%d\n",b-(a+W));
    }
    
    return 0;
}


Measured memory_bytes: 128
N, A, B, C, D = list(map(int,input().split()))
S = input()

for i in range(A-1,C):
    if S[i] == '#' and S[i+1] == '#':
        print('No')
        exit()

for ii in range(B-1,D):
    if S[ii] == '#' and S[ii+1] == '#':
        print('No')
        exit()

if C > D:
    for j in range(B-1,D):
        if S[j-1] == '.' and S[j] == '.' and S[j+1] == '.':
            print('Yes')
            exit()

    print('No')
    exit()

else:
    print('Yes')
    exit()

Measured memory_bytes: 3572
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
// #include <prettyprint.hpp>
using namespace std;
#define rep(i,n) for(i=0;i<(ll)n;i++)
typedef long long ll;
static const ll max_length = 50000;
static const ll M = 2000;
vector<bool> ab(max_length*2, true);
vector<bool> ac(max_length*2, true);
vector<bool> bc(max_length*2, true);

bool match(char a, char b){
    bool ok = false;
    ok = (a=='?') || (b == '?') || (a == b);
    return ok;
}


int main(){
    // int u, v;
    // bool updated = false;
    // ll ans = 0;
    string a, b, c;
    cin >> a >>b >> c;

    ll i, j;
    rep(i, a.size()) rep(j,b.size()) if(!match(a[i], b[j])) ab[i-j+max_length] = false;
    rep(i, a.size()) rep(j,c.size()) if(!match(a[i], c[j])) ac[i-j+max_length] = false;
    rep(i, b.size()) rep(j,c.size()) if(!match(b[i], c[j])) bc[i-j+max_length] = false;
    
    ll ans = M * 10;
    for(i=-M*2;i<=M*2;i++){
        for(j=-M*2;j<=M*2;j++){
            // bの先頭に対するcの先頭でokな位置がbc[a+max_length]のaが記録しているもの。
            // ab[i], ac[j]okていうのはaの先頭に対してbの先頭はi個前はok, cの先頭はj個前はok,という意味。
            // だからab[i], ac[j]の時のbの先頭に対するcの先頭の相対位置はj - iになる。
            if(ab[i+max_length] && ac[j+max_length] && bc[j-i+max_length]){
                ll L = min((ll)0, min(i, j));
                ll R = max((ll)a.size(), max(i+(ll)b.size(), j+(ll)c.size()));
                
                ans = min(ans, R - L);
            }
        }
    }
    printf("%lld\n", ans);
    
    // double limit = 1. / (double)(4 * M);



    return 0;

}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}




int main() {
	int n, d, x; cin >> n >> d >> x;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >>a[i];
	}
	
	int sum = 0;

	for (int i = 0; i < n; i++) {
		for (int j = 0; a[i] * j + 1 <= d; j++) {
			sum++;
		}
	}
	cout << sum + x << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(1, n - 1):
    if p[i - 1] < p[i] < p[i + 1] or p[i - 1] > p[i] > p[i + 1]:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll gcd (ll a, ll b) {
    return b ? gcd (b, a % b) : a;
}
int main()
{
    ll n;
    cin>>n;
    pair<ll,ll> ar[n];
    for(int x=0;x<n;x++)
    {
        cin>>ar[x].second;
        cin>>ar[x].first;
    }
    sort(ar,ar+n);
    bool k=true;
    ll tim=0;
    for(int x=0;x<n;x++)
    {
        tim+=ar[x].second;
        if(tim>ar[x].first)
        {
            k=false;
            break;
        }
    }
    if(k)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 3328
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

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

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    unsigned int N;
    string ans = "Three";
    char c;

    cin >> N;
    rep(i,N){
        cin >> c;
        if(c == 'Y') ans="Four";
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
N, W = map(int, input().split())
dp = [-1]*(W+1)
dp[0] = 0

# 品物の数ループ
for _ in range(N):
    value, weight = map(int, input().split())
    for i in range(W, weight-1, -1):
        if dp[i-weight] == -1:
            continue
        dp[i] = max(dp[i], dp[i-weight]+value)

ans = 0
for i in range(W+1):
    ans = max(ans, dp[i])
print(ans)



Measured memory_bytes: 5920
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n, i, count;
        n = cin.nextInt();
        int[] A = new int[n];
        for (i = 0; i < n; i++) {
            A[i] = cin.nextInt();
        }
        
        count = sectionSort(A, n);
        
        for (i = 0; i < n - 1; i++) {
            System.out.print(A[i] + " ");
        }
        System.out.println(A[i] + "\n" + count);
    }
    
    static int sectionSort(int[] A, int n) {
        int i, j, min, count = 0;
        for (i = 0; i < n; i++) {
            min = i;
            for (j = i; j < n; j++) {
                if (A[j] < A[min]) {
                    min = j;
                }
            }
            if (min != i) {
                int temp = A[i];
                A[i] = A[min];
                A[min] = temp;
                count++;
            }
        }
        return count;
    }
}


Measured memory_bytes: 26376
#include<bits/stdc++.h>
#define pb push_back
#define INF (ll)1e9
#define deb(x) cerr<<#x<<" "<<x<<"\n"
using namespace std;
using ll = long long;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vector<int> v(n);
	vector<int> pos[n+1];
	for(int i=1;i<=n;i++){
		pos[i].pb(0);
	}
	for(int i =0;i<n;i++){
		cin>>v[i];
		pos[v[i]].pb(i+1);
		pos[v[i]][0]++;
	}
	int start =0;
	int current =0;
	for(int i=1;i<=n;i++){
		if(pos[i][0] == 0){
			break;
		}
		else{
			bool cond = false;
			for(int j=1;j<=pos[i][0];j++){
				if(pos[i][j]>current){
					current = pos[i][j];
					start++;
					deb(start);
					cond = true;
					break;
				}
			}
			if(!cond){
				break;
			}
			
		}
	}
	if(start == 0){
		cout<<"-1";
	}
	else{
		cout<<n - start;
	}
	
	
}




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

const int MAXN = 100010;

char s[MAXN];
int n, fa[MAXN];

int main()
{
	scanf("%s", s + 1); n = strlen(s + 1);
	if(s[1] != '1' || s[n] != '0') return puts("-1"), 0;
	for(int i = 1; i <= n / 2; ++i)
		if(s[i] != s[n - i]) return puts("-1"), 0;
	int rt = 1, now = 1;
	for(int i = 2; i <= n; ++i)
		if(s[i] == '1')
		{
			now = i;
			for(int j = rt; j < now; ++j)
				printf("%d %d\n", j, now);
			rt = now;
		}
	printf("%d %d\n", n - 1, n);
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int k, x;
    cin >> k >> x;

    cout << (500 * k >= x ? "Yes\n" : "No\n");

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[100001][101],wt[100001],val[100001];
ll n,W;
ll fun(ll w,ll i)
{
	ll ans1=0,ans2=0;
	if(i>n)
	return 0;
	if(dp[w][i]!=-1)
	return dp[w][i];
	if(w+wt[i]<=W)
	ans1=val[i]+fun(w+wt[i],i+1);
	return dp[w][i]=max(ans1,fun(w,i+1));
}
int main()
{
	ll i;
	memset(dp,-1,sizeof(dp));
	cin>>n>>W;
	for(i=1;i<=n;i++)
	cin>>wt[i]>>val[i];
	cout<<fun(0,1)<<endl;
}

Measured memory_bytes: 79232
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int h,w;
    cin >> h >> w;
    cout << string(w+2, '#') << endl;
    for (int i=0; i<h; i++) {
        string s;
        cin >> s;
        cout << '#' << s << '#' << endl;
    }
    cout << string(w+2, '#') << endl;

}

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

using namespace std;

#define INF 1e9 + 5

typedef long long ll;

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> v(n);
	for(int i = 0;i<n;i++)
		cin >> v[i];
		
	vector<int> dp(n + k,INF);	
	dp[0] = 0;
	for(int i = 0;i<n - 1;i++){
		for(int j = 1;j<=k;j++){
			dp[i + j] = min(dp[i] + abs(v[i] - v[i + j]), dp[i + j]);
		}
	}
	cout << dp[n - 1] << "\n";
}

Measured memory_bytes: 1024