akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define initdp(a, b)  for (int i = 0; i <= a; i++)   for (int j = 0; j <= b; j++) dp[i][j] = -1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define ll long long
#define pll pair<ll, ll>
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define umapi unordered_map<ll, ll>
#define umapc unordered_map<char, int>
#define endl "\n"
using namespace std;
 
 
void solve()
{
    int n,d;
    cin>>n>>d;

    int ans = 0;
    while(n--) {
        double x,y;
        cin>>x>>y;

        double temp = x*x + y*y;
        double dist = sqrt(temp);
        if(dist <= d) {
            ans++;
        }
    }

    cout<<ans<<endl;
    
}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
  //  cin >> t;
    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3800
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BModerateDifferences solver = new BModerateDifferences();
        solver.solve(1, in, out);
        out.close();
    }

    static class BModerateDifferences {
        private static final String YES = "YES";
        private static final String NO = "NO";

        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints();
            long a = in.longs(), b = in.longs(), c = in.longs(), d = in.longs();
            for (int i = 0; i < n; i++) {
                long max = a + d * i - c * (n - 1 - i);
                long min = a + c * i - d * (n - 1 - i);
                if (min <= b && b <= max) {
                    out.println(YES);
                    return;
                }
            }
            out.println(NO);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

        public long longs() {
            return Long.parseLong(string());
        }

    }
}



Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl '\n'
#define ld long double
#define mid (l+r)/2
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
const int maxn=100005;
const int up=1e5;
pii c[2][maxn];
int main()
{
    #ifdef local
    freopen("in.txt","r",stdin);
    #endif // local
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        c[i%2][x].fi--;
        c[i%2][x].se=x;
    }
    sort(c[0]+1,c[0]+1+up);
    sort(c[1]+1,c[1]+1+up);
    int ans=1e9;
    for(int i=1;i<=up;i++)
    {
        for(int j=1;j<=2;j++)
        {
            if(c[0][i].se==c[1][j].se) continue;
            ans=min(ans,n+c[0][i].fi+c[1][j].fi);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
// itne me hi thakk gaye?
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")
#define ll long long 
#define ull unsigned long long
using ld = long double;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const ll rk = 256;
const ll mod2 = 998244353;
const ld PI = 3.141592653589793;
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define print(a) for(auto j:a) {cout<<j<<",";} cout << "\n";
#define endl '\n'
#define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
#define lwi(x) cout << " your " << #x << " is ---> " << x << " ";
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
// // Printing pair
ostream & operator << (ostream & os, pair <ll, ll> const& x) {
    os << x.first << "," << x.second;
    return os;
}
 
// printing vector
template <class T>
ostream & operator << (ostream & os, vector <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
// printing set
template <class T>
ostream & operator << (ostream & os, set <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
const int mxn = 1e6+5;
vc <int> divs(int n) {
    vc <int> d;
    for(int i=1; i<=sqrt(n); i++) {
        if(n%i == 0) {
            if(n/i == i) {
                d.pb(i);
            } else {
                d.pb(i);
                d.pb(n/i);
            }
        }
    }
    return d;
}
int32_t main(){
    FastIO;
    int n;
    cin >> n;
    vc <int> arr(n, 0);
    map<int, int> f;
    for(int i=0; i<n; i++) {
        cin >> arr[i];
        f[arr[i]]++;
    }    
    int ans = 0;
    for(auto &i: arr) {
        auto di = divs(i);
        bool ok = true;
        // whatis(i);
        if(f[i] > 1) {
            // cout << "here\n";
            ok = false;
        } else {
            for(auto el: di) {
                if (f.find(el) != f.end() && el != i) {
                    // cout << "found " << el << endl;
                    ok = false;
                    break;
                }
            }
        }
        if(ok) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13384
#include <iostream>
#include <vector>
#include <climits>
 
using namespace std;

int prefix(string s){
  vector<int> p;
  p.push_back(0);

  for(int i = 1; i < s.size(); i++)
  {
    int j = p[i-1];
    while(j > 0 && s[i] != s[j]) j = p[j-1];
    if(s[i] == s[j]) j++;
    p.push_back(j);
  }
  return p[s.size()-1];
}

int main(){
  int n;
  cin >> n;
  int dp[100100];
  int a[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  dp[1] = abs(a[1]-a[0]);
  dp[2] = abs(a[2]-a[1]);
  dp[0] = 0;
  for(int i = 2; i < n; i++){
    dp[i] = min(dp[i-1] + abs(a[i-1]-a[i]), dp[i-2] + abs(a[i-2]-a[i]));
  }
  cout << dp[n-1];
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v) {os << " [" << i++ << "]" << x; if (i % 10 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp) {os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  std::string s;
  std::cin >> s;

  print(s.substr(0, s.size()-8));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

int main() {
	ll n, d; cin >> n >> d;
	cout << (n - 1)/ (2*d + 1) + 1 << endl;
	return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  string s;
  cin >> s;
  string t;
  LL ans=0,tmp;
  for(int i=0;i<(1<<(s.length()-1));i++){
    t="";
    for(int j=0;j<s.length();j++){
      t+=s[j];
      if(i&(1<<j)){
        t+="+";
      }
    }
    tmp=0;
    for(int j=0;j<t.length();j++){
      if(t[j]=='+'){
        ans+=tmp;
        tmp=0;
      }else{
        tmp=tmp*10+(t[j]-'0');
      }
    }
    ans+=tmp;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int a,b; cin>>a>>b;
    if(b%a==0) cout<<a+b<<endl;
    else cout<<b-a<<endl;
}

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

#define		fuckshitup  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) // don't use for small inputs
#define		endl		"\n"
#define		ll			long long int
#define		mod			1000000007
#define		f(i,a,b)	for(ll i = (ll)(a); i < (ll)(b); i++)
#define		rf(i,a,b)   for(ll i = (ll)(a); i > (ll)(b); i--)
#define		ull			unsigned long long
#define		ld			long double

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = std::chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main()
{
    fuckshitup;
    ll a, b;
    cin >> a >> b;
    ll amt = -1;
    for (ll i = 1; i <= 1100; i++)
    {
        ll a1 = i * .08;
        ll a2 = i * 0.1;
        if (a1 == a && a2 == b)
        {
            amt = i;
            break;
        }
    }
    cout << amt << endl;
}


Measured memory_bytes: 256
// 2015/01/19 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int N, W;
	cin >> N >> W;

	int v[100];
	int w[100];
	for(int i=0; i<N; i++){
		cin >> v[i] >> w[i];
	}

	int dp[10001] = {0};

	for(int i=0; i<N; i++){
		for(int j=w[i]; j<=W; j++){
			dp[j] = max(dp[j], dp[j-w[i]]+v[i]);
		}
	}

	cout << dp[W] << endl;

	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

//#define INF 1e9
const ll INF = 1LL << 61;
int main(){
  int N;
  cin >> N;
  vector<ll> A(N), sum(N+1, 0);
  REP(i, N){
    cin >> A[i];
  }
  REP(i, N){
    sum[i+1] = sum[i] + A[i];
  }
  ll ans = INF;
  int l = 1, r = 2+1;
  FOR(i, 2, N-1) {
    if(i == r) r++;
    while(l< i-1 && abs(sum[i] - 2*sum[l]) > abs(sum[i] - 2*sum[l+1])){
      l++;
    }
    ll R = sum[N] - sum[i];
    while(r < N-1 && abs(R - 2*(sum[r]-sum[i])) > abs(R-2*(sum[r+1]-sum[i]))){
      r++;
    }
    ll MAX = max(max(sum[i]-sum[l], sum[l]), max(sum[N] - sum[r], sum[r] - sum[i]));
    ll MIN = min(min(sum[i]-sum[l], sum[l]), min(sum[N] - sum[r], sum[r] - sum[i]));
    ans = min(ans, abs(MAX-MIN));
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
	int nN, nK;
	cin >> nN;
	cin >> nK;

	int* aP = new int[nN];

	for (int i = 0; i < nN; i++)
	{
		cin >> aP[i];
	}

	sort(aP, aP+nN);
	int nSum = 0;

	for (int i = 0; i < nK; i++)
	{
		nSum += aP[i];
	}

	cout << nSum << endl;
}

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



int main(){
	
	int N;
	cin>>N;
	
	vector<long long> a(N);
	for(int i=0;i<N;i++)cin>>a[i];
	
	long long ans = 0LL;
	
	for(int i=1;i<N;i++){
		long long temp = 0LL;
		int r = (N-1)-i;
		int l = i;
		set<int> S;
		while(true){
			if(S.count(l)||S.count(r))break;
			if(r-i<=0)break;
			if(l>=N-1)break;
			if(r==l)break;
			temp += a[l]+a[r];
			ans = max(ans,temp);
			S.insert(l);
			S.insert(r);
			l+=i;
			r-=i;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 8772
#include<iostream>
#include<iomanip>
#include<cmath>
int main(){
  double r;
  std::cin >> r;
  std::cout << std::fixed << std::setprecision(6) << r * r * M_PI << " ";
  std::cout << std::fixed << std::setprecision(6) << 2 * r * M_PI << std::endl;
  return 0;
}

Measured memory_bytes: 3208
#include <iostream>

using namespace std;

int main(){
  int d,g;
  cin >> d >> g;
  int p[d];
  int c[d];
  int count_max=0;
  for (int i = 0; i < d; i++) {
    cin >> p[i] >> c[i];
    count_max+=p[i];
  }

  int min = count_max;
  for (int bit = 0; bit < (1<<d); bit++) {
    int sum=0;
    int count=0;
    for (int i = d-1; i >=0; i--) {
      if (bit & (1<<i)) {
        for (int k = 1; k <= p[i]; k++) {
          sum+=100*(i+1);
          count++;
          if (k==p[i]) {
            sum+=c[i];
          }
          if (sum>=g && min > count) {
            min = count;
          }
        }
      }
    }
  }

  cout << min << endl;
  return 0;
}

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

int main(){
  int n; cin >> n;
  int a[n+1], b[n+1], c[n+1];
  for(int i=1; i<=n; i++) cin >> a[i];
  for(int i=1; i<=n; i++) cin >> b[i];
  for(int i=1; i<=n; i++) cin >> c[i];

  sort(a+1, a+n+1); sort(b+1, b+n+1); sort(c+1, c+n+1);

  long long int ans=0;
  for(int i=1; i<=n; i++){
    long long int as = (long long int)(lower_bound(a+1, a+n+1, b[i])-a)-1;
    long long int cs = n-(long long int)(upper_bound(c+1, c+n+1, b[i])-c)+1;
    ans += as*cs;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
template< typename T >
struct SegmentTree{
    using F = function< T (T,T)  >;

    int size;
    vector< T > seg;

    const F f;
    const T M1;

    SegmentTree(int n,const F f,const T &M1): f(f),M1(M1){
	size = 1;
	while(size < n) size <<= 1;
	seg.assign(2*size,M1);
    }

    void set(int k, const T &x){
	seg[k+ size] = x;
    }
    void build(){
	for(int k = size-1;k>0;k--){
	    seg[k] = f( seg[2*k] , seg[2*k+1] );
	}
    }
    void update(int k,const T &x){
	k += size;
	seg[k] = x;
	while( k>>=1 ){
	    seg[k] = f(seg[2*k] , seg[2*k+1] );
	}
    }
    T query(int a,int b){
	T L = M1, R = M1;
	for( a += size, b += size; a < b ;  a >>= 1 , b >>= 1 ){
	    if( a & 1 ) L = f(L , seg[a++]);
	    if( b & 1 ) R = f(seg[--b], R) ;
	}
	return f(L,R);
    }
    T operator[](const int &k){
	return seg[ k+size ];
    }
};




int main(){
    // aoj DSL 2A
    int n,q;
    cin>>n>>q;
    SegmentTree<ll> seg( n , [](ll a,ll b){ return min(a,b) ;} , (1LL<<31)-1);
    for(int i=0;i<q;i++){
	ll t,a,b;
	cin>>t>>a>>b;
	if(t==0){
	    seg.update(a,b);
	}else{
	    cout<<seg.query(a,b+1)<<endl;
	}
    }
    return 0;
}



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

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

int main()
{
	int N;
	cin >> N;
	vec(A)
		fx(N) {
		vecp(A)
	}

	bool flag = true;
	fx(N-1) {

		if (A.at(x + 1) >= A.at(x) + 1) {
			A.at(x + 1)--;
		}

		if (A.at(x)>A.at(x+1)) {
			flag = false;
			break;
		}
	
	}
	if (flag) {
		ce("Yes")
	}
	else {
		ce("No")
	}
    return 0;
}



Measured memory_bytes: 892
#include <stdio.h>
 
int main(void){
  int n,m, vac;
  int sum =0;
  scanf("%d", &n);
  scanf("%d", &m);
  int a[n];
  for(int i=0;i<m;i++){
  scanf("%d", &a[i]);
  sum+=a[i];
  }
  vac=n-sum;
  if(vac<0)
    printf("-1\n");
  else
    printf("%d\n", vac);
  return 0;
}

Measured memory_bytes: 1736
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var b = o.l();
  var ans = b[0]+b[n-2];
  for(var i = 1; i < n-1; i++){
    ans += Math.min(b[i-1],b[i])
  }
  return ans;
}

Measured memory_bytes: 21064
s = input()
ans = []
n = len(s)
a = 1
if s[0] == "0" or s[-1] == "1":
  print(-1)
  exit()
for i in range(n-1):
  if s[i] != s[n-i-2]:
    print(-1)
    exit()
oya = n
for i in range(n-1,0,-1):
  ans.append([oya,i])
  if s[i-1] == "1":
    oya = i
for i in ans:
  print(*i)

Measured memory_bytes: 56992
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

////////////////////////////////////////////////////////

int main() {
    ll d, g; cin >> d >> g;
    Vl p(d+1), c(d+1);
    Rep(i, 1, d) cin >> p[i] >> c[i];
    // d(点数の種類) <= n であるからどの点数でコンプリートするかをbit全探索
    // 残ったもので点数の高いものから解いていく
    ll ans = INF;
    for(int tmp = 0; tmp < (1 << d); tmp++){
        ll sum = 0;
        ll so = 0;
        Vl cnt(d+1);
        Rep(i, 1, d) cnt[i] = p[i];
        bitset<15> s(tmp);
        rep(i, 0, d){
            if(s.test(i)){
                sum += (i+1)*100*p[i+1] + c[i+1];
                cnt[i+1] = 0;
                so += p[i+1];
            }
        }
        if(sum >= g){
            chmin(ans, so);
            continue;
        }

        ////////////////////////////////////////////////////////////
        // cout << s << " : ";
        // print(cnt);
        // cout << " : " << so << " " << sum ;
        ///////////////////////////////////////////////////////////

        // gを超えるまで残ったもので大きいものから解く
        for(int i = d; i >= 1; i--){
            bool f = false;
            rep(j, 0, cnt[i]){
                sum += i*100;
                so++;
                if(sum >= g){
                    f = true;
                    break;
                }
            }
            if(f) break;
        }
        chmin(ans, so);

        ////////
        // cout << " : ans " << ans << endl;
        ////////
    }
    co(ans);

    return 0;
}


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

namespace AtCoder0705
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            if (N % 1000 == 0) { Console.WriteLine(0); }
            else
            {
                Console.WriteLine(1000 - N % 1000);
            }
        }
    }
}


Measured memory_bytes: 27528
import Control.Monad (forever)
import Data.Functor ((<$>))
import System.Exit (exitSuccess)

main :: IO ()
main = forever $ do
  [a,op,b] <- words <$> getLine
  let a' = read a :: Int
      b' = read b :: Int
  case op of
    "+" -> print $ a' + b'
    "-" -> print $ a' - b'
    "*" -> print $ a' * b'
    "/" -> print $ a' `div` b'
    "?" -> exitSuccess



Measured memory_bytes: 4028
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		
		String s1="Sunny";
		String s2="Cloudy";
		String s3="Rainy";
		if(s.equals(s1)){
			System.out.println(s2);
		}else if(s.equals(s2)){
			System.out.println(s3);
		}else
			System.out.println(s1);
		
	}

}


Measured memory_bytes: 21716
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)


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

#define int long long

using namespace std;

signed main(void) {

  string s;
  cin >> s;

  int win = 0;
  for (int i = 0; i < s.length(); ++i) if (s[i] == 'o') ++win;

  if (s.length() - win > 7) {
    cout << "NO";
  } else
    cout << "YES";
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  long long n,m;cin>>n>>m;
  multiset<pair<long long,long long>> s; //{date,get}
  multiset<pair<long long,long long>> u; //{get,date}
  for (long long i=0;i<n;i++) {
    long long a,b;cin>>a>>b;
    s.insert({a,b});
  }
  for (auto p=s.rbegin();p!=s.rend();p++) {
    // cout<<p->first<<" "<<p->second<<endl;
    if ((u.size()+p->first)<=m){
      u.insert({p->second,p->first});
    }else if(u.size()&&(u.begin()->first)<(p->second)&&(u.size()-1+p->first)<=m){
      u.erase(u.begin());
      u.insert({p->second,p->first});
    }
  }
  long long a=0;
  for(auto p:u) a+=p.first;
  cout<<a<<endl;
}

Measured memory_bytes: 12800
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
vector<bool> sieve_of_eratosthenes(int num) {
  vector<bool> res(num + 1, true);
  if (num >= 0) {
    res[0] = false;
    if (num >= 1) res[1] = false;
  }
  for (int i = 2; i * i <= num; ++i) if (res[i]) {
    for (int j = i * i; j <= num; j += i) res[j] = false;
  }
  return res;
}

int main() {
  int x; cin >> x;
  vector<bool> primes = sieve_of_eratosthenes(1000000);
  while (true) {
    if (primes[x]) {
      cout << x << '\n';
      return 0;
    }
    ++x;
  }
}


Measured memory_bytes: 1020
#define  REP(i, s, e) for (register int i = (s), end_##i = (e); i <= end_##i; i++)
#define DREP(i, s, e) for (register int i = (s), end_##i = (e); i >= end_##i; i--)
#define DEBUG fprintf(stderr, "Passing [%s] in Line %d\n", __FUNCTION__, __LINE__)

#define chkmax(a, b) (a < (b) ? a = (b) : a)
#define chkmin(a, b) (a > (b) ? a = (b) : a)

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <queue>

using namespace std;

template <typename T> T read()
{
	T ans(0), flag(1);
	char c(getchar());
	while (!isdigit(c))
	{
		if (c == '-') flag = -1;
		c = getchar();
	}
	while (isdigit(c))
	{
		ans = ans * 10 + c - 48;
		c = getchar();
	}
	return ans * flag;
}

void file(string s)
{
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}


int main()
{
#ifdef CraZYali
	file("C");
#endif
	long long N;
	cin >> N;
	long long ans = 1e18;
	for (long long i = 1; i * i <= N; i++)
		if (N % i == 0) chkmin(ans, i + (N / i) - 2);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>

using namespace std;

int main() {
   
   int N;
   cin >> N;
   int a[N];
   double sum = 0;
   for (int i = 0; i < N; i++) {
      cin >> a[i];
      sum += a[i];
   }
   sum = (double) sum / N;

   double min = 200.;
   int ans;
   for (int i = 0; i < N; i++) {
      double tmp = abs(a[i] - sum);
      if (tmp < min) {
         min = tmp;
         ans = i;
      }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

int main()
{
	int n, c = 0;
	cin >> n;

	vector<int> v(n);
	for (int &x: v)
		cin >> x;

	for (auto i = v.begin(), e = v.end(); i != e - 1; i++) {
		auto min = i, j = i;
		for (; j != e; j++)
			if (*j < *min)
				min = j;
		if (i != min)
			swap(*i, *min), c++;
	}

	for (int &x: v)
		cout << (&x == &v[0] ? "" : " ") << x;
	cout << endl << c << endl;
}


Measured memory_bytes: 3112
nn = input()
n = str(input())

if len(n) % 2 == 1:
  print('No')
else:
  a = n[0 : len(n)//2]
  b = n[len(n)//2 : len(n)]
  if a == b:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 8968
n,a,b = map(int,input().split())
s = input()
count = 0
foreign = 0
for i in range(n):
    if s[i] == "a":
        if count < a+b:
            print("Yes")
            count += 1
        else:
            print("No")
    elif s[i] == "b":
        if count < a+b and foreign < b:
            print("Yes")
            count += 1
            foreign += 1
        else:
            print("No")
    else:
        print("No")


Measured memory_bytes: 4016
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const int MOD = 1000000007;

// 行列の積
template <class T>
vector<vector<T> > matrixProduct(const vector<vector<T> >& x, const vector<vector<T> >& y)
{
    int a = x.size();
    int b = x[0].size();
    int c = y[0].size();
    vector<vector<T> > z(a, vector<T>(c, 0));
    for(int i=0; i<a; ++i){
        for(int j=0; j<c; ++j){
            for(int k=0; k<b; ++k){
                z[i][j] += x[i][k] * y[k][j];
                z[i][j] %= MOD;
            }
        }
    }
    return z;
}

// 行列の累乗
template <class T>
vector<vector<T> > matrixPower(const vector<vector<T> >& x, long long k)
{
    int n = x.size();
    vector<vector<T> > y(n, vector<T>(n, 0));
    for(int i=0; i<n; ++i)
        y[i][i] = 1; // 積の単位元

    vector<vector<T> > z = x;
    while(k > 0){
        if(k & 1)
            y = matrixProduct(y, z);
        z = matrixProduct(z, z);
        k >>= 1;
    }
    return y;
}

int main()
{
    int n;
    long long k;
    cin >> n >> k;
    vector<vector<long long> > a(n, vector<long long>(n));
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            cin >> a[i][j];
        }
    }

    a = matrixPower(a, k);
    long long ans = 0;
    for(int i=0; i<n; ++i){
        ans += accumulate(a[i].begin(), a[i].end(), 0LL);
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/


int main() {
  ll N;cin >> N;
  vector<ll> a(N);
  rep(i,N) cin >> a[i],a[i]-=(i+1);
  sort(All(a));
  ll mid = a[N/2];
  ll res = 0;
  rep(i,N){
    res+=abs(a[i]-mid);
  }
  cout << res << endl;
}

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

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

int main() {
    i64 k, n;
    cin >> k >> n;
    vector<i64> a(2 * n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) a[n + i] = k + a[i];
    i64 ans = 1e9;
    for (int i = 0; i < n; ++i) {
        ans = min(ans, a[i + n - 1] - a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (int) 1e9+7
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define vi vector<int>
ll fun(ll n) {
	return (n * (n + 1)) / 2;
}
int main()
{

#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out1.txt", "w", stdout);
#endif
	fio;
	ll n;
	cin >> n;
	ll ans = 0;
	for (ll i = 1; i <= n; i++)
		ans += fun(i);
	for (ll i = 0; i < n - 1; i++) {
		ll a, b;
		cin >> a >> b;
		if (a > b)
			swap(a, b);
		ll temp = a * (n - b + 1);
		ans -= temp;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<cstdio>
#include<cstring>
#define mod 1000000007
#define N 2010
#define ll long long
using namespace std;
struct matrix{
	ll num[2][2];
	matrix(int u=0){memset(num,0,sizeof(num));num[0][0]=num[1][1]=u;}
}o,ans(1);
matrix operator +(const matrix a,const matrix b)
{
	matrix c;
	for(int i=0;i<2;i++)
		for(int j=0;j<2;j++)
		c.num[i][j]=(a.num[i][j]+b.num[i][j])%mod;
}
matrix operator *(const matrix a,const matrix b)
{
	matrix c;
	for(int i=0;i<2;i++)
		for(int j=0;j<2;j++)
			for(int k=0;k<2;k++)
			c.num[i][j]=(c.num[i][j]+a.num[i][k]*b.num[k][j])%mod;
	return c;
}
ll ksm(ll a,ll b=mod-2)
{
	if(b==0) return 1;
	if(b==1) return a;
	ll q=ksm(a,b>>1);
	if(b&1) return q*q%mod*a%mod;
	return q*q%mod;
}
bool mp[N][N];
char str[N];
int main()
{
	int n,m;
	ll k;
	scanf("%d%d%lld",&n,&m,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",str+1);
		for(int j=1;j<=m;j++)
		mp[i][j]=str[j]=='#';
	}
	int res1,res2,cnt1,cnt2,tot;
	tot=res1=cnt1=cnt2=res2=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		if(mp[i][j])
		{
			tot++;
			res1+=mp[i][j-1];
			res2+=mp[i-1][j];
		}
	for(int i=1;i<=n;i++)
	cnt1+=mp[i][1] && mp[i][m];
	for(int i=1;i<=m;i++)
	cnt2+=mp[1][i] && mp[n][i];
    if(cnt1 && cnt2){puts("1");return 0;}
    if(!cnt1 && !cnt2){printf("%lld",ksm(tot,k-1));return 0;}
    if(cnt1<cnt2){swap(cnt1,cnt2);swap(res1,res2);}
    o.num[0][0]=tot;
    o.num[1][0]=res1;
    o.num[1][1]=cnt1;
    k--;
    while(k)
    {
		if(k&1) ans=ans*o;
		o=o*o;
		k>>=1;
	}
	printf("%lld",(ans.num[0][0]-ans.num[1][0]+mod)%mod);
	return 0;
}


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

using namespace std;

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

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    deque<int> b;
    rep(i, n) {
        if (i % 2 == 0)
            b.push_back(a[i]);
        else
            b.push_front(a[i]);
    }
    if (n % 2 == 1) reverse(all(b));
    for (auto e : b) cout << e << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 3840
import math
A, B = map(int, input().split())
# [0.08x] = A so A <= 0.08x < A+1
# Thus, A/0.08 <= x < A+1
# For the first condition, mix(x) = ceil(A/0.08) and max(x) = ceil((A+1)/0.08)-1

min_A = math.ceil(A/0.08)
max_A = math.ceil((A+1)/0.08) - 1

min_B = math.ceil(B/0.1)
max_B = math.ceil((B+1)/0.1) - 1

if min(max_A, max_B) < max(min_A, min_B):
  print('-1')
else:
  print(max(min_A, min_B))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int ab=a+b, cd=c+d;
  string ans;
  if(ab>cd) ans="Left";
  if(ab<cd) ans="Right";
  if(ab==cd) ans="Balanced";
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[100007],a[107],n,k;
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<=k;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i<a[j]) break;
			if(!dp[i-a[j]])
			{
				dp[i]=1;
				break;
			}
		}
	}
	if(dp[k]) cout<<"First";
	else cout<<"Second";
}

Measured memory_bytes: 3928
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;

void solve(){
	int n;
	cin >> n;
	int a[n];
	int cnt = 0;
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		if(a[i] == 0){
			cnt++;
		}
	}
	if(cnt > 0){
		cout << 0 << endl;
		return ;
	}
	
	const int pp = 1e18;
	sort(a, a + n);
	int ans = a[0];
	for(int i = 1; i < n; ++i){
		int qq = pp / ans;
		if(pp % ans != 0)qq++;
		if(a[i] <= qq){
			ans *= a[i];
		}else{
			cout << -1 << endl;
			return ;
		}
	}
	if(ans <= pp)cout << ans << endl;
	else cout << -1 << endl;
}

int32_t main(){
	IO;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif // ONLINE_JUDGE
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


Measured memory_bytes: 4452
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<numeric>

using namespace std;

using ll = int64_t;

/// <summary>
/// 単純なcoutの時に使う
/// </summary>
#define co(a) cout<<a<<"\n"


/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)
#define reps(i, a, b) for(ll i = a; i < b; ++i)

/// <summary>
/// 迷路等で使う方向のベクトル
/// </summary>
const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

/// <summary>
/// デバッグ時に使う
/// </summary>
#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

///////////////////////////////////////////////////////////////////////////

int main() {
	ll A, B;
	cin >> A >> B;

	if ((A % 2 == 0 && B % 2 != 0) || (A % 2 != 0 && B % 2 == 0)) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}

	ll ans = (abs (A - B) / 2) + min(A, B);

	cout << ans << endl;
}



Measured memory_bytes: 256
def main():
    S = input()
    n = len(S) - 1
    ans = 0

    if n == 0:
        print(int(S))
        return

    for i in range(2 ** n):
        plus_lst = [0] * n
        for j in range(n):
            if (i >> j) & 1 == 1:
                plus_lst[n - 1 - j] = 1  # 0: "", 1: "+"

        res = 0
        num = S[0]
        for j in range(n):
            if plus_lst[j] == 0:
                num += S[j + 1]

            if plus_lst[j] == 1:
                res += int(num)
                num = S[j + 1]

            if j == n - 1:
                res += int(num)

        ans += res

    print(ans)


if __name__ == "__main__":
    main()


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

#define y1 as214
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back
#define t top()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , n) for(int i = 0 ; i < n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define ll long long
#define oo 1e16
#define int long long

const int N = 1e2 + 5;
const int VAL = 1e5 + 5;
int n , m , mod = 1e9 + 7;
int a[N];
int dp[N][VAL] , dp1[N][VAL];

int add(int a , int b)
{
    return (a + b) % mod;
}

int sub(int a , int b)
{
    return ((a - b) % mod + mod) % mod;
}

main()
{
    //freopen("candy.inp","r",stdin);
    //freopen("candy.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    FOR(i , 1 , n)
        cin >> a[i];
    if(n <= 2)
    {
        if(n == 1)
        {
            if(a[1] >= m)
                cout << "1" << "\n";
            else
                cout << "0" << "\n";
        }
        else
        {
            int r = m;
            int l = m - a[1];
            r = min(r , a[2]);
            l = max(l , (ll)0);
            cout << r - l + 1 << "\n";
        }
    }
    else
    {
        dp[0][0] = 1;
        FOR(j , 0 , m)
            dp1[0][j] = 1;
        FOR(i , 1 , n)
        {
            FOR(j , 0 , m)
            {
                dp[i][j] = dp1[i - 1][j];
                if(j - a[i] - 1 >= 0)
                    dp[i][j] = sub(dp[i][j] , dp1[i - 1][j - a[i] - 1]);
            }
            dp1[i][0] = dp[i][0];
            FOR(j , 1 , m)
                dp1[i][j] = add(dp1[i][j - 1] , dp[i][j]);
        }
        cout << dp[n][m];
    }
}


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

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  if (S[K - 1] == 'A')
    S[K - 1] = 'a';
  else if (S[K - 1] == 'B')
    S[K - 1] = 'b';
  else 
    S[K - 1] = 'c';
  cout << S << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    S=input()
    for i,s in enumerate(S,1):
        if(i&1 and s=='L'):
            print("No")
            return
        if(i&1==0 and s=='R'):
            print("No")
            return
    print("Yes")
resolve()

Measured memory_bytes: 38384
while 1:
  n = input()
  if n==0: break
  A = []
  for _ in [0]*n:
    x,y,h,w = map(int, raw_input().split())
    a = max(5-(160-x-y-h)/20, 0)
    b = 5-(25-w)/5 if w>2 else 0
    A.append(max(a, b))
  print sum([600 + e*200  for e in A if e<6])

Measured memory_bytes: 4508
N,M= map(int, input().split())
X= list(map(int, input().split()))

X.sort()

if N >= M:
    print(0)

elif N == 1:
    print(abs(max(X) - min(X)))

else:
    load = [X[i] - X[i - 1] for i in range(1, M)]
    load.sort()
    print(sum(load[:M - N]))

Measured memory_bytes: 20868
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;

template<typename T>
inline bool chmin(T& x, T a) {
	if (x >= a) { x = a; return true; }
	return false;
}

template<typename T>
inline bool chmax(T& x, T a) {
	if (x <= a) { x = a; return true; }
	return false;
}

int main() {
	ll A, B, M; cin >> A >> B >> M;
	vector<ll> a, b;

	ll m1 = 1LL << 60, m2 = 1LL << 60;
	for (int i = 0; i < A; i++) {
		ll c; cin >> c;
		a.push_back(c);
		chmin(m1, c);
	}
	for (int i = 0; i < B; i++) {
		ll c; cin >> c;
		b.push_back(c);
		chmin(m2, c);
	}

	ll ans = m1 + m2;
	for (int i = 0; i < M; i++) {
		int x, y, c; cin >> x >> y >> c;
		x--, y--;
		chmin(ans, a[x] + b[y] - c);
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  
  if ((a<=c)&&(b>=c)&&(b<=d)){
    cout << b-c <<endl;
  }
  else if((c>=a)&&(b>=d)){
    cout << d-c <<endl;
  }
   else if((c<=a)&&(a<=d)&&(b>=d)){
     cout <<d-a <<endl;
   }
  else if((c<=a)&&(d>=b)){
    cout << b-a <<endl;
          }
  else{
    cout << "0" <<endl;
  }
}
    

    


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;

int main()
{
    int n;
    int i;
    int temp;
    int cnt4=0,cnt2=0;

    scanf("%d",&n);
    for(i = 1;i <= n;i++)
    {
        scanf("%d",&temp);
        if(temp%4 == 0)
        {
            cnt4++;
        }
        else if(temp%2 == 0)
        {
            cnt2++;
        }
    }
    cnt4 += cnt2/2;
    if(cnt4 >= n/2) printf("Yes\n");
    else printf("No\n");

    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
    int h,w;
    scanf("%d%d",&h,&w);
    char s[h+1][w+1];
    for (int i=0; i<h; i++){
        scanf("%s",s[i]);
    }
    for (int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(s[i][j]=='#'){
                if(s[i][j-1]=='#' || s[i][j+1]=='#' || s[i-1][j]=='#' || s[i+1][j]=='#'){
                    
                } else {
                    printf ("No\n");
                    exit (0) ;
                }
            }
        }
    }
    printf ("Yes\n");
    return 0 ;
}

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

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

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

    // start
    char a, b;
    cin >> a >> b;
    if (a == '9' || b == '9')
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    // end

    return 0;
}


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

int main() {
    int h,w;
    cin >> h >> w;
    vector<string> c(h);
    for(int i=0;i<h;i++){
        cin >> c[i];
    }
    for(int i=0;i<h;i++){
        cout << c[i]<< endl;
        cout << c[i]<< endl;
    }


    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    S = [int(s) for s in list(input().strip())][::-1]
    N,P = len(S), 2019
    
    num = 0
    ans = 0
    
    if P == 2 or P == 5:
    	for i in range(N):
    		if S[i] % P == 0:
    			ans += N-i
    	print(ans)
    	return

    L = [0] * P
    L[0] = 1
    t = 0
    s = 1
	
    for z in S:
    	t = (z * s + t)%P	
    	L[t]+=1
    	s = s * 10 % P
	
    for l in L:
    	ans += l * (l - 1) // 2
    
    print(ans)


if __name__ == '__main__':
	main()

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

bool ok(char a, char b, char c)
{
    return ((a != b) and (a != c) and (b != c));
}
int main()
{
    int n;
    cin >> n;

    string s;
    cin >> s;

    vector<int> r, g, b;

    for (int i = 0; i < n; i++)
    {
        if(s[i] == 'R')
            r.push_back(i);
        else if(s[i] == 'G')
            g.push_back(i);
        else
            b.push_back(i);
    }

    long long cnt = r.size()*g.size()*b.size();

    for (int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            if(s[i] == s[j])
                continue;
            int k = 2 * j - i;

            if(k>=n or s[j] == s[k] or s[i] == s[k])
                continue;

            cnt--;
        }
    }

  

    // for (int i = 0; i < s.size(); i++)
    // {
    //     for (int j = i + 1; j < s.size(); j++)
    //     {
    //         for (int k = j + 1; k < s.size(); k++)
    //         {
    //             if (ok(s[i], s[j], s[k]))
    //             {
    //                 if (j - i != k - j)
    //                     cnt++;
    //             }
    //         }
    //     }
    // }

    cout << cnt << endl;
}

Measured memory_bytes: 3644