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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int w,a,b; cin>>w>>a>>b;
    cout<<max(0,abs(b-a)-w)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  int arr[10];
  int cnt=0;
  int N=n;
  while(N!=0){
    arr[cnt++]=N%10;
    N/=10;
  }
  int sum=0;
  for(int i=0;i<cnt;i++){
    sum+=arr[i];
  }
  printf(n%sum==0?"Yes":"No");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#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 LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

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

int main(void) {
    int total=0;
    int m,d;

    cin>>m>>d;

    FOR(i,1,m){
        FOR(k,1,d){
            int p,q;
            p=k%10;
            q=k;
            q=q/10;
            if(p>=2&&q>=2&&p*q==i){
                total++;
            }
        }
    }
    cout<<total<<endl;
}


Measured memory_bytes: 256
//{{{By oToToT
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <random>
#include <utility>
#include <stack>
#include <sstream>
#include <functional>
#include <deque>
#include <cassert>
using namespace std;
/* include everything for Kotori~ <3 */

using lld = int64_t;
using llu = uint64_t;
using llf = long double;
using PII = pair<int,int>;
using PIL = pair<int,lld>;
using PLI = pair<lld,int>;
using PLL = pair<lld,lld>;
template<typename T>
using maxHeap = priority_queue<T,vector<T>,less<T>>;
template<typename T>
using minHeap = priority_queue<T,vector<T>,greater<T>>;
/* define some types for Ruby! */

#define FF first
#define SS second
#define SZ(x) (int)((x).size())
#define ALL(x) begin(x), end(x)
#define PB push_back
#define WC(x) while(x--)
/* make code shorter for Di~a~ */

template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
	s<<"[";
	for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
	s<<"]";
	return s;
}
template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.FF<<","<<p.SS<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
/* make output easier for Ainyan~n~ */

bool debug = 0;
#define DUMP(x) if(debug) cerr<<__PRETTY_FUNCTION__<<":"<<__LINE__<<" - "<<(#x)<<"="<<(x)<<'\n'
template<typename T>
void DEBUG(const T& x){if(debug) cerr<<x;}
template<typename T, typename... Args>
void DEBUG(const T& head,const Args& ...tail){
	if(debug){cerr<<head; DEBUG(tail...);}
}
/* Let's debug with Nico~Nico~Ni */
//}}}
static constexpr int C = 1000000 + 5;

struct Edge{
	int u, v, w;
};
vector<Edge> egs;
void solve(int,int,int);

int main(int argc, char* argv[]){
	if(argc>1 and string(argv[1])=="-D") debug=1;
	if(!debug){ios_base::sync_with_stdio(0);cin.tie(0);}
	int x; cin >> x;
	int ed=0;
	for(ed=0;(1<<ed)<=x;++ed);
	solve(1,ed,x);
	cout<<ed<<' '<<SZ(egs)<<'\n';
	for(auto e: egs)
		cout<<e.u<<' '<<e.v<<' '<<e.w<<'\n';
	return 0;
}

void solve(int st, int ed, int x){
	if(x==1) return;
	if(x&1){
		egs.PB({st,ed,x-1});
		solve(st,ed,--x);
		return;
	}
	// should make [0, x)
	egs.PB({st,st+1,x/2});
	egs.PB({st,st+1,0});
	solve(st+1,ed,x/2);
}

Measured memory_bytes: 256
a, b = map(int, input().split())
s_list = list(input())
flag = True

if s_list[a] == "-":
    s_list.pop(a)
    for digit in s_list:
        if digit == "-":
            flag = False
            break
else:
    flag = False

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF 999999999999999

using namespace std;

typedef long long ll;

int main(){
	ll ans = -INF;
	int n,m;
	cin >> n >> m;
	ll p[n][3];
	for(int i = 0; i < n; i++)cin >> p[i][0] >> p[i][1] >> p[i][2];
	for(int i = -1; i < 2; i+=2){
		for(int j = -1; j < 2; j+=2){
			for(int k = -1; k < 2; k+=2){
				ll dp[m+1];
				fill(dp,dp+m+1,-INF);
				dp[0]=0;
				for(int l = 0; l < n; l++){
					ll dp2[m+1];
					for(int q = 1; q <= m; q++){
						dp2[q]=max(dp[q], dp[q-1]+p[l][0]*i+p[l][1]*j+p[l][2]*k);
					}
					for(int r = 1; r <= m; r++)dp[r]=dp2[r];
				}
				ans = max(ans, dp[m]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    for (auto & a: A) cin >> a;
    set<int> S;
    for (const auto a: A) S.insert(a);
    puts(S.size() == N ? "YES" : "NO");
    return 0;
}


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

using ll=long long;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int N;
    ll D;
    cin>>N>>D;
    vector<ll> d(N);
    for(int i=0;i<N;i++) cin>>d[i];
    
    vector<ll> dp(N+1);
    for(int i=N-1;i>=0;i--){
        if(d[i]<=2*dp[i+1]+1){
            dp[i]=dp[i+1]+d[i];
        }
        else{
            dp[i]=dp[i+1];
        }
    }
    
    vector<ll> dn(N+1);
    dn[0]=D;
    for(int i=0;i<N;i++){
        dn[i+1]=min(dn[i],abs(dn[i]-d[i]));
    }
    
    int Q;
    cin>>Q;
    for(int i=0;i<Q;i++){
        int q;
        cin>>q;
        q--;
        // cerr<<dn[q]<<" "<<dp[q+1]<<endl;
        cout<<(dn[q]<=dp[q+1] ? "NO\n" : "YES\n");
    }
    return 0;
}

Measured memory_bytes: 13696
/**
 *  author: sourav rakshit
 *  created: 22.08.2020 17:37:39
**/

#include <bits/stdc++.h>
using namespace std;

#define ar array
#define all(x) begin(x), end(x)
#define len(x) (int)(x).size()
#define fast ios::sync_with_stdio(false), cin.tie(nullptr)
#ifdef LOCAL
#define log(x) cerr<<"[ " << #x << " : " << (x) << " ]\n";
#else
#define log(x) (void)0x30
#endif

using ll = long long;

int toint(char c) {
    return int(c) - int('0');
}

bool solve() {
    string n;
    cin >> n;
    ll sum = 0;
    for(char& c : n) {
        sum+=toint(c);
    }
    return sum % 9 == 0;
}

int32_t main() {
    fast; 
    int tt = 1;
    while(tt--){
        cout << (solve() ? "Yes" : "No") << '\n';
    }
#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
}



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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

typedef long long ll;
const ll mod = 1e9+7;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  int n;  cin >> n;
  ll a[n];
  for (int i = 0; i < n; ++i){
    cin >> a[i];
  }
  ll pref[n+1];
  pref[0] = 0;
  for (int i = 0; i < n; ++i){
    pref[i+1] = pref[i] + a[i];
    pref[i+1] %= mod;
  }
  ll ans = 0;
  for (int i = 1; i < n; ++i){
    ans += pref[i]*a[i]%mod;
    ans %= mod;
  }

  cout << ans%mod << endl;

  return 0;
}

Measured memory_bytes: 6764
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[40][1 << 16];
 
signed main() {
    int N, M;
    while(cin >> N >> M, N || M) {
        const int BIN = 16;
        vector<int> A(N), B(M+1);
        for(int i=0; i<N; i++) {
            for(int k=0; k<BIN; k++) {
                int val; cin >> val;
                A[i] |= (val << k);
            }
        }
        for(int i=0; i<M; i++) {
            for(int k=0; k<BIN; k++) {
                int val; cin >> val;
                B[i] |= (val << k);
            }
        }
        M++;

        fill(dp[0], dp[N+1], -1);
        dp[0][0] = 0;

        for(int i=0; i<N; i++) {
            for(int bit=0; bit<(1<<BIN); bit++) {
                if(dp[i][bit] < 0) continue;
                int abit = bit | A[i];
                for(int j=0; j<M; j++) {
                    int beat = abit & B[j];

                    int nbit = abit - beat;
                    chmax(dp[i+1][nbit], dp[i][bit] + __builtin_popcount(beat));
                }
            }
        }
        cout << *max_element(dp[N], dp[N] + (1 << BIN)) << endl;
    }
    return 0;
}


Measured memory_bytes: 18976
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine()
            .Split(' ')
            .Select(txt => int.Parse(txt))
            .ToList();
        var N = inputs[0];
        var K = inputs[1];

        var dict = new Dictionary<int, int>();
        for (int i = 1; i <= N; i++)
        {
            dict.Add(i, 0);
        }

        for (int i = 0; i < K; i++)
        {
            Console.ReadLine();
            var names = Console.ReadLine()
                .Split(' ')
                .Select(txt => int.Parse(txt))
                .ToList();
            foreach (var n in names)
            {
                dict[n]++;
            }
        }

        var count = dict.Count(kvp => kvp.Value == 0);
        Console.WriteLine(count.ToString());
    }
}

Measured memory_bytes: 28652
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	String s = scan.next();
      	if(s.contains("a")||s.contains("i")||
          s.contains("u")||
          s.contains("e")||s.contains("o")){
        	System.out.print("vowel");
        }
      	else{
        	System.out.print("consonant");
        }
    }
 
}

Measured memory_bytes: 23508
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

int main(){
  string L;
  cin >> L;
  reverse(L.begin(), L.end());
  int N=L.length();

  vector<int> dp(N);
  dp[0]=1;
  srep(i,1,N){
    dp[i]=(long)dp[i-1]*3%mod;
  }

  int count=1;
  int sum=0;
  for(int i=N-1; i>0; i--){
    if(L[i]=='1'){
      sum=(sum+(long)dp[i]*count%mod)%mod;
      count=count*2%mod;
      //printf("sum=%d, count=%d\n", sum, count);
    }
  }
  if(L[0]=='0'){
    sum=((long)sum+1*count)%mod;
  }
  else{
    sum=(sum+(long)3*count)%mod;
  }

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

}


Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
#include <vector>

#define MAX_N 256

using namespace std;
typedef pair<int, pair<int, int> > edge;//cost, node, node

int n, m;
int parent[MAX_N];
int rank[MAX_N];

void uf_init(int n){
	
	for(int i=0; i<n; ++i){
		parent[i]=i;
		rank[i]=0;
	}
}

int find(int x){
	if(parent[x] == x)
		return x;
	else
		return parent[x] = find(parent[x]);
}

void unite(int x, int y){
	
	x = find(x);
	y = find(y);

	if(x==y)
		return;
	
	if(rank[x] < rank[y]){
		parent[x] = y;
	}
	else{
		parent[y] = x;
		
		if(rank[x] == rank[y])
			rank[x]++;
	}
}

bool is_same_group(int x, int y){
	return find(x) == find(y);
}

int solve_krascal(const vector<edge> als){

	int res = 0;
	int cnt = 0;
	
	uf_init(n);

	for(int i=0; (i<m && cnt<n-1); ++i){
		
		int a = als[i].second.first,
			b = als[i].second.second;
		
		if(!is_same_group(a, b)){
		
			res += als[i].first;
			unite(a, b);
			cnt++;
		}
	}

	return res/100;
}


int main(){

	while(cin >> n, n){

		vector<edge> als;
		cin >> m;
		
		int a, b, c;
		char cm;
		
		for(int i=0; i<m; ++i){
			
			scanf("%d,%d,%d", &a, &b, &c);
			als.push_back(make_pair(c-100, make_pair(a, b)));
		}

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

		cout << solve_krascal(als) << endl;

	}

	return 0;
}

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

int main() {
  char a,b;
  cin>>a>>b;
  if(a=='H'){
    cout<<b<<endl;
  }else{
    if(b=='D')cout<<'H'<<endl;
    else cout<<'D'<<endl;
  }
  return 0;
}

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


using namespace std;


using ll = long long;


int main(void) {
    string S;

    cin >> S;

    vector<ll> remainders(2019, 0);
    remainders[0]++;

    ll cur = 0;
    ll base = 1;
    for (int i = S.length() - 1; i >= 0; i--) {
        cur += (S[i] - '0') * base;
        cur %= 2019;
        remainders[cur]++;
        base = base * 10 % 2019;
    }

    ll ans = 0;
    for (ll i = 0; i < 2019; i++) {
        ans += remainders[i] * (remainders[i] - 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[100010];
bool b[100010];
int main() {
	ll n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		a[i]=1;
	}
	b[0]=true;
	for(int i=0;i<m;i++){
		ll l,r;
		cin>>l>>r;
		l--,r--;
		if(b[l]){
			b[r]=true;
			if(a[l]==1){
				b[l]=false;
			}
		}
		a[l]--,a[r]++;
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		if(b[i]){
			ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1152
n = int(input())
a, b, c = [[0] * n for i in range(3)]
for i in range(n):
  a[i], b[i], c[i] = map(int, input().split())

dp = [[0, 0, 0] for i in range(n)]

dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]

for i in range(1, n):
  dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i]
  dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + b[i]
  dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i]

print(max(dp[n-1]))

Measured memory_bytes: 64248
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
        p: [usize;n],
    }

    let mut cnt = 0;
    for i in 1..n-1{
        let max = std::cmp::max(p[i-1], std::cmp::max(p[i], p[i+1]));
        let min = std::cmp::min(p[i-1], std::cmp::min(p[i], p[i+1]));
        if p[i]!=max && p[i]!=min {
            cnt += 1;
        }
    }
    println!("{}", cnt);
    return;
}

Measured memory_bytes: 4352
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	cin >> str;
	cout << count(str.begin(), str.end(), 'o') * 100 + 700 << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    Main(){
	Scanner sc = new Scanner(System.in);
	int sum = 0;
	String str;

	while(sc.hasNext()){
	    char[] ch = (sc.nextLine()).toCharArray();

	    for(int i = 0; i < ch.length; i++)
		if(check(ch[i])){
		    str = String.valueOf(ch[i++]);
		    for(; i < ch.length && check(ch[i]); i++)
			str += String.valueOf(ch[i]);

		    sum += Integer.parseInt(str);
		}
	}

	System.out.println(Integer.toString(sum));
    }

    boolean check(char c){
	return ('0' <= c && c <= '9');
    }

    public static void main(String[] args){
	new Main();
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define pii pair<int , int>
#define sz(a) (int)(a.size())
const int INF = 1000 * 1000 * 1000 + 7;
const ll LINF = INF * (ll)INF;
const int mod = 987654319;
const int MAX = 200 * 1000 + 5;

ll dp[1005];
int p[1005];
int a[1005];
int main()
{	
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	int mx = -INF;
	int ps = -1;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		if(a[i] > mx)
		{
			mx = a[i];
			ps = i;
		}
	}
	if(mx < 0)
	{
		cout << mx << endl;
		cout << n - 1 << endl;
		for(int i = 1; i <= ps; i++)
			cout << 1 << endl;
		n -= ps;
		while(n > 1)
		{
			cout << n << endl;
			n--;
		}
		return 0;
	}
	for(int i = 0; i < n; i++)
	{
		dp[i] = a[i];
		p[i] = -1;
	}
	
	for(int i = 0; i < n; i++)
		for(int j = i + 2; j < n; j += 2)
			if(dp[i] + a[j] > dp[j])
			{
				dp[j] = dp[i] + a[j];
				p[j] = i;
			}
	
	int deMax = 0;
	for(int i = 0; i < n; i++)
		if(dp[i] > dp[deMax])
			deMax = i;
	cout << dp[deMax] << endl;
	vector<int> pos;
	while(p[deMax] != -1)
	{
		pos.pb(deMax + 1);
		deMax = p[deMax];
	}
	pos.pb(deMax + 1);
	
	vector<int> ans;
	while(n > pos[0])
	{
		ans.pb(n--);
	}
	for(int i = 0; i < sz(pos) - 1; i++)
	{
		int p1 = pos[i] , p2 = pos[i + 1];
		int cnt = (p1 - p2 - 1) / 2;
		
		while(cnt--)
			ans.pb(p2 + 2);
		ans.pb(p2 + 1);
	}
	for(int i = 1; i < pos.back(); i++)
		ans.pb(1);
	cout << sz(ans) << endl;
	for(auto x : ans)
		cout << x << endl;
}


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


int main(void) {
	ll x, y, n, ans = 0;

	cin >> x >> y;

	n = x;
	while (n <= y) {
		n *= 2;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int Maxn = 100000;
int n,m;
int main()
{
    cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  ll a[N]={0};
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  sort(a,a+N);
  ll ans=abs(a[0]-a[N-1]);
  cout  << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/// @author MUSTAFA MOGHAZY
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a [10];
int main()
{
 int c = 3;
 while(c--){
    int in; cin>>in;
    ++a[in];
 }
 if(a[5]==2 && a[7]==1){
    cout<<"YES";
 }
 else
    cout<<"NO";

}


Measured memory_bytes: 3556
#include <iostream>
#include <algorithm> // min()
#include <string>
#include <vector>
#include <climits> // INT_MAX
#include <cmath> // ceil()
#define rep(i, n) for (int i = 0; i < n; ++i)

using namespace std;
using ll = long long;
const int INF = INT_MAX;
using Graph = vector<vector<int>>;
using Vi = vector<int>;
using Vpii = vector<pair<int, int>>;
using Pii = pair<int, int>;


vector<bool> seen;
int ans = 0;
int land = 0;
bool is_tree = false;
Pii region;


void dfs(Graph &g, int x, int y) {
    if (x < 0 || x >= region.first) return;
    if (y < 0 || y >= region.second) return;

    if (g[y][x] == 0) return;

    if (g[y][x] == 1) {
        g[y][x] = 0;
        land--;
    }

    dfs(g, x + 1, y);
    dfs(g, x - 1, y);
    dfs(g, x, y + 1);
    dfs(g, x, y - 1);
    dfs(g, x + 1, y + 1);
    dfs(g, x + 1, y - 1);
    dfs(g, x - 1, y + 1);
    dfs(g, x - 1, y - 1);
}


int main() {
    string s;
    int k;
    cin >> k >> s;

    if (s.size() <= k)
        cout << s << endl;
    else
        cout << s.substr(0, k) << "..." << endl;

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define scan(a,n) for(long int index=0;index<n;index++) cin>>a[index];
#define print(a,n) for(long int index=0;index<n;index++) cout<<a[index]<<" ";cout<<endl;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define vli vector<long long int>
#define vlli vector<pair<long long int,long long int>>
#define vsi vector<string>
#define vci vector<char>


 
int main() {
   #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    fast;
    ll x, k, d;
    cin>>x>>k>>d;
    x=abs(x);
    ll a = x/d;
    if(a>=k){
        cout<<x - d*k<<endl;
        return 0;
    }
    ll b = k-a;
    
    if(b%2 == 0){
        cout<<x - a*d<<endl;
    } else {
        cout<<abs(x - a*d - d)<<endl;
    }
return 0;    
 }  

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll i_3=998244353;

int main(){
    ll n,s;cin>>n>>s;
    ll a[n+1];rep(i,1,n)cin>>a[i];
    ll dp[s+1][n+1][3];
    rep(i,0,s){
        if(i==0){
            dp[i][0][0]=1;
            dp[i][0][1]=0;
            dp[i][0][2]=0;
        }else{
            dp[i][0][0]=0;
            dp[i][0][1]=0;
            dp[i][0][2]=0;
        }
    }
    rep(i,1,n){
        rep(j,0,s){
            if(j==0){
                dp[j][i][0]=1;
            }else{
                dp[j][i][0]=0;
            }
            if(j-a[i]>=0){
                dp[j][i][1]=(dp[j][i-1][0]+dp[j][i-1][1]+dp[j-a[i]][i-1][0]+dp[j-a[i]][i-1][1])%i_3;
            }else{
                dp[j][i][1]=(dp[j][i-1][0]+dp[j][i-1][1])%i_3;
            }
            if(j<s){
                dp[j][i][2]=0;
            }else{
                if(j-a[i]>=0){
                    dp[j][i][2]=(dp[j][i-1][2]+dp[j][i-1][1]+dp[j-a[i]][i-1][1]+dp[j-a[i]][i-1][0])%i_3;
                }else{
                    dp[j][i][2]=(dp[j][i-1][2]+dp[j][i-1][1])%i_3;
                }
            }
        }
    }
    /*
    rep(i,0,s){
        rep(j,0,n){
            rep(k,0,2){
                cout<<dp[i][j][k];
            }
            if(j<n){
                cout<<' ';
            }else{
                cout<<endl;
            }
        }
    }*/
    cout<<dp[s][n][2]<<endl;
    
    
    return 0;
}






Measured memory_bytes: 211328
N = int(input())
A = list(map(int,input().split()))
ans = [0] * N
index = []
M = 0
for i in range(N-1,-1,-1):
    a = ans[i:N:i+1]
    if sum(a) % 2 == A[i]:
        ans[i] = 0
    else:
        ans[i] = 1
        index.append(i+1)
        M += 1
print(M)
print(*index[::-1])

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

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define FOR(i,l,r) for(long long i=l; i<r; i++)
#define FOR_REV(i,r,l) for(long long i=r; i>=l; i--)
#define pb push_back
#define mp make_pair

int main()
{
	int n;
  	cin>>n;
  
    int a[200009];

    FOR (i,1,n+1)
    {
        cin>>a[i];
    }

    int dp[200009];

    dp[1] = 0;
    dp[2] = abs(a[2]-a[1]);
    FOR(i,3,n+1)
    {
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
    }

    cout<<dp[n]<<endl;
}


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

char a[52],b[52];

int main()
{
    cin>>a;
    cin>>b;
    int la=strlen(a),lb=strlen(b);
    int l=min(la,lb),ll=max(la,lb);
    for(int i=0;i<=l-1;i++)
        cout<<a[i]<<b[i];
    if(la>lb)
        for(int i=l;i<=ll-1;i++)
            cout<<a[i];
    else for(int i=l;i<=ll-1;i++)
            cout<<b[i];
    return 0;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    AC = [False] * N
    WA = [0] * N
    w = 0
    for _ in range(M):
        p, s = input().split()
        p = int(p) - 1
        if s == 'AC' and not AC[p]:
            w += WA[p]
            AC[p] = True
        if s == 'WA':
            WA[p] += 1
    print(AC.count(True), w)

main()



Measured memory_bytes: 4596
#include<iostream>
#include<queue>
#include<cmath>
using namespace std;
int flag[100001];
int main()
{
    int n,x,y;
    int k;
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            k=min(j-i,(int)abs(x-i)+(int)abs(j-y)+1);
            flag[k]++;
        }
    }
    for(int i=1;i<n;i++)
        cout<<flag[i]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <vector>
#include <array>
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
	int n;
	int a[3][101] = {0};
	std::cin >> n;
	for ( int i = 1 ; i <= 2 ; i++ ) {
		for ( int ii = 1 ; ii <= n ; ii++ ) {
			std::cin >> a[i][ii];
		}
	}
	int c=a[1][1],d=a[1][1];
	for ( int i = 1 ; i < n ; i++ ) {
		c += a[1][i+1];
		d += a[2][i];
		a[0][i] = c-d;
	}
	c += a[2][n];
	d += a[2][n];
	a[0][n] = c-d;
	int max = -99;
	int index = 0;
	for ( int i = 1 ; i <= n ; i++ ) {
		if(max < a[0][i]){
			max = a[0][i];
			index = i;
		}
	}
	if (max<=0) index = -99;
	int ans = a[1][1];
	for ( int i = 1 ; i <= n ; i++ ) {
		if(i<index+1) ans+=a[1][i+1];
		else ans+=a[2][i];
	}
	std::cout << ans << std::endl;


	return 0;
}



Measured memory_bytes: 256
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
//		 static int mod =  (int) (Math.pow(10,9)+7);
		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
		 static long[] kaijo;
		 static long[] kaiinv;
	    public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();
	        int M = sc.nextInt();
	        int K = sc.nextInt();
	        
	        kaijo = new long[N+100];
	        kaijo[0]=1;
	        for(int i=1;i<=N+88;i++) {
	        	kaijo[i]=(kaijo[i-1]*i)%mod;
	        }
	        kaiinv = new long[N+100];
	        kaiinv[0]=1;
	        kaiinv[1]=1;
	        for(int i=2;i<N+88;i++) {
	        	kaiinv[i]=modinv(kaijo[i])%mod;
	        }

	        
	        
	        long[] c = new long[N];
	        for(int i=0;i<N;i++) {
	        	c[i]=(((nCr(N-1,i)*M%mod)%mod)*((pow(M-1,N-1-i))%mod))%mod;
	        }
	        long ans=0;
	        for(int i=0;i<=K;i++) {
	        	ans=(ans+c[i])%mod;
	        }
	        
	        System.out.println(ans);
			return;		        		
	    }
	    
	    
		static long nCr(int n, int r) {
			if(n<r) {
				return 0;
			} else {
				return (kaijo[n]*(kaiinv[r]*kaiinv[n-r]%mod))%mod;
			}
		}

		public static long pow(long a,long n) {
		    long res=1;
		    while (n>0) {
		        if ((n-n/2*2)==1) {
		            res=(res*a)%mod;
		        }
		        a=(a*a)%mod;
		        n>>=1;
		    }
		    return res;
		}
	 
		public static long modinv(long n) {
			return pow(n, mod-2)%mod;
		}
	}
	

Measured memory_bytes: 40536
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;


int main(int argc, const char * argv[]) {

    int a, b, c, d;
    string ans;
    
    cin >> a >> b >> c >> d;
    
    while(1)
    {
        c = c - b;
        if(c <= 0)
        {
            ans = "Yes";
            break;
        }
        
        a = a - d;
        if(a <= 0)
        {
            ans = "No";
            break;
        }
    }
    
    cout << ans << endl;
    
    
    return 0;
    
}


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

const int mod = 1000000007;

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

    ll ans = 0;
    for (ll i = K; i <= N + 1; ++i) {
        ans = (ans + (i * ((N + 1 - i + 1) + N + 1) / 2 - i * (i + 1) / 2 + 1) %
                         mod) %
              mod;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3600
from collections import deque
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    G[a].append(b)
    G[b].append(a)

que = deque([0])
guideposts = [-1] * N
guideposts[0] = None

while que:
    n = que.pop()
    for to in G[n]:
        if guideposts[to] != -1:
            continue
        guideposts[to] = n
        que.appendleft(to)

print('Yes')
print(*[guisepost + 1 for guisepost in guideposts[1:]], sep="\n")


Measured memory_bytes: 38408
//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <atcoder/all>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 998244353;
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
struct S{
	ll sum, sum_base;
};
struct F{
	ll ch_digit;
};
S op(S l, S r){ return S{(l.sum+r.sum)%mod, (l.sum_base+r.sum_base)%mod}; }
S e(){ return S{0, 0}; }
S mapping(F l, S r){
	if(l.ch_digit == -1) return r;
	else return S{(r.sum_base*l.ch_digit)%mod, r.sum_base};
}
F composition(F l, F r){
	if(l.ch_digit == -1) return r;
	return l;
}
F id(){
	return F{-1};
}
int n, q;
int main(){
	cin >> n >> q;
	vector<S>ini;
	ll v = 1;
	for(int i=0;i<n;i++){
		ini.pb(S{v, v});
		v = v * 10LL % mod;
	}
	reverse(ini.begin(), ini.end());
	lazy_segtree<S, op, e, F, mapping, composition, id>kaede(ini);
	rep(i, q){
		int l, r; ll d; cin >> l >> r >> d; l--;
		kaede.apply(l, r, F{d});
		cout << kaede.all_prod().sum << '\n';
	}
}

Measured memory_bytes: 16724
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B, C;
    cin >> A >> B >> C;
 
    int i = 0;
    int coin = 0;
 
    while( coin < C ) {
        ++i;
        coin += A;
 
        if( i % 7 == 0 ) {
            coin += B;
        }
    }
 
    cout << i << endl;
}


Measured memory_bytes: 3100
N,Y = map(int,input().split())
a=-1
b=-1
c=-1
for x in range(N+1):
    for y in range(N+1-x):
        if N - x - y >= 0 and 10000*x + 5000*y + 1000*(N - x - y) == Y:
            a = x
            b = y
            c = N - x - y
            break

print(a,b,c)


Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  long long H;
  scanf("%lld",&H);
  long long ans = 0;
  long long body = 1;
  while(H>0){
    ans += body;
    H /= 2;
    body *= 2;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 888
def solve(N, M, A):
    from math import log, ceil
    from heapq import heappush, heappop, heapify
    Q = [-a for a in A]
    heapify(Q)

    if len(A) == 1:
        return A[0]>>M

    while Q and M:
        a = - heappop(Q)
        b = - Q[0]
        if a == 0:
            continue
        if b == 0:
            k = M
        elif b < a:
            k = min(M, ceil(log(a,2) - log(b, 2)))
        else:
            k = min(M, 1)
        c = a >> k
        #print("prev=%d, dis=%d, %d - %d = %d" % (a, c, M, k, M-k))
        M -= k
        heappush(Q, -c)
    return sum(-a for a in Q)


def main():
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())
    A = sorted([int(x) for x in input().split()], reverse=True)

    print(solve(N, M, A))

def gen():
    import random
    with open("9", "w") as f:
        print(10**5, 10**5, file=f)
        print(*[random.randint(1, 10**9) for i in range(10**5)],file=f)

main()



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

using namespace std;

long long h;
map<long long,long long> m;

long long solve(long long s)
{
    if (m[s]) return m[s];
    return solve(s/2)*2+1;
}

int main()
{
    scanf("%lld",&h);
    m[1]=1;
    cout<<solve(h);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(void) {
	int N;
	string s;
	int p, min=0;
	int count = 0;
	int count_W[300000] = { 0 };
	int count_E[300000] = { 0 };
	cin >> N>>s;
	min = N;
	for (int i = 0;i < N;i++) {
		if (i != 0) {
			count_W[i] = count_W[i - 1];
			count_E[i] = count_E[i - 1];
		}
		if (s[i] == 'W')
			count_W[i] ++;
		else 
			count_E[i] ++;
	}
	for (p = 0;p < N;p++) {
		count = 0;
		if (p != 0)
			count += count_W[p - 1];
		if (p != N - 1)
			count += count_E[N - 1] - count_E[p];

		if (count < min)
			min = count;
	}
	cout << min << endl;
	return 0;
}


Measured memory_bytes: 3204
//第8回シンデレラガール総選挙は是非本田未央ちゃんに投票をお願いします！
//ファンのことも他のアイドルの子たちのことも本当に大事にしてて、今まで周りに色んなものを与えてくれました。
//今度は私たちが未央ちゃんにお返しをする番です。みんなでガラスの靴を履かせてあげましょう！
// #本田未央を一番星に #本田未央を令和のシンデレラガールに #第8回シンデレラガール総選挙
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint gcd( lint m, lint n )
{
	int a=max(m,n),b=min(m,n);
	if(m==0) return n;if(n==0) return m;
	if(a%b==0) return b;
	return gcd(b,a-b*(a/b));
}
int n;
lint a[10100],b[10100];
bool ng[4001000];
vector<lint> so;
bool ch(lint x,lint mo){
	//if(mo>1145141919 && mo<2) return false;
	if(mo<2) return false;
	lint now=0;
	for(int i=n;i>=0;i--){
		now=now*x+a[i];now%=mo;
	}
	//cout<<a[n]<<' '<<a[n-2]<<endl;
	//cout<<x<<' '<<mo<<' '<<now<<endl;
	return (now==0);
}
bool cal(lint ko){
	//cout<<ko<<endl;
	rep(i,150){
		lint x=rand()%ko;
		if(!ch(x,ko)) return false;
	}
	return true;
}
int main()
{
	cin>>n;
	for(int i=n;i>=0;i--) cin>>a[i];//cout<<a[0]<<a[1]<<a[2]<<a[3]<<endl;
	memset(ng,false,sizeof(ng));
	for(int i=2;i<4000100;i++){
		if(ng[i]) continue;
		so.pb(i);
		for(int j=i*2;j<4000100;j+=i) ng[j]=true;
	}
	lint sum=0;
	rep(i,n+1) sum=gcd(sum,abs(a[i]));
	//cout<<sum<<endl;
	vector<lint> ko;
	rep(i,so.size()){
		if(sum%so[i]==0){
			ko.pb(so[i]);
			while(sum%so[i]==0) sum/=so[i];
		}
	}
	if(sum>1) ko.pb(sum);
	//if(f<1 && sum>1) ko.pb(sum);
	//rep(i,ko.size()) cout<<ko[i]<<endl;
	REP(i,2,n+10){
		if(!ng[i]) ko.pb(i);
	}
	//rep(i,ko.size()) cout<<ko[i]<<endl;
	sort(All(ko));ko.erase(unique(All(ko)),ko.end());
	//rep(i,ko.size()) cout<<ko[i]<<endl;
	rep(i,ko.size()){
		if(cal(ko[i])) cout<<ko[i]<<endl;
	}
}


Measured memory_bytes: 10352
#include <iostream>
#include <string>

using namespace std;

int main(){
  int n;
  cin >> n;
  string str_n = to_string(n);
  int sum = 0;

  for(int i = 0; str_n.length() > i; i++){
    sum += (int)str_n[i] - 48;
  }

  if(n % sum == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


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

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

template<class T> vector<T> read_vector(sint n) {
	vector<T> vs;
	for (sint i = 0; i < n; ++i) {
		vs.push_back(read<T>());
	}
	return vs;
}

inline void write() {
}

template<class T> void write(T const& t) {
	cout << t;
}

template<class T> void write(vector<T> const& ts) {
	if (ts.size() > 0) {
		cout << ts[0];
	}
	for (size_t i = 1; i < ts.size(); ++i) {
		cout << ' ' << ts[i];
	}
}

template<class T, class... Args> void write(T const& t, Args const&... args) {
	cout << t << ' ';
	write(args...);
}

template<class... Args> void writeln(Args const&... args) {
	write(args...);
	cout << '\n';
}

int main() {
	ios_base::sync_with_stdio(false);
	cin .exceptions(ios_base::badbit | ios_base::failbit);
	cout.exceptions(ios_base::badbit | ios_base::failbit);
	cin .tie(nullptr);
	cout.tie(nullptr);
	cout.precision(16);
	void run();
	run();
	return 0;
}

void run() {
	auto const A = read<sint>();
	auto const B = read<sint>();
	writeln(max(A - B * 2, sint(0)));
}

Measured memory_bytes: 256
n = int(input())
arr = list(map(int,input().split()))

solution = [0]*n
for i in range(n):
    if i == 0:
        solution[i] = arr[i]
    elif i == n-1:
        solution[i] = arr[i-1]
    else:
        solution[i] = min(arr[i-1], arr[i])

print(sum(solution))

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

using namespace std;
typedef long long ll;

int main() {
    int t[100];
    int n;
    cin >> n;
    int sum = 0;
    for(int i=0;i<n;i++){
        cin >> t[i];
        sum += t[i];
    }
    int m;
    cin >> m;
    int p, x;
    for(int i=0;i<m;i++){
        cin >> p >> x;
        cout << sum-t[p-1]+x << "\n";
    }

}


Measured memory_bytes: 256
import numpy as np





n = int(input())
arr = list(map(int,input().split()))


#
# if n <= 3:
#     ans = np.linalg.solve(A, arr)
#
#     for i in range(n - 1):
#         print(int(ans[i]), end=" ")
#
#     print(int(ans[n - 1]))
# else:

odd = 0
eq = 0
all = [0,0]

for i in range(n):
    if i % 2 == 0:
        eq += arr[i]
        all.append(eq)
    else:
        odd += arr[i]
        all.append(odd)


ans = [0 for i in range(n)]

base = eq-odd
base2 = odd-eq+2*arr[0]
for i in range(n):
    if i %2 ==  0:
        ans[i] = base
        if i == n-1:
            break
        base -= 2*arr[i]
        base += 2* arr[i+1]


    if i %2 ==  1:
        ans[i] =base2
        base2 -= 2*arr[i]
        base2 += 2*arr[i+1]



for i in range(n-1):
    print(ans[i],end=" ")
print(ans[-1])







Measured memory_bytes: 25892
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-13;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
char t[7];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	int ret=0;
	for(int i=a;i<=b;i++){
		sprintf(t,"%d",i);
		if(t[0]==t[4]&&t[1]==t[3])ret++;
	}printf("%d\n",ret);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int  string_check(bool first,string &s){
  int ans =0;
  rep(i,s.size()){
    if(first&&s.at(i)=='1') ans++;
    else if((!first)&&s.at(i)=='0') ans++;
    first = !first;
  }
  return ans;
}

int main(){
  string s; cin >> s;
  cout << min(string_check(true,s),string_check(false,s)) <<endl;
}

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

int main(){
	string s;
	int Q;
	cin>>s>>Q;
	string R,T;	R=T="";

	bool rev=false;

	for(int qi=0;qi<Q;qi++){
		int t;	cin>>t;
		if(t==1){
			rev=(rev? false:true);
			continue;
		}else{
			int f;
			char c;
			cin>>f>>c;

			if(rev){
				if(f==1)T+=c;
				else R+=c;
			}else{
				if(f==1)R+=c;
				else T+=c;
			}
		}
	}

	if(rev==false){
		reverse(R.begin(),R.end());
		cout<<R<<s<<T<<endl;
	}else{
		reverse(T.begin(),T.end());
		reverse(s.begin(),s.end());
		cout<<T<<s<<R<<endl;
	}

	return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int[] buf = new int[50];
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int R = sc.nextInt();
			int[] v = new int[N];
			for (int i = 0; i < N; ++i) {
				v[i] = N - i;
			}
			for (int i = 0; i < R; ++i) {
				int P = sc.nextInt() - 1;
				int C = sc.nextInt();
				for (int j = 0; j < C; ++j) {
					buf[j] = v[P + j];
				}
				for (int j = 0; j < P; ++j) {
					buf[C + j] = v[j];
				}
				for (int j = 0; j < C + P; ++j) {
					v[j] = buf[j];
				}
			}
			System.out.println(v[0]);
		}
	}
}

Measured memory_bytes: 28680