akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	N := getStdinInt64()
	A := getStdinIntArr64()
	Apush := make([]int64, 0)

	sort.Slice(A, func(i, j int) bool { return A[i] > A[j] })
	var i int64 = 0
	var ans int64 = 0
	Apush = append(Apush, A[0])
	for i = 1; i < N; i++ {
		Apush = append(Apush, A[i])
		Apush = append(Apush, A[i])
	}
	for i = 0; i < N-1; i++ {
		ans += Apush[i]
	}

	fmt.Printf("%d\n", ans)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 30712
s = int(input())

a = [0]
count = 0

def f(x):
    if x % 2 == 0:
        ans = x // 2
    else:
        ans = 3 * x + 1

    return ans

while True:
    if count == 0:
        a[0] = s
        count += 1
    else:
        a.append(f(a[count-1]))
        if a[count] in a[:(count-1)]:
            print(count+1)
            exit()
        else:
            count += 1

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

int main(){
  double a,b;cin>>a>>b;
  double ans=a/b;
  cout<<ans;
}

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

int n;

const int MOD = 1e9 + 7;

char s[3055];

int dp[3055][3055];
int pref[3055][3055];

inline void add(int &a, int b) {
	a += b;
	
	if (a >= MOD) {
		a -= MOD;
	}
}
inline int sum(int i, int l, int r) {
	int res = pref[i][r];
	
	if (l > 0) {
		res = (res - pref[i][l - 1] + MOD) % MOD;
	}
	
	return res;
}
int main() {
	cin >> n;
	scanf("%s", s);
	
	dp[0][0] = 1;
	pref[0][0] = pref[0][1] = 1;
	
	
	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= i; j++) {
			if (s[i - 1] == '>') {
				add(dp[i][j], sum(i - 1, j, i));
			} else {
				add(dp[i][j], sum(i - 1, 0, j - 1));
			}
		}
		
		pref[i][0] = dp[i][0];
		
		for (int j = 1; j <= i + 1; j++) {
			pref[i][j] = (pref[i][j - 1] + dp[i][j]) % MOD;
		}
	}
	
	int res = 0;
	
	for (int i = 0; i < n; i++) {
		add(res, dp[n - 1][i]);
	}
	
	cout << res;
}


Measured memory_bytes: 71296
#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define D                double
#define F                first
#define S                second
#define pb               push_back
#define pf               push_front
#define MP               make_pair
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define it(it,mp)        for(auto it=mp.begin() ; it!=mp.end() ; it++)
#define IOS              ios_base :: sync_with_stdio(false); cin.tie(NULL);
const int N = 1e5 + 5;
const int inf = 1e9 + 1;
const double eps = 1e-15;
const double EPS = 1e-9;
const double PI = acos(-1.0);
typedef long long int                   ll;
typedef pair<int,int>                   PII;

int main()
{
    IOS
    // READ(0test.txt);
    //WRITE(0out.txt) ;
    ll n, m,a, b,cnt=0;
    cin >> n >> m ;
    ll arr[n+5], k=m ;
    memset(arr,0,sizeof arr);
    for(int i=0 ; i< m ; i++)
    {
        cin >> a >> b ;
        arr[a-1]++;
        arr[b]--;
    }
    if(arr[0]>=m)cnt++;
    for(int i=1;  i< n ; i++){
        arr[i] +=arr[i-1];
        if(arr[i]>=m)cnt++;
    }
    cout<<cnt;

}


Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <vector>
#include <bitset>

using namespace std;

typedef bitset<50> state;

int main() {
    while (1) {
        int n; cin >> n;
        if (n == 0) break;

        vector< vector<int> > schedule(31);

        vector<state> states(n);
        state final_state;
        for (int i = 0; i < n; ++i) {
            states[i].set(i);
            final_state |= states[i];

            int m; cin >> m;
            while (m--) {
                int d; cin >> d;
                schedule[d].push_back(i);
            }
        }

        bool found = false;
        for (int d = 1; d <= 30; ++d) {
            vector<int> s = schedule[d];
            state new_state;
            for (vector<int>::iterator it = s.begin(); it != s.end(); ++it) {
                new_state |= states[*it];
            }
            if (new_state == final_state) {
                cout << d << endl;
                found = true;
                break;
            }
            for (vector<int>::iterator it = s.begin(); it != s.end(); ++it) {
                states[*it] = new_state;
            }
        }
        if (!found) {
            cout << -1 << endl;
        }
    }
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  string s;cin >> s;
  int ans = 0;
  for(int i = 0; i < 3; ++i){
    if(s[i]=='1')++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll>cnt(3);
  rep(i,n){
    ll a;cin>>a;
    a--;
    cnt[a]++;
  }

  unordered_map<ll,double>ma;
  function<double(ll,ll,ll)>dfs=[&](ll a,ll b,ll c){
    double res=0;
    if(a==0&&b==0&&c==0)return 0.0;
    ll abc=a*512*512+b*512+c;
    if(ma.count(abc))return ma[abc];
    double w=(double)n/(a+b+c);
    if(a>0)res+=(dfs(a-1,b,c)+w)/(a+b+c)*a;
    if(b>0)res+=(dfs(a+1,b-1,c)+w)/(a+b+c)*b;
    if(c>0)res+=(dfs(a,b+1,c-1)+w)/(a+b+c)*c;
    return ma[abc]=res;
  };
  cout<<setprecision(13)<<dfs(cnt[0],cnt[1],cnt[2])<<endl;
  return 0;

}


Measured memory_bytes: 239704
#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>
using namespace std;
typedef long long ll;

int const SIZ = 10001;

bitset<SIZ> sieve;
vector<int> primes;

void prepare() {
    sieve.set();
    sieve.set(0, 0);
    sieve.set(1, 0);
    for (int i=4; i<SIZ; i+=2) {
        sieve.set(i, 0);
    }
    for (int i=3; i*i<SIZ; i+=2) {
        if ( ! sieve[i]) {
            continue;
        }
        for (int j=2; i*j<SIZ; ++j) {
            sieve.set(i*j, 0);
        }
    }

    for (int i=0; i<SIZ; ++i) {
        if (sieve[i]) {
            primes.push_back(i);
        }
    }
}

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

    int n;
    cin >> n;

    prepare();

    unordered_map<int,int> checked;
    int m, ans = 0;
    for (int i=0; i<n; ++i) {
        cin >> m;
        if (checked[m]) {
            continue;
        }
        if (m < SIZ && sieve[m]) {
            ++ ans;
            checked[m] = 1;
            continue;
        }
        bool isprime = true;
        for (int i=0; i<(int)primes.size(); ++i) {
            if (m % primes[i] == 0) {
                isprime = false;
                break;
            }
        }
        if (isprime) {
            ++ ans;
            checked[m] = 1;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1532
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

ll mod = 1e9 + 7;
ll modpow(ll A, ll B) {
	if (B == 0) return 1;
	if (B % 2) return A * modpow(A, B - 1) % mod;
	ll half = modpow(A, B / 2);
	return half * half % mod;
}

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


	int N, A, B, C;
	cin >> N >> A >> B >> C;

	if (N > 1) {
		ll Pkake[100000];
		Pkake[0] = 1;
		rep(i, N - 1) {
			Pkake[i + 1] = Pkake[i] * (i + N) % mod;
		}
		ll Pwaru[100000];
		Pwaru[0] = 1;
		rep(i, N - 1) {
			Pwaru[i + 1] = Pwaru[i] * (N - i - 1) % mod;
		}

		ll Pbunsi[100000];
		rep(i, N) Pbunsi[i] = Pkake[i] * Pwaru[N - 1 - i] % mod;

		ll AA[100001], BB[100001], HU[200001];
		AA[0] = 1;
		rep(i, N) AA[i + 1] = AA[i] * A % mod;
		BB[0] = 1;
		rep(i, N) BB[i + 1] = BB[i] * B % mod;
		HU[0] = 1;
		rep(i, 2 * N) HU[i + 1] = HU[i] * (A + B) % mod;

		ll Esum = 0;
		rep(i, N) {
			ll kari = Pbunsi[i] * AA[N] % mod;
			kari = kari * BB[i] % mod;
			kari = kari * HU[N - i] % mod;
			kari = kari * 100 * (N + i) % mod;
			Esum = (Esum + kari) % mod;

			kari = Pbunsi[i] * BB[N] % mod;
			kari = kari * AA[i] % mod;
			kari = kari * HU[N - i] % mod;
			kari = kari * 100 * (N + i) % mod;
			Esum = (Esum + kari) % mod;
		}
		Esum = Esum * modpow(100 - C, mod - 2) % mod;
		Esum = Esum * modpow(Pwaru[N - 1], mod - 2) % mod;
		Esum = Esum * modpow(HU[2 * N], mod - 2) % mod;
		co(Esum);

	}
	else {

		co(100 * modpow(100 - C, mod - 2) % mod);

	}

	Would you please return 0;
}

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

int main() {
  int n; string s;
  cin>>n>>s;
  int r = 0, w = 0;
  for(auto c : s) r+= c=='R', w += c == 'W';
  int cnt = 0;
  for(int i=0; i < r; i++) cnt += s[i] == 'R' ;
  r -= cnt;
  r = max(r, 0);
  cout<<min(r,w)<<endl;
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll a,b;
  cin >> a >> b;
  cout << (a + b + 1) / 2 << endl;
}

Measured memory_bytes: 256
from itertools import accumulate
import sys
input = sys.stdin.readline

mod = 998244353
S = list(map(int, input().rstrip()))
N = len(S)
front = [0] * N
back = [0] * N
cum = list(accumulate(S))
for i in range(N-1):
    front[i+1] = max(front[i], i + 1 - cum[i])
    back[i+1] = max(back[i], cum[i] - (i + 1))
cnt = cum[-1]
dp = [1] * (2 * N - cnt + 1)
for i in range(N - 1, -1, -1):
    for c in range(S[i]):
        f = front[i]
        b = 2 * N - cum[-1]
        for j in range(N):
            if back[j] == cnt:
                b = 2 * j - cum[j-1]
                break
        for j in range(b - 1, f - 1, -1):
            dp[j] = (dp[j] + dp[j+1]) % mod
        for j in range(f - 1, -1, -1):
            dp[j] = dp[j+1]
        cnt -= 1
print(dp[0])



Measured memory_bytes: 69300
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

vi G[MAX_N];
int ans[MAX_N];
int c[MAX_N];
int f[MAX_N];

void dfs(int x, int sum){
    sum += c[x];
    ans[x] = sum;
    f[x] = 1;
    rep(i,G[x].size()){
        if(f[G[x][i]]==0){
            dfs(G[x][i], sum);
        }
        
    }
}

int main() {
    int n, q;
    scanf("%d%d",&n,&q);

    rep(i,n-1){
        int a,b; 
        scanf("%d%d",&a,&b);
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,q){
        int p,x;
        scanf("%d%d",&p,&x);
        c[p] += x;
    }
    dfs(1,0);

    srep(i,1,n+1){
        printf("%d\n", ans[i]);
    }

    return 0;
}
 
 


Measured memory_bytes: 24832
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve(){

  ll x=0,y=0,c=0,ans=0;
  ll n,m,k;
  cin>>n>>k;
  if(n*500>=k)
  {
    c("Yes");
  }
  else c("No");

}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  ll T=1;
  //cin>>T;
  while(T--){
  solve();
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n;
  cin >> n;
  vi h(n);
  rep(i, n) cin >> h[i];
  h[0]--;
  rep2(i, 1, n) {
    if(h[i - 1] > h[i]) {
      cout << "No" << endl;
      return 0;
    }
    if(h[i - 1] < h[i]) h[i]--;
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 640
package main

import (
        "bufio"
        "fmt"
        "os"
)

func solution(n, k int, a []int) []string {
        out := make([]string, n-k)
        for i := k; i < n; i++ {
                if a[i-k] < a[i] {
                        out[i-k] = "Yes"
                } else {
                        out[i-k] = "No"
                }
        }
        return out
}

func main() {
        r := bufio.NewReader(os.Stdin)
        var n, k int
        fmt.Fscan(r, &n, &k)
        a := make([]int, n)
        for i := range a {
                fmt.Fscan(r, &a[i])
        }
        for _, t := range solution(n, k, a) {
                fmt.Println(t)
        }
}

Measured memory_bytes: 9604
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector <int> ar(n);
	for(int &x: ar) cin >> x;

	int res = 0;
	for(int i=0; i<min(n, k); i++){ // number of taken items
		for(int j=0; j<=i+1; j++){ // number of items taken from the left side
			int sum = 0;
			vector <int> vec;
			for(int x=0; x<j; x++){
				vec.pb(ar[x]);
				sum += ar[x];
			}

			for(int x=0; x<=i-j; x++){
				vec.pb(ar[n-x-1]);
				sum += ar[n-x-1];
			}
			int kk = k-i-1;
			sort(ALL(vec));
			for(int i: vec){
				if(i >= 0) break;
				if(!kk--) break;
				sum -= i;
			}
			res = max(res, sum);
		}
	}
	
	cout << res;

	return 0;
}

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

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

  int cnt = 0;
  queue<tuple<ll, int>> q;
  rep(i, 9) q.push(make_tuple(0, i +1));

  while (true) {
    tuple<ll, int> t = q.front();
    q.pop();
    cnt++;
    int current = get<1>(t);
    ll x = get<0>(t) * 10 + current;
    if (cnt == k) {
      cout << x << endl;
      return 0;
    }

    vector<int> next;
    if (current != 0) {
      next.push_back(current - 1);
    }
    next.push_back(current);
    if (current != 9) {
      next.push_back(current + 1);
    }

    for (int n : next) {
      q.push(make_tuple(x, n));
    }
  }
}

Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define endl "\n"

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

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX
#define TWELVE 12



inline int calen(int bm, int bw){
	int x = abs(bm - bw);
	return x*(x-30)*(x-30);
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	vector<int> bitc;
	
	for(int i = 0; i <= (1<<(TWELVE)); i++){
		int con = 0;
		for(int j = 0; (1<<j) <= i; j++){
			if((1<<j)&i) con++;
		}
		// cout<<i<<" "<<con<<endl;
		bitc.push_back(con);
	}
	
	while(true){
		int M, W;
		int ans = 0;
		vector<int> m, w;
		vector<vector<int>>dp;
		
		cin>>M>>W;
		
		if(!M &&!W) break;
		
		m.resize(M);
		w.resize(W);
		
		for(int i = 0; i < M; i++){
			cin>>m[i];
		}
		
		for(int i = 0; i < W; i++){
			cin>>w[i];
		}
		if(W > M){
			swap(w,m);
			swap(W,M);
		}
		
		dp.resize((1<<M), vector<int>(W+1,0));
		
		for(int i = 1; i <= W; i++){
			for(int j = 1; j < (1<<M); j++){
				if(bitc[j] != i) continue;
				for(int k = 0; k < M; k++){
					int bit = j&(~(1<<k));
					
					if(bit == j) continue;
					dp[j][i] = max(dp[bit][i-1] + calen(m[k], w[i-1]),  dp[j][i]);
					
					// cout<<i<<" "<<j<<" "<<k<<" dp "<<dp[j][i]<<endl;
					ans = max(dp[j][i], ans);
				}
			}
		}
	
		
		cout<<ans<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const int MOD = 1000000007; 

int check(vector<int>& hs) {
    bool is_flag = false;
    rep(i, hs.size()) {
        if(hs[i]) {
            is_flag = true;
            hs[i]--;
        } else {
            if (is_flag) {
                return true;
            }  
        } 
    }
    return is_flag;
}

int main() {
    int n; 
    cin >> n;
    vector<int> hs(n);
    rep(i, n) cin >> hs[i];
    int cnt = 0; 
    while(check(hs)) {
        cout << endl;
        ++cnt;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
} read;

const int maxn = 200005, mod = 998244353;
std::vector<int> G[maxn];
int sg[3][maxn];
ll f[3][maxn];
ll po[maxn * 3];

int main () {
	int n = read, len = 1;
	while (len < n)
		len <<= 1;

	po[0] = 1;
	ll bs = 1000000000000000000ll % mod;
	for (int i = 1; i <= n * 3; i ++)
		po[i] = po[i - 1] * bs % mod;

	for (int o = 0; o < 3; o ++) {
		int m = read;
		for (int i = 1; i <= n; i ++)
			G[i].clear();
		for (int i = 1; i <= m; i ++) {
			int u = read, v = read;
			if (u < v) G[u].push_back(v);
			if (v < u) G[v].push_back(u);
		}
		for (int i = n; i; i --) {
			std::set<int> mex;
			for (int j : G[i])
				mex.insert(sg[o][j]);
			while (mex.count(sg[o][i]))
				++ sg[o][i];
		}
		for (int i = 1; i <= n; i ++)
			(f[o][sg[o][i]] += po[i]) %= mod;
	}

	ll ans = 0;
	for (int i = 0; i < 500; i ++)
		for (int j = 0; j < 500; j ++)
			(ans += f[0][i] * f[1][j] % mod * f[2][i ^ j]) %= mod;
	printf("%lld\n", ans);
}


Measured memory_bytes: 13932
from math import gcd
k = int(input())
sum = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        gcd_ij = gcd(i, j)
        for k in range(1, k + 1):
            sum += gcd(gcd_ij, k)
print(sum)

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

    a, b, M = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    ans = min(A) + min(B)
    for _ in range(M):
        x, y, c = map(int, input().split())
        ans = min(ans, A[x-1] + B[y-1] - c)
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 64800
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const X = parseInt(arg[0].split(" ")[1]);
    
    let a = [1];
    let p = [1];
    
    for(let i=1; i<N; i++) {
        a.push((a[i-1] * 2) + 3);
        p.push((p[i-1] * 2) + 1);
    }

    const rec = (N, X) => {
        if(N === 0) {
            return X <= 0 ? 0 : 1;
        } else if(X <= 1 + a[N-1]) {
            return rec(N-1, X-1);
        } else {
            return p[N-1] + 1 + rec(N-1, X-2-a[N-1]);
        }
    }
    
    let answer = rec(N, X);
    
    console.log(answer)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21192
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-5;
const ll MOD=1e9+7;
int main(){
    int n,k;cin>>n>>k;
    int id;
    for(int i=0;i<n;i++){
        int a;cin>>a;
        if(a==1){
            id=i;
        }    
    }
    k--;
    int ans=(id/k)+(id%k>0?1:0);
    int s=n-id-1-(id%k>0?k-id%k:0);
    if(s>0){
        ans+=s/k+(s%k>0?1:0);
    }
    cout<<ans<<endl;
}   


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<unordered_set>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<string>
#include<cmath>
#include<climits>
using namespace std;

int main() {
    int n;
    cin>>n;
    vector<double> p(n);
    for(int i=0;i<n;i++)    cin>>p[i];
    // vector<vector<double>> dp(n+1, vector<double> (n+1,0));
    // dp[0][0]=1.0;
    // for(int i=1;i<=n;i++) {
    //     for(int j=0;j<=i;j++) {
    //         if(j==0) 
    //             dp[i][j] = dp[i-1][j]*(1-p[i-1]);
    //         else 
    //             dp[i][j] = dp[i-1][j]*(1-p[i-1]) + dp[i-1][j-1]*p[i-1];
    //     }
    // }
    // double res=0.0;
    // for(int i=n/2+1;i<=n;i++)    
    //     res += dp[n][i];
    // printf("%0.20lf",res);

    vector<double> dp(n+1,0);
    dp[0]=1;
    for(int i=1;i<=n;i++) {
        for(int j=n;j>=0;j--) {
            if(j==0)
                dp[j] = dp[j]*(1-p[i-1]);
            else
                dp[j] = dp[j]*(1-p[i-1]) + dp[j-1]*p[i-1];
        }
    }
    double res=0;
    for(int i=1+n/2;i<=n;i++)
        res += dp[i];
    printf("%0.15lf",res);
}


Measured memory_bytes: 3888
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<cstring>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
	double r,w,c,nr;
	while(cin >> r>>w>>c>>nr,r+w+c+nr){
		int ans = 0;
		if(r/w>= c){ans = 0;;}
		else {
			for(int i = 1;;i++){
				if((r+i*nr)/w>=c){ans = i;break;}
		}}cout << ans << endl;
	}
}

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

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

int main() {
    vector<int> x(5);
    rep(i, 5) {
        cin >> x[i];
    }
    rep(i, 5) {
        if (x[i] == 0) {
            cout << i+1 << " " << endl;
            return 0;
        } 
    }
    return 0;
}


Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int arr[n];
  int sum=0;
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
      sum+=arr[i];
  }
  int val = ceil(float(sum)/(4*m));
  int count=0;
  for(int i=0;i<n;i++)
  {
      if(arr[i]>=val)
        count++;

  }
  if(count>=m)
    cout<<"Yes\n";
  else
    cout<<"No\n";

}


Measured memory_bytes: 256
# coding: utf-8
from collections import deque
K = int(input())
D = [str(i) for i in range(1, 10)]
D = deque(D)
cnt = 0
while cnt < K:
    v = D.popleft()
    if v[-1] == "0":
        D.append(v + "0")
        D.append(v + "1")
    elif v[-1] == "9":
        D.append(v+"8")
        D.append(v+"9")
    else:
        D.append(v + str(int(v[-1]) - 1))
        D.append(v + v[-1])
        D.append(v + str(int(v[-1]) + 1))
    cnt += 1
print(v)

Measured memory_bytes: 17012
#include <iostream>
using namespace std; 
int main() { 
  int n, m;
  cin >> n >> m; 
  for(int i=0; i<m; i++) {  
    int x, y, color; 
    cin >> x >> y; 
    if(x<=n/2) { 
      if(y>=x && y<=n+1-x) color=x%3; 
      else if(y<x) color=y%3; 
      else color=(n-y+1)%3;  
    } else {    
      if(y>=n+1-x && y<=x) color=(n+1-x)%3;
      else if(y<n+1-x) color=y%3;   
      else color=(n-y+1)%3;  
    }  
    if(color==0) color=3; 
    cout << color << endl; 
  }
  return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


vector<ll> alpha(4);

ll devDiffab(ll devider){
  return alpha[1] / devider \
    - (alpha[0]-1) / devider;
}

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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  REP(i,4)
    cin >> alpha[i];
  ll lcm = alpha[2] * alpha[3] / gcd(alpha[2], alpha[3]);
  cout << devDiffab(1) - devDiffab(alpha[2]) \
    - devDiffab(alpha[3]) + devDiffab(lcm) << "\n";
  
  
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,l,ii,jj;
ll n,m,c;
ll a[300005],b[300005];
ll x,y,ans=0,look;
bool flag;

int main(){
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	if(a[0]!=0)flag=true;
	if(a[1]>=2)flag=true;
	for(i=0;i<n-1;i++){
		if(a[i+1]>=a[i]+2)flag=true;
	}
	a[n]=0;
	for(i=0;i<n;i++){
		if(a[i]<a[i+1])continue;
		if(a[i]==a[i+1]){
			ans+=a[i];
		}
		if(a[i]>a[i+1]){
			ans+=a[i];
		}
	}
	if(flag){
		p(-1);
	}else{
		p(ans);
	}
	return 0;
}

Measured memory_bytes: 7552
// https://atcoder.jp/contests/abc071/tasks/abc071_c
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t;
    cin >> n;
    map<int, int, greater<int>> mp;
    REP(i, n) {
        cin >> t;
        mp[t]++;
    }
    vector<int> v;
    for (auto &x : mp) {
        if (x.second >= 2) {
            if (x.second >= 4) {
                v.push_back(x.first);
                v.push_back(x.first);
                break;
            } else {
                v.push_back(x.first);
                if (v.size() == 2) {
                    break;
                }
            }
        }
    }
    if (v.size() >= 2) {
        cout << (ll)v[0] * v[1] << endl;
    } else {
        cout << "0\n";
    }

    return 0;
}


Measured memory_bytes: 4992
N = int(input())
b = [int(num) for num in input().split()]
queue = [[b,[]]]

def bfs(queue):
    c,prev = queue.pop(0)
    cnt = len(c)-1
    while cnt >= 0:
        if c[cnt] == cnt+1:
            del c[cnt]
            prev = [cnt+1] + prev
            queue.append([c,prev])
            break
        cnt -= 1
    return queue

ans = -1
while queue != []:
    if queue[-1][0] == []:
        ans = queue[-1]
        break
    queue = bfs(queue)
        
if ans == -1:
    print(ans)
else:
    for num in ans[1]:
        print(num)
        




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

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

#define INF  (int)1e9
#define LINF (long long)1e18

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

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

    int N;
    std::cin >> N;

    vector<int> D(N);
    REP(i, N) {
        std::cin >> D[i];
    }

    SORT(D);

    int med_index = std::ceil(D.size() / 2.0) - 1;
    std::cout << D[med_index + 1] - D[med_index] << std::endl;

    return 0;
}


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

S={}
maxr=0
for i in range(n):
    s=input()
    if s in S:
        S[s]+=1
    else:
        S[s]=1

maxc = max(S.values())

ans=[]
for s in S:
    if S[s]==maxc :
        ans.append(s)

ans.sort()
for s in ans:
    print(s)        

Measured memory_bytes: 35084
#include <stdio.h>
int main(void)
{
  int W,H,x,y,r;

  scanf("%d",&W);
  scanf("%d",&H);
  scanf("%d",&x);
  scanf("%d",&y);
  scanf("%d",&r);

  if (y>=r && x>=r && x+r<=W && y+r<=H) {
	printf("Yes\n");
  }
  else
	printf("No\n");

  return 0;
}

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

#define pb push_back
#define ppp pop_back
#define fi first
#define se second
#define pii pair<int,int>

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    string s;
    cin >> s;
    ll k=0, cnt=0;
    for (int i=0; i<s.length(); i++) {
        if (s[i] == 'W') {
            k++;
            cnt += i;
        }
    }
    ll ans;
    if (k == 0) ans = 0;
    else ans = cnt - (k-1)*k/2;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  string s;
  cin >> s;
  bool ok = true;
  rep (i, s.size()) {
    if ((i + 1) & 1) {
      if (s[i] == 'L') {
        ok = false;
        break;
      }
    } else {
      if (s[i] == 'R') {
        ok = false;
        break;
      }
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

def I(): 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 main():
    s = sorted(input())
    t = sorted(input(), reverse=True)
    n = len(s)
    m = len(t)
    if n < m:
        for i in range(n):
            if s[i] != t[i]:
                break
        else:
            print("Yes")
            sys.exit()
    for i in range(min(n, m)):
        if s[i] != t[i]:
            if s[i] < t[i]:
                print("Yes")
                sys.exit()
            break
    print("No")

if __name__ == '__main__':
    main()

Measured memory_bytes: 9092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

			double nodo = 0;
			int[] ans = new int[2];
			for (int i = 0; i <= input[5] / (100 * input[0]); i++)
			{
				for (int j = 0; j <= input[5] / (100 * input[1]); j++)
				{
					int water = 100 * input[0] * i + 100 * input[1] * j;
					if (water > input[5]) continue;
					int s_max = (input[4] * water) / 100;
					for (int k = 0; k <= s_max / input[2]; k++)
					{
						for (int l = 0; l <= (s_max - k * input[2]) / input[3]; l++)
						{
							int sato = input[2] * k + input[3] * l;
							if (water + sato > input[5]) continue;
							if (100 * sato > input[4] * water) continue;
							if (nodo <= (double)sato / (water + sato))
							{
								nodo = (double)sato / (water + sato);
								ans[0] = water + sato;
								ans[1] = sato;
							}
						}
					}
				}
			}
			Console.WriteLine(ans[0] + " " + ans[1]);
			//Console.ReadLine();
		}
	}
}

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

int main() {
    string S;
    cin >> S;

    int ans = 0;

    for (int i = 0, j = S.size() - 1; i < S.size() / 2; ++i, --j) {
        if (S[i] != S[j]) ++ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, k) = readInputLine().split(" ").map { it.toLong() }
    val map = mutableMapOf<Long, Long>()
    
    for (i in 1..n) {
        val (a, b) = readInputLine().split(" ").map { it.toLong() }
        val num = map.get(a) ?: 0L
        
        map.put(a, num + b)
    }
    
    var num = 0L
    
    for (key in map.keys.toList().sorted()) {
        num += map.get(key)!!
        
        if (num >= k) {
            println(key)
            break
        }
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 60608
#include<iostream>
#include<algorithm>
#include <cmath>
#include<vector>

using namespace std;

int main(){
    int N;
    cin >> N;
    int A[N];
    vector<int> sa;
    for(int i = 0; i < N;i++){
        cin >> A[i];
        int tmp = A[i] - (i+1);
        sa.push_back(tmp);
    }
    sort(sa.begin(), sa.end());
    //for(int i = 0; i < N; i++)cout << sa[i] << " ";
    if(N%2 != 0){
        int b = sa[(N+1)/2 - 1];
        //cout << "\nb=" << b << endl;
        long sum = 0;
        for(int i = 0; i < N; i++)sum+=abs(A[i] - (i+1)-b);
        cout << sum;
        return 0;
    }
    int b1 = sa[N/2 -1];
    int b2 = sa[N/2];
    long sum1 = 0;
    long sum2 = 0;
    for(int i = 0; i < N; i++){
        sum1+=abs(A[i] - (i+1)-b1);
        sum2+=abs(A[i] - (i+1)-b2);
    }
    if(sum1 < sum2)cout << sum1;
    else cout << sum2;
}

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

using namespace std;

#define pb push_back
#define sz size()
#define ll long long

map<int, vector<int> > W;
int a[200010];

int main() {

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

    int canTake = min(n, k - 1), last;

    W[0].pb(-1);
    ll s = 0, ans = 0;

    for(int i = 0; i < n; i++){
        s += a[i];
        s %= k;
        last = i - canTake;
        if(last < 0) {
            ans += (ll)W[s].sz;
            W[s].pb(i);
            continue;
        }
        ll loc = W[s].end() - lower_bound(W[s].begin(), W[s].end(), last);
        ans += loc;

        W[s].pb(i);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 22912
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            boolean ok = false;
            int odd = 0;
            int mo4 = 0;
            for (int i = 0; i < n; i++) {
                if (a[i] % 4 == 0) {
                    mo4++;
                } else if (a[i] % 2 != 0) {
                    odd++;
                }
            }
            if (n != mo4 + odd) {
                if (mo4 >= odd) ok = true;
            } else {
                if (mo4 >= odd - 1) ok = true;
            }

            out.println(ok ? "Yes" : "No");

        }

    }
}



Measured memory_bytes: 48824
N, L = map(int, input().split())

total = 0
list = []
ajilist = []
for i in range(N):
    aji = i + L
    total += aji
    list.append(abs(aji))
    ajilist.append(aji)

I = list.index(min(list))

ans = total - ajilist[I]

print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

ll gcd(ll a, ll b) {
  return b != 0 ? gcd(b, a % b) : a;
}

int main(){
  ll n,x;cin>>n>>x;
  ll temp;
  ll ans;
  cin>>temp;
  if(temp!=x){
  		ans=abs(temp-x);
  }
  rep(i,n-1){
  	cin>>temp;
  	if(temp!=x){
  		ans=gcd(abs(temp-x),ans);
  	}
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
ll N;
  cin >>N;
  vl a(N);
  rep(i,N) {
cin >>a.at(i);
  }
  ll sum=0;
  rep(i,N) {
    sum +=a.at(i);
  }
  sum=sum-N;
  cout<<sum<<endl;
}

    
  
  

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<stack>
#include<queue>
using namespace std;

int max(int x, int y);
int min(int x, int y);
int gcd(int x, int y);	/*最大公約数*/
int lcm(int x, int y);	/*最小公倍数*/
void swap(int* x, int* y);	/*値の交換*/
void downsort(int* a, int n);	/*降順ソート*/
void upsort(int* a, int n);	/*昇順ソート*/

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*/

/*ここからmain関数*/

int main()
{
	int t[5];
	for (int i = 0;i < 5;i++)
		cin >> t[i];

	int tmod[5], tup[5];

	for (int i = 0;i < 5;i++)
	{
		tmod[i] = t[i] % 10;
		if (tmod[i] == 0)
			tmod[i] = 10;
		tup[i] = t[i] + 10 - tmod[i];
	}

	int m = min(tmod[0], min(tmod[1], min(tmod[2], min(tmod[3], tmod[4]))));

	int ans = 0;
	for (int i = 0;i < 5;i++)
		ans += tup[i];
	ans -= (10 - m);

	cout << ans;

	return 0;
}

/*2数の大きい方を返す*/
int max(int x, int y)
{
	int max;

	if (x < y)
		max = y;
	else
		max = x;

	return max;
}

/*2数の小さい方を返す*/
int min(int x, int y)
{
	int min;

	if (x < y)
		min = x;
	else
		min = y;

	return min;
}

/*2数の最大公約数を返す*/
int gcd(int x, int y)
{
	int m;
	int gcd = 1;

	m = min(x, y);

	for (int i = 1;i <= m; i++)
	{
		if (x%i == 0 && y%i == 0)
			gcd = i;
	}

	return gcd;
}

/*2数の最小公倍数を返す*/
int lcm(int x, int y)
{
	int m;

	for (int i = 1;i <= y;i++)
	{
		if ((x*i) % y == 0) {
			m = x * i;
			break;
		}
	}

	return m;
}

/*2数の値を交換する*/
void swap(int* px, int* py)
{
	int temp;

	temp = *px;
	*px = *py;
	*py = temp;
}

/*クイックソートによる降順並べ替え*/
void downsort(int* a, int n)
{
	//初期設定
	int l = 0, r = n - 1;

	// ピボットの決定
	int piv = *a;

	//ピボットより大を左に、ピボット以下を右に
	while (l < r)
	{
		if (*(a + l) > piv)
			l++;
		else if (*(a + r) <= piv)
			r--;
		else
			swap(a + l, a + r);
	}

	//再帰処理
	if (n == 2)
		return;
	else if (l == 1 || l == 0)
		downsort(a + 1, n - 1);
	else if (r == n - 1)
		downsort(a, n - 1);
	else
	{
		downsort(a, l);
		downsort(a + l, n - l);
	}
}

/*クイックソートによる昇順ソート*/
void upsort(int* a, int n)
{
	downsort(a, n);

	for (int i = 0;i < n / 2;i++)
		swap(a[i], a[n - 1 - i]);
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[0] << c[0] << endl;
    return 0;
};


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

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

    int x=0;
    int x_max=0;

    for(int i=0; i<n; i++){
        if(s.at(i)=='I'){
            x++;
        }else{
            x--;
        }
        if(x>x_max){
            x_max=x;
        }
    }

    cout<<x_max<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>

using namespace std;

int main(void){
	
	int table;
	char inpt_data[11]={'0'};
	
	while(cin>>inpt_data){
		
		for(int j=9;j>=0;j--){
			for(int i=0;i<j;i++){
				table=(inpt_data[i]-'0')+(inpt_data[i+1]-'0');
				if(table>9){
					table=table-10;
				}
				/*if(i==j){
					inpt_data[i]='0';
				}*/
				inpt_data[i]=table+'0';
			}
		}
		cout<<inpt_data[0]<<endl;
		memset(inpt_data,'0',sizeof(inpt_data));
	}
}

Measured memory_bytes: 1132
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int n,m;cin>>n>>m;
    vector<pair<int,int>> p(n/2);
    if(m%2==0){
        rep(i,m/2){
            p[i].first=i+1;
            p[i].second=m+1-i;
        }
        rep(i,m/2){
            p[i+m/2].first=m+2+i;
            p[i+m/2].second=2*m+1-i;
        }
    }else{
        rep(i,m/2){
            p[i].first=i+1;
            p[i].second=m-i;
        }
        rep(i,(m+1)/2){
            p[i+m/2].first=m+1+i;
            p[i+m/2].second=2*m+1-i;
        }
    }
    rep(i,m){
        cout<<p[i].first<<" "<<p[i].second<<endl;
    }
}

Measured memory_bytes: 3960
#include <cstdio>
using namespace std;
int main(){
    int N,A[100],max,min;
    scanf("%d",&N);
    scanf("%d",&A[0]);
    max=A[0];
    min=A[0];
    for(int i=1;i<N;i++){
        scanf("%d",&A[i]);
            if(max < A[i]){
                max = A[i];
            }
            if(min > A[i]){
                min = A[i];
            }
    }    
    printf("%d\n",max-min);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>

using namespace std;

int main() {
    int r, g, b, n;

    cin >> r >> g >> b >> n;

    set<int> s;
    for (int n_b = 0; n_b * b <= n; n_b++) {
        s.insert(n - n_b * b);
    }

    int ans = 0;
    for (int n_r = 0; n_r * r <= n; n_r++) {
        for (int n_g = 0; n_g * g <= n; n_g++) {
            if (s.find(n_r * r + n_g * g) != s.end()) ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 384