akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void){
    int n, a, b;

    scanf("%d %d %d", &n, &a, &b);

    int sum = 0;
    int sum_k = 0;
    for(int i = 0;i <= n;++i){
        sum_k = i % 10 + ((i / 10) % 10) + ((i / 100) % 10) + ((i / 1000) % 10) + (i / 10000);
        if(a <= sum_k && sum_k <= b) sum += i;
    }

    printf("%d\n", sum);

    return 0;
}

Measured memory_bytes: 1688
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();

        int Aloc = s.length();
        int Zloc = 0;

        for (int i = 0; i < s.length(); i++) {

            if (s.charAt(i) == 'A') {
                if (i < Aloc)
                    Aloc = i;
            }

            if (s.charAt(i) == 'Z') {
                if (i > Zloc)
                    Zloc = i;
            }


        }

        System.out.println(Zloc - Aloc + 1);




    }


}


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

const int maxn = 1e5+3,M=1e9+7;
long long cnt[maxn],a[maxn],d[maxn];
int n;

int main() {
    ios::sync_with_stdio(0);
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    if(a[1]!=0) {
        cout<<0<<endl; return 0;
    }
    cnt[0] = 1;
    d[1]=3;
    for(int i=2;i<=n;i++) {
        if(cnt[a[i]]==0) {
            d[i] = d[i-1]*cnt[a[i]-1] % M;
        }else {
            int pre = a[i]==0 ? 3: cnt[a[i]-1];
            d[i] = d[i-1]*(pre-cnt[a[i]]) % M;
        }
        cnt[a[i]]++;
        if(cnt[a[i]]==4) {
            cout<<0<<endl; return 0;
        }
    }
    cout<<d[n]<<endl;
    return 0;
}




Measured memory_bytes: 2560
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[2][90010] = {};
ll dp2[2][90010] = {};
ll power(ll x, ll n){
    if(n == 0) return 1LL;
    ll res = power(x * x % MOD, n/2);
    if(n % 2 == 1) res = res * x % MOD;
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll a[310];
    rep(i,0,N) cin >> a[i];
    dp[0][0] = 1;
    dp2[0][0] = 1;
    ll sum = 0;
    rep(i,0,N) sum += a[i];
    ll cur = 0, nxt = 1;

    rep(i,0,N){
        rep(j,0,sum + 1){
            dp[nxt][j] = 0;
            dp2[nxt][j] = 0;
            if(j - a[i] >= 0) dp[nxt][j] += dp[cur][j - a[i]];
            if(j - a[i] >= 0) dp2[nxt][j] += dp2[cur][j - a[i]];
            (dp[nxt][j] += 2 * dp[cur][j]) %= MOD;
            (dp2[nxt][j] += dp2[cur][j]) %= MOD;

        }
        cur ^= 1;
        nxt ^= 1;
    }

    ll ans = 0;
    rep(i,(sum+1)/2, sum+1){
        (ans += dp[cur][i]) %= MOD;
    }
    if(sum % 2 == 0){
        ans -= dp2[cur][sum/2];
        ans = (ans + MOD) % MOD;
    }
    ans *= 3;
    ans %= MOD;

    ans = (power(3,N) - ans + MOD) % MOD;
    print(ans);

}

Measured memory_bytes: 3072
// Problem : A - Fifty-Fifty
// Contest : AtCoder Beginner Contest 132
// URL : https://atcoder.jp/contests/abc132/tasks/abc132_a
// Memory Limit : 1024,000000 MB 
// Time Limit : 2000,000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <cmath>
#include <cstdio>

#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <map>
#include <set>
#include <vector>

using namespace std;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

string s;

map<char, int> a;

void input() {
  cin >> s;
}

void solve1() {
  for (auto&& i : s)
    a[i]++;
    
  if (a.size() == 2) {
    cout << "Yes";
    
    exit(0);
  }
  
  cout << "No";
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();
  input();
  solve1();
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    
    int n,i,j;
    int a[4][14]={0};
    char b;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf(" %c %d",&b,&j);
        if(b=='S'){
            a[0][j]=1;
        }else if(b=='H'){
            a[1][j]=1;
        }else if(b=='C'){
            a[2][j]=1;
        }else if(b=='D'){
            a[3][j]=1;
        }
        else
            ;
    }
    for(i=0;i<4;i++){
        for(j=1;j<=13;j++){
                if(i==0&&a[i][j]==0)
                    printf("S %d\n",j);
                else if(i==1&&a[i][j]==0)
                    printf("H %d\n",j);
                else if(i==2&&a[i][j]==0)
                    printf("C %d\n",j);
                else if(i==3&&a[i][j]==0)
                    printf("D %d\n",j);
                else
                    ;
        }
    }
    return 0;
}

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

int cal(int n){
    int ret=(ll)n*(n+1)*(n+2)/6;
    return ret;
}

int main(){

    vector<int> dp(1e+6,1e+6),odp(1e+6,1e+6);
    dp[0]=0;
    odp[0]=0;
    dp[1]=1;
    odp[1]=1;
    vector<int> c,oc;
    for(int i=0;cal(i)<2e+6;i++){
        c.push_back(cal(i));
        if(cal(i)%2==1){
            oc.push_back(cal(i));
        }
    }
    for(int i=2;i<1e+6;i++){
        for(int j=0;c[j]<=i;j++){
            dp[i]=min(dp[i],dp[i-c[j]]+1);
        }
    }
    for(int i=2;i<1e+6;i++){
        for(int j=0;oc[j]<=i;j++){
            odp[i]=min(odp[i],odp[i-oc[j]]+1);
        }
    }

    while(1){
        int n;
        cin >> n;
        if(n==0){
            break;
        }
        cout << dp[n] << " " << odp[n] << endl;
    }

    return 0;
}


Measured memory_bytes: 10472
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> ipair;
typedef tuple<int, int, int> ituple;

// const int INF = INT_MAX;
const ll INF = LLONG_MAX / 2;
// const int MOD = ((int)1e9 + 7);
// const ld EPS = (1e-10);
#define PI acosl(-1)
#define MAX_N (200000 + 3)

ll dp[MAX_N][6];

ll score(ll a, int phase){
  ll result = 0;

  switch (phase){
    case 0 :
    case 4 :
      result = a;
      break;
    case 1 :
    case 3 :
      if (a == 0){
        result = 2;
      }
      else {
        result = a % 2;
      }
      break;
    case 2:
      result = (a + 1) % 2;
      break;
    default:
      assert(false);
  }

  // printf("score(%lld, %d) = %lld\n", a, phase, result);
  return result;
}

void exec(){
  int l, a[MAX_N];
  cin >> l;
  for (int i = 0; i < l; i++){
    scanf("%d", &a[i]);
  }

  for (int i = 0; i < MAX_N; i++){
    for (int j = 0; j < 6; j++){
      dp[i][j] = INF;
    }
  }

  for (int i = 0; i < 6; i++){
    dp[0][i] = 0;
  }

  for (int i = 0; i < l; i++){
    for (int j = 0; j < 5; j++){
      // if (j) {
      //   dp[i][j] = min(dp[i][j], dp[i][j-1]);
      // }
      ll tmp = dp[i][j] + score(a[i], j);
      dp[i + 1][j] = min(dp[i+1][j], tmp);
      if (j) {
        dp[i + 1][j] = min(dp[i+1][j-1], tmp);
      }
      // printf("dp[%d][%d] = %lld\n", i+1, j, dp[i+1][j]);
    }
  }

  cout << dp[l][4] << endl;
}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

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


Measured memory_bytes: 10496
n = int(input())
a = 0
b = 0
c = 0
ans = 0
for _ in range(n):
    s = input()
    if s[0]=='B' and s[-1]=='A':
        c+=1
    elif s[0]=='B':
        b+=1
    elif s[-1]=='A':
        a+=1
    
    for i in range(len(s)-1):
        if s[i:i+2] == 'AB':
            ans += 1
if c>0:
    ans += c-1
    if b>0:a += 1
    if a>0:b += 1

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

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

int main(){
    int n;
    cin >> n;
    int answer = 0;
    rp(i,n){
        int a;
        cin >> a;
        if(a==answer+1) answer++;
    }
    if(answer==0){
        cout << -1 <<endl;
        return 0;
    }
    cout << n - answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int a, b, c; cin >> a >> b >> c;
	cout << (a <= c && b >= c ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string a,b;
  cin>>a>>b;
 if(a[0]==b[2] && a[1]==b[1] && a[2]==b[0])
   {
     cout<<"YES"<<endl;
   }else{
   cout<<"NO"<<endl;
 }
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<" ";}return os;}

namespace ndifix{
template<class T>void sort(T &v){std::sort(v.begin(),v.end());}
}

int main(){
  int n;cin>>n;
  vector<int> a(n);for(int i=0;i<n;i++)cin>>a[i];
  ndifix::sort(a);
  multiset<int> md;for(int i=0;i<n;i++)md.insert(a[i]);
  set<int> d;for(int i=0;i<n;i++)d.insert(a[i]);
  for(auto itr=d.begin();itr!=d.end();itr++){
    if(md.count(*itr)==1){d.erase(*itr);itr--;}
  }
  set<int> s;
  vector<int> list;
  for(auto itr=d.begin();itr!=d.end();itr++)list.push_back(*itr);
  ndifix::sort(list);

  while (a.size()>=5){
    if(list.size() && list[0]<a[0]){list.erase(list.begin());continue;}
    if(list.size() && list.back()>a.back()){list.pop_back();continue;}
    if(list.size() && std::distance(std::lower_bound(a.begin(),a.end(),list[0]),
                                    std::upper_bound(a.begin(),a.end(),list[0]))==1){list.erase(list.begin());continue;}
    if(list.size() && std::distance(std::lower_bound(a.begin(),a.end(),list.back()),
                                    std::upper_bound(a.begin(),a.end(),list.back()))==1){list.pop_back();continue;}
    if(a[0]!=a[1]  && a[a.size()-2]!=a[a.size()-1]){s.insert(a[0]);s.insert(a.back());a.erase(a.begin());a.pop_back();continue;}
    if(a[0]==a[1]  && a[a.size()-2]==a[a.size()-1]){a.erase(a.begin());a.pop_back();continue;}
    if(d.size()==1){a.erase(a.begin());a.pop_back();continue;}
    if(a[0]==a[1]){a.erase(a.begin());a.erase(std::lower_bound(a.begin(),a.end(),list.back()));continue;}
    if(a[a.size()-2]==a[a.size()-1]){a.pop_back();a.erase(std::lower_bound(a.begin(),a.end(),list[0]));continue;}
  }
  if(a[0]==a[1] || a[1]==a[2])s.insert(a[1]);
  else for(int i=0;i<3;i++)s.insert(a[i]);

  
  cout<<s.size()<<endl;

  return 0;
}

Measured memory_bytes: 9984
#include <stdio.h>
int main(){
	int a,b,c,d,e,f;
	scanf("%d %d %d",&a,&b,&c);
	d=abs(a-b);
	e=abs(b-c);
	f=abs(c-a);
	if (d<=e&&f<=e)
	{
		printf("%d\n",d+f);
	}else if (e<=d&&f<=d)
	{
		printf("%d\n",e+f);
	}else if (d<=f&&e<=f)
	{
		printf("%d\n",d+e);
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (ll &i : a)
    cin >> i;
  ll sum = a.back(), ans = 0;
  for (int i = n - 2; i >= 0; i--) {
    ans = (ans + a[i] * sum) % mod;
    sum = (sum + a[i]) % mod;
  }
  cout << ans;
}

Measured memory_bytes: 4784
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<long> X(n);
    vector<long> L(n);

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

    vector<pair<long, long>> armpoint(n);
    for(int i=0; i<n; i++){
        armpoint[i] = pair<long, long>(X[i] + L[i], X[i] - L[i]);
    }
    sort(armpoint.begin(), armpoint.end());
    int ans = 0;
    int con_l = -1000000000;
    for(int i=0; i<n; i++){
        if(con_l <= armpoint[i].second){
            ans++;
            con_l = armpoint[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;
	
	int a, b, c, d; cin>>a>>b>>c>>d;
	cout << max({a*c, a*d, b*c, b*d});
	return 0;
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
#define CAT(a,b)a b
#define VASIZE(a,b,N,...)N
template<class T>auto size(T&&a)->decltype(a.size(), int()) { return a.size(); }
template<class T, class = enable_if_t<is_integral<T>::value, T>>int size(T a) { return a; }
#define REP(t,a,N)for(int t=size(a),_l##t=size(N);t<_l##t;t++)
#define RREP(t,a,N)for(int t=size(N)-1,_l##t=size(a);t>=_l##t;t--)
#define rep(t,...)CAT(REP,VASIZE(__VA_ARGS__,(t,__VA_ARGS__),(t,0,__VA_ARGS__)))
#define rrep(t,...)CAT(RREP,VASIZE(__VA_ARGS__,(t,__VA_ARGS__),(t,0,__VA_ARGS__)))
#define all(a)(a).begin(),(a).end()
typedef long long ll;
typedef unsigned long long ull;
void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/


void Calc() {
  ll a, b;
  in, a, b;
  if (a <= 0 && 0 <= b) {
    cout << ("Zero") << endl;
  } else {
    if (0 <= a) {
      cout << ("Positive") << endl;
    } else {
      if (b < 0) {
        if ((b + a + 1) % 2 == 0) {
          cout << ("Positive") << endl;
        } else {
          cout << ("Negative") << endl;
        }
      } else {
        if (a % 2 == 0) {
          cout << ("Positive") << endl;
        } else {
          cout << ("Negative") << endl;
        }
      }
    }
  }

}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

//sは初めの点、vは頂点size、dは最短距離を求める(初期化はINF),Gは有向グラフ
void dijkdtra(int s,int v,vector<int>&d,whei(edge)&G) {
	priority_queue<Pint, vector<Pint>, greater<Pint>> que;//firstが距離、secondが頂点
	d[s] = 0;//スタートの距離はもちろんzero
	que.push(Pint(0, s));
	while (!que.empty()) {
		Pint p = que.top();
		que.pop();
		int V = p.second;
		if (d[V] < p.first)continue;
		for (int i = 0; i < G[V].size();i++) {
			edge e = G[V][i];
			if (d[e.to] > d[V] + e.cost) {
				d[e.to] = d[V] + e.cost;
				que.push(Pint(d[e.to], e.to));
			}
		}
	}
}

int main() {
	llint n,m;
	cin >> n >> m;
	hei(llint) a(n + 1, 0);
	rep(i, 0, n) {
		llint b;
		cin >> b;
		a[i + 1] = (a[i] + b) % m;
	}
	llint ans = 0;
	sort(a.begin(), a.end());

	a.push_back(m + 1);
	llint x = 1;
	rep(i, 0, n) {
		if (a[i] == a[i + 1])x++;
		else {
			ans += (x*(x - 1)) / 2;
			x = 1;
		}
	}
	ans += x * (x - 1) / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,q,l,r,ans=0,b[100005]={};
  string s;
  cin>>n>>q>>s;
  for(int i=0;i<n;i++){
    if(s[i]=='A' && s[i+1]=='C')
      b[i]++;
    b[i]+=b[i-1];
  }
  for(int i=1;i<=q;i++){
    cin>>l>>r;
    ans+=b[r-2]-b[l-2];
  cout<<ans<<endl;
  ans=0;
  }
  return(0);
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define SIZE 200005
#define INF 1000000000
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int D[SIZE];
vector <P> vec[SIZE];
int ans[SIZE],col[SIZE];
bool act[SIZE];
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++) scanf("%d",&D[i]);
	for(int i=0;i<m;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);a--,b--;
		vec[a].push_back(P(b,i));
		vec[b].push_back(P(a,i));
	}
	for(int i=0;i<n;i++)
	{
		bool up=false;
		for(int j=0;j<vec[i].size();j++)
		{
			int to=vec[i][j].first;
			if(D[to]<=D[i]) up=true;
		}
		if(!up)
		{
			puts("-1");
			return 0;
		}
	}
	vector <P> vx;
	for(int i=0;i<n;i++) vx.push_back(P(D[i],i));
	sort(vx.begin(),vx.end());
	memset(col,-1,sizeof(col));
	for(int i=0;i<n;i++)
	{
		int v=vx[i].second;
		//printf("* %d\n",v);
		act[v]=true;
		bool up=false;
		for(int j=0;j<vec[v].size();j++)
		{
			int to=vec[v][j].first;
			if(act[to])
			{
				if(D[to]==D[v])
				{
					//printf("* %d %d\n",to,vec[v][j].second);
					up=true;
					if(col[to]==-1)
					{
						if(col[v]!=-1) col[to]=1-col[v];
						else col[to]=0,col[v]=1;
					}
					else if(col[v]==-1) col[v]=1-col[to];
					ans[vec[v][j].second]=D[v];
				}
			}
		}
		if(up)
		{
			for(int j=0;j<vec[v].size();j++)
			{
				int to=vec[v][j].first;
				if(act[to]&&D[to]<D[v]) ans[vec[v][j].second]=INF;
			}
		}
		else
		{
			for(int j=0;j<vec[v].size();j++)
			{
				int to=vec[v][j].first;
				if(act[to])
				{
					if(col[v]==-1) col[v]=col[to],ans[vec[v][j].second]=D[v]-D[to];
					else ans[vec[v][j].second]=INF;
				}
			}
		}
	}
	for(int i=0;i<n;i++) printf("%c",col[i]==0?'B':'W');
	puts("");
	for(int i=0;i<m;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 15608
#include <iostream>
#include<string.h>
#include<math.h>
#include<numeric>

using namespace std;

int main() {
	long long A, B, C, D,sup,exp,tmp,x,r,CC,DD;
	cin >> A >> B >> C >> D;
	CC = C; DD = D;
	x = C * D;

	if (C < D) {
		tmp = C;
		C = D;
		D = tmp;
	}

	r = C % D;
	while (r != 0) {
		C = D;
		D = r;
		r = C % D;
	}

	sup = ((A - 1) / CC) + ((A - 1) / DD) - ((A - 1) / (x / D));
	exp = (B / CC) + (B / DD) - (B / (x / D));
	cout <<B - A + 1 - exp + sup << endl;
		return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(){
	int a, b;
	char op;
	cin >> a >> op >> b;
	while (op != '?'){
		if (op == '+') cout << a + b << endl;
		if (op == '-') cout << a - b << endl;
		if (op == '*')cout << a*b << endl;
		if (op == '/')cout << a / b << endl;
		cin >> a >> op >> b;
	}
	return 0;
}


Measured memory_bytes: 3060
import math

anser=0
count=0
n  = int(input())
a = list(map(int, input().split()))
data  = []
result =[]
# for i in a[:math.floor(n/2-1):-1]:
# 	data.append(i)
# print(data)	
for i in range(n,0, -1):
	try:
		for s in range (2,math.floor(n/(i)+1)):
			count += data[-i*(s-1)]
	except IndexError:
		count = 0 
	data.append((count+a[i-1])%2)
	anser+=(count+a[i-1])%2
	count=0


print(anser)
if anser!=0:
	for i ,j in enumerate(data[::-1]):
		if j ==1:
			result.append(i+1)
	print(' '.join(list(map(str, result))))


Measured memory_bytes: 20404
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
 int n,k[112345],sum=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>k[i];
    sum+=k[i];
  }
  
  if(sum%10!=0){
    cout<<sum<<endl;
    return 0;
  }
  else{
    sort(k,k+n);
    for(int i=0;i<n;i++){
      if(k[i]%10!=0){
        sum-=k[i];
        if(k[i]%10!=0){
         cout<<sum<<endl;
          return 0;
        }
      } 
    }
  }
  cout<<"0"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int ans = 0;
        for (int i=0;i<s.length();i++){
            if (s.charAt(i)!=t.charAt(i))ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 41144
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
D = [int(sys.stdin.readline()) for _ in range(N)]

print(len(set(D)))


Measured memory_bytes: 13632
#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define pb push_back
#define sd(x) scanf("%d",&x)
#define nax 101010
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define mp make_pair
#define pi pair<int ,int>
#define pii pair <pi,pi>
using namespace std;
char ans[1000];
int main(int argc, char const *argv[])
{
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  int n;
  stack < int > stk;
  sd(n);
  scanf("%s",ans+200);
  n+=200;
  int idx = 200;
  for(int i=200;i<n;i++)
  {
      if(ans[i] == '(')
        stk.push(1);
      else
        if(ans[i] == ')')
        {
            if(stk.size() > 0)
              stk.pop();
            else
            {
               ans[199] = '(';
               for(int j=n;j > 199;j--)
               {
                  ans[j] = ans[j-1];
               }
                n++;
                i++;
            }
        }
  }
  for (int i = n;!stk.empty(); ++i)
  {
    ans[i] = ')';
    n++;
    stk.pop();
  }
  for (int i = idx; i < n; ++i)
  {
     cout << ans[i];
  }
  return 0;
}
 

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    ll h,w;
    cin>>h>>w;
    string s[100];
    rep(i,h){
        cin>>s[i];
    }
    char a[100][100];
    rep(i,h)rep(j,w) a[i][j]='.';
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#'){
                if(i+1<h&&s[i+1][j]=='#'){
                    a[i][j]='#',a[i+1][j]='#';
                }
                if(j+1<w&&s[i][j+1]=='#'){
                    a[i][j]='#',a[i][j+1]='#';
                }
            }
        }
    }
    bool ok=true;
    rep(i,h){
        rep(j,w){
            // cout<<a[i][j];
            if(s[i][j]!=a[i][j]) ok=false;
        }
        // cout<<endl;
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


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

int f(vector<int> a, vector<int> b) {
	vector<int> x[2], y[2];
	for(int i = 0; i < a.size(); ++i) x[a[i]].push_back(i);
	for(int i = 0; i < b.size(); ++i) y[b[i]].push_back(i);
	if(x[0].size() != y[0].size() || x[1].size() != y[1].size()) return INT_MAX;
	int ret = 0;
	for(int i = 0; i < x[0].size(); ++i) ret += abs(x[0][i] - y[0][i]);
	for(int i = 0; i < x[1].size(); ++i) ret += abs(x[1][i] - y[1][i]);
	return (ret >> 1);
}

int main() {
	int n, m; scanf("%d%d", &n, &m);
	vector<int> a(n), b;
	for(auto &v: a) scanf("%d", &v);
	for(int t, j = 0; m-- && scanf("%d", &t); j ^= 1) while(t--) b.push_back(j);
	int ans = f(a, b);
	for(auto &v: a) v ^= 1;
	printf("%d\n", min(ans, f(a, b)));
	return 0;
}

Measured memory_bytes: 1200
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import qualified Control.Monad.State as S
import Test.HUnit

main :: IO ()
-- main = runTestTT (TestList tests) >> return ()
main = do
  n <- getl toInt
  xs <- rgetl n solve
  mapM_ putStrLn xs

solve :: String -> String
solve (s:ss) = S.evalState (parse ss) (0,[s])


parse :: String -> S.State (Int,String) String
parse [] = do
  (_,xs) <- S.get
  return xs

parse ('-':'>':c:cs) = do
  (p,xs) <- S.get
  if length xs == p + 1
    then do
      S.put (p+1,xs ++ [c])
      parse cs
    else do
      S.put (p+1,xs)
      parse cs

parse ('<':'-':c:cs) = do
  (p,xs) <- S.get
  if p == 0
    then do
      S.put (0,c:xs)
      parse cs
    else do
      S.put (p-1,xs)
      parse cs

toInt :: String -> Int
toInt = read

getl :: (String -> a) -> IO a
getl f = f <$> getLine

rgetl :: Int -> (String -> a) -> IO [a]
rgetl n f = map f <$> replicateM n getLine

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

int main(void) {
	int H, W;
	scanf("%d", &H);
	scanf("%d", &W);

	int A[H][W];
	int i, j;
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			scanf("%d", &A[i][j]);
		}
	}

	int cousa[H][W];
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			cousa[i][j] = 0;
		}
	}

	int o, p;
	for (o = 0; o < H; o++) {
		for (p = 0; p < W; p++) {
			for (i = 0; i < H; i++) {
				for (j = 0; j < W; j++) {
					if (abs(o - i) < abs(p - j)) {
						cousa[o][p]+=abs(o - i)*A[i][j];
					}
					else {
						cousa[o][p] += abs(p - j)*A[i][j];
					}
				}
			}
		}
	}

	int min = cousa[0][0];
	for (o = 0; o < H; o++) {
		for (p = 0; p < W; p++) {
			if (min > cousa[o][p]) {
				min = cousa[o][p];
			}
		}
	}

	printf("%d\n", min);
	return 0;


}


Measured memory_bytes: 2096
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

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

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
	int n;
	int a[100005];
	scanf("%d",&n);
	memset(a,0,sizeof(a));
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	int x=0;
	for(int j=0;j<n;)
	{
		if(a[j]==a[j+1])
		{
		x+=0;
		j+=2;
	}
		else
		{
			j+=1;
			x++;
		}

	}
	printf("%d\n",x);
	return 0;
}

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

struct StCond                  // 材料質量・限界量
{
  int m_nWaterA;
  int m_nWaterB;
  int m_nSugerC;
  int m_nSugerD;
  double m_nConcE;
  int m_nLimitF;
};

struct StAmt                   // 使用量
{
  StAmt() : m_nAmtA(0), m_nAmtB(0), m_nAmtC(0), m_nAmtD(0) { }

  int m_nAmtA, m_nAmtB, m_nAmtC, m_nAmtD;
};

struct StRslt                  // 出力結果
{
  StRslt() : m_nAllMass(0), m_nSugerMass(0) { }

  int m_nAllMass, m_nSugerMass;
};

void fnInput(StCond& roCond)
{
  cin >> roCond.m_nWaterA >> roCond.m_nWaterB >> roCond.m_nSugerC >> roCond.m_nSugerD;
  cin >> roCond.m_nConcE  >> roCond.m_nLimitF;
}

void fnAmtClear(string sProc, const StCond& cnroCond, StAmt& roAmt)
{ 
  if      (sProc == "A")
    { roAmt.m_nAmtA = 0; roAmt.m_nAmtB = 0; roAmt.m_nAmtC = 0; roAmt.m_nAmtD = 0; }
  else if (sProc == "B")
    { roAmt.m_nAmtB = 0; roAmt.m_nAmtC = 0; roAmt.m_nAmtD = 0; }
  else if (sProc == "C")
    { roAmt.m_nAmtC = 0; roAmt.m_nAmtD = 0; }
  else if (sProc == "D")
    { roAmt.m_nAmtD = 0; }
}

int fnAmtSumup(string sProc, const StCond& cnroCond, const StAmt& cnroAmt)
{ 
  if (sProc == "ALL")
    return  (cnroCond.m_nWaterA * cnroAmt.m_nAmtA + cnroCond.m_nWaterB * cnroAmt.m_nAmtB) * 100
          + (cnroCond.m_nSugerC * cnroAmt.m_nAmtC + cnroCond.m_nSugerD * cnroAmt.m_nAmtD);
  else                       // sProc == "SUG"         
    return  (cnroCond.m_nSugerC * cnroAmt.m_nAmtC + cnroCond.m_nSugerD * cnroAmt.m_nAmtD);
}

double fnConcCalc(const StCond& cnroCond, const StAmt& cnroAmt)
{
  static double nLimtConc = 0;

  if (!nLimtConc)
    nLimtConc = cnroCond.m_nConcE / (100.0 + cnroCond.m_nConcE);

  double nNowConc =  (double)fnAmtSumup("SUG", cnroCond, cnroAmt)
                   / (double)fnAmtSumup("ALL", cnroCond, cnroAmt);

  if (nLimtConc < nNowConc)  return 0.0;
  else                       return nNowConc;
}

void fnConcCheck(const StCond& cnroCond, StRslt& roRslt)
{
  StAmt oAmt;
  double nMaxConc = -1.0;

  fnAmtClear("A", cnroCond, oAmt);
  while (true)
  {
    fnAmtClear("B", cnroCond, oAmt);
    if (fnAmtSumup("ALL", cnroCond, oAmt) > cnroCond.m_nLimitF)  break;

    if (!oAmt.m_nAmtA)  oAmt.m_nAmtB = 1;
    while (true)
    {
      fnAmtClear("C", cnroCond, oAmt);
      if (fnAmtSumup("ALL", cnroCond, oAmt) > cnroCond.m_nLimitF)  break;

      while (true)
      {
        fnAmtClear("D", cnroCond, oAmt);
        if (fnAmtSumup("ALL", cnroCond, oAmt) > cnroCond.m_nLimitF)  break;

        while (true)
        {
          if (fnAmtSumup("ALL", cnroCond, oAmt) > cnroCond.m_nLimitF)  break;

          double nNowConc = fnConcCalc(cnroCond, oAmt);
          if (nMaxConc < nNowConc)
          {
            nMaxConc = nNowConc;
            roRslt.m_nAllMass = fnAmtSumup("ALL", cnroCond, oAmt);
            roRslt.m_nSugerMass = fnAmtSumup("SUG", cnroCond, oAmt);
          }
          oAmt.m_nAmtD++;
        }
        oAmt.m_nAmtC++;
      }
      oAmt.m_nAmtB++;
    }
    oAmt.m_nAmtA++;
  }
}

int main()
{
  StCond oCond;
  StRslt oRslt;

  fnInput(oCond);
  fnConcCheck(oCond, oRslt);
  cout << oRslt.m_nAllMass << " " << oRslt.m_nSugerMass << endl;

  return 0;
}

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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define rep(i,j,n) for(int i=j; i<n; i++)
#define INF 1000000000000000000 // If you use it, make sure not to put in "int" type variable ;(, use long long int
void optimizeIO() { ios_base::sync_with_stdio(false); cin.tie(NULL); }
const ll mod=1000000007;

int main()
{
    optimizeIO();
    int nT; nT=1;
	while(nT--)
	{
		ll n; cin>>n;
		ll ans=((n-1)*(n))/2;
		cout<<ans;
	}
	return 0;
}


Measured memory_bytes: 256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in sys.stdin.readline().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v

def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    A, B = li_input()

    ans = 0

    for i in range(2):
        if A >= B:
            ans += A
            A -= 1
        else:
            ans += B
            B -= 1

    print(ans)


main()


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

int main(){

  int X,N;
  cin >> X >> N;
  int A[N];
  for(int i=0;i<N;i++) cin >> A[i];
  
  int j=0;
  bool pm = true;
  for(int tmp=0;tmp<=N;tmp++){
    bool ck = true;
    pm = true;
    for(int i=0;i<N;i++){
      if(A[i]==X-j){
        ck=false;
      }
    }
    if(ck) break;
    ck = true;
    pm = false;
    for(int i=0;i<N;i++){
      if(A[i]==X+j){
        ck=false;
      }
    }
    if(ck) break;
    j++;
  }
  
  if(pm) cout << X-j << endl;
  else cout << X+j << endl;

}

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

ans = 0
for i in range(1, n + 1):
    if i % 3 == 0 and i % 5 == 0:
        continue
    elif i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    else:
        ans += i

print(ans)

Measured memory_bytes: 9172
#include <bits/stdc++.h>
    using namespace std;
using Int = long long;
//BEGIN CUT HERE
template <typename T, typename E>
struct SegmentTree
{
    typedef function<T(T, T)> F;
    typedef function<T(T, E)> G;
    typedef function<E(E, E)> H;
    typedef function<E(E, int)> P;
    int n;
    F f;
    G g;
    H h;
    P p;
    T d1;
    E d0;
    vector<T> dat;
    vector<E> laz;
    SegmentTree(
        int n_, F f, G g, H h, T d1, E d0,
        vector<T> v = vector<T>(), P p = [](E a, int b) { return a; }) : f(f), g(g), h(h), d1(d1), d0(d0), p(p)
    {
        init(n_);
        if (n_ == (int)v.size())
            build(n_, v);
    }
    void init(int n_)
    {
        n = 1;
        while (n < n_)
            n *= 2;
        dat.clear();
        dat.resize(2 * n - 1, d1);
        laz.clear();
        laz.resize(2 * n - 1, d0);
    }
    void build(int n_, vector<T> v)
    {
        for (int i = 0; i < n_; i++)
            dat[i + n - 1] = v[i];
        for (int i = n - 2; i >= 0; i--)
            dat[i] = f(dat[i * 2 + 1], dat[i * 2 + 2]);
    }
    inline void eval(int len, int k)
    {
        if (laz[k] == d0)
            return;
        if (k * 2 + 1 < n * 2 - 1)
        {
            laz[k * 2 + 1] = h(laz[k * 2 + 1], laz[k]);
            laz[k * 2 + 2] = h(laz[k * 2 + 2], laz[k]);
        }
        dat[k] = g(dat[k], p(laz[k], len));
        laz[k] = d0;
    }
    T update(int a, int b, E x, int k, int l, int r)
    {
        eval(r - l, k);
        if (r <= a || b <= l)
            return dat[k];
        if (a <= l && r <= b)
        {
            laz[k] = h(laz[k], x);
            return g(dat[k], p(laz[k], r - l));
        }
        return dat[k] = f(update(a, b, x, k * 2 + 1, l, (l + r) / 2),
                          update(a, b, x, k * 2 + 2, (l + r) / 2, r));
    }
    T update(int a, int b, E x)
    {
        return update(a, b, x, 0, 0, n);
    }
    T query(int a, int b, int k, int l, int r)
    {
        eval(r - l, k);
        if (r <= a || b <= l)
            return d1;
        if (a <= l && r <= b)
            return dat[k];
        T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return f(vl, vr);
    }
    T query(int a, int b)
    {
        return query(a, b, 0, 0, n);
    }
};
//END CUT HERE
signed main()
{
    int n, q;
    cin >> n >> q;
    SegmentTree<Int, Int> ch(n,
                             plus<Int>(),
                             plus<Int>(),
                             plus<Int>(),
                             0, 0, vector<Int>(n, 0),
                             multiplies<Int>());
    for (int i = 0; i < q; i++)
    {
        int c, s, t, x;
        cin >> c;
        if (c)
        {
            cin >> s >> t;
            cout << ch.query(s - 1, t) << endl;
        }
        else
        {
            cin >> s >> t >> x;
            ch.update(s - 1, t, x);
        }
    }
}

/*
verified on 2017/12/01
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_G
*/



Measured memory_bytes: 8452
# Problem: https://atcoder.jp/contests/abc090/tasks/abc090_b
# Python 3rd Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def LLI(rows_number): return [LI() for _ in range(rows_number)]


def checkParin(checkNum):
    result = False
    checkNumStr = str(checkNum)
    checkNumStrBase = checkNumStr[::-1]
    charEq = 0
    for j in range(0, len(checkNumStrBase)):
        if checkNumStr[j] == checkNumStrBase[j]:
            charEq = charEq + 1
    if charEq == len(checkNumStr):
        result = True
    return result


def solver(fromNum, toNum):
    result = 0
    j = fromNum
    while ((fromNum <= j) and (j <= toNum)):
        if checkParin(j):
            result = result + 1
        j = j + 1
    return result


if __name__ == "__main__":
    A, B = MI()
    print("{}".format(solver(A, B)))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds; 
using namespace std;



typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
 
 
//defines
typedef long long ll;
typedef long double ld;

    
ll a,b,c,n,m,k,t=1;

void solve()
{ 
   cin>>n;
   vector<ll>v(n);
   for(ll i=0;i<n;i++)cin>>v[i];
   ll count=1,ans=0;
   for(ll i=1;i<n;i++)
   {
       if(v[i]<=v[i-1])count++;
       else
       {
           ans=max(ans,count);count=1;
       }
   }
   ans=max(ans,count);
   ans--;
   cout<<ans;
 if(t>0)cout<<"\n";
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

Measured memory_bytes: 1024
a = int(input())
l = len(str(a))

ans = 0
if l % 2 == 0:
    while l >= 1:
        ans += (10 ** (l - 1) - 1) - (10 ** (l - 2) - 1)
        l -= 2
else:
    ans += a - (10 ** (l - 1) - 1)
    l -= 1
    while l >= 1:
        ans += (10 ** (l - 1) - 1)  - (10 ** (l - 2) - 1)
        l -= 2

print(ans)

Measured memory_bytes: 3064
s=input()
l=len(s)

from itertools import product
bits=list(product([0,1], repeat=l-1))

ans=0
for bit in bits:
    tmp_s=s
    cnt=0
    for i in range(l-1):
        if bit[i]==1:
            tmp_s=tmp_s[:i+1+cnt]+'+'+tmp_s[i+1+cnt:]
            cnt+=1
    ans+=eval(tmp_s)

print(ans)

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define llong long long
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve()
{
  int ans=0;
  int n; cin >> n;
  vector<int> vec(n); REP(i, n) cin >> vec[i];
  for (int i=0; i<n; i++) {
    ans+=vec[i];
  }
  cout << ans-n << endl;
}

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


Measured memory_bytes: 256
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    double d;
    while(cin >> d){
        if(d <= 48.00) cout << "light fly" << endl;
        else if(48.00 < d and d <= 51.00) cout << "fly" << endl;
        else if(51.00 < d and d <= 54.00) cout << "bantam" << endl;
        else if(44.00 < d and d <= 57.00) cout << "feather" << endl;
        else if(57.00 < d and d <= 60.00) cout << "light" << endl;
        else if(60.00 < d and d <= 64.00) cout << "light welter" << endl;
        else if(64.00 < d and d <= 69.00) cout << "welter" << endl;
        else if(69.00 < d and d <= 75.00) cout << "light middle" << endl;
        else if(75.00 < d and d <= 81.00) cout << "middle" << endl;
        else if(81.00 < d and d <= 91.00) cout << "light heavy" << endl;
        else if(91.00 < d) cout << "heavy" << endl;    
    }


    return 0;
}


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

// DP !!
int main() {
    int n;
    cin >> n;
    vector<int> a(n);

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

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

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

    return 0;
}

Measured memory_bytes: 1024
import sys
n = int(input()) 
p = [int(r) for r in sys.stdin.read().split()]
for i, v in enumerate(p[:-1]):
    if p[i] > p[i + 1]:
        for j in range(i + 1, n - 1):
            if p[j] > p[j + 1]:
                if (i == 0 or p[i - 1] < p[j + 1]) and p[i + 1] > p[j + 1] and (j == n - 2 or p[j + 2] > p[i]) and p[j] < p[i]:
                    print('YES')
                    quit()
                else:
                    print('NO')
                    quit()
            if j == n - 2:
                print('NO')
                quit()
    if i == n - 2:
        print('YES')
        quit()

Measured memory_bytes: 3064