akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;

int main()
{
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string op;
    cin >> op;
    int n = op.size();
    int stat = (1 << (n - 1)) - 1;
    ll ans = 0;
    for(int i = 0; i <= stat; i++)
    {
        vector<int> v;
        int tmp = 1;
        int cnt = 0;
        while(tmp  <= i)
        {
            if(tmp & i)
            {
                v.push_back(cnt);
            }
            cnt++;
            tmp <<= 1;
        }
        
        v.push_back(n-1);
        /*for(int j = 0; j < v.size(); j++)
        {
            cout << v[j] << ' ';
        }
        cout << endl;*/
        ll num = 0;
        for(int j = 0; j < v.size(); j++)
        {
            ll tmp = 0;
            //dbg(v[j]);
            if(!j)
            {
                for(int k = 0; k <= v[j]; k++)
                {
                    tmp = tmp * 10 + op[k] - '0';
                    //dbg(op[k] - '0');
                }
            }
            else
            {
                for(int k = v[j-1]+1; k <= v[j]; k++)
                {
                    tmp = tmp * 10 + op[k] - '0';
                }
            }
            num += tmp;
            //dbg(tmp);
        }
        ans += num;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// Ryo Kamoi
//#define DEBUG

#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)

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

int INF = 1000000000;

int n, q;
string s;

char t[200010], d[200010];
int lidx, ridx;
int main(){
    cin >> n >> q;
    cin >> s;

    REP(i, q) {
        cin >> t[i] >> d[i];
    }

    lidx = 0;
    ridx = n-1;
    for(int i=q-1; i>=0; i--) {
        if (d[i]=='R') {
            if (t[i] == s[ridx]) ridx--;
            if (lidx > 0) {
                if (t[i] == s[lidx-1]) lidx--;
            }
        }

        if (d[i]=='L') {
            if (t[i] == s[lidx]) lidx++;
            if (ridx < (n-1)) {
                if (t[i] == s[ridx+1]) ridx++;
            }
        }
#ifdef DEBUG
        cout << i << " " << d[i] << " " << lidx << " " << ridx << endl;
#endif
    }

    cout << max(0, ridx-lidx+1) << endl;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
map<int,int>mp;
int main()
{
	int n,cc=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		mp[x]++;
		if(mp[x]>=2)cc++;
	}
	cout<<mp.size()-cc%2<<endl;
	return 0;
}

Measured memory_bytes: 4992
// AOJ 2134: Deadly Dice Game
// 2017.11.9 bal4u@uu

#include <stdio.h>
#include <string.h>

double a[2002][2002];

char buf[2002], *bp;
int getint()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int main()
{
	int n, t, i, j, ii, jj, k;
	double p, ans;
	
	while (fgets(bp=buf, 20, stdin) && *bp != '0') {
		n = getint(), bp++, t = getint();
		memset(a, 0, sizeof(a));
		fgets(bp=buf, sizeof(buf), stdin);
		for (i = 0; i < n; i++) a[0][i] = (*bp++ == 'R');
		for (ii = 1, i = 0; i < t; i++, ii++) for (j = 0; j < n; j++) {
			jj = j, p = a[i][j]/6;
			k = 6; while (k--) { if (++jj == n) jj = 0; a[ii][jj] += p; }
		}
		for (ans = 0, i = 0; i < n; i++) if (a[t][i] > ans) ans = a[t][i];
		printf("%.12f\n", ans);
	}
	return 0;
}

Measured memory_bytes: 33000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef multiset<ll> S;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
int main(){
  int n;cin>>n;
  vi x(3);
  rep(i,3)cin>>x[i];
  ll ans=inf;
  vi v(n);
  rep(i,n)cin>>v[i];
  rep(i,(1<<n*2)){
    ll k=i;
  	vi num(4);
  	vi sum(4);
    rep(j,n){
      num[(k&3)]++;
      sum[(k&3)]+=v[j];
      k>>=2;
    }
    if(num[1]==0||num[2]==0||num[3]==0)continue;
    ll p=0;
    rep(j,3)p+=(num[j+1]-1)*10;
    rep(j,3)p+=abs(sum[j+1]-x[j]);
    chmin(ans,p);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
int main(){
    int like[100005]={0,},n,ans=0,v[100005]={0,};
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&like[i]);
    for(int i=1;i<=n;i++){
        if(!v[i])
            if((like[like[i]]==i) && !v[like[i]]){
                ans++;
                v[like[i]]=1;
                v[i]=1;
            }
    }
    printf("%d",ans);
}

Measured memory_bytes: 896
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define MOD 100000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
using namespace std;
#define MAX 10000

int minRoute(vector<vector<char>> table) {
    int H = table.size();
    int W = table[0].size();
    vvi dp(H + 2, vi(W + 2, MAX));
    dp[1][1] = 1;
    rep(times, H * W) {
        for (int i = 1; i < H + 1; i++) {
            for (int j = 1; j < W + 1; j++) {
                if (table[i - 1][j - 1] == '.') {// if white then dp refresh
                    dp[i][j] = min({ dp[i][j],dp[i - 1][j] + 1,dp[i + 1][j] + 1 });
                    dp[i][j] = min({ dp[i][j],dp[i][j - 1] + 1,dp[i][j + 1] + 1 });

                }
            }
        }
    }
    if (dp[H][W] == MAX) {
        return -1;
    }
    return dp[H][W];
}
int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> table(H, vector<char>(W));
    int cnt = 0;
    rep(i, H) rep(j, W) {
        cin >> table[i][j];
        if (table[i][j] == '#') cnt++;
    }

    int ans = 0;
    if (minRoute(table) == -1) {
        ans = -1;
    }
    else {
        ans = H * W - minRoute(table)-cnt ;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define maxn 100005
#define Mod 1000000007
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef set<int> si; 
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
//#define __builtin_popcountll bitCountLL
//#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
const int INF = 2e9;
const ll ML = 4e18;
int help(int x) {
    int r = 0;
    while(x) {
        r++;
        x %= __builtin_popcount(x);
    }
    return r;
}
void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0;
    for(char c : s ) cnt += (c == '1');
    int a[2][n];
    if(cnt != 1) a[0][0] = 1 % (cnt - 1);
    a[1][0] = 1 % (cnt + 1);
    fori(i,1,n) {
        if(cnt != 1) a[0][i] = a[0][i- 1] * 2 % (cnt - 1);
        a[1][i] = a[1][i-1] * 2 % (cnt + 1);
    }
    vi res(n);
    int x = 0, y = 0;
    fori(i,0,n) if(cnt > 1) x = (x + a[0][i] * (s[n - 1 - i] - '0')) % (cnt - 1);
    fori(i,0,n) y = (y + a[1][i] * (s[n - 1 - i] - '0')) % (cnt + 1);
    rep(j,n-1,0) {
        int t;
        int i = n - 1 - j;
        if(s[j] == '0') {
            t = (y + a[1][i]) % (cnt + 1);
            
        }
        else {
            if(cnt == 1) {
                res[j] = 0;
                continue;
            }
            else {
                t = (x - a[0][i] + cnt - 1) % (cnt - 1);
            }
        }
        res[j] = help(t) + 1;
    }
    //reverse(all(res));
    fori(i,0,n) cout << res[i] << "\n";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
//	freopen("D:\\data_in.txt", "r", stdin);
    solve();
    
    /*clock_t start,finish;
    start = clock();
   
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


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

#define ll long long
#define ld long double
#define FOR(x,y) for(ll i=x;i<=y;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define matrix(x) vector<vector<x>>
#define vss vector<string>
#define PI (2*acos(0.0))
#define sqr(x) ((x)*(x))
#define sf(a)   scanf("%d",&a)
#define sfl(a)  scanf("%lld",&a)
#define sff(a,b)    scanf("%d %d",&a,&b)
#define sffl(a,b)   scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%lld %lld %lld",&a,&b,&c)
#define ms(a,b) memset(a, b, sizeof(a))
#define ff  first
#define ss  second
#define lcm(a, b)   ((a)*((b)/__gcd(a,b)))
#define all(a)  a.begin(),a.end()
#define readfile freopen("input.txt","r",stdin);
#define writefile freopen("output.txt","w",stdout);
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define gap " "
#define mx 104
#define inf (ll)1e9
#define WHITE 1
#define GRAY 2
#define BLACK 3
#define EMPTY_VALUE -1
#define mod 1000000007
#define MOD(a,b) (a%b + b)%b

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int main()
{
    //fastio
    ll x;
    cin>>x;
    if(x>=30) cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}

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

min = n
for i in range(1, n):
  j = n -i
  
  a = i
  b = j
  # print(a, b)
  
  total = 0
  while a > 0:
    total += a % 10
    a = int(a/10)
  while b > 0:
    total += b % 10
    b = int(b/10)
  if min > total:
    min = total
        
print(min)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<int,int>
#define pb push_back
#define INF INT_MAX
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
#define MEM(a, b) memset(a, (b), sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  (B) <= (A) && (A) <= (C)
#define AIN(A, B, C) assert(IN(A, B, C))

int main() {
     //#ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
     //#endif
     ios;
      int x,n;
      cin>>x>>n;
      map<int,int>mp;
      if(n==0){
       cout<<x;
       return 0;
      }
      f(i,0,n){
         int p;
         cin>>p;
         mp[p]++;
      }
      int g=x ,h=x;
      while(1){
        if(mp.find(g)==mp.end()){
          cout<<g;
          break;
        }
        else if(mp.find(h)==mp.end())
        {
           cout<<h;
           break;
        }
        g--;h++;

      }

}


Measured memory_bytes: 3640
#include <stdio.h>
    int main(void){
	int a,b;
	int max = 0;
	int min = 1000;
	scanf("%d\n",&a);
	for (b = 0; b < a; b++){
		int c;
		scanf("%d",&c);
		if(c > max)
		max = c;
		if(c < min)
		min = c;
	}
	printf("%d\n", max-min);
	return 0;
}


Measured memory_bytes: 128
#ifdef __GNUC__
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#endif

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>

#include <string>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <cassert>//assert();
#include <fstream>
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)

/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#define PII pair<int,int>
/////////
using namespace::std;

// 最大公約数
template<class T>
inline T gcd(T a, T b){return b == 0 ? a : gcd(b, a % b);}
// 最小公倍数
template<class T>
inline T lcm(T a, T b){return a * b / gcd(a, b);}
////////////////////////////////

inline void solve(){
	int x;
	cin >> x;
	if( x >= 1200 ){
		cout << "ARC";
	}else{
		cout << "ABC";
	}
}

int main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数をいっぱい表示する。16?

	solve();

	return 0;
}


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

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;

  int S = s.length(), T = t.length();
  vvi dp(S + 1, vi(T + 1, 0)); // dp[i][j] = sのi番目までとtのj番目までの最長のもの
  REP(i, S) REP(j, T) {
    if (s[i] == t[j])
      dp[i+1][j+1] = dp[i][j] + 1;
    else
      dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
  }

  int i = S, j = T;
  string ans = "";
  while (i > 0 && j > 0) {
    if (dp[i][j] == dp[i-1][j])
      --i;
    else if (dp[i][j] == dp[i][j-1])
      --j;
    else {
      --i; --j;
      ans.push_back(s[i]);
    }
  }
  reverse(ALL(ans));
  cout << ans << "\n";

  return 0;
}


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

int main(){
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    for(int i = 0; i < n; i++) cin >> t[i];

    int ans = 1;
    sort(t.begin(), t.end(), greater<int>());
    int tlim = t[0], pnum = 1;
    for(int i = 1; i < n; i++){
        if(t[i]+k < tlim || pnum == c){
            ans++;
            tlim = t[i];
            pnum = 1;
        }else{
            pnum++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
N = int(input())
s = input()

Red = 0
Blue = 0

for i in range(len(s)):
  if s[i] == 'R':
    Red = Red + 1
  elif s[i] == 'B':
    Blue = Blue + 1

if Red > Blue:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;
 
 
int main() {
    int n;
    cin >> n;
    vector<vector<int>> c(10,vector<int>(10));
    rep(i,n+1) {
        int k=i;
        int l,r;
        r=k%10;
        while(k>0) {
            l=k;
            k/=10;
        }
        ++c[l][r];
    }
    rep(i,10) {
        c[i][0]=0;
        c[0][i]=0;
    }
    ll ans=0;
    rep(i,10) {
        rep(j,10) {
            ans+=c[i][j]*c[j][i];
        } 
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int dp[100000 + 1000][15];
int main() {
  string S;
  cin >> S;
  reverse(S.begin(), S.end());
  if (S[0] == '?') {
    REP(i, 10) dp[0][i] = 1;
  } else {
    dp[0][S[0] - '0']++;
  }
  int tot = 10;
  for (int i = 1; i < S.size(); i++) {
    if (S[i] == '?') {
      REP(j, 14) REP(k, 10) {
        dp[i][(j + k * tot) % 13] += dp[i - 1][j];
        dp[i][(j + k * tot) % 13] %= MOD;
      }
    } else {
      REP(j, 14) {
        dp[i][(j + (S[i] - '0') * tot) % 13] += dp[i - 1][j];
        dp[i][(j + (S[i] - '0') * tot) % 13] %= MOD;
      }
    }
    tot *= 10;
    tot %= 13;
  }
  cout << dp[S.size() - 1][5] << endl;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

int main(){
    int x; cin >> x;
    int ans = 0;

    if(400 <= x && x <= 599){
        ans = 8;
    }else if(600 <= x && x <= 799){
        ans = 7;
    }else if(800 <= x && x <= 999){
        ans = 6;
    }else if(1000 <= x && x <= 1199){
        ans = 5;
    }else if(1200 <= x && x <= 1399){
        ans = 4;
    }else if(1400 <= x && x <= 1599){
        ans = 3;
    }else if(1600 <= x && x <= 1799){
        ans = 2;
    }else{
        ans = 1;
    }

    cout << ans << endl;


}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define fill(x,y) memset(x,y,sizeof(x))
#define name(x) #x
using namespace std;


const int INF = INT_MAX-100;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

int main() {
    
    string S;
    cin >> S;
    
    int len = S.size()%2;
    
    
    if ((S[0] == S[S.size()-1])^(len==1)){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }
    
    
    
    return 0;
}




Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

constexpr int INF = 1e9+7;
constexpr ll INFL = 9*1e18;

constexpr int dx[4] = { 1, 0, -1, 0 };
constexpr int dy[4] = { 0, 1, 0, -1 };

// constexpr int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
// constexpr int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

int inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
template<typename T>inline void print(T&& x){cout<<setprecision(32)<<x<<endl;}

int n,m;
vector<vector<int>> ab;
vector<map<int,int>> ans;
int dfs(int now,map<int,int> did){
  int res = 0;
  if(did.size() == n){
    return 1;
  }
  for(auto a : ab[now]){
    auto copy = did;
    if(copy[a])continue;
    copy[a]++;
    res += dfs(a,copy);
  }
  return res;
}


// TODO: write
int main() {
  cin>>n>>m;
  vector<vector<int>> a(n+1);
  rep(i,m){
    int a_i,b_i;
    cin>>a_i>>b_i;
    a_i--;b_i--;
    a[a_i].pb(b_i);
    a[b_i].pb(a_i);
  }
  ab = a;
  map<int,int> tmp;tmp[0]++;
  
  print(dfs(0,tmp));
  return 0;
}

Measured memory_bytes: 3580
#!/usr/bin/env python3

N = int(input().split()[0])
p_list = list(map(int, input().split()))
count = 0
for i in range(N):
    index = i + 1
    if index == p_list[i]:
        if i != 0 and i != N - 1:
            if p_list[i + 1] == index + 1:
                p_list[i] = p_list[i + 1]
                p_list[i + 1] = index
            else:
                p_list[i] = p_list[i - 1]
                p_list[i - 1] = index
        elif i != 0:
            p_list[i] = p_list[i - 1]
            p_list[i - 1] = index
        elif i != N - 1:
            p_list[i] = p_list[i + 1]
            p_list[i + 1] = index

        count += 1

ans = count
print(ans)


Measured memory_bytes: 14008
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int X,A,B;
    cin >> X >> A >> B;
    if(B<=X){
      cout << "delicious";
    }else if(B<=A+X){
      cout << "safe";
    }else{
      cout << "dangerous";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int n;

string s, t;

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

    int overlap = 0;

    for (int i = n; i >= 1; i--) {
        if (s.substr(n - i, i) == t.substr(0, i)) {
            overlap = i;
            break;
        }
    }

    cout << 2 * n - overlap << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
 int n,k;
  cin>>n>>k;
  if(k*2-1<=n){
    cout<<"YES"<<endl;}
  else{
    cout<<"NO"<<endl;}
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 3e7 + 5;
const int MOD = 1e9 + 7;




int main()
{
   ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
   int a, b ,c;
   cin >> a >> b >> c;
   cout << min(a*b,c) << endl;
   return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#define fin freopen("in.txt", "r", stdin);
typedef long long ll;
const int mod = 1e9+7;
const int maxn = 1e5+5;
ll fac[maxn];
ll quick_mod(ll a, ll b){
    ll ans = 1;
    while(b){
        if(b & 1) (ans *= a) %= mod;
        (a *= a) %= mod;
        b >>= 1;
    }
    return ans;
}
int n;
void pre_hand(){
    //预处理
    for(ll i = 1; i <= n; i++){
        fac[i] = (fac[i-1] + quick_mod(i, mod-2)) % mod;  //预处理1/1+1/2+...1/i的前缀和 
    }
}

int main(){
   // fin;
    scanf("%d", &n);
    pre_hand();
    ll x, res = 1, ans = 0;
    for(int i = 1; i <= n; i++){
        scanf("%lld", &x);
        ans = (ans + x * (fac[i] + fac[n-i+1] - 1 + mod) % mod) % mod;
        (res *= i) %= mod;    //res最终结果是n!
    }
    printf("%lld\n", ans * res % mod);
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; cin>>n;
	map<int, int> mp;
	for(int i = 0; i < (1<<n); i++){
		int x; cin>>x;
		mp[x]++;
	}
	vector<int> vec;
	int val = (*mp.rbegin()).first;
	vec.push_back(val);
	mp[val]--; if(!mp[val])mp.erase(val);
	for(int i = 0; i < n; i++){
		vector<int> nvec;
		for(auto x : vec){
			auto it = mp.lower_bound(x);
			if(it == mp.begin()){
				cout<<"No\n";
				exit(0);
			}
			it--; int val = it->first;
			nvec.push_back(x);
			nvec.push_back(val);
			mp[val]--; if(!mp[val])mp.erase(val);
		}
		sort(nvec.begin(), nvec.end());
		vec = nvec;
	}
	cout<<"Yes\n";

	return 0;
}

Measured memory_bytes: 14576
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;

int main(){
  ll n,ans=0;cin>>n;
  vll a(n),b(n);
  rep(i,0,n){
    ll x;cin>>x;
    a[i]=i-x;b[i]=i+x;
  }
  sort(b.begin(),b.end());
  rep(i,0,n){
    auto it=lower_bound(b.begin(),b.end(),a[i]);
    auto it2=upper_bound(b.begin(),b.end(),a[i]);
    ans+=it2-it;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 6420
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String keyboard = sc.next();
		char[] keychars = keyboard.toCharArray();
		
		String editer = "";
		for(char c:keychars) {
			switch(c) {
				case '0':
					editer += "0";
					break;
				case '1':
					editer += "1";
					break;
				case 'B':
					if(editer.length() == 0) {break;}
					editer = editer.substring(0,editer.length()-1);
			}
		}
		
		System.out.println(editer);
		sc.close();
		
	}

}

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

int main(){
  ll n;
  cin >>n;
  bool nine = true;
  int cnt = 0;
  while(n>=10){
    if(n%10!=9) nine = false;
    n /= 10;
    cnt++;
  }
  int ans = n+9*cnt;
  if(nine) cout << ans << endl;
  else cout << ans-1 << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back


int main()
{
    ll N, M;
    cin >> N >> M;
    vector<string> A(N), B(M);
    REP(i,0,N) cin >> A[i];
    REP(i,0,M) cin >> B[i];

    bool f = true;
    REP(i,0,N-M+1) {
        REP(j,0,N-M+1) {
            f = true;
            REP(k,0,M) {
                REP(l,0,M) {
                    if(A[i+k][j+l] != B[k][l]) {
                        f = false;
                        break;
                    }
                }
            }
            if(f) break;
        }
        if(f) break;
    }

    if(f) PR("Yes");
    else PR("No");

    return 0;
}

/*



*/

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int d = 0;
  if(a != b) ++d;
  if(b != c) ++d;
  if(c != a) ++d;
  
  if(d > 0){
    cout << d;
  }else{
    cout << 1;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
int n;
vector<vi> g;
int G(int v, int p) {
	int val = 0;
	for(auto i : g[v]) {
		if(i == p) continue;
		val ^= 1+G(i, v);
	}
	return val;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	g.resize(n+1);
	for(int f, t, i = 1; i < n; i++) {
		cin >> f >> t;
		g[f].pb(t);
		g[t].pb(f);
	}
	cout << (G(1, 1)?"Alice":"Bob");
}


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

using ll = long long; 
using P = pair<int,int>;

int main() {

  int N;
  cin >> N;

  int count = 0;
  int ans = 0;
  rep(i,N+1){
    count = 0;
    rep(j,i){
      if(i%(j+1)==0){
      count++;
      }
    }
    if (count==8 && i%2==1){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define P pair<int,int>
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
	int n;
	cin >> n;
	int a[n], b[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b, b + n);
	int tmp = b[n / 2];
	for (int i = 0; i < n; i++) {
		if (a[i] >= tmp) {
			cout << b[(n / 2) - 1] << endl;
		} else {
			cout << b[n / 2] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3712
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <vector>

using namespace std;

// #define DEBUG 1
#define DFILE "t1.1"

int main() {
  char s[5];
  char s1[3];
  char s2[3];

#ifdef DEBUG
#define cin fin
  fstream fin(DFILE);
#endif

  // int max_date[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  cin >> s;
  s1[0] = s[0];
  s1[1] = s[1];
  s1[2] = 0;
  s2[0] = s[2];
  s2[1] = s[3];
  s2[2] = 0;
  int d1, d2;
  sscanf(s1, "%d", &d1);
  sscanf(s2, "%d", &d2);
  // cout << d1 << " " << d2 << endl;
  int f1, f2;
  if (1 <= d1 && d1 <= 12) {
    f1 = true;
  } else {
    f1 = false;
  }
  if (1 <= d2 && d2 <= 12) {
    f2 = true;
  } else {
    f2 = false;
  }
  // cout << f1 << f2 << endl;
  if (f1 && f2) {
    cout << "AMBIGUOUS" << endl;
  } else if (f1 && !f2) {
    cout << "MMYY" << endl;
  } else if (!f1 && f2) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
double hh(double x,double xx,double y,double yy){
  double dx=x-xx;
  double dy=y-yy;
  return sqrt(dx*dx+dy*dy);
}

int main(){
  int n;
  cin>>n;
  vector<double> x(n);
  vector<double> y(n);
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
  }
  vector<int> ff(n);
  for(int i=1;i<=n;i++){
    ff[i-1]=i;
  }
  double ans=0;
  do{
        for(int i=0;i<n-1;i++){
        ans+=hh(x[ff[i]-1],x[ff[i+1]-1],y[ff[i]-1],y[ff[i+1]-1]);
        }
    }while(next_permutation(ff.begin(),ff.end()));
  cout<<fixed << setprecision(10);
  double t=1;
  for(int i=1;i<=n;i++){
    t*=i;
  }
  cout<<ans/t<<endl;
}
    
  


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect_left
from heapq import heappush, heappop
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
c = [LIST() for _ in range(10)]
A = [LIST() for _ in range(H)]

dist = [[INF]*10 for _ in range(10)]
for i in range(10):
    for j in range(10):
        dist[i][j] = c[i][j]

graph = csr_matrix(dist)
dist_mat = floyd_warshall(graph, directed=True)

ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] != -1:
            ans += dist_mat[A[i][j]][1]
print(int(ans))


Measured memory_bytes: 18584
#include<iostream>
#include<string>
#include<stack>
#include<cstdlib>
 
 
int main(){
 
  std::stack<int> st;
  std::string str;
  int a,b;
  while(std::cin>>str){
     
   if(str=="+"){
     a=st.top(); st.pop();
      b=st.top(); st.pop();
      st.push(a+b);
    }else if(str=="-"){
      a=st.top(); st.pop();
      b=st.top(); st.pop();
      st.push(b-a);
    }else if(str=="*"){
      a=st.top(); st.pop();
      b=st.top(); st.pop();
      st.push(a*b);
   }else{
     st.push(atoi(str.c_str())); 
   }
   }
     std::cout<<st.top()<<std::endl;
    
   }


Measured memory_bytes: 3156
package main

import "fmt"

func main() {
	var m int64
	fmt.Scan(&m)

	for n := int64(1); n <= 3500; n++ {
		for w := int64(1); w <= 3500; w++ {
			d := 4*n*w - m*(w+n)
			if d != 0 && m*n*w%d == 0 {
				h := m * n * w / d
				if h > 0 {
					fmt.Println(h, n, w)
					return
				}
			}
		}
	}
}


Measured memory_bytes: 512
N=int(input())
H=list(map(int,input().split()))
flg=True
for i in range(N-1):
    if H[i]<H[i+1]:
        H[i+1]-=1
    if H[i]>H[i+1]:
        flg=False
        break
print('Yes' if flg else 'No')

Measured memory_bytes: 14252
#include <iostream>
int MAX_DAY[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

class Data{
public:
	Data(int _year, int _month, int _day)
		: year(_year), month(_month), day(_day){}
	void add(){
		if(year%4 == 0){
			if(year%100 != 0 || year%400 == 0)
				MAX_DAY[2] = 29;
		}
		else
			MAX_DAY[2] = 28;
		if(day < MAX_DAY[month])day++;
		else{
			year += month / 12;
			month = month%12 + 1;
			day = 1;
		}
	}

	bool equals(Data d){
		return (d.year == year && d.month == month && d.day == day);
	}
	int year, month, day;
};

int main(){
	int y0, m0, d0, y1, m1, d1;
	while(std::cin >> y0 >> m0 >> d0 >> y1 >> m1 >> d1, y0 != -1){
		Data a = Data(y0, m0, d0), b = Data(y1, m1, d1);
		int count = 0;
		while(!a.equals(b)){
			a.add();
			count++;
		}
		std::cout << count << std::endl;
	}
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

int main(){
	string sA, sB;
	char before;
	int cntA = 0, cntB = 0;
	cin >> sA;
	sB = sA;

	before = '0';
	rep(i, sA.length()){
		if (sA[i] == before){
			++cntA;
			// cout << sB[i] << ", ";
			sA[i] = (before == '0' ? '1' : '0');
			// cout << sB[i] << ", " << i << ", " << cntB << endl;
		}
		before = sA[i];
	}

	before = '1';
	rep(i, sB.length()){
		if (sB[i] == before){
			++cntB;
			// cout << sB[i] << ", ";
			sB[i] = (before == '0' ? '1' : '0');
			// cout << sB[i] << ", " << i << ", " << cntB << endl;
		}
		before = sB[i];
	}

	// cout << "A: " << cntA << endl;
	// cout << "B: " << cntB << endl;
	cout << (cntA < cntB ? cntA : cntB) << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int sum = 0;
  rep(i, 3001){
    rep(j, 3001){
      if(n == i*r+j*g) sum++;
      if(n > i*r+j*g){
      	if((n-(i*r+j*g)) % b == 0) sum++;
      }
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()
count=0
for i in range(n):
    for j in range(i+1,n):
        x=l[i]+l[j]
        idx=bisect.bisect_left(l,x,j+1,n)
        count+=idx-j-1
        #print(idx,l[idx-1],x,idx-j-1)
print(count)

Measured memory_bytes: 43868
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int n;
int a[101],b[101];
vector<int> c,ans;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>b[i];
        c.push_back(b[i]);
    }
    for(int i=1;i<=n;i++){
        bool ok=0;
//        for(int j=0;j<c.size();j++)
//            cout<<c[j]<<" ";
//        cout<<endl;
        for(int j=n-i;j>=0;j--){
            if(c[j]==j+1){
                ok=1;
                ans.push_back(j+1);
                c.erase(c.begin()+j);
                break;
            }
        }
        if(ok==0){
            cout<<"-1"<<endl;
            return 0;
        }
    }
    reverse(ans.begin(),ans.end());
    for(int i=0;i<n;i++)
        cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int H, W;
	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0) {
			break;
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll k, n;
ll a[200005];
ll ans = 4e18;

int main()
{
    scanf("%lld%lld", &k, &n);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
    }
    for(ll i = 0; i < n; i++)
    {
        ans = min(ans, k - a[i + 1] + a[i]);
    }
    ans = min(ans, a[n - 1] - a[0]);
    cout<<ans<<endl;
    return 0;
}


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

int const MAX = 10000;
int const NIL = -1;

struct Node {int parent, left, right;};

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){ //引数u はノード番号　d = depth
  if(u == NIL ) return;
  D[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right, d+1);
}

int setHeight(int u) { 
  int h1 = 0, h2 = 0;
  if(T[u].left != NIL) h1 = setHeight(T[u].left) + 1;
  if(T[u].right != NIL) h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1: h2);  
}

int getSibling(int u){
  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
    return T[T[u].parent].right;
    return NIL; 
}

void print( int u ){
    cout << "node " << u << ": ";
  cout << "parent = " << T[u].parent << ", ";
  cout << "sibling = " << getSibling(u) << ", ";

  int deg = 0;
  if(T[u].left != NIL) deg++;
  if(T[u].right != NIL) deg++;

  cout << "degree = " << deg << ", ";  
  cout << "depth = " << D[u] << ", ";
  cout << "height = " << H[u] << ", ";

  if( T[u].parent == NIL ) cout << "root\n";
  else if( T[u].left == NIL && T[u].right == NIL) cout << "leaf\n";
  else cout << "internal node\n";
}

int main(){
  int v, l, r, root = 0;
  cin >> n; //How many nodes
  rep(i,n) T[i].parent = NIL;

  rep(i,n){
    scanf("%d %d %d", &v, &l, &r);
    T[v].left = l;
    T[v].right = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }

  rep(i,n){
    if(T[i].parent == NIL)root = i; //根ノードを探す
  }

  setDepth(root,0); //根ノードを親として子供を数えて深さを取得
  setHeight(root);
  
  rep(i,n) print(i); //入力された順番に出力

  return 0;
}


Measured memory_bytes: 3252
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			String input[] = br.readLine().split("\\s+");

			BigInteger A = new BigInteger(input[0]);
			BigInteger B = new BigInteger(input[1]);

			BigInteger ans;

			ans = A.multiply(B);
			System.out.println(ans);

		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}
}




Measured memory_bytes: 25040
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
  cin>>s;
  if(s.at(0)==s.at(1)&&s.at(2)==s.at(3)&&s.at(0)!=s.at(2)){
    cout<<"Yes"<<endl;  
  }
  else  if(s.at(0)!=s.at(1)&&s.at(0)==s.at(2)&&s.at(1)==s.at(3)){
    cout<<"Yes"<<endl;  
  }
   else  if(s.at(0)==s.at(3)&&s.at(1)==s.at(2)&&s.at(0)!=s.at(2)){
    cout<<"Yes"<<endl;  
  }
  else{cout<<"No"<<endl;}
}


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

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    if (N % 2 == 1){
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < N/2; i++) {
        if (S[i] != S[i+N/2]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    ll N;
    cin >> N;

    vector<pair<ll,ll>> A(N);
    for (int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        A[i] = {a, i};
    }

    sort(all(A));
    reverse(all(A));
    vector<ll> ans(N);
    ans[A[0].second] = A[1].first;
    for (int i = 1; i < N; i++) {
        ans[A[i].second] = A[0].first;
    }

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




    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 6272
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int a, b;
	cin >> a >> b;

	cout << max(max(a + b, a - b), a * b) << endl;

}

Measured memory_bytes: 256
#include<cstdio>
#define RI register int
#define CI const int&
using namespace std;
const int N=100005;
int n,q,a[N],b[N],c[N],cur; long long m;
class UnionFindSet
{
	private:
		int fa[N];
	public:
		inline void init(void)
		{
			for (RI i=1;i<=n;++i) fa[i]=i;
		}
		inline int getfa(CI x)
		{
			return x!=fa[x]?fa[x]=getfa(fa[x]):x;
		}
		inline void Union(int x,int y)
		{
			x=getfa(x); y=getfa(y); if (x!=y) fa[x]=y;
		}
		inline bool identify(CI x,CI y)
		{
			return getfa(x)==getfa(y);
		}
}S;
int main()
{
	RI i; for (scanf("%d%lld%d",&n,&m,&q),S.init(),i=1;i<=q;++i)
	{
		scanf("%d%d%d",&a[i],&b[i],&c[i]); ++a[i]; ++b[i];
		if (!c[i]) S.Union(a[i],b[i]); if (m==n-1&&c[i]) return puts("No"),0;
	}
	if (m==n-1) return puts("Yes"),0; for (i=1;i<=q;++i)
	if (c[i]&&S.identify(a[i],b[i])) return puts("No"),0;
	for (i=1;i<=n;++i) cur+=S.getfa(i)==i;
	return puts(m<=n+(1LL*cur*(cur-3)>>1)?"Yes":"No"),0;
}

Measured memory_bytes: 1664