akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

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

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}


int main() {
	int n;
	cin >> n;
	double ans = 0;
	rep(i, n) {
		double x; string u;
		cin >> x >> u;
		if (u == "BTC") ans += x * 380000.0;
		else ans += x;
	}
	cout << ans;
	return 0;
}










Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> ll size(const T &x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

int n;
int H[100100];
int mem[100100];
int dp(int at){
    if(at >= n){
        return 10000000;
    }
    if(at == n-1) return 0;
    if(mem[at] != -1) return mem[at];
    int ans = min(abs(H[at]-H[at+1])+dp(at+1), abs(H[at]-H[at+2])+dp(at+2));
    return mem[at] = ans;
}

int main()
{
    cin.sync_with_stdio(false);
    memset(mem, -1, sizeof(mem));
    cin >> n;
    rep(i,0,n) cin >> H[i];
    cout << dp(0) << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
int main(){
int i, j, size, a[100], key;
scanf("%d", &size);
for(i = 0; i < size; i++){
scanf("%d",&a[i]);
}
for(j = 0; j < size-1; j++){
printf("%d ",a[j]);
}
printf("%d\n", a[size-1]);
for(i = 1; i < size; i++){
key = a[i];
j = i-1;
while(j >= 0 && a[j] > key){
a[j+1] = a[j];
j--;
a[j+1] = key;
}
for(j = 0; j < size-1; j++){
  printf("%d ", a[j]);
}
printf("%d\n", a[size-1]);
}
return 0;
}


Measured memory_bytes: 2056
#define loop(i, s, e) for(ll i = s;i < e;i++)

#include <iostream>
#include <iomanip>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <map>
#include <cmath>
//#include "vector2d.cpp"

using namespace std;
//using namespace libcgl;
typedef long long signed ll;

ll n,a[100000];

pair<ll,ll> extgcd(ll a,ll b) {
    if(b == 0) return make_pair(1,0);
    ll c = a % b;
    ll s = a / b;
    auto g = extgcd(b,c);
    return make_pair(g.second,g.first - s * g.second);
}

ll invmod(ll mod,ll n) {
    auto g = extgcd(mod,n);
    return g.second;
}

int main() {
    cin >> n;
    loop(i,0,n) cin >> a[i];
    sort(a,a+n);
    auto l = lower_bound(a,a+(n-1),a[n-1]/2);
    if(*l == a[n-1]) cout << a[n-1] << " " << *(l-1);
    else if(*l == a[0]) cout << a[n-1] << " " << a[0];
    else if(abs((double)*l - ((double)a[n-1] / 2)) > abs((double)*(l-1) - ((double)a[n-1] / 2)) )
        cout << a[n-1] << " " << *(l-1);
    else cout << a[n-1] << " " << *l;
}



Measured memory_bytes: 1024
import sys
 
s= sys.stdin.readline().strip()
#
MOD=10**9+7
mmap= []
for i in range(6):
    b = 10**i % 13
    mmap.append( [ [ (b*i+j)%13 for i in range(1,10) ] for j in range(13) ] )
#
dp= [ 0 ] * 13
dp[0] = 1
j= 0
for c in reversed(s):
    tmp = dp.copy()
    #
    if c=="0": pass
    elif c=="?":
        bset = mmap[j]
        for m,num in enumerate(tmp):
            if num==0: continue
            for idx in bset[m]: dp[idx]+=num
        #
        for i in range(13): dp[i]%=MOD
    else:
        b= mmap[j][0][int(c)-1]
        for m in range(13):
            idx= (m+b)%13
            dp[idx]= tmp[m]
    #
    if j==5: j=0
    else: j+=1
#
print(dp[5])

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#include <stdio.h>
#define int long long
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt=1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
inline void shoki()
{
	srand((unsigned int)time(NULL));
}

/*Library End!*/
int n, a[100005],two,four;
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 4 == 0)four++;
		if (a[i] % 2 == 0)two++;
	}
	if (four * 2 + 1 >= n || four * 2 + (two - four) >= n)puts("Yes");
	else puts("No");
end:;
	system("PAUSE");
	return 0;
}



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

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;

    vector<int> perm(n), x(n), y(n);
    for (size_t i = 0; i < n; i++){
        perm[i] = i;
        cin >> x[i] >> y[i];
    }

    double ave = 0;
    int n_perm = 0;
    do {
        n_perm++;
        double d = 0;
        for (size_t i = 0; i < n-1; i++) {
            d += sqrt((x[perm[i+1]]-x[perm[i]]) * (x[perm[i+1]]-x[perm[i]]) + (y[perm[i+1]]-y[perm[i]]) * (y[perm[i+1]]-y[perm[i]]));
        }
        ave += d;
    } while(next_permutation(perm.begin(), perm.end()));
    ave /= n_perm;

    printf("%.10f\n", ave);
    return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 1000002
mt19937 myrand(time(0));

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(a[i]==a[j] || a[j]==a[k] || a[i]==a[k]) continue;
                if(a[i]>=(a[j]+a[k]) || a[j]>=(a[i]+a[k]) || a[k]>=(a[i]+a[j])) continue; 
                //debug()<<imie(i+1)imie(j+1)imie(k+1);
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
int main() {
  std::string s;
  std::cin>>s;
  
  long diff = 99999999999L;
  for(int i=0;i<s.length();i++) {
    int end = i+3;
    if(end>s.length()) {
    	continue;
    }
    int start = i;
    long sum = 0;
    for(int j=start;j<end;j++) {
    	sum=sum*10+s[j]-'0';
    }
    sum=sum-753;
    sum = sum<0?-sum:sum;
    diff=diff<sum?diff:sum;
  }
  std::cout<<diff;
  return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  int S;
  S = H * W;
  
  vector<string> pix(S);
  for (int i=0; i<S; i++) {
    cin >> pix.at(i);
  }
  
  for(int j=0; j<W+2; j++){
    cout << "#";
  }
  cout << endl;
  
  for(int k=0; k<H; k++){
    cout << "#";
      cout << pix.at(k);
    cout << "#" << endl;
  }
  
  
  for(int m=0; m<W+2; m++){
    cout << "#";
  }
  cout << endl;
}
  

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

#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
// using P = pair<ll, ll>;
const int dx[] = {0, 1, -1, 0};
const int dy[] = {1, 0, 0, -1};
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //////////////////////////////////////
  int n, m;
  cin >> n >> m;
  dsu d(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    d.merge(a, b);
  }
  map<int, int> mp;
  rep(i, n) mp[d.leader(i)]++;
  cout << mp.size() - 1 << endl;
  return 0;
}

Measured memory_bytes: 7692
// Last Change: 03/22/2020 21:18:48.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  long double L, hen;
  cin >> L;
  hen = L / 3;
  cout << std::fixed << std::setprecision(15) << hen * hen * hen << endl;
}


Measured memory_bytes: 888
def cp(a,b,c,d,e,f,g,h):
    A = a*d-b*c
    B = e*h-f*g
    C = d-b
    D = e-g
    E = c-a
    F = f-h
    det = C*D - E*F
    x = A*D + B*E
    y = A*F + B*C
    return [x/det,y/det]

q = int(input())
for i in range(q):
    a,b,c,d,e,f,g,h = [int(i) for i in input().split()]
    P = cp(a,b,c,d,e,f,g,h)
    print(P[0],P[1])

Measured memory_bytes: 7752
s=list(input())
t=list(input())
s.sort()
t.sort()
ss=''
tt=''
for i in range(len(s)):
    ss+=s[i]   
    
for i in range(len(t)):
    tt+=t[len(t)-1-i]
if ss<tt:
    print('Yes')
else:
    print('No')

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

int main() {
  int n; cin>>n;
  bool ans=false;
  rep(i, 1, 10) {
    rep(j, 1, 10) {
      if (i*j==n) ans=true;
    }
  }
  if (ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

int main(){
    ios::sync_with_stdio(false);    cin.tie(NULL);  cout.tie(NULL);
    int n;  cin >> n;   vector<long long int> vec(n);
    vector< vector<long long int> > dp(n, vector<long long int>(n));
    for(int i=0;n>i;i++){
        cin >> vec[i];
    }
    for(int left=n-1;left>=0;left--){
        for(int right=left;right<n;right++){
            if(right==left){
                dp[left][right]=vec[right]; continue;
            }
            dp[left][right]=max(vec[left]-dp[left+1][right], vec[right]-dp[left][right-1]);
        }
    }
    cout << dp[0][n-1];
}

Measured memory_bytes: 70784
#include <iostream>
#include <cstdio>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <set>
#include <vector>
using namespace std;
#define ll long long
const int maxx = 2005;
const ll mod = 1e9+7;
int a[maxx],b[maxx];
ll dp[maxx][maxx];
int n,m;
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=m;i++) scanf("%d",&b[i]);

    for(int i=1;i<=n;i++){
        ll cnt = 0;
        for(int j=1;j<=m;j++){
            cnt += dp[i-1][j] , cnt %= mod;
            if(a[i] == b[j]){
                dp[i][j] = cnt + 1 , dp[i][j] %= mod;
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    ll ans = 1;
    for(int i=1;i<=m;i++){
        //cout<<dp[n][i]<<endl;
        ans += dp[n][i] , ans %= mod;
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007

int main() {
    int n,h,w;cin>>n>>h>>w;

    cout<<(n-w+1)*(n-h+1)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) (((long long)mod_x)%modulo)


int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<int> S(N),T(M);
	
	for(int i=0;i<N;i++)cin>>S[i];
	for(int i=0;i<M;i++)cin>>T[i];
	
	vector<vector<int>> dp(N+1,vector<int>(M+1,0));
	dp[0][0] = 1;
	for(int i=1;i<=N;i++){
		for(int j=1;j<=M;j++){
			if(S[i-1]==T[j-1])dp[i][j]=1;
		}
	}
	


	vector<vector<int>> sum(N+1,vector<int>(M+1,0));
	for(int i=0;i<=N;i++){
		for(int j=0;j<=M;j++){
			
			if(i!=0&&j!=0){
				dp[i][j] =  mod(dp[i][j] * sum[i-1][j-1]);

			}
			sum[i][j] = dp[i][j];
			if(i!=0)sum[i][j] = mod(sum[i][j] +sum[i-1][j]) ;
			if(j!=0)sum[i][j] = mod(sum[i][j] + sum[i][j-1]) ;
			if(i!=0&&j!=0){
				sum[i][j] -= sum[i-1][j-1];
				if(sum[i][j]<0)sum[i][j]+=modulo;
			}
		}
	}
	



	
	long long ans = 0;
	for(int i=0;i<=N;i++){
		for(int j=0;j<=M;j++){
			ans = mod(ans+dp[i][j]);
		}
		
	}
	
	//cout<<ans+1<<endl;
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 31744
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map
#include<cstring>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}
/*
ll Integer_factorization(ll n){
    ll num = 0;
    ll ndash = n;
    if(n == 1) return 1;
    ll a = 2;
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    return num;
}
*/

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}

ll dig(ll n){
    ll d = 0;
    while(n != 0){
        n/=10;
        d++;
    }
    return d;
}

void solve() {
    int n;
    cin >> n;
    double t,a;
    cin >> t >> a;
    double h;
    double m = INF;
    int j = 0;
    for(int i = 0;i < n;i++){
        cin >> h;
        if(m > fabs(a-t+h*0.006) ) {
            m = fabs(a-(t-h*0.006));
            j = i+1;
        }
    }
    cout << j << endl;
}




int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}



Measured memory_bytes: 256
using LL = long long;
#include"bits/stdc++.h"

using namespace std;
  
 //~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~
  
  
 int main() {
  
     int N;
     cin >> N;
  
     vector<int> A(N), B(N), C(N);
     for (int i = 0; i < N; i++) cin >> A[i];
     for (int i = 0; i < N; i++) cin >> B[i];
     for (int i = 0; i < N; i++) cin >> C[i];
     sort(A.begin(), A.end());
     sort(B.begin(), B.end());
     sort(C.begin(), C.end());
  
     LL ans = 0;
  
     for (int i = 0; i < N; i++) {
         LL pre = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
         LL over = C.end() - upper_bound(C.begin(), C.end(), B[i]);
         ans += pre * over;
     }
  
  
     cout << ans;
  
     return 0;
 }
  

Measured memory_bytes: 1408
#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
#include <queue>
using namespace std;

#define x first
#define y second
#define ll long long
#define ld long double
#define pii pair<int,int>
#define wh(x) (x).begin(),(x).end()
#define ri(x) int x;cin>>x;
#define rii(x,y) int x,y;cin>>x>>y;
#define rl(x) ll x;cin>>x;
#define rv(v) for(auto&_cinv:v) cin>>_cinv;
#define wv(v) for(auto&_coutv:v) cout << _coutv << ' '; cout << endl;
#define ev(v) for(auto&_cerrv:v) cerr << _cerrv << ' '; cerr << endl;
#define MOD 1000000007

namespace std { 
template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}};
}
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

int main(int,char**) {
    ios_base::sync_with_stdio(false);

    int N; cin >> N;
    ll ans = 1;
    vector<bool> F(N+1, true);
    for (int i = 2; i <= N; i++) {
        if (F[i]) {
            for (int j = i*i; j <= N; j+=i) {
                F[j] = false;
            }
            int c = 0;
            for (int k = i; k <= N; k*=i) {
                for (int j = k; j <= N; j+=k) ++c;
            }

            ans = ans * (c+1) % MOD;

        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		for(int a = -100000; a <= 100000; a++){
			for(int b = -10000; b < a; b++){
				if(a*a*a*a*a - b*b*b*b*b == x){
					System.out.println(a + " " + b);
					return;
				}
			}
		}
    }
}

Measured memory_bytes: 38760
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 200010
#define LL long long
int dis[MAXN],id[MAXN],n,m,st[MAXN];
LL ans[MAXN];
LL k;
bool vis[MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&dis[i]);
		id[i]=i;
	}
	for(int i=n;i;i--)
		dis[i]=dis[i]-dis[i-1];
	scanf("%d%lld",&m,&k);
	int u;
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&u);
		swap(id[u],id[u+1]);
	}
	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			int c=0;
			for(int j=i;!vis[j];j=id[j]) st[c++]=j,vis[j]=1;
			for(int j=0;j<c;j++)
				ans[st[j]]=dis[st[(k+j)%c]];
		}
	for(int i=1;i<=n;i++)
	{
		ans[i]+=ans[i-1];
		printf("%lld\n",ans[i]);
	}
}

Measured memory_bytes: 4352
n,m = map(int,input().split())
H = list(map(int,input().split()))
T = {}

for i in range(1,n+1):
    T[i] = "good"

for _ in range(m):
    a,b = map(int,input().split())
    if H[a-1] <= H[b-1]:
        T[a] = "bad"
    if H[a-1] >= H[b-1]:
        T[b] = "bad"

#print (T)
print (list(T.values()).count("good"))


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

typedef long long int ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int a, b;
    cin >> a >> b;
    cout << a*b << '\n';
    
    return 0;
}


Measured memory_bytes: 3652
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const ceil=(a)=>{return Math.ceil(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};const gcd=(x,y)=>{while(y){[x,y]=[y,x%y]}return x};const sum=(arr)=>{return arr.reduce((a,b)=>a+b);};const isPrime=(n:number):boolean=>{if(n<2)return false;const suq=Math.sqrt(n);for(let i=2;i<=suq;i++){if(n%i==0){return false;}}return true;};
const main=()=>{
  let a=tn()
  while(true){
    if(isPrime(a)){
      to(a)
      return
    }
    a++
  }
}
main()


Measured memory_bytes: 7372
#include<iostream>
using namespace std;
int main()
{
int n,a[100],ans=0;
cin >> n;
for(int i=0;i<n;i++)cin >> a[i];
for(int i=0;i<n;i++){
for(int j=n-1;j>=i+1;j--){
if(a[j]<a[j-1]){
    swap(a[j],a[j-1]);
ans++;}}
}
for(int i=0;i<n;i++){
if(i==n-1)cout << a[i] << "\n";
else cout << a[i] << " ";
}
cout << ans << "\n";
}

Measured memory_bytes: 3120
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 1
ans = 0
inf = float("inf")

s = s()
k = k()

if s[0]*len(s) == s:
    print(len(s)*k // 2)
    sys.exit()

res = [1]

for i in range(len(s)-1):
    if s[i] == s[i+1]:
        res[-1] += 1
    else:
        res.append(1)

for i in res:
    ans += (i//2)*k
if s[0] == s[-1]:
    diff = (res[0]+res[-1])//2 - (res[0]//2 + res[-1]//2)
    ans += diff*(k-1)
print(ans)


Measured memory_bytes: 10100
#include <stdio.h>
#define bit(n,m)(((n)>>(m))&1)

int main(){
	int n,c;
	scanf("%d%d",&n,&c);
	for(int x=0;x<1<<n;x++)if(__builtin_popcount(x)==c){
		printf("%d:",x);
		for(int k=0;k<n;k++)if(bit(x,k))printf(" %d",k);
		puts("");
	}
}


Measured memory_bytes: 2112
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int coor[101][101],tmp[101][101];
int main()
{
	for(int i=0;i<101;i++)
	{
		for(int j=0;j<101;j++)
		{
			coor[i][j]=0;
			tmp[i][j]=0;
		}
	}
	string s;
	int k=0,p=0;
	while(cin >> s)
	{
		int len=s.size(),in=0;
		for(int i=0;i<=len;i++)
		{
			if(s[i]==','||i==len)
			{
				coor[k][p]=in;
				in=0;
				p++;
			}
			if(s[i]!=',')
			{
				in*=10;in+=s[i]-'0';
			}
		}
		k++;p=0;
	}
	/*for(int i=0;i<k;i++)
	{
		for(int j=0;j<min(i+1,k-i);j++)
		{
			cout << coor[i][j] <<' ';
		}
		cout << endl;
	}*/
	tmp[0][0]=coor[0][0];
	for(int i=0;i<k/2;i++)
	{
		for(int j=0;j<i+1;j++)
		{
			tmp[i+1][j]=max(tmp[i+1][j],tmp[i][j]+coor[i+1][j]);
			tmp[i+1][j+1]=max(tmp[i+1][j+1],tmp[i][j]+coor[i+1][j+1]);
		}
	}
	int c=k/2;
	for(int i=0;i<k/2;i++)
	{
		for(int j=0;j<(k/2-i);j++)
		{
			tmp[i+c+1][j]=max(tmp[i+c][j],tmp[i+c][j+1])+coor[i+c+1][j];
		}
	}
	/*for(int i=0;i<k;i++)
	{
		for(int j=0;j<min(i+1,k-i);j++)
		{
			printf("%2d ",tmp[i][j]);
		}
		cout << endl;
	}*/
	cout << tmp[k-1][0] << endl;
	return 0;
}

Measured memory_bytes: 1268
#include <stdio.h>

int main(void) {
  int n;
  int bool = 0;
  scanf("%d", &n);
  for(int i = 100; i >= 1; i /= 10) {
    if(n / i == 7) {
      printf("Yes");
      bool = 1;
      break;
    } else {
      n %= i;
    }
  }
  if(bool == 0) {
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 1704
#include<cstdio>
#include<algorithm>
#define fi first
#define se second
#define MP make_pair
using namespace std;
typedef pair<int,int> PA;
const int N=100005,inf=1047483647;
struct PP
{
	PA x,y;
	PP operator +(const PP &B)
	{
		PP C;
		if (x.fi==B.x.fi)
			C.x=x,C.y=min(y,B.y);
		else
			if (x<B.x)
				C.x=x,C.y=min(y,B.x);
			else
				C.x=B.x,C.y=min(x,B.y);
		return C;
	}
};
struct node { int y,next; } a[N<<1],A[N*200];
struct node1 { int x,y; } b[N];
struct node2 { PP A; int b; } t[N<<2];
int s[N],C[N],top[N],dfn[N],h[N],fa[N],head[N],Head[N<<2],i,j,k,n,m,T,l,r,x,y,z,F;
bool p[N];
char c;

inline char getc()
{
	#define VV 10000000
	static char s[VV],*l=s,*r=s;
	if (l==r)
		l=s,r=s+fread(s,1,VV,stdin);
	return l==r?0:*l++;
}

int read(){ int z=0; do c=getc(); while (c<'0'||c>'9'); while (c>='0'&&c<='9') z*=10,z+=c-'0',c=getc(); return z; }

void jb(int x,int y)
{
	a[++k]=(node){y,head[x]},head[x]=k,
	a[++k]=(node){x,head[y]},head[y]=k;
}

void JB(int x,int y)
{
	A[++k]=(node){y,Head[x]},Head[x]=k;
}

void dfs1(int w)
{
	s[w]=1,h[w]=h[fa[w]]+1;
	for (register int j=head[w];j;j=a[j].next)
	{
		int c=a[j].y;
		if (c!=fa[w])
		{
			fa[c]=w,dfs1(c),s[w]+=s[c];
			if (s[c]>s[C[w]]) C[w]=c;
		}
	}
}

void dfs2(int w)
{
	dfn[w]=++T;
	if (C[w])
		top[C[w]]=top[w],dfs2(C[w]);
	for (register int j=head[w];j;j=a[j].next)
	{
		int c=a[j].y;
		if (c!=fa[w]&&c!=C[w])
			top[c]=c,dfs2(c);
	}
}

void push(int w,int z)
{
	t[w].b+=z,t[w].A.x.fi+=z,t[w].A.y.fi+=z;
}

void pushdown(int w)
{
	int &z=t[w].b;
	if (z)
		push(w<<1,z),push(w<<1|1,z),z=0;
}

void build(int w,int L,int R)
{
	if (L==R)
	{
		t[w].A=(PP){MP(0,L),MP(inf,0)};
		return;
	}
	int mid=L+R>>1;
	build(w<<1,L,mid),build(w<<1|1,mid+1,R),
	t[w].A=t[w<<1].A+t[w<<1|1].A;
}

void motree(int w,int L,int R)
{
	if (l<=L&&r>=R)
	{
		if (z>0) JB(w,F);
		push(w,z);
		return;
	}
	pushdown(w);
	int mid=L+R>>1;
	if (l<=mid)
		motree(w<<1,L,mid);
	if (r>mid)
		motree(w<<1|1,mid+1,R);
	t[w].A=t[w<<1].A+t[w<<1|1].A;
}

void mt(int x,int y,int D)
{
	z=D,F=i;
	while (top[x]!=top[y])
	{
		if (h[top[x]]<h[top[y]])
			swap(x,y);
		l=dfn[top[x]],r=dfn[x],motree(1,1,n),
		x=fa[top[x]];
	}
	if (x==y) return;
	if (h[x]>h[y]) swap(x,y);
	l=dfn[x]+1,r=dfn[y],motree(1,1,n);
}

int qtree(int w,int L,int R)
{
	while (Head[w]&&p[A[Head[w]].y]) Head[w]=A[Head[w]].next;
	if (Head[w]) return A[Head[w]].y;
	pushdown(w);
	int mid=L+R>>1;
	x>mid?qtree(w<<1|1,mid+1,R):qtree(w<<1,L,mid);
}

bool solve()
{
	for (i=1;i<n;++i)
	{
		x=t[1].A.x.fi==1?t[1].A.x.se:t[1].A.y.fi==1?t[1].A.y.se:0;
		if (!x) return 0;
		p[y=qtree(1,1,n)]=1,
		mt(b[y].x,b[y].y,-1);
	}
	return 1;
}

int main()
{
	n=read(),k=1;
	for (i=1;i<n;++i) jb(read(),read());
	k=0;
	dfs1(1),top[1]=1,dfs2(1);
	build(1,1,n);
	for (i=1;i<n;++i)
		b[i]=(node1){x=read(),y=read()},mt(x,y,1);
	puts(solve()?"YES":"NO");
	return 0;
}

Measured memory_bytes: 39680
from bisect  import bisect_left

n = int(input())
a = list(map(int,input().split()))
a.sort()
#print(a)

sum = 0
for i in range (len(a)-1,-1,-1):

    b = 1
    while b <= a[i]:
        b = b<<1
    t = b - a[i]
    #print("2^",t)

    k = bisect_left(a,t)
    if a[k] == t and k < i:
        sum += 1
        a[k] -= 0.1
        a[i] += 0.1
print(sum)

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

// これでもダメ. 複雑になっているのでloopの順番から考え直すべき。
// pointはh==0のデータの取扱。
void update (vector<vector<int> > &mat, vector<int> &in_x, vector<int> &in_y, vector<int> &in_h, bool do_check_previous) {
	int x, y, h;
	cin >> x >> y >> h;
	in_x.push_back(x);
	in_y.push_back(y);
	in_h.push_back(h);
	for (int cx=0; cx <=100; cx++) {
		int dx = abs(x - cx);
		for (int cy=0; cy<=100; cy++) {
			int dy = abs(y - cy);
			if (do_check_previous) {
				if (h == 0) {
					if (mat[cx][cy] > dx + dy) {
						mat[cx][cy] = 0; 
					}
				} else {
					if (mat[cx][cy] == -1) {
						mat[cx][cy] = h + dx + dy;
					} else if (mat[cx][cy] != h + dx + dy) {
						mat[cx][cy] = 0;
					}
				}
			} else {
				if (h==0) {
					// h==0情報を使った場合であることを記録: -1
					mat[cx][cy] = -1;
				} else {
					mat[cx][cy] = h + dx + dy;
				}
			}
		}
	}
}

int main (){
	int N;
	cin >> N;
	vector<int> temp_v(101, 0);
	vector<vector<int> > h_x_y(101,temp_v); 
	vector<int> in_x, in_y, in_h;
	update (h_x_y, in_x, in_y, in_h, false);
	for (int i=2; i<=N; ++i) {
		update (h_x_y, in_x, in_y, in_h, true);
	}
	int ans_x = 0, ans_y = 0;
	int ans_h = h_x_y[0][0];
	for (int x=0; x<=100; ++x) {
		for (int y=0; y<=100; ++y) {
			if (h_x_y[x][y] > ans_h) {
				bool isOK = true;
				for (int i=0; i<N; ++i) {
					//cout << in_x[i] << "," << in_y[i] << "," << in_h[i] << endl;
					if (in_h[i] != max(h_x_y[x][y] - abs(in_x[i]-x) - abs(in_y[i]-y), 0)) {
						isOK = false;
					}
				}
				if (!isOK) {
					continue;
				}
				ans_h = h_x_y[x][y];
				ans_x = x;
				ans_y = y;
			}
		}
	}
	cout << ans_x << " " << ans_y << " " << ans_h << endl; 
	return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.Map.Entry;

public class Main {
	
	static int INF = Integer.MAX_VALUE / 2;
		
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] h = new int[N+1];
		int[] dp = new int[N+1];
		
		for(int i = 1; i <= N; i++)
			h[i] = sc.nextInt();
		
		Arrays.fill(dp, INF);
		dp[1] = 0;
		
		for(int i = 1; i <= N; i++){
			for(int k = 1; k <= K; k++){
				if(i + k <= N)
					dp[i+k] = Math.min(dp[i+k], dp[i] + Math.abs(h[i] - h[i+k]));
			}
		}
		
		System.out.println(dp[N]);
		
	}//end main
	
	
}//end Main

class Pair{
	int r;
	int c;
	public Pair(int r, int c){
		this.r = r;
		this.c = c;
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22488
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll b[300000+20];
int main()
{

    ll n,i,x;


    cin>>n;

    for(i=2; i<=n; i++)
    {
        cin>>x;
        b[x]++;
    }
    for(i=1; i<=n; i++)
    {
        cout<<b[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 5104
#include <set>          
#include <map>           
#include <list>
#include <ctime>
#include <deque>         
#include <bitset>        
#include <vector>
#include <list>
#include <stack>
#include <random>		 
#include <string>       
#include <numeric>      //  needed for  accumulate
#include <utility>      // needed for std:: move
#include <iterator> 
#include <iostream>   
#include <algorithm> 
#include <functional>    
#include <cmath>         
#pragma warning(disable:4996) // ignore this
#define ve vector
#define pb push_back
#define mp make_pair                     
#define srt(x) sort(x.begin(),x.end())         
#define mod static_cast<long long> (1e9+7)     
#define sumx(x) accumulate(x.begin(),x.end(),0LL)
#define pi 3.14159265358979323846
#define testing 0
using namespace std;
template<typename T>
istream& operator >> (istream& in, ve<T> &v)
{
	for (auto &x : v)
		in >> x;
	return in;
}
template<typename T>
ostream& operator<<(ostream& in, ve<T> &v)
{
	for (auto &x : v)
		in << x << " ";
	return in;
}
long long fast(long long a, long long b, long long mid)
{
	if (b == 0)
		return 1;
	a %= mid;
	long long ans = 1;
	while (b)
	{
		if (b & 1)
		{
			ans = (ans*a) % mid;
		}
		a *= a;
		a %= mid;
		b >>= 1;
	}
	return ans;
}
class solve
{
	long long n,m;
public:
	solve()
	{
		cin >> n >> m;
		ve<int> v(n);
		cin >> v;
		srt(v);
		cout << accumulate(v.end()-m,v.end(),0);
		
	}
};
 
int32_t main()
{
	int t = 1, i = 1;
//	scanf("%d", &t);
	while (t--)
	{
		new solve;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define vi vector<ll>
#define all(_x) _x.begin(), _x.end()
#define rep(i, s, e) for (ll i = s; i < e; i++)
#define lb(_x, _a) (lower_bound(all(_x), _a) - _x.begin())
#define ub(_x, _a) (upper_bound(all(_x), _a) - _x.begin())

int main()
{
  	// ll is int now
    ll x,y,a,b,c; cin>>x>>y>>a>>b>>c;
    ll res = 0;
    vi p(a), q(b), r(c),arr;
    for(auto &x: p) cin>>x; for(auto &x: q) cin>>x; for(auto &x: r) cin>>x;
    sort(all(p), greater<ll>()); 
    sort(all(q), greater<ll>());
    sort(all(r), greater<ll>());
    
    rep(i,0,x) arr.pb(p[i]);
    rep(i,0,y) arr.pb(q[i]);
    rep(i,0,c) arr.pb(r[i]);

    sort(all(arr), greater<ll>());
    
    rep(i,0,x+y) res+=arr[i];
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 8816
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
int main() {
  int a,b,x;
  cin>>a>>b>>x;
  if(a<=x&&x<=a+b) cout<<"YES";
  else cout<<"NO";
  return 0;
}

Measured memory_bytes: 3636
import sys

if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    print(a*b)
    return





a, b = RA()
solve()


Measured memory_bytes: 85336
package main

import (
	"fmt"
)

func main() {
	var s, w int
	fmt.Scanf("%d %d", &s, &w)
	answer := isSafe(s, w)
	fmt.Println(answer)
}

func isSafe(s, w int) string {
	if s <= w {
		return "unsafe"
	}
	return "safe"
}


Measured memory_bytes: 1816
using System;
class Program{
	static void Main(){
		string s=Console.ReadLine();
		int p=0;
		char c=s[0];
		for(int i=1;i<s.Length;i++){
			if(s[i]!=c){
				p++;
				c=s[i];
			}
		}
		Console.WriteLine("{0}",p);
	}
}

Measured memory_bytes: 13408
fun main(args : Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val hh = IntArray(n)
    repeat(n) {
        hh[it] = readLine()!!.toInt()
    }
    hh.sort()

    var min = Int.MAX_VALUE

    for (i in 0..n-k) {
        val diff = hh[i+k-1] - hh[i]
        if (diff < min) min = diff
    }

    println(min)
}

Measured memory_bytes: 41720
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	for(int i = 1 ; i <= 5; i++){
        	int x = sc.nextInt();
          	if(x==0){
              System.out.println(i);
              break;
            }
        }
    }
}


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

int main() {
  
  int a;
  cin >> a;
  
  if(a < 1200) cout << "ABC" << endl;
  else cout << "ARC" << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define f(i,s,e) for(i=s;i<e;++i)
#define fr(i,s,e) for(i=s;i>=e;i--)
#define ff(i,s,e,f) for(i=s;i<e && f;++i)
#define mem(arr,val) memset(arr, val, sizeof(arr))
#define mems(arr, val, n) memset(arr, val, n)
#define vec vector<pr>
#define pr pair<int,int>
#define vp vector<trip>
#define _in(v) for(auto &x:v) cin>>x;
#define _out(v) for(auto x:v) cout<<x<<" "; cout<<endl;
#define lim 1000000
#define mod 1000000007
#define Arena ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define flush this_thread::sleep_for(chrono::seconds(0));
using namespace std;


signed main(void)
{
    Arena
    register int i,j,num,z,t=1;
    //cin>>t;
    f(z,1,t+1)
    {
        int x,y,a,b,c;cin>>x>>y>>a>>b>>c;
        vec v(a+b+c);
        f(i,0,a)
        {
            cin>>num;
            v[i]=pr (num,0);
        }
        f(i,a,a+b)
        {
            cin>>num;
            v[i]=pr (num,1);
        }
        f(i,a+b,a+b+c)
        {
            cin>>num;
            v[i]=pr (num,2);
        }
        sort(v.begin(),v.end());
        int x1=0,x2=0,x3=0,ans=0;
        fr(i,a+b+c-1,0)
        {
            if(x1+x2+x3==x+y)
                break;
            if(v[i].second==0 && x1<x)
            {
                ans+=v[i].first;
                x1++;
            }
            if(v[i].second==1 && x2<y)
            {
                ans+=v[i].first;
                x2++;
            }
            if(v[i].second==2 && x3<(x+y-x1-x2))
            {
                ans+=v[i].first;
                x3++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

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

int main(){
  int64_t N, K;
  cin >> K >> N;

  vector<int64_t> A(N);
  rep(i, N) cin >> A.at(i);

  int64_t max = K+A.at(0)-A.at(N-1);

  for(int64_t i=0; i<N-1; i++){
    if(A.at(i+1)-A.at(i)>max) max=A.at(i+1)-A.at(i);
  }

  cout << K-max;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n, m;
  cin >> n >> m;
  ll h[n + 5];
  for (ll i = 1; i <= n; i++)
    cin >> h[i];

  ll max1[n + 5];
  memset(max1, -1, sizeof(max1));
  for (ll i = 1; i <= m; i++) {
    ll a, b;
    cin >> a >> b;
    max1[a] = max(max1[a], h[b]);
    max1[b] = max(max1[b], h[a]);
  }

  ll res = 0;
  for (ll i = 1; i <= n; i++) {
    res += (h[i] > max1[i]);
  }
  cout << res << en;
  return 0;
}


Measured memory_bytes: 5208
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		 Scanner sc = new Scanner(System.in);
		 int N=sc.nextInt();
	     sc.close();
	     int count=0;
	     for(int i=1;i<N+1;i++)
	    	 count+=i;
	     System.out.println(count);
	 }
}


Measured memory_bytes: 21844
import 'dart:io';

main(List<String> args){
  List numbers = stdin.readLineSync().split(" ").map((n) => int.parse(n)).toList();
  int a=numbers[0];
  int b=numbers[1];
  int c=numbers[2];
  int d=numbers[3];
  bool check=true;
  while(true){
    c-=b;
    if(c<=0){
      check=true;
      break;
    }
    a-=d;
    if(a<=0){
      check=false;
      break;
    }
  }
  print(check?"Yes":"No");
}

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

int main(void)
{
    int n;
    int p[20];
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    int count = 0;
    for (int i = 1; i < n-1; i++)
    {
        if ((p[i-1]<p[i]&& p[i]<p[i+1]) || (p[i-1]>p[i] && p[i]>p[i+1]) )
        {
            count++;
        }
    }
    cout << count << endl;
    

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <ctime>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const int INF = 1001001001;
const int MAX_M = 100000;

int dp[5005][5005];


int main(int argc, char *args[]) {
	int A, B;
	cin >> A >> B;
	if (A > 9 || B > 9) {
		cout << -1 << endl;
	}
	else {
		cout << A*B << endl;
	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool h[100000];
int main(){
	int n,a,b,cnt=0,cnt2=0;
	string s;
	cin>>n>>a>>b>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='a'&&cnt<a+b){
			cnt++;
			cout<<"Yes"<<endl;
		}
		else if(s[i]=='b'&&cnt<a+b&&cnt2<b){
			cnt++;
			cnt2++;
			cout<<"Yes"<<endl;
		}
		else if(s[i]=='b'){
			cout<<"No"<<endl;
			cnt2++;
		}
		else{
			cout<<"No"<<endl;
		}
	}
}


Measured memory_bytes: 896
from math import cos, radians

A, B, H, M = map(int, input().split())
temp = abs(30 * H + 0.5 * M - 6 * M)
deg = min(temp, 360 - temp)
d = (A**2 + B**2 - 2*A*B*cos(radians(deg))) ** 0.5
print(d)

Measured memory_bytes: 9496
#include <iostream>
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    map<int,queue<int>>theval;
    for(int i=1;i<=n;i++){
        for(int j=0;j<n-1;j++){
            int a;
            cin>>a;
            theval[i].push(a);
        }
    }
    int days=0;
    queue<int>toloop;
    for(int i=1;i<=n;i++){
        toloop.push(i);
    }
    while(true){
        bool shahad=false;
        bool noans=true;
       set<int>numberstaken;
       days++;
       int xx=toloop.size();
       for(int j=0;j<xx;j++){
           int i=toloop.front();
         if(!numberstaken.count(i)&&theval[i].size()>0&&!numberstaken.count(theval[i].front())){
             shahad=true;
            if(!numberstaken.count(theval[i].front())&&theval[theval[i].front()].size()>0&&theval[theval[i].front()].front()==i){
            numberstaken.insert(i);
            numberstaken.insert(theval[i].front());
            //cout<<i<<" "<<theval[i].front()<<endl;
            toloop.push(i);
            toloop.push(theval[i].front());
            theval[theval[i].front()].pop();
            theval[i].pop();
            noans=false;
            } 
            
         }  
         toloop.pop();
       }
       if(shahad==0){break;}
       if(noans==true){cout<<-1<<endl; return 0;}
         
    }
    cout<<days-1<<endl;
}

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

using namespace std;

#define ll long long
constexpr ll inf = 1e9+7;

int main() {
    ll N, T;
    cin>>N>>T;
    vector<ll> Ts(N);
    for (ll n = 0; n < N; n++) cin>>Ts[n];

    ll ans = 0;
    for (ll n = 0; n < N - 1; n++) {
        ans += min(T, Ts[n+1] - Ts[n]);
    }
    cout<<ans + T<<endl;
}

Measured memory_bytes: 1792
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()
N_str = str(N)
n_keta = len(N_str)

# 条件にあうやつを数え上げる。
# 条件に合えば、10の倍数は基本的に条件を満たすが
from collections import defaultdict
container = defaultdict(lambda: 0)

for n in range(N + 1):
    if n % 10 == 0:
        continue
    n_str = str(n)
    container[(int(n_str[0]), int(n_str[-1]))] += 1

ans = 0
from itertools import product
for i, j in product(range(1, 10), range(1, 10)):
    ans += container[(i, j)] * container[(j, i)]

print(ans)


Measured memory_bytes: 3316