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

int main(){
	int n;
    scanf("%d", &n);
	int h[n], cost[n] = {0};
    for(int i=0;i<n;i++){
    	scanf("%d", &h[i]);
    }
    if(n>1)cost[1] = abs(h[1] - h[0]);
    for(int i=2;i<n;i++){
    	cost[i] = min(cost[i-1] + abs(h[i] - h[i-1]), cost[i-2] + abs(h[i] - h[i-2]));
    }
	printf("%d\n", cost[n-1]);
    return 0;
}

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

auto solve() {
    int d, n;
    cin >> d >> n;

    if(n == 100) {
        n++;
    }
    cout << n;
    for(int i=0; i<d; i++) {
        cout << "00";
    }
    cout << endl;
}


int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
 
int gcd( int x, int y )
{
    int t;
    while( 0 < y ) {
        t = y;
        y = x % y;
        x = t;
    }
     
    return x;
}
 
int main( )
{   
    int x, y;
      
    scanf( "%d%d", &x, &y );
      /*
    int t;
    if( y < x ) {
        t = x;
        x = y;
        y = t;
    }
      */
    printf( "%d\n", gcd( x, y ) );
     
    return 0;
}

Measured memory_bytes: 1812
#include<iostream>
#include<cmath>

using namespace std;

char getMoveChar1(int path){
    switch(path){
        case 1:
            return 'U';
        case 2:
            return 'D';
        case 3:
            return 'U';
        case 4:
            return 'D';
    }
}

char getMoveChar2(int path){
    switch(path){
        case 1:
            return 'R';
        case 2:
            return 'L';
        case 3:
            return 'R';
        case 4:
            return 'L';
    }
}


int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dy = ty - sy;
    int dx = tx - sx;
    for(int path=1; path<=4; path++){
            int len1 = dy;
            int len2 = dx;
            if(path == 3){
                len1++;
                len2++;
                cout << 'L';
            }else if(path == 4){
                len1++;
                len2++;
                cout << 'R';
            }
            for(int i=0; i<len1; i++){
                cout << getMoveChar1(path);
            }
            for(int i=0; i<len2; i++){
                cout << getMoveChar2(path);
            }
            if(path == 3){
                cout << 'D';
            }else if(path == 4){
                cout << 'U';
            }
    }
}



Measured memory_bytes: 3104
// A - Grouping
#include <bits/stdc++.h>
using namespace std;

int main(){
	int x,y; cin>>x>>y;

	int x_group = 0;
	int y_group = 0;

	if(x==1
	|| x==3
	|| x==5
	|| x==7
	|| x==8
	|| x==10
	|| x==12
	) x_group = 1;

	if(y==1
	|| y==3
	|| y==5
	|| y==7
	|| y==8
	|| y==10
	|| y==12
	) y_group = 1;

	if(x==4
	|| x==6
	|| x==9
	|| x==11
	) x_group = 2;

	if(y==4
	|| y==6
	|| y==9
	|| y==11
	) y_group = 2;

	if(x==2
	) x_group = 3;

	if(y==2
	) y_group = 3;

	cout<< (x_group == y_group? "Yes":"No") <<endl;

}

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

int main() {
  int n,maxi,sub,l;
  cin >> n;
  cin >> sub;
  maxi = sub;
  l = sub;
  for(int i = 1; i < n; i++){
    cin >> sub;
    maxi = max(maxi,sub);
    l += sub;
  }
  if(maxi * 2 < l)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
ans = []

def dfs(keta, value):
    ans.append(value)
    if keta == 10:
        return

    for j in range(-1, 2):
        add = (value % 10) + j
        if add >= 0 and add <= 9:
            dfs(keta+1, value * 10 + add)

def solve_D():
    k = int(input())
    for i in range(1, 10):
        dfs(1, i)
    ans.sort()
    return ans[k-1]


print(solve_D())

Measured memory_bytes: 19368
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include<iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;
const ll mod=1000000007;
/*pi*/const double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll n;cin>>n;
 string s;cin>>s;
 map<char,ll>map;
 rep(i,0,n)map[s[i]]++;
 char c;
 ll ans=1;
 rep(i,0,26){
  c='a'+i;
  map[c]++;
  ans*=map[c];
  ans%=mod;
 }
 ans--;
 pr(ans);
return 0;}


Measured memory_bytes: 3764
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <sstream>
#include <limits>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>
#define PI (acos(-1.0))
#define Abs(a) (((a)<0) ? (-(a)) :(a) )
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define Rep(i,n) for(int i=0;i<(n);i++)
#define Rrep(i,n) for(int i=((n)-1);i>=0;i--)
#define rrep(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define Pii pair<int,int>
#define PB push_back
#define Size(x) ((int)(x.size()))
using namespace std;
typedef long long mint;
typedef unsigned long long umint;
#define SZ 100005
vector<int> v[SZ];
int par[SZ];
bool vis[SZ];
//int curC[SZ], cc;
int c1 = -1, c2 = -1;
void dfs(int node)
{
    //cout <<"holla " << node << endl;
    if(node == -1)
    {
        throw runtime_error("err");
    }
    vis[node] = true;
    bool child = true;
    Rep(i, Size(v[node]))
    {
        int cur = v[node][i];
        if(!vis[cur])
        {
            /*if(node == 0)
            {
                //cout << cc <<"seit " << endl;
                cc = cur;
            }*/
            child = false;
            par[cur] = node;
            //cout << node <<" " << cur <<endl;
            dfs(cur);
        }
    }
    if(child)
    {
        //cout << "olla " << node << endl;
        //curC[cc] = node;
        if(c1 == -1)
        {
            c1 = node;
            throw runtime_error("holla");
        }
        else if(c2 == -1)
        {
            c2 = node;
            throw runtime_error("holla");
        }
    }
}
int main()
{
    //freopen("in.txt","r",stdin);
    int n,m;
    cin >> n >> m;
    int a,b;
    Rep(i,m)
    {
        scanf("%d%d",&a, &b);
        v[a - 1].PB(b - 1);
        v[b - 1].PB(a - 1);
    }
    par[0] = -1;
    try{
    dfs(0);
    }
    catch(...)
    {
        
    }
    int c = c1;
    vector<int> v1,v2;
    //cout << c1 << endl;
    int last = par[c1];
    while(c1 != -1)
    {
        for(int i = 0; i < v[c1].size(); i++)
        {
            if(v[c1][i] == c)
            {
                last = c1;
            }
        }
        c1 = par[c1];
    }
    //cout << last << endl;
    c1 = c;
    while(c1 != last)
    {
        v1.PB(c1);
        c1 = par[c1];
    }
    v1.PB(last);
    while(c1 != -1)
    {
        vis[c1] = false;
        c1 = par[c1];
    }
    //cout << last <<" k"<< endl;
    memset(par, -1, sizeof(par));
    try{
        dfs(last);
    }
    catch(...)
    {}
    //cout <<c1 <<endl;
    while(c1 != -1)
    {
        v2.PB(c1);
        c1 = par[c1];
    }
    vector<int>ans(v1);
    if(v2.size())
    {
        v2.pop_back();
    }
    Rrep(i, Size(v2))
    {
        ans.PB(v2[i]);
    }
    printf("%u\n", ans.size());
    Rep(i, Size(ans) - 1)
    {
        printf("%d ", ans[i] + 1);
    }
    cout << ans.back() + 1 << endl;
    return 0;
}




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

int main() {
    long long A, B, C; cin >> A >> B >> C;
    if (A % 2 && B % 2 && C % 2) {
        cout << min({A * B, A * C, B * C}) << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <climits>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(var) var.begin(), var.end()
#define input freopen("input", "r", stdin)
#define output freopen("output", "w", stdout)
#define Fast ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
typedef long long ll;
using namespace std;

int main(){
    int a,b; cin >> a >> b;
    cout << a*b << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n-h+1)*(n-w+1) << endl;
    return 0;
}

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

ll N;
ll A[202020];
ll B[202020];
ll C[202020];

void solve(){
  ll tmp = 0;
  rep(i, N){
    C[i] = B[i] * (B[i] - 1) / 2;
    tmp += C[i];
  }
  rep(i, N){
    ll a = A[i];
    ll b = B[a] - 1;
    ll ans = tmp - C[a] + (b >= 1 ? b*(b-1)/2 : 0);
    cout << ans << "\n";
  }
}


signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> N;
  rep(i, N){
    cin >> A[i];
    A[i]--;
    B[A[i]]++;
  }
  solve();
  return 0;
}




Measured memory_bytes: 6912
# -*- coding: utf-8 -*-
def CountingSort(array,maxval):
    m=maxval+1
    count=[0]*m
    for a in array:
        count[a]+=1
    i=0
    for a in range(m):
        for c in range(count[a]):
            array[i]=a
            i+=1
    return array

if __name__ == '__main__':
    maxval = 2000000
    n = int(input())
    a = [int(i) for i in input().split()]
    print(" ".join([str(s) for s in CountingSort(a,max(a))]))

Measured memory_bytes: 232836
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) a.begin(),a.end()
#define INF 1e9

int n;

int LIS(vector<int> v){
    vector<int> dp(n, INF);
    rep(i,n){
        *lower_bound(all(dp),v[i]) = v[i];
    }
    return lower_bound(all(dp),INF) - dp.begin();
}

vector<int> make(int a, int b){
    vector<int> v;
    b--;
    int mx = n, mn = 1, rem = n;
    bool modeA = true;
    while(rem){
        vector<int> seq;
        if(modeA){
            rep(i,a){
                seq.push_back(mx);
                mx--;
                rem--;
                if(rem==0)break;
            }
            a--;
            modeA = false;
        }else{
            rep(i,b){
                seq.push_back(mn);
                mn++;
                rem--;
                if(rem==0)break;
            }
            b--;
            modeA = true;
        }
        reverse(all(seq));
        v.insert(v.end(),all(seq));
    }
    return v;
}

int main(void){
    int a,b;
    cin>>n>>a>>b;
    vector<int> v = make(a,b);
    vector<int> rev = v;
    reverse(all(rev));
    if(LIS(v) == a && LIS(rev) == b){
        rep(i,n){
            printf("%d%c",v[i],(i<n-1 ? ' ' : '\n'));
        }
    }else{
        cout<<-1<<endl;
    }
    return 0;
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000
#define MAX_N 100010

int par[MAX_N]; // 親
int depth[MAX_N]; // 木の深さ

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

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

    // xとyの属する集合を併合
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return;

        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;

    }

    // xとyが同じ集合に属するか否か
    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return -par[root(x)];
    }
};

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

  int n, m;
  cin >> n >> m;
  int p[n];
  rep(i, 0, n) {
    cin >> p[i];
    p[i]--;
  }
  UnionFind uf(n);
  rep(i, 0, m) {
    int x, y;
    cin >> x >> y;
    uf.unite(p[--x], p[--y]);
  }
  int rsl = 0;
  rep(i, 0, n) {
    if(p[i] == i or uf.same(i, p[i])) rsl++;
  }
  cout << rsl << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    map<string,int> mp;
    REP(i,n){
        string s;cin >> s;
        mp[s]++;
    }
    string t[4]={"AC","WA","TLE","RE"};
    REP(i,4){
        cout << t[i] << " x " << mp[t[i]] << endl;
    }
}

Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    ll n,a; cin >>n>>a;
    vector<ll> x(n); REP(i,n) cin >> x[i];

    for (ll i = 0; i < n; i++) {
        x[i] -= a;
    }

    vector<vector<ll> > dp(n+1, vector<ll>(5001, 0));
    dp[0][2500] = 1;
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < 5001; j++) {
            if (j - x[i] >= 0) {
                dp[i+1][j] = dp[i][j - x[i]] + dp[i][j];
            } else {
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    cout << dp[n][2500]-1 << endl;

    return 0;
}





Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
for (int i = 0; i < N; i++)
  {
    B.at(i) = A.at(i);
  }
  sort(B.begin(), B.end());
for (int i = 0; i < N; i++)
  { 
    if (B.at(N-1) == A.at(i))
    {
       cout << B.at(N-2) << endl;
    }
    else
    {
       cout << B.at(N-1) << endl; 
    }
  }

}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
int x[25],y[25],r[25],c[25];
int max_del;
int isVisit[1<<24];
bool can_delete(int t,int sid){
	bool ret=1;
	for(int i=0;i<t;i++){
		if(!(sid>>i&1)){
			int dis=(x[i]-x[t])*(x[i]-x[t])+(y[i]-y[t])*(y[i]-y[t]);
			if(dis<(r[i]+r[t])*(r[i]+r[t]))ret=0;
		}
	}
	return ret;
}

int num_deleted(int sid){
	int ret=0;
	while(sid){
		if(sid&1)ret++;
		sid=sid>>1;
	}
	return ret;
}

void dfs(int sid){
	max_del=max(max_del,num_deleted(sid));
	for(int i=0;i<n-1;i++){
		if(((!(sid>>i&1))&&can_delete(i,sid))){
			for(int j=i+1;j<n;j++){
				
				//cout<<sid<<endl;
				if((!(sid>>j&1))&&can_delete(j,sid)){
					if(c[i]==c[j]){
						int newsid=(sid|1<<i|1<<j);
						if(isVisit[newsid]==0){
							isVisit[newsid]=1;
							dfs(newsid);
						}
					}
				}
			}
		}
	}
}

int main(){
	while(1){
		cin>>n;
		if(n==0)break;
		max_del=0;
		REP(i,n)
			cin>>x[i]>>y[i]>>r[i]>>c[i];
		/*for(int i=0;i<n;i++){
				cout<<can_delete(i)<<endl;
		}*/
		REP(i,1<<24){
			isVisit[i]=0;
		}
		isVisit[0]=1;
		dfs(0);
		cout<<max_del<<endl;
	}
	return 0;
}


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

const int MAX_H = 2020;
const int MAX_W = 2020;

char grid[MAX_H][MAX_W];
int up[MAX_H][MAX_W], down[MAX_H][MAX_W], l[MAX_H][MAX_W], r[MAX_H][MAX_W];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> grid[i][j];
        }
    }
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (grid[i][j] == '#') continue;
            up[i][j] = up[i - 1][j] + 1;
            l[i][j] = l[i][j -1] + 1;
        }
    }
    for (int i = H; i >= 1; i--) {
        for (int j = W; j >= 1; j--) {
            if (grid[i][j] == '#') continue;
            down[i][j] = down[i + 1][j] + 1;
            r[i][j] = r[i][j + 1] + 1;
        }
    }
    int ans = 0;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (grid[i][j] == '#') continue;
            ans = max(ans, up[i][j] + down[i][j] + l[i][j] + r[i][j] - 3);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

vector <int> h;

int main(){
#ifdef HOME
    freopen("input.txt", "rt", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    h.resize(n);
    for (int i = 0; i < n; i++)
        cin >> h[i];
    h[0]--;
    for (int i = 1; i < n; i++){
        if (h[i - 1] - h[i] >= 1){
            cout << "No";
            return 0;
        }
        else if (h[i - 1] < h[i]){
            h[i]--;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<queue>
#include<set>
#include<climits>
using namespace std;

int main()
{
  long long n, max, min;
  cin >> n;
  vector<long long> v(n, 0);
  vector<long long> t(n, 0);

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

    if (i == n / 2)
      min = v[i];
    if (i == (n / 2) + 1)
      max = v[i];
  }

  t = v;

  sort(t.begin(), t.end());

  min = t[n / 2 - 1];
  max = t[n / 2];

  for (int i = 0; i < n; i++)
  {
    if (v[i] <= min)
      cout << max << endl;
    else if (v[i] >= max)
      cout << min << endl;
  }

}


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

int main(){
  int n,m;
  cin >>n >>m;
  int p;
  string s;
  int t[n+10]={0};//errorカウンター
  int u[n+10]={0};//正答チェッカー
  rep(i,m){
    cin>>p>>s;

    if(u[p-1])continue;
    if(s=="AC"){
  //    cout<<"AC入力"<<endl;
      u[p-1]=1;
    }
    else {
  //    cout<<p[i]<<"  "<<u[p[i]]<<endl;
      if (!u[p-1])t[p-1]+=1;
    }
  }
  int sum_A =0;
  int sum_e =0;
  rep(i,n){
    sum_A += u[i];
    if(u[i])sum_e += t[i];
  }
  cout <<sum_A<<" "<<sum_e<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    vi h(n);
    rep(i, n) cin >> h[i];

    int res = 0;
    int m = -1;

    rep(i, n) {
        m = max(m, h[i]);
        if (m == h[i]) res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}

int main(){
    int n;cin >> n;
    vector<P> R(n),B(n);
    for(int i=0;i<n;i++) cin >> R[i].first >> R[i].second;
    for(int i=0;i<n;i++) cin >> B[i].first >> B[i].second;
    sort(R.begin(),R.end());
    sort(B.begin(),B.end());
    vector<int> ng;
    int ans=0;
    for(int i=0;i<n;i++){
        vector<P> list;
        for(int j=0;j<n;j++){
            if(B[i].first>R[j].first&&B[i].second>R[j].second){
                list.push_back(P(R[j].second,j));
            }
        }
        sort(list.rbegin(),list.rend());
        for(auto num: list){
            //cout << "要素" << num.first << " " << num.second << endl;
            bool ok=true;
            for(int j=0;j<ng.size();j++){
                if(ng[j]==num.second) ok=false;
            }
            if(!ok) continue;
            ng.push_back(num.second);
            ans++;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
long long n,a[6],ans;
string s[200000];
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) cin>>s[i];
	for(int i=1;i<=n;i++){
		if(s[i][0]=='M') ++a[1];
		if(s[i][0]=='A') ++a[2];
		if(s[i][0]=='R') ++a[3];
		if(s[i][0]=='C') ++a[4];
		if(s[i][0]=='H') ++a[5];
	}
	ans+=a[1]*a[2]*a[3];
	ans+=a[1]*a[2]*a[4];
	ans+=a[1]*a[2]*a[5];
	ans+=a[1]*a[3]*a[4];
	ans+=a[1]*a[3]*a[5];
	ans+=a[1]*a[4]*a[5];
	ans+=a[2]*a[3]*a[4];
	ans+=a[2]*a[3]*a[5];
	ans+=a[3]*a[4]*a[5];
	ans+=a[2]*a[4]*a[5];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
int n,m;
int s[20][20];
int p[20];
int ans;
int sta[20];
void dfs(int id)
{
	if(id==n+1)
	{
		//	for(int i=1;i<=n;i++)
		//		cout<<sta[i]<<" ";
		//	cout<<endl;
		int flag=true;
		for(int i=1;i<=m;i++)
		{
			int ii=0;
			for(int j=1;j<=s[i][0];j++)
			{
				if(sta[s[i][j]])
					ii++;
			}
			if(ii%2!=p[i])
			{
				flag=0;
				break;
				//for(int i=1;i<=n;i++)
				//	cout<<sta[i]<<endl;
			}
		}
		if(flag)
		{
			ans++;
			
		}
		return;
	}
	sta[id]=0;
	dfs(id+1);
	sta[id]=1;
	dfs(id+1);
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>s[i][0];
		for(int j=1;j<=s[i][0];j++)
		{
			cin>>s[i][j];
		}
	}
	for(int i=1;i<=m;i++)
	{
		cin>>p[i];
	}
	dfs(1);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main
{
	public static void main(String as[])
    {
		String a;
        Scanner sc=new Scanner(System.in);
      String es="es";
      String s="s";
      	a=sc.nextLine();
      if(a.charAt(a.length()-1)=='s')
      {
      //  a=a.substring(0,a.length()-1);
        a+=es;
      }
      else
        a+=s;
      System.out.println(a);
    }
}

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

int main()
{
    int N;
    cin >> N;
    if(N%2==1){
        N++;
    }cout << N/2 << endl;
}


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code
int a[4];

int main()
{
  string s;
  cin>>s;
  rep(i, 0, s.length())
  {
    a[i] = s[i] - '0';
  }
  rep(i, 0, 8)
  {
    int ans = 0;
    char op1, op2, op3;
    if((i & (1<<2))) ans += (a[0] + a[1]), op1 = '+';
    else ans += (a[0] - a[1]), op1 = '-';
    if((i & (1 << 1))) ans += a[2], op2 = '+';
    else ans -= a[2], op2 = '-';
    if((i & (1 << 0))) ans += a[3], op3 = '+';
    else ans -= a[3], op3 = '-';
    //cout<<ans<<endl;
    if(ans == 7)
    {
      cout<<s[0]<<op1<<s[1]<<op2<<s[2]<<op3<<s[3]<<'='<<ans<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
	int R[MAX], n;

	cin >> n;
	for (int i = 0; i < n; i++) cin >> R[i];

	int maxv = -2000000000;
	int minv = R[0];

	for (int i = 1; i < n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}

	cout << maxv << endl;

	return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vst;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=(1e+9)+7;
const ll inf=1e+16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

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

 ll x;
  cin >> x;
 ll m=x/100;
  
  bool flag=false;
 rep(i,0,m+1){
  ll y=x;
   y-=i*100;
   if(y>=0&&y<=5*i) {
     flag=true;
     break;
   }
   }  
  
  if(flag) cout << 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] H = new int[N];
		int ans = 1;
		System.out.println();
		H[0] = sc.nextInt();
		int flg = H[0];
		for(int i = 1;i<N;i++){
			H[i]= sc.nextInt();
			if(flg<=H[i]){
				flg = H[i];
 				ans++;
			}
		}
		System.out.println(ans);
	}
}

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

#define endl '\n'
#define ll long long
#define ld long double
#define fi first
#define se second
#define MP make_pair
#define pii pair<int, int>
#define pll pair<long long, long long>
#define mod (ll) (1e9 + 7)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) v.begin(), v.end()
#define dvec(v) for(auto i: v) cout << i << " "; cout << '\n';
#define gcd(a,b) __gcd(a, b)
#define lcm(a,b) ((a)*((b)/gcd(a,b)))
#define darr(a,n) for(int i=0; i<n;i++) cout << a[i] << " "; cout << '\n';
#define what_is(x) cerr << #x << " : " << x << '\n';


int main() {
    fast;
    int n, k;
    cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    vector<int> dp(n+1, INT_MAX);
    dp[1] = 0;
    dp[2] = abs(h[0] - h[1]);

    for (int i = 3; i <= n; i++) {
        for (int step = 1; step <= k; step++) {
            if (i-1-step < 0) continue;
            dp[i] = min(dp[i], dp[i-step] + abs(h[i-1-step] - h[i-1]));
        }
    }
    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

// 2 ** 40 = 1024 ** 4 ~ 10 ** 12
// cnts[j] ... count of 1 in each bit of A. The bit is counted from left.
// e.g. 100 -> [1, 0, 0]
ll cnts[40];

// lower_bits[j] .. Represetns which should be in j bits.
ll lower_bits[40];

int main(int argc, char** argv) {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) {
    cin >> A[i];
  }

  // At first, we want to calculate the count of 1 in each bit.
  // Then, lefter bit should be the other bit. (e.g. If 1 is smaller in j bit, then the j bit of X should be 1.)
  rep(i, N) {
    rep(j, 40) {
      if ((A[i] >> (39 - j)) & 1) {
        ++cnts[j];
      }
    }
  }
  rep(j, 40) {
    if (cnts[j] > N / 2) { // The count of 1 is larger
      lower_bits[j] = 0;
    } else { // The count of 0 is larger
      lower_bits[j] = 1;
    }
  }

  // Here, if K is INF, the result is represented by lower_bits.
  // But, we have the limitation of X <= K, so check that "current X is equal or lower than K".
  ll X = 0;
  rep(j, 40) {
    ll d = lower_bits[j] << (39LL-j);
    if ((X + d) <= K) {
      X += d;
    }
  }

  // Now, f(X) is the answer.
  ll ans = 0;
  rep(i, N) {
    ans += X ^ A[i];
  }

  cout << ans << endl;
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  long long int n,k;
  double ans=0;
  cin>>n>>k;
  vector<int> v(n);
  for(int i=1;i<=n;i++){
    int a=i,count=0;
    while(a<k){
      a*=2;
      count++;
    }
    v[i-1]=count;
  }
  for(int i=0;i<n;i++){
    ans+=(double)pow(0.5,v[i]);
  }
  cout<<setprecision(10)<<(double)ans/n<<endl;
}
///////////////////////////



Measured memory_bytes: 640
#include <bits/stdc++.h>
 using namespace std;
 typedef long long ll;
 
 const ll mod = 1e9 + 7;
 
 ll modpow(ll n, ll k) {
     if (k == 0) return 1;
     if (k == 1) return n;
 
     if (k % 2 == 0) {
         ll root = modpow(n, k / 2);
         return root * root % mod;
     } else {
         return n * modpow(n, k - 1) % mod;
     }
 }
 
 ll comb(ll n, ll k) {
     ll mul = 1;
     ll div = 1;
 
     for (ll i = 0; i < k; i++) {
         mul *= n - i;
         mul %= mod;
 
         div *= i + 1;
         div %= mod;
     }
 
     ll ans = mul * modpow(div, mod - 2) % mod;
     return ans;
 }
 
 int main() {
     ll n, a, b; cin >> n >> a >> b;
 
     ll ans = modpow(2, n) - 1;
     ans -= comb(n, a);
     if(ans<0) ans += mod;
     ans -= comb(n, b);
 
     if (ans < 0) ans += mod;
 
     cout << ans << endl;
 }

Measured memory_bytes: 256
def main():
    D, G, *pc = map(int, open(0).read().split())
    p = pc[::2]
    c = pc[1::2]
    ans = 1e9 + 7
    # コンプリート
    comp = [c[i] + 100 * (i + 1) * p[i] for i in range(D)]
    # 2 ** D - 1 まで
    for b in range(2 ** D):
        num = 0
        pnt = 0
        # コンプリートしない MAX
        x = None
        # 得点が高い方から
        for i in range(D - 1, -1, -1):
            # i 番目 の フラグ が 立っている
            if b >> i & 1:
                num += p[i]
                # コンプリートする
                pnt += comp[i]
            elif x is None:
                x = i
        # コンプリート オール
        # または 既に 目標の 総合スコア に到達
        if x is None or G <= pnt:
            ans = min(ans, num)
        # コンプリートしない MAX で 目標の 総合スコア に到達
        elif G < (100 * (x + 1)) * p[x] + pnt:
            ans = min(ans, num - (-(G - pnt) // (100 * (x + 1))))
    print(ans)
    return


main()


Measured memory_bytes: 3064
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m;
vector<int> a;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    while(n){
      if(n%10==9)return yes,0;
      n/=10;
    }
  	no;
}


Measured memory_bytes: 256
#![allow(unused_imports)]

use std::cmp::{max, min};
use std::collections::{HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let _n: usize = input().unwrap();
    let a: Vec<usize> = input_vec().unwrap();

    let mut continuous = Vec::new();
    let mut count = 0;
    for (i, e) in a.iter().enumerate() {
        if i + 1 == *e {
            count += 1;
        } else {
            continuous.push(count);
            count = 0;
        }
    }
    continuous.push(count);

    // dbg!(&continuous);

    let ans = continuous.iter().map(|&x| (x + 1) / 2).sum::<usize>();
    println!("{}", ans);
}

pub fn input<T: FromStr>() -> Result<T, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    Ok(buf.trim().parse().ok().unwrap())
}

pub fn input_vec<T: FromStr>() -> Result<Vec<T>, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    Ok(buf
        .trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>())
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}


Measured memory_bytes: 8444
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a))
#define Reverse(a) reverse(All(a))
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define Lower(a,t) lower_bound(All(a),t)
using namespace std;
int max_int = 1000000007;
void Debug(auto a);

int nibutan(vector<int> &a,int b){
    int x = Lower(a,b) - a.begin();
    return x;
}

signed main(){
    int n;
    cin >> n;
    vec(a,n);
    vec(b,n);
    vec(c,n);
    REP(i,n){
        cin >> a[i];
    }
    REP(i,n){
        cin >> b[i];
    }
    REP(i,n){
        cin >> c[i];
    }
    Sort(a);
    Sort(b);
    Sort(c);
    int ans = 0;
    REP(i,n){
        int x = nibutan(a,b[i]);
        int y = n - nibutan(c,b[i]+1);
        ans += x*y;
		
    }
    cout << ans << endl;
    
    return 0;
}



void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}


Measured memory_bytes: 2560
# -*- coding:utf-8 -*-
N = int(input())
a_list = list(map(int,input().split()))

Alice = 0
Bob = 0

a_list.sort(reverse=True)

for i in range(N):
    if i % 2 == 0:
        Alice += a_list[i]
    else:
        Bob += a_list[i]

print(Alice-Bob)


Measured memory_bytes: 9132
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

bool wf[101][101][101][101] = {}, bf[101][101][101][101] = {};
int dp[101][101] = {};
int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; ++i) cin >> s[i];
    for (int r = 0; r < h; ++r) {
        for (int c = 0; c < w; ++c) dp[r][c] = 1 << 29;
    }
    for (int r1 = 0; r1 < h; r1++) {
        for (int c1 = 0; c1 < w; c1++) {
            for (int r0 = 0; r0 <= r1; r0++) {
                for (int c0 = 0; c0 <= c1; c0++) {
                    if (s[r1][c1] == '.') {
                        bool f = wf[r0][c0][r1][c1] =
                            (r1 > r0 && wf[r0][c0][r1 - 1][c1]) || 
                            (c1 > c0 && wf[r0][c0][r1][c1 - 1]) ||
                            (r1 == r0 && c1 == c0);
                        if (f) {
                            if (r0 > 0) {
                                dp[r1][c1] = min(dp[r1][c1], dp[r0 - 1][c0]);
                            }
                            if (c0 > 0) {
                                dp[r1][c1] = min(dp[r1][c1], dp[r0][c0 - 1]);
                            }
                            if (r0 == 0 && c0 == 0) dp[r1][c1] = 0;
                        }
                    } else {
                        assert(s[r1][c1] == '#');
                        bool f = bf[r0][c0][r1][c1] =
                            (r1 > r0 && bf[r0][c0][r1 - 1][c1]) || 
                            (c1 > c0 && bf[r0][c0][r1][c1 - 1]) ||
                            (r1 == r0 && c1 == c0);
                        if (f) {
                            if (r0 > 0) {
                                dp[r1][c1] = min(dp[r1][c1], dp[r0 - 1][c0] + 1);
                            }
                            if (c0 > 0) {
                                dp[r1][c1] = min(dp[r1][c1], dp[r0][c0 - 1] + 1);
                            }
                            if (r0 == 0 && c0 == 0) dp[r1][c1] = 1;
                        }
                    }
                }
            }
        }
    }
    cout << dp[h - 1][w - 1] << endl;
    
    
    return 0;
}

Measured memory_bytes: 203008
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

#a,bの最大公約数
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a
#a,bの最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

N,M = map(int,readline().split())
A = list(map(int,readline().split()))

B = [A[i]//2 for i in range(N)]
ans = 1

dev_c = 0
while A[0]%2 != 1:
    A[0] = A[0]//2
    dev_c += 1
#print(dev_c)

for i in range(1,N):
    dev_c2 = 0
    while A[i]%2 != 1:
        A[i] = A[i]//2
        dev_c2 += 1
    if dev_c != dev_c2:
        ans = 0
        break

l = B[0]
if ans == 1:
    for i in range(N):
        l = lcm(l,B[i])

#print(l)

if ans != 0:
    ans = (M//l+1)//2

print(ans)

Measured memory_bytes: 58224
# ABC085C - Otoshidama
def main():
    N, Y = tuple(map(int, input().split()))
    Y //= 1000
    for i in range(N + 1):
        for j in range(N + 1 - i):
            k = N - i - j
            if i * 10 + j * 5 + k == Y:
                print(i, j, k)
                return
    print(-1, -1, -1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <cstdio>
using namespace std;

int p[2000000];
int id,q;
int k;

int parent(int i){
    if(i%2==0){
        return i/2;
    }else{
        return (i-1)/2;
    }
}

int left(int i){
    return 2*i;
}

int right(int i){
    return 2*i+1;
}

int inside(int i){
    if(i > id || i <= 0){
        return 0;
    }else{
        return 1;
    }
}

void maxHeapify(int i){
    if(inside(left(i))==0||(p[right(i)]<=p[i]&&p[left(i)]<=p[i])){
    }else{
        if(p[left(i)]>=p[right(i)]){
            q = p[left(i)];
            p[left(i)] = p[i];
            p[i] = q;
            maxHeapify(left(i));
        }else{
            q = p[right(i)];
            p[right(i)] = p[i];
            p[i] = q;
            maxHeapify(right(i));
        }
    }
}

void insert(int k){
    id++;
    int i = id;
    p[id] = k;
    for(;;){
        if(i != 1&&p[parent(i)]<=p[i]){
            q = p[parent(i)];
            p[parent(i)] = p[i];
            p[i] = q;
            i = parent(i);
        }else{
            break;
        }
    }
}

int extract(){
    int ret = p[1];
    p[1] = p[id];
    id--;
    maxHeapify(1);
    return(ret);
}

int main(){
    for(;;){
        char s_[100];
        scanf("%s", s_);
        string s = s_;
        if(s=="end"){
            break;
        }else if(s=="insert"){
            int k;
            scanf("%d", &k);
            insert(k);
        }else if(s=="extract"){
            printf("%d\n", extract());
        }
    }
    return 0;
}

Measured memory_bytes: 5320
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
const long long int mod = 1e9 + 7;
int main()
{
    int a, b ;
    cin >> a >> b;
    int del = b - a;
    int x = del * (del-1) / 2 - a;

    cout << x << endl;
}

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

ll rec(vector<ll> v[],ll dp[],ll n,ll m,ll s)
{
    if(dp[s]!=-1)
        return dp[s];
    dp[s]=0;
    ll p=dp[s];
    for(ll i=0;i<v[s].size();i++)
    {
            p=max(p,rec(v,dp,n,m,v[s][i])+1);
    }
    dp[s]=p;
    return p;
}

int main()
{
    ll n,m;
    cin>>n>>m;
    vector<ll> v[n+1];
    for(ll i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        v[x].push_back(y);
    }
    ll dp[n+1]={0};
    memset(dp,-1,sizeof(dp));
    for(ll i=1;i<=n;i++)
    {
        if(dp[i]==-1)
            ll p=rec(v,dp,n,m,i);
    }
    ll ans=0;
    /*for(ll i=1;i<=n;i++)
        cout<<dp[i]<<" ";
    cout<<endl;*/
    for(ll i=1;i<=n;i++)
        ans=max(ans,dp[i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9472
/*
      author  : nishi5451
      created : 14.08.2020 22:23:05
*/

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


int main(){
    int n,t,a;
    cin >> n >> t >> a;
    map<double,int> mp;
    rep(i,n){
        int h;
        cin >> h;
        double key = fabs(a-(t-h*0.006));
        mp[key]=i;
    }
    auto itr = mp.begin();
    cout << int(itr->second)+1 << endl;
    return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h> 
using namespace std; 
  
long long int countOrderedPairs(int N) 
{ 
    int count_pairs = 0; 
    for (int i = 1; i <= sqrt(N - 1); ++i) { 
        for (int j = i; j * i < N; ++j) 
            ++count_pairs; 
    } 
    count_pairs *= 2; 
    count_pairs -= int(sqrt(N - 1)); 
    return count_pairs; 
} 
int main(){
    long long int n;
    cin>>n;
    long long int res;
    res = countOrderedPairs(n);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> vp(n);
  rep(i, n){
    int a, b;
    cin >> a >> b;
    vp.at(i) = {a, b};
  }
  sort(ALL(vp));
  ll ans = 0;
  for(auto p : vp){
    if(m - p.second > 0){
      ans += (ll)p.first * p.second;
    }else{
      ans += (ll)p.first * m;
      break;
    }
    m -= p.second;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4028