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

int main(){
	string N;
	int res;
  cin >> N;
	for(int i = 0;i < 4; i++){
		if(N.substr(i,1) == "2"){
			res = res + 1;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
//Amumu-style
#include<bits/stdc++.h>
#define ll long long
#define IOSF ios::sync_with_stdio(false)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ini(a,b) memset(a,b,sizeof(a))
#define ms multiset
#define um unordered_map
using namespace std;
int main() {
	string s;
	cin>>s;
	if(s=="RRR") cout<<3;
	if(s=="RRS") cout<<2;
	if(s=="RSR") cout<<1;
	if(s=="RSS") cout<<1;

	if(s=="SRR") cout<<2;
	if(s=="SRS") cout<<1;
	if(s=="SSR") cout<<1;
	if(s=="SSS") cout<<0;
	return 0;
}
//当年陈刀仔！

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int p[200];
int main(){
	int n;cin>>n;
	int a,b;cin>>a>>b;
	int A=0,B=0,C=0;
	rep(i,n){
		int p;cin>>p;
		if(p<=a)A++;
		else if(p<=b)B++;
		else C++;
	}
	cout<<min({A,B,C})<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	ll a, b;
	cin >> a >> b;

	println(a * b);
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ll long long
#define ch char
#define st string
using namespace std;
ll a,b,c,d,e,f,g,h;
st s;
void Urvatullo_Atoev()
{
    cin>>s;
    a=s[0]-'0';
    b=s[1]-'0';
    c=s[2]-'0';
    d=s[3]-'0';
    if(a+b+c+d==7)
    {
        cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<"=7";
    }
    else if(a+b+c-d==7)
    {
        cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<"=7";
    }
    else if(a+b-c-d==7)
    {
        cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<"=7";
    }
    else if(a-b-c-d==7)
    {
        cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<"=7";
    }
    else if(a+b-c+d==7)
    {
        cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<"=7";
    }
    else if(a-b+c+d==7)
    {
        cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<"=7";
    }
    else if(a-b-c+d==7)
    {
        cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<"=7";
    }
    else if(a-b+c-d==7)
    {
        cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<"=7";
    }
}
int main()
{
    Urvatullo_Atoev();
}


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;


signed main() {
  int64_t n;
  cin >> n;
  priority_queue<int64_t> q;
  int64_t val;
  for(int64_t i=0;i<n;i++){
    cin >> val;
    q.push(val);
  }
  
  int64_t count = 1;
  int64_t countMax = q.size()-1;
  int64_t comfortableness = q.top();
  q.pop();
  while(!q.empty()){
    int64_t next = q.top();
    q.pop();
    if(count<countMax-1){
      comfortableness += next*2;
      count += 2;
    }
    else if(count==countMax-1){
      comfortableness += next;
      count++;
    }
    if(count==countMax){
      break;
    }
  }
  cout << comfortableness << endl;

  return 0;
}


Measured memory_bytes: 5428
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int h, currentH;
    cin >> currentH;
    currentH--;
    for (int i=1; i<n; i++) {
        cin >> h;
        if(currentH - h>= 1) {
            cout << "No";
            return 0;
        } 
        if (h > currentH) {
            currentH = h - 1;
        }
    }
    cout << "Yes";
}


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

int compare (const void * a, const void * b) {
   return ( *(int*)a - *(int*)b );
}

int main() {
    int n;
    scanf("%d", &n);
    int nums[n];
    
    for (int i = 0; i < n; i++) {
        scanf("%d", &nums[i]);
    }

    qsort(nums, n, sizeof(int), compare);
    
    if (n % 2 == 0) {
        if (nums[n / 2] == nums[n / 2 - 1])
            printf("0\n");
        else
            printf("%d\n", nums[n / 2] - nums[n / 2 - 1]);
    } else {
        printf("0\n");
    }
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define FAST cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("C:/Users/Aman/Desktop/kachda/input.txt", "r", stdin); freopen("C:/Users/Aman/Desktop/kachda/output.txt", "w", stdout);

using namespace std;

signed main()
{
	//FILEIO
 	FAST
	int n;
	cin>>n;


	int a[n + 1], b[n + 1];
	int d[n + 1];
	int s1 = 0, s2 = 0;

	fr(i,1,n + 1)
	{
		cin>>a[i];
		s1 += a[i];
	}

	fr(i,1,n + 1)
	{
		cin>>b[i];
		d[i] = a[i] - b[i];
		s2 += b[i];
	}

	if(s1  < s2) return  cout<<-1, 0;
	if(n == 1)
	{
		cout<<0;
		return 0;
	}

	sort(d + 1, d + n + 1);

	int l = 1, r = n;
	int ans = 0;
	bool ok[n + 1] = {0};

	while(l < r)
	{
		if(d[l] < 0)
		{
			int temp = min(-d[l], d[r]);
			d[l] += temp;
			d[r] -= temp;
			ok[r] = 1;
			ok[l] = 1;

			if(d[l] == 0)l++;
			if(d[r] == 0)r--;
		}
		else break;	
	}


	fr(i,1,n + 1) {ans += ok[i];}

	cout<<ans;

}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll f(ll x,ll c,ll d){
    ll res =x;
    res -=x/c;
    res -=x/d;
    res+= x/lcm(c,d);
    return res;
}

int main(){
   ll n,k;
   cin>>n>>k;
   vector<ll>v(3);
   rep(i,3)cin>>v[i];
   ll sum=0;
   string a;
   cin>>a;
   rep(i,n){
       if(a[i]=='s')sum+=v[0];
       if(a[i]=='p')sum+=v[1];
       if(a[i]=='r')sum+=v[2];
   }
   rep(i,k){
     bool ok=true;
     ll j=i+k;
     while(j<n){
         if(a[j]==a[j-k]){
             if(ok){
                   if(a[j]=='s')sum-=v[0];
                   if(a[j]=='p')sum-=v[1];
                   if(a[j]=='r')sum-=v[2];
                   j+=k;
                   ok=false;
                   continue;
             }
         }
         ok=true;
         j+=k;
     }
   }
cout<<sum<<endl;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n;
    cin >> n;
    VI t(n);
    cin >> t;
    SORT(t);
    VI r;
    for (int i = 1; i * i <= t.back(); i++) {
        if (!(t.back() % i)) {
            r.push_back(i);
            if (i * i != t.back()) {
                r.push_back(t.back() / i);
            }
        }
    }
    SORT(r);
    for (int i = 2; i * t.back() <= 10000; i++)r.push_back(i * t.back());

    int ans = 0;
    FOR(i, 0, n) {
        ans += *lower_bound(all(r), t[i]) - t[i];
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
  int n, m; cin >> n >> m;
  vector<int> a(n);
  REP(i, n) cin >> a[i];

  vector<pair<int, int>> vp(m);
  REP(i, m){
    int b, c; cin >> b >> c;
    vp[i] = make_pair(c, b);
  }

  sort(vp.begin(), vp.end(), greater<pair<int, int>>());

  vector<int> b(n, -1);
  for(int i=0, j=0; i<n && j<m; j++){
    int cnt = 0;
    while(cnt < vp[j].second && i<n){
      b[i] = vp[j].first;
      i++; cnt++;
    }
  }

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

  ll ans = 0LL;
  REP(i, n){
    ans += max(a[i], b[i]);
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <memory.h>
#include <math.h>

#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) > (b)) ? (b) : (a))
#define SWAP(t, a, b) do{t c = a; a = b; b = c;}while(0)

int main (int argc, char **argv)
{
  int64_t n = 0;
  int64_t ans = 0;

  scanf("%lld", &n);

  if(n == 100000)
  {
    ans = 9 + 900 + 90000;
  }
  else if(n >= 10000)
  {
    ans = 9 + 900 + (n - 10000 + 1);
  }
  else if(n >= 1000)
  {
    ans = 9 + 900;
  }
  else if(n >= 100)
  {
    ans = 9 + (n - 100 + 1);
  }
  else if(n >= 10)
  {
    ans = 9;
  }
  else
  {
    ans = n;
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

long long int gcd(long long int x,long long int y){
    long long int r;
    if(x == 0 || y == 0)  return 0;
    while((r = x % y) != 0) 
    {
         x = y;
        y = r;
    }
    return y;
}

int main(){
    int t; cin >> t;
    rep(i,t){
        ll a,b,c,d; cin >> a >> b >> c >> d;
        if(a < b || d < b){cout << "No" << endl; continue;}
        if(b <= c){cout << "Yes" << endl; continue;}
        if(b == 1){cout << "Yes" << endl; continue;}
      	if(d % b == 0 && a % b > c){cout << "No" << endl; continue;}
        else if(d % b == 0){cout << "Yes" << endl; continue;}
        d = d % b;
        ll gc = gcd(b , d);
        if(b-c-1 >= gc){cout << "No" << endl; continue;}
        bool flag = true;
        /*
        rep(i, 500000){
            a = a % b;
            if(a > c){flag = false; break;}
            a += d;
        }
        */
        if(flag){cout << "Yes" << endl; continue;}
        else{cout << "No" << endl; continue;}
    }
    return 0;
}


Measured memory_bytes: 256
# 湖の円周、家の数
K, N = map(int, input().split())

A_list = list(map(int, input().split()))

A_list = sorted(A_list)

max_d = 0

for i in range(N-1):
    d = A_list[i + 1] - A_list[i]

    if d > max_d:
        max_d = d

l = K - A_list[N -1] + A_list[0]
if l > max_d:
    max_d = l


print(K - max_d)



Measured memory_bytes: 26444
#include <bits/stdc++.h>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
using ll = long long;
using namespace std;
vector<ll> t;
int main(){
  int n;
  cin >> n;
  if(n % 10 == 9 || (n - n % 10) / 10 == 9){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/*
  __________    							|										   ___  __
	|       |     						    |											|   /
	|       |     						    |									  		|  /
	|       |                               |                         __                | /      _______
	|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
	| \               | |      | |          |      |          | / | /   |               |\       |
	|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
	|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void solve(){
	char a;cin>>a;
	int t=(int)a+1;
	cout<<(char)t;
}

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

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=(1e5)+10;
int n,m;
ll ans;
char s[maxn],t[maxn];
int gcd(int a,int b) {
	if (!a||!b) return a+b;
	return gcd(b,a%b);
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(m);
	scanf("%s %s",s+1,t+1);
	int c=gcd(n,m);
	for (int i=1,j=1;i<=n&&j<=m;i+=n/c,j+=m/c)
		if (s[i]!=t[j]) {
			printf("-1\n");
			return 0;
		}
	ans=(ll)n*m/c;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <string>
#include <climits>
#include <set>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <numeric>
using namespace std;

int main()
{
	int n, a, b;
	cin >> n >> a >> b;

	if (a * n <= b)
		cout << n * a;
	else cout << b;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using piii = pair<int, pair<int, int>>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    string S;
    cin >> S;

    int N = S.length();
    bool isok = true;
    for (int i = 0; i < N / 2; ++i)
        if (S[i] != S[N - i - 1])
            isok = false;

    if (isok) {
        int N2 = (N - 1) / 2;
        for (int i = 0; i < N2 / 2; ++i) {
            if (S[i] != S[N2 - i - 1])
                isok = false;
        }
    }

    cout << (isok ? "Yes" : "No") << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<string> l(n);
    rep(i, n) cin >> l[i];

    sort(all(l));
    rep(i, n)
    {
        cout << l[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n+1];
  rep(i,n+1) cin>>a[i];
  int mx[n+1];
  int now=0;
  repn(i,n){
    now+=a[i];
    mx[i]=now;
  }
  if(n==0 && a[0]==1){
    cout<<1<<endl;
    return 0;
  }
  int nex=1;
  int ans=1;
  if(a[0]>0){
    cout<<-1<<endl;
    return 0;
  }
  repi(i,1,n+1){
    nex-=a[i-1];
    nex*=2;
    nex=min(nex,mx[i]);
    if(nex<=0){
      cout<<-1<<endl;
      return 0;
    }
    ans+=nex;
    //cout<<nex<<endl;
  }
  if(nex<a[n]) cout<<-1<<endl;
  else cout<<ans<<endl;
    
	   

  return 0;
}


Measured memory_bytes: 5216
/*                                    *
 * 私の腸のように衝撃に弱いプログラム *
 *                                    */

#include <stdio.h>
#include <stdlib.h>

typedef struct {
    char from;
    char to;
} table_t;

void* smalloc ( size_t size )
{
    void* pntr = malloc( size );
    if ( pntr == NULL )
    {
        fputs( "malloc failed.\n", stderr );
        exit( EXIT_FAILURE );
    }
    return pntr;
}

char converter( table_t* table, int elements, const char data )
{
    int i;
    for ( i = 0; i < elements; i++ )
    {
        if ( data == table[i].from )
            return table[i].to;
    }
    return data;
}

int main ( void )
{
    int i, convertTableElements;
    char convertTarget;
    table_t* convertTable;

    while ( 1 )
    {
        scanf( "%d\n", &convertTableElements );

        convertTable = (table_t*)smalloc( sizeof(table_t) * convertTableElements );
        for ( i = 0; i < convertTableElements; i++ )
            scanf( "%c %c\n", &convertTable[i].from, &convertTable[i].to );

        if ( convertTableElements <= 0 )
            break;

        for ( scanf( "%d\n", &i ) ; i > 0; i-- )
        {
            scanf( "%c\n", &convertTarget );
            printf( "%c", converter( convertTable, convertTableElements, convertTarget ) );
        }
        puts("");

        free(convertTable);
    }

    return 0;
}

Measured memory_bytes: 592
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
ll memo[2020];
ll rec(ll rest){
    if(rest == 0) return 1;
    if(memo[rest] != -1) return memo[rest];
    ll res = 0;

    for(ll i = rest - 3; i >= 0; i--){
        res += rec(i);
        res %= MOD;
    }

    return memo[rest] = res;
}
int main(void){
    ll s;
    cin >> s;

    rep(i, 2020){
        memo[i] = -1;
    }

    cout << rec(s) << endl;

}


Measured memory_bytes: 3608
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
	int a, b, k;
	scanf("%d%d%d", &a, &b, &k);
	for (int i = 0; i < k; i++) {
		if (i % 2 == 0) {
			b += a / 2;
			a /= 2;
		}
		else {
			a += b / 2;
			b /= 2;
		}
	}
	printf("%d %d\n", a, b);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <iterator>
using namespace std;


vector<vector<long long> > g, in;
vector<long long> ans;
long long mx = 0;

void dfs(long long v, long long p, long long k){
  if(v != 0) ans[p] = k;
  long long next = 1;
  for(int i = 0; i < g[v].size(); ++i){
    if(p != -1 && next == ans[p]) next++;
    dfs(g[v][i], in[v][i], next);
    mx = max(mx, next);
    next++;
  }
}


int main(){
    long long n, a, b;
    cin >> n;
    g.resize(n);
    ans.resize(n - 1);
    in.resize(n);
    for(int i = 0; i < n - 1; ++i){
      cin >> a >> b;
      g[a - 1].push_back(b - 1);
      in[a - 1].push_back(i);
    }
    dfs(0, -1, 1);
    cout << mx << endl;
    for(int i = 0; i < n - 1; ++i) cout << ans[i] << endl;
}


Measured memory_bytes: 9984
#include <stdio.h>

# define NUM 4000
# define TOTAL 1000000

typedef enum { FALSE, TRUE } Bool; // ??????????????????TRUE ????????¨???FALSE;

typedef struct _sala{
    int num;
    int cost;
    int sale;
    int sum;
    Bool flag;
} Sala;



int main(void){
    int n;  // ????????°
    int ct;
    int k1, k2;


    Sala men[NUM];

    while( 1 ){
        ct = 0;
        scanf("%d", &n);
        if ( !n ){ break; }

        for ( k1 = 0; k1 < n; k1++ ){
            scanf("%d %d %d", &men[k1].num, &men[k1].cost, &men[k1].sale);
            men[k1].flag = TRUE; //????????°

            men[k1].sum = men[k1].cost * men[k1].sale; //?¨????

            for ( k2 = 0; k2 < k1; k2++ ){
                if ( men[k1].num == men[k2].num ){
                    men[k2].sum += men[k1].sum;
                    men[k1].flag = FALSE;  //??????????????????
                }
            }
        }

        for ( k1 = 0; k1 < n; k1++ ){
            if ( men[k1].flag == FALSE ){ continue; }
            if ( TOTAL <= men[k1].sum ){
                printf("%d\n", men[k1].num);
                ct++;
            }
        }
        if ( !ct ){ printf("NA\n"); }
    }

    return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  string S; cin >> S;
  string result = "AC";
  int C = 0;
  if(S[0]!='A') result = "WA";
  for(int i=1; i<S.length(); i++) {
    if (S[i]<'a') {
      if (i>=2&&i<=S.length()-2&&S[i]=='C') C++;
      else { result = "WA"; break; };
    }
  }
  if (C!=1) result = "WA";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 384
h, w = map(int, input().split())

l = []
ll = [[True for i in range(w)] for j in range(h)]
for _ in range(h):
    s = input()
    cells = list(s)
    # print(cells)
    l.append(cells)
    
# print(l)

for h_i in range(h):
    flag = True
    for w_i in range(w):
        # print(l[h_i][w_i])
        if l[h_i][w_i] == "#":
            flag = False
            break
    if flag:
        for w_i in range(w):
            ll[h_i][w_i] = False

for w_i in range(w):
    flag = True
    for h_i in range(h):
        # print(l[h_i][w_i])
        if l[h_i][w_i] == "#":
            flag = False
            break
    if flag:
        for h_i in range(h):
            ll[h_i][w_i] = False
            
# print(ll)

for i in range(h):
    lll = []
    for j in range(w):
        # print(l[i][j])
        if ll[i][j]:
            lll.append(l[i][j])
    if len(lll) > 0:
        print(''.join(lll))

Measured memory_bytes: 9412
#include "bits/stdc++.h"
using namespace std;
int main(){
string s;
cin>>s;
char al[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int cnt[26];
for(int i=0;i<26;i++)cnt[i]=0;
for(int i=0;i<26;i++){
for(int j=0;j<26;j++){
if(s[i]==al[j]){
if(cnt[j]){
cout<<"no"<<endl;
return 0;
}
cnt[j]++;
}
}
}
cout<<"yes"<<endl;
}


Measured memory_bytes: 256
def main1(N, lstA, lstB, lstC):
    bounus = 0
    for i in range(0, len(lstA)-1):
        if (lstA[i] + 1) == lstA[i+1]:
            bounus += lstC[lstA[i]-1]
    print(sum(lstB) + bounus)

N = int(input())
lstA = list(map(int, input().split()))
lstB = list(map(int, input().split()))
lstC = list(map(int, input().split()))
main1(N, lstA, lstB, lstC)


Measured memory_bytes: 3060
fn main() {
    let mut a_s = String::new();
    std::io::stdin().read_line(&mut a_s).ok();
    let a: i32 = a_s.trim().parse().ok().unwrap();
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let k = solve(a, s);
    println!("{}", k);
}

fn solve(a: i32, s: String) -> String {
    if a >= 3200 {
        return s;
    }
    else {
        return "red".to_string();
    }
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main()
{
	int piece_max;  cin >> piece_max;
	int grid_max;	cin >> grid_max;
	vector<int> grid_set;

	if (grid_max <= piece_max)
	{
		cout << 0;
		return 0;
	}

	grid_set.resize(grid_max);
	for (int i = 0; i < grid_max; i++)
		cin >> grid_set[i];
	sort(grid_set.begin(), grid_set.end());

	multiset<int> grid_length_set;
	for (int i = 0; i < grid_max-1; i++)
		grid_length_set.insert(grid_set[i+1] - grid_set[i]);

	auto it = grid_length_set.rbegin();
	for (int i = 0; i < piece_max - 1; i++)
		it++;
	int move_length;
	while (it != grid_length_set.rend())
	{
		move_length += *it;
		it++;
	}

	cout << move_length;

	return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::string s;std::cin>>s;
    lint q;std::cin>>q;
    while(q--){
        lint k;std::cin>>k;
        lint a=0,b=0,c=0,ans=0;
        for(lint i=0;i<n;i++){
            if(k<=i){
                if(s.at(i-k)=='D')a--,c-=b;
                if(s.at(i-k)=='M')b--;
            }
            if(s.at(i)=='D')a++;
            if(s.at(i)=='M')b++,c+=a;
            if(s.at(i)=='C')ans+=c;
        }
        std::cout<<ans<<'\n';
    }
}
/*
 * D, M, DM の数 a,b,c を管理です。
 */


Measured memory_bytes: 1948
#include <stdio.h>

int main(void)
{
	int a, b;
	int la, lb;
	int r;
	int tmp;
	int gcd[50], lcm[50];
	int i = 0, j;
	
	while (scanf("%d %d", &a, &b) != EOF){
		la = a;
		lb = b;
		
		if (b > a){
			tmp = a;
			a = b;
			b = tmp;
		}
		
		do {
			r = a % b;
			gcd[i] = b;
			a = b;
			b = r;
		}while (r != 0);
		
		lcm[i] = la / gcd[i] * lb;
		i++;
	}
	
	for (j = 0; j < i; j++){
		printf("%d %d\n", gcd[j], lcm[j]);
	}
	
	return (0);
}

Measured memory_bytes: 596
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <iterator>

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

using namespace std;

bool ok(const vector<pair<int64_t,int64_t>>& c, int64_t cells) {
  multiset<int64_t> s;
  int64_t sum = 0;
  for (auto p : c) {
    if (s.size() < cells) {
      s.insert(p.second);
      sum += p.second;
    } else {
      int64_t maxval = *prev(end(s));
      if (maxval > p.second) {
        s.erase(prev(s.end()));
        s.insert(p.second);
        sum -= maxval - p.second;
      }
    }
    if (s.size() == cells && sum <= cells * p.first) return true;
  }
  return false;
}

int main() {
  int n;
  cin >> n;
  vector<pair<int64_t,int64_t>> c;
  REP(i,n) {
    int64_t a,b;
    cin >> a >> b;
    c.emplace_back(b,a);
  }
  sort(begin(c),end(c),greater<pair<int64_t,int64_t>>());
  int i = 524288;
  int cells = 0;
  while(i){
    if(ok(c,cells+i)) {
      cells += i;
    }
    i /= 2;
  }
  cout << cells << endl;
  return 0;
}

Measured memory_bytes: 21876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; i++)
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#ifdef _DEBUG
#define PRE_COMMAND             \
    std::cin.rdbuf(in.rdbuf()); \
    std::cout << fixed << setprecision(15);
#else
#define PRE_COMMAND cout << fixed << setprecision(15);
#endif
const double EPS = 1e-10, PI = acos(-1.0);
template <class T> auto MAX(T& seq) {
    return *max_element(seq.begin(), seq.end());
}
template <class T> auto MIN(T& seq) {
    return *min_element(seq.begin(), seq.end());
}
template <class T> auto SUM(T& seq) {
    T temp{0};
    auto& temp2 = temp[0];
    return accumulate(seq.begin(), seq.end(), temp2);
}
template <class T> void SORT(T& seq) { sort(seq.begin(), seq.end()); }
template <class T, class S> void SORT(T& seq, S& sort_order) {
    sort(seq.begin(), seq.end(), sort_order);
}
template <class T> void SORTR(vector<T>& seq) {
    sort(seq.begin(), seq.end(), greater<T>());
}
template <class T, class S, class R> long long pow(T n_0, S k_0, R mod_0) {
    long long n = n_0, k = k_0, mod = mod_0, now = 1;
    while (true) {
        if (k & 1) { now = now * n % mod; }
        if ((k >>= 1) == 0) { return now; }
        n = (n * n) % mod;
    }
}
template <typename T> istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}

int main() {
    PRE_COMMAND
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < n + 1; i++) {
        for (int j = 0; j < m + 1; j++) {
            if (i * j + (n - i) * (m - j) == k) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3588
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
#include <x86intrin.h>
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
const int maxn = 1e6 + 3;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	cout << (n*(n-1) + m*(m-1))/2 << '\n';
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};

const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/

int main(){
  ll N, M;
  cin >> N >> M;
  vector<ll> A(N);
  rep(i, N){
    cin >> A[i];
    A[i]--;
  }

  vector<ll> ef(2 * M, 0), re(2 * M, 0), ans(M, 0);
  ll x = 0;
  rep(i, N-1){

    ll s = A[i], t = A[i+1];
    if(s > t) t += M;
    ll need = t - s;
    if(t >= M && need >= 2){
      x += 1 + t - M;
    }else{
      x += need;
    }
    if(need <= 1) continue;
    ef[s+2]++;
    ef[t+1]--;
    re[t+1] -= need - 1;
  }

  rep(i, 2 * M - 1){
    ef[i+1] += ef[i];
  }

  rep(i, M){
    ef[i] += ef[i+M];
    re[i] += re[i+M];
  }


  ans[0] = x;
  rep(i, M-1){
    ans[i+1] = ans[i] - ef[i+1] - re[i+1];
  }

  sort(ans.begin(), ans.end());
  cout << ans[0] << endl;

}


Measured memory_bytes: 4992
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

ans = []
for i in range(M):
    ax,bx,c = map(int,input().split())
    ans.append(a[ax - 1] + b[bx - 1] - c)

print(min(min(ans),(min(a)+min(b))))

Measured memory_bytes: 18652
loop do
  n = gets.to_i
  break if n == 0
  start = {}
  bless = Hash.new(0)
  n.times do
    gets =~ /^(\d\d)\/(\d\d) (\d\d):(\d\d) (.) (\d\d\d)/
    # p [$1.to_i, $2.to_i, $3.to_i, $4.to_i, $5, $6.to_i]
    t = $3.to_i * 60 + $4.to_i
    io = $5
    p = $6.to_i
    if io == ?I
      start[p] = t
    elsif p == 0
      start_g = start[0]
      start.delete(0)
      start.each do |q, start_q|
        bless[q] += t - [start_g, start_q].max
      end
    else
      start_p = start[p]
      start.delete(p)
      start_g = start[0]
      bless[p] += t - [start_g, start_p].max if start_g
    end
  end
  p bless.values.max || 0
end



Measured memory_bytes: 6852
from collections import deque


def solve():
    H, W, N = list(map(int, input().split()))
    # print(H, W, N)

    # 座標は(y, x)
    blacks = {}
    for _ in range(N):
        pos = input().split()
        blacks[(int(pos[0]), int(pos[1]))] = 0

    # print(blacks)

    # [*][*][*]
    # [*][c][*]
    # [*][*][*]
    # ある座標から, それを中心にした9つの座標を返す
    def center_of_boxes_from_point(y, x):
        center_pos_lis = deque()

        for dy in range(-1, 2):
            for dx in range(-1, 2):
                cy = y + dy
                cx = x + dx
                if 1 <= cy <= H and 1 <= cx <= W:
                    center_pos_lis.append((cy, cx))
        return center_pos_lis

    ANS_TABLE = [0 for _ in range(10)]

    # 探索を終了したboxを保存する
    # keyはboxの中心の座標
    done_boxes = {}
    for blk in blacks:
        # print(blk)
        y, x = blk
        boxes = center_of_boxes_from_point(y, x)

        # boxを探索して黒マスをカウントする
        for center_of_box in boxes:
            if center_of_box not in done_boxes:
                y, x = center_of_box
                if 2 <= y < H and 2 <= x < W:
                    count = 0
                    for dy in range(-1, 2):
                        for dx in range(-1, 2):
                            cy = y + dy
                            cx = x + dx
                            if (cy, cx) in blacks:
                                count += 1
                    # print(center_of_box, count)
                    ANS_TABLE[count] += 1
                    done_boxes[center_of_box] = 0

    # print('total boxes', (W - 2) * (H - 2))
    ANS_TABLE[0] = (W - 2) * (H - 2) - sum(ANS_TABLE)

    return ANS_TABLE


if __name__ == '__main__':
    res = solve()
    for r in res:
        print(r)


Measured memory_bytes: 146804
<?php
fscanf(STDIN, "%s", $s);
// $s = str_split($s);
// $count = 0;
if($s === "SSS") {
    echo 0 . "\n";
} elseif($s === "RRS" || $s === "SRR") {
    echo 2 . "\n";
} elseif ($s === "RRR") {
    echo 3 . "\n";
} else {
    echo 1 . "\n";
}


Measured memory_bytes: 16100
#include <iostream>

using namespace std;
typedef long long ll;
const int N=2e5+10;
const int mod=1e9+7;
int inv[N];
int p[N];
int qmi(int a,int b)
{
    int ans=1;
    while(b){
        if(b&1)ans=(ll)ans*a%mod;
        a=(ll)a*a%mod;
        b>>=1;
    }
    return ans;
}
int C(int a,int b)
{
    int ans=1;
    ans=(ll)ans*p[a]%mod;
    ans=(ll)ans*inv[b]%mod;
    ans=(ll)ans*inv[a-b]%mod;
    return ans;
}
int main()
{
    int n,m,a,b;
    cin>>n>>m>>a>>b;
    p[0]=1,inv[0]=1;
    for(int i=1;i<=n+m;i++)
    {
        p[i]=(ll)i*p[i-1]%mod;
        inv[i]=(ll)inv[i-1]*qmi(i,mod-2)%mod;
    }
    ll res=0;
    for(int i=0;i<=n-a-1;i++)
    {
        res=((ll)res+(ll)C(n-a+b-2-i,b-1)%mod*C(m+a-b+i-1,m-b-1)%mod)%mod;
        // cout<<(m+a-b+i-2)<<' '<<(m-b-1)<<endl;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1792
n = int(input())
xy = [list(map(int,input().split())) for _ in range(n)]
ans = 0

for x1,y1 in xy:
    for x2,y2 in xy:
        X = x1-x2
        Y = y1-y2
        ans += (X**2+Y**2)**0.5

print(ans/n)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int A,B,C,X,Y;
int main() {
	scanf("%d%d%d%d%d",&A,&B,&C,&X,&Y);
	if(2*C>=A+B) {
		printf("%d\n",A*X+B*Y);
	}else {
		int ans1=max(X,Y)*C*2;
		int d=min(X,Y),ans=2*C*d;
		X-=d; Y-=d;
		if(X) ans+=X*A;
		if(Y) ans+=Y*B;
		printf("%d\n",min(ans1,ans));
	}
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define fi first
#define se second
#define pi pair<int, int>
#define ppi pair<pi, pi>
#define pb push_back
#define rep(i, a, n) for(int i = a; i <= n; i++)
#define REP(i, a, n) for(int i = a; i < n; i++)
#define per(i, a, n) for(int i = a; i >= n; i--)
#define PER(i, a, n) for(int i = a; i > n; i--)
#define pqi priority_queue<int>
#define Y "YES"
#define N "NO"
#define PI 3.14159265358979323846
using namespace std;

string s;
int n;
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	//freopen("in.txt", "r", stdin);

	cin >> n >> s;
	if (s.length() <= n) cout << s; 
	else cout << s.substr(0, n) << "...";
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 1LL << 60;
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll n;
  cin >> n;
  vector<ll> a(100010);
  rep(i,n) {
    ll q;
    cin >> q;
    ++a[q];
  }
  ll ans = 1;
  rep(i,100000) {
    ll t = a[i+1]+a[i+2]+a[i];
    ans = max(ans,t);
  }
  cout << ans << '\n';
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> D(N);
    REP(i, N) {
        int d;
        cin >> d;
        D[i] = d;
    }

    ll res = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            res += D[i] * D[j];
        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
main(){
  int N;
  cin>>N;
  int ans=0;
  int u=9;
  int uu=90;
  int uuu=900;
  int uuuu=9000;
  int uuuuu=90000;
  if(N<10){
    cout<<N<<endl;
  }
  else if((10<=N)&&(N<100)){
    cout<<u<<endl;
  }
  else if((100<=N)&&(N<1000)){
    cout<<N-uu<<endl;
  }
  else if((1000<=N)&&(N<10000)){
    cout<<u+uuu<<endl;
  }
  else if((10000<=N)&&(N<100000)){
    cout<<N-uu-uuuu<<endl;
  }
  else{
    cout<<u+uuu+uuuuu<<endl;
  }
}
          
          
          
  

Measured memory_bytes: 256
n = int(input())
b = [int(i) for i in input().split()]
a = [b[0]]
for i in range(n-2):
    c = min(b[i], b[i+1])
    a.append(c)
    
try:
    if b[-2]<=b[-1]:
        a.append(max(b[-2],b[-1]))
    else:
        a.append(min(b[-2],b[-1]))
except:
    a.append(b[0])
print(sum(a))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
const int N = (int)1e5+10 ;
const int M = (int)1000000007;
ll n ;
ll v[N] , w[N] ;
ll cache[102][N] ;
ll calc(ll idx , ll weight){
    if(idx==n )return 0 ;
    if(cache[idx][weight]) return cache[idx][weight] ;
    if(w[idx]>weight) return cache[idx][weight] =  calc(idx+1 , weight ) ;
    return cache[idx][weight] = max( v[idx] + calc(idx+1 , weight-w[idx]) , calc(idx+1 , weight) ) ;
}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    ll  i , W ;
    cin >> n >> W ;
    //ll w[n] , v[n] ;
    for(i=0 ; i<n ; i++){
        cin >> w[i]  >> v[i] ;
    }
    
    cout << calc(0 , W) ;

    
    return 0 ;
}

Measured memory_bytes: 78080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

vector<ll> par(1000000);
vector<pair<ll, ll>> rnk(1000000);

void init(ll n){
  rep(i, n){
    par.at(i) = i;
    rnk.at(i) = {0, 0};
  }
}

ll root(ll x){
  if(par.at(x) == x){
    return x;
  }
  else{
    par.at(x) = root(par.at(x));
    return par.at(x);
  }
}

bool same(ll x, ll y){
  if(root(x) == root(y)){
    return true;
  }
  else{
    return false;
  }
}

void unite(ll x, ll y){
  x = root(x);
  y = root(y);
  if(x == y){
    return;
  }
  if(rnk.at(x) < rnk.at(y)){
    par.at(x) = y;
    rnk.at(y).first += rnk.at(x).first;
    rnk.at(y).second += rnk.at(x).second;
  }
  else{
    par.at(y) = x;
    rnk.at(x).first += rnk.at(y).first;
    rnk.at(x).second += rnk.at(y).second;
  }
}

int main()
{
    ll H, W;
    cin >> H >> W;
    vector<string> S(H+1);
    rep(i, H){
        cin >> S.at(i);
        S.at(i) += "x";
    }
    S.at(H) = "";
    rep(i, W+1){
        S.at(H) += "x";
    }
    init(H*W);
    rep(i, H){
        rep(j, W){
            if(S.at(i).at(j) == '#'){
                rnk.at(i*W+j) = {1, 0};
            }
            else{
                rnk.at(i*W+j) = {0, 1};
            }
        }
    }
    rep(i, H){
        rep(j, W){
            if(S.at(i).at(j) == '#' && S.at(i).at(j+1) == '.'){
                unite(i*W+j, i*W+j+1);
            }
            if(S.at(i).at(j) == '#' && S.at(i+1).at(j) == '.'){
                unite(i*W+j, (i+1)*W+j);
            }
            if(S.at(i).at(j) == '.' && S.at(i).at(j+1) == '#'){
                unite(i*W+j, i*W+j+1);
            }
            if(S.at(i).at(j) == '.' && S.at(i+1).at(j) == '#'){
                unite(i*W+j, (i+1)*W+j);
            }
        }
    }
    set<ll> black;
    rep(i, H){
        rep(j, W){
            if(S.at(i).at(j) == '#'){
                black.insert(root(i*W+j));
            }
        }
    }
//    rep(i, H){
//        rep(j, W){
//            cout << i*W+j << " " << root(i*W+j) << endl;
//        }
//    }
//    for(auto b: black){
//        cout << b << " " << rnk.at(b).first << " " << rnk.at(b).second << endl;
//    }
    ll ans = 0;
    for(auto b : black){
        ans += rnk.at(b).first * rnk.at(b).second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 33116
n,m,x = map(int, input().split())
data_list = []
for i in range(n):
    data_list.append(list(map(int, input().split())))
    
price = 12000000

for i in range(2 ** n):
    value_list = [0]*(m+1)
    value = []
    for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            value.append(data_list[j])

    for i in range(len(value)):
        for j in range(m+1):
            value_list[j] += value[i][j]

    if min(value_list[1:]) >= x and value_list[0] < price:
        price = value_list[0]
    
    
if price == 12000000:
    print(-1)
else:
    print(price)

Measured memory_bytes: 9152