akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<climits>
using namespace std;
int main() {

    int n,k;
    cin>>n>>k;
    int arr[n],dp[n]={0};

    for(int i=0;i<n;i++)
     cin>>arr[i];

    dp[1]=abs(arr[0]-arr[1]);
    for(int i=2;i<n;i++)
    {
        int temp=k;
        int j=i-1,gmin=INT_MAX;
        // cout<<i<<"= ";
        while(j>=0&&temp>0)
        {
          int lmin=dp[j]+abs(arr[i]-arr[j]);
          gmin=min(gmin,lmin);

        //   cout<<lmin<<" ";
          j--;temp--;
          
        }
        // cout<<endl;
        dp[i]=gmin;
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 4312
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n+1), b(n);
    rep(i, n+1) cin >> a[i];
    rep(i, n) cin >> b[i];

    ll ans = 0;
    rep(i, n) {
        ans += min(a[i], b[i]);
        b[i] -= min(a[i], b[i]);
        ans += min(a[i+1], b[i]);
        a[i+1] -= min(a[i+1], b[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3940
fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let a: Vec<usize> = sc.read_vec(n);

    let mut sum = vec![0; n + 1];
    let mut xor_sum = vec![0; n + 1];
    for i in 0..n {
        sum[i + 1] = sum[i] + a[i];
        xor_sum[i + 1] = xor_sum[i] ^ a[i];
    }

    let mut ans = 0;
    for l in 0..n {
        let mut high = n;
        let mut ok = l;
        while high - ok > 1 {
            let r = (high + ok) / 2;
            let s = sum[r + 1] - sum[l];
            let x = xor_sum[r + 1] ^ xor_sum[l];
            if s == x {
                ok = r;
            } else {
                high = r;
            }
        }
        ans += ok - l + 1;
    }
    println!("{}", ans);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


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

using namespace std;

int main(void){

	int n;

	cin >> n;

	vector<int> a(n);



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

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


	int m = a[n-1];


	int k = 0;


	for (int i = 0; i < n; i++){
		if (abs((m + 1)/2 - a[i]) < abs((m + 1)/2 - k))
			k = a[i];
	}


	cout << m << " " << k << endl;


}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#define REP(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)

using namespace std;

int main(){
  string s[3];
  int start = 0;
  REP(i,0,3) cin>>s[i];
  int pos[3] = {0,0,0};
  while(true){
    if(pos[start] >= s[start].size()){
      cout<<char('A' + start)<<endl;
      break;
    }
    start = s[start][pos[start]++]-'a';
  }
  
  return 0;
}


Measured memory_bytes: 256
s = gets.chomp
x, y = gets.split.map(&:to_i)
s_size = s.size

f_counts = s.split('T').map(&:size)
x_counts = f_counts.select.with_index { |size, i| i.even? }
y_counts = f_counts.select.with_index { |size, i| i.odd? }

def exec_dp(pos, counts)
  dp = {}
  dp[pos] = true
  (counts || []).each do |c|
    next if c == 0
    new_dp = {}
    dp.each do |i, _|
      new_dp[i - c] = true
      new_dp[i + c] = true
    end
    dp = new_dp
  end
  dp
end

xdp = if x_counts.size == 0
  { 0 => true }
else
  exec_dp(x_counts[0], x_counts[1..-1])
end
ydp = exec_dp(0, y_counts)
is_ok = xdp[x] && ydp[y]
puts(is_ok ? 'Yes' : 'No')

Measured memory_bytes: 85168
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	if (n<3 ){
		printf("%d\n",0);
		}
	else if(n%3==0){
		printf("%d\n",n/3);
	}
	else if(n%3==1){
		printf("%d\n",(n-1)/3);
	}
	else{
		printf("%d\n",(n-2)/3);
	}
    return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define INF (1 << 29)
const int mod = 1000000007;

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

ll lcm(int a, int b) { return a / gcd(a, b) * b; }

int main() {
    ll A, B;
    cin >> A >> B;
    cout << lcm(A, B) << endl;
    return 0;
}

Measured memory_bytes: 3632
IDENTIFICATION DIVISION.
PROGRAM-ID. 136B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 N    PIC 9(6).
01 I    PIC 9(1).
01 KSU  PIC 9(6).
01 OUT  PIC ZZZZ9.
*>
PROCEDURE DIVISION.
  ACCEPT N.
  MOVE 0 TO KSU.
  PERFORM VARYING I FROM 1 BY 2 UNTIL (10 ** (I - 1) > N)
    IF (N >= 10 ** I) 
      COMPUTE KSU = KSU + (10 ** I) - (10 ** (I - 1))
    ELSE
      COMPUTE KSU = KSU + N - (10 ** (I - 1))  + 1
    END-IF
  END-PERFORM.
*>
  MOVE KSU TO OUT.
  DISPLAY FUNCTION TRIM(OUT).
*>
  STOP RUN.


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
#define ll long long;

int main(){
  string s;
  cin>>s;
  if(s=="Sunny")cout<<"Cloudy";
  else if(s=="Cloudy")cout<<"Rainy";
  else if(s=="Rainy")cout<<"Sunny";
  

}


Measured memory_bytes: 3524
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double xs = sc.nextDouble();
        double ys = sc.nextDouble();
        double xg = sc.nextDouble();
        double yg = sc.nextDouble();
        int N = sc.nextInt();
        double[] x = new double[N+2];
        double[] y = new double[N+2];
        double[] r = new double[N+2];
        for (int i=0;i<N;i++) {
            x[i] = sc.nextDouble();
            y[i] = sc.nextDouble();
            r[i] = sc.nextDouble();
        }
        x[N]=xs;y[N]=ys;r[N]=0;x[N+1]=xg;y[N+1]=yg;r[N+1]=0;

        ArrayList<ArrayList<double[]>> edge = new ArrayList<ArrayList<double[]>>();
        for (int i=0;i<N+2;i++) {
            ArrayList<double[]> add = new ArrayList<double[]>();
            edge.add(add);
        }
        for (int i=0;i<N+2;i++) {
            for (int j=0;j<N+2;j++) {
                if (i==j) continue;
                double dist = Math.pow(Math.pow(x[i]-x[j], 2)+Math.pow(y[i]-y[j], 2), 0.5);
                double[] add = {j, Math.max(dist-r[i]-r[j], 0)};
                edge.get(i).add(add);
            }
        }

        double[] dist_arr = new double[N+2];
        Arrays.fill(dist_arr, -1);
        double[] first = {N, 0};
        PriorityQueue<double[]> pq = new PriorityQueue<double[]>((o1, o2)->Double.compare(o1[1], o2[1]));
        pq.add(first);
        while (!pq.isEmpty()) {
            double[] rem = pq.poll();
            if (dist_arr[(int)rem[0]]!=-1) continue;
            dist_arr[(int)rem[0]] = rem[1];
            for (double[] tmp : edge.get((int)rem[0])) {
                double[] add = {tmp[0], rem[1]+tmp[1]};
                pq.add(add);
            }
        }
        System.out.println(dist_arr[N+1]);
        // System.out.println(Arrays.toString(dist_arr));
        // System.out.println(edge);
    }
}

Measured memory_bytes: 142628
s=input()
ans=[0]*len(s)
check=0
now='R'
count=0
for t,i in enumerate(s):
    if now=='L':
        if i=='L':
            count+=1
        else:
            ans[check-1]+=count//2
            ans[check]+=-(-count//2)
            count=1
            now='R'
    elif now=='R':
        if i=='R':
            count+=1
        else:
            check=t
            ans[check-1]+=-(-count//2)
            ans[check]+=count//2
            count=1
            now='L'
if count>0:
    ans[check-1]+=count//2
    ans[check]+=-(-count//2)
print(*ans)

Measured memory_bytes: 6400
#include<iostream>
using namespace std;int main(){int n,m;int map[3000]={0};int a;int i;for(;;){cin>>n>>m;if(n==0&&m==0)break;int now=0,ans=0;for(i=0;i<n;i++)cin>>map[i];for(i=0;i<m;i++){cin>>a;now+=a;if(map[now]!=0&&ans==0)now+=map[now];if(now>=n-1&&ans==0)ans=i+1;}cout<<ans<<endl;}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define MAXN 500009
#define MAXM 4000009
#define MOD 998244353
#define INF 1000000009
#define FOR(x,n) for(int x=0; x<n; x++)
#define FOR1e(x,n) for(int x=1; x<=n; x++)
typedef pair<int, int> ii;
typedef long long ll;

ll fat[MAXN], ifat[MAXN];

ll fexp(ll val, ll p) {
	ll ans = 1;
	while (p > 0) {
		if (p&1) ans = (ans*val)%MOD;
		val = (val*val)%MOD;
		p >>= 1;
	}
	return ans;
}

ll C(ll a, ll b) {
	if (b < 0) return 0;
	return (((fat[a]*ifat[a-b])%MOD) *ifat[b])%MOD;
}
int main() {
	int n, k;
	cin >> n >> k;
	fat[0] = 1; ifat[0] = 1;

	for (int i = 1; i <= max(n, k); i++) {
		fat[i] = (fat[i-1]*i)%MOD;
		ifat[i] = fexp(fat[i], MOD-2);
	}

	ll ans = 0;
	for (int R = n; R <= k; R++) {
		int B = k-R;
		if (B > R) continue;
		if (B == R) {
			ans += C(R + B-1, R);
			ans %= MOD;
			ans += MOD - C(R + B-1, B-1 - (B-n+1));
			ans %= MOD;
		}
		if (B < R) {
//			cout << B - (R-n+1) << endl;
			ans += C(R+B, R);
			ans %= MOD;
			ans += MOD - C(R+B, B - (R-n+1));
			ans %= MOD;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 8064
#include <iostream>
#include <string>
#define max(x, y) ((x) > (y) ? (x) : (y))
using namespace std;
const int N = 4000;
int dp[N][N];
int main() {
	string x, y;
	cin >> x >> y;
	int n = x.length(), m = y.length();
	for (int i = 0; i < N; i++) {
		dp[0][i] = 0; 
		dp[i][0] = 0;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (x[i - 1] == y[j -1]) {
				dp[i][j] = 1 + dp[i - 1][j - 1];
			}
			else{
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}
	int index = dp[n][m];
	string z(index, 0);
	int i = n; 
	int j = m;
	while (i > 0 && j > 0) {
		if (x[i - 1] == y[j - 1]) {
			z[index - 1] = x[i - 1];
			index--;
			i--;
			j--;
		}
		else if (dp[i][j - 1] > dp[i - 1][j]) {
			j--;
		}
		else{
			i--;
		}
	}
	cout << z;
	return 0;
}


Measured memory_bytes: 61952
import typing
class SegTree:
    def _ceil_pow2(self, n: int) -> int:
        x = 0
        while (1 << x) < n:
            x += 1
        return x
    
    def __init__(self,
                 op: typing.Callable[[typing.Any, typing.Any], typing.Any],
                 e: typing.Any,
                 v: typing.Union[int, typing.List[typing.Any]]):
        self._op = op
        self._e = e

        if isinstance(v, int):
            v = [e] * v

        self._n = len(v)
        self._log = self._ceil_pow2(self._n)
        self._size = 1 << self._log
        self._d = [e] * (2 * self._size)

        for i in range(self._n):
            self._d[self._size + i] = v[i]
        for i in range(self._size - 1, 0, -1):
            self._update(i)
    
    def set(self, p: int, x: typing.Any) -> None:
        assert 0 <= p < self._n
        p += self._size
        self._d[p] = x
        for i in range(1, self._log + 1):
            self._update(p >> i)

    def prod(self, left: int, right: int) -> typing.Any:
        assert 0 <= left <= right <= self._n
        sml = self._e
        smr = self._e
        left += self._size
        right += self._size

        while left < right:
            if left & 1:
                sml = self._op(sml, self._d[left])
                left += 1
            if right & 1:
                right -= 1
                smr = self._op(self._d[right], smr)
            left >>= 1
            right >>= 1

        return self._op(sml, smr)

    def all_prod(self) -> typing.Any:
        return self._d[1]

    def _update(self, k: int) -> None:
        self._d[k] = self._op(self._d[2 * k], self._d[2 * k + 1])

N, K = map(int, input().split())
A = list(int(input()) for _ in range(N))
max_A = max(A)
seg = SegTree(max, -1, [0]*(max_A+1))
for v in A:
    l = max(0, v-K)
    r = min(max_A, v+K)
    seg.set(v, seg.prod(l, r+1)+1)
print(seg.all_prod())

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

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

int main(){
    int N, K;
    cin >> N >> K;
    long long H[N], sum = 0;
    int i;

    for(i = 0; i < N; i++){
        cin >> H[i];
    }
    if (N <= K)
    {
        cout << 0 << endl;
        exit(0);
    }
    qsort(H, N, sizeof(long long), compare_int);
    for(i = 0; i < N-K; i++){
        sum += H[i];
    }
    cout << sum << endl; 
    return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

const int MAX_NUM = 111, MAX_WEIGHT = 11111;
int N, W;
int weight[MAX_NUM], value[MAX_NUM];
int dp[MAX_NUM][MAX_WEIGHT];

int main() {
   cin >> N >> W;
   rep (i, N) {
      cin >> value[i] >> weight[i];
   }

   for (int i = 0; i < N; i++) {
      for (int j = 0; j <= W; j++) {
         if (j >= weight[i]) {
            dp[i+1][j] = max(dp[i][j], dp[i][j-weight[i]]+value[i]);
         } else {
            dp[i+1][j] = dp[i][j];
         }
      }
   }

   cout << dp[N][W] << endl;

   return 0;
}


Measured memory_bytes: 7396
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int arr[m];
	int sum=0;
	for(int i = 0;i<m;i++){
		cin>>arr[i];
		sum = sum+arr[i];
	}
	
	if(sum>n){
		cout<<-1;
	}else{
		cout<<n-sum;
	}
	return 0;
}


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

using namespace std;

int main(void) {
  int n;
  while (cin >> n, n) {
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }

    vector<int> cum(n + 1, 0);
    stack<int> st;
    st.push(1);
    for (int i = 2; i <= n; i++) {
      if (a[i] == a[i - 1]) continue;
      if (i & 1) {
        st.push(i);
      } else {
        int v;
        if (st.empty()) {
          v = 1;
        } else {
          v = st.top();
          st.pop();
        }
        cum[v - 1]--, cum[i - 1]++;
      }
    }

    for (int i = n - 1; i >= 0; i--) {
      cum[i] += cum[i + 1];
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
      ans += (a[i] + cum[i]) % 2 == 0;
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
#define tf T.front()
using namespace std;
signed main()
{
	deque<long long>T;
	long long x;
	cin>>x;
	for (int i=1;i<10;i++)  T.pb(i);
	long long i=0;
	while (i<x-1){
		if (tf%10)  T.pb(tf*10+tf%10-1);
		T.pb(tf*10+tf%10);
		if (tf%10!=9)  T.pb(tf*10+tf%10+1);
		i++,T.pop_front();
	}
	cout<<tf;
	re 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <string.h>
#include <cassert>
 
#ifdef _DEBUG
#define typeof(X) std::identity<decltype(X)>::type //C++0x (for vs2010)
#else
#define typeof(X) __typeof__(X) // for gcc
#endif
 
#define sz(a)  int((a).size())
#define FOREACH(it, c) for (typeof((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define FOR(i,count) for (int i = 0; i < (count); i++)
 
using namespace std;
typedef long long ll;
const int MODULO = 1000000007;
 
typedef pair<int,int> Pii;
// begin

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a * b / gcd(a,b); }

int get_n(int a,int m){
	int r = a;
	for (int i = 1; i < m; i++){
		if(r == 1) return i;
		r *= a;
		r %= m;
	}
	return -1;
}

int main()
{
	int a[3],m[3];
	while(cin>>a[0]>>m[0]>>a[1]>>m[1]>>a[2]>>m[2]){
		if(!(a[0]||a[1]||a[2]||m[0]||m[1]||m[2]))
			break;
		ll p[3];
		for (int i = 0; i < 3; i++){
			p[i] = get_n(a[i],m[i]);
		}
		ll l = lcm(lcm(p[0],p[1]),p[2]);
		cout << l << endl;
	}
    return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<algorithm>
#include<iostream>

using namespace std;

const int N_MAX = 100;

int N;
int a[N_MAX + 1];

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

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

  sort(a, a + N, greater<int>());
  int alice = 0;
  int bob = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      alice += a[i];
    } else {
      bob += a[i];
    }
  }
  printf("%d\n", alice - bob);
}


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

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

    vector<int> A(2*N);
    for(int i = 0; i < 2*N; i++) cin >> A[i];
    sort(A.begin(), A.end());

    int res = 0;
    for(int i = 0; i < 2*N; i += 2) res += A[i];

    cout << res << '\n';
    return 0;
}


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

char c[60][60]; 
int a, b;

int main() {
	cin >> a >> b;
	for (int i = 0; i < a; i++) {
		for (int j = 0; j < b; j++) 
          cin >> c[i][j];
	}
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			if (c[i][j] == '#' && c[i][j - 1] != '#' && c[i - 1][j] != '#' && c[i][j + 1] != '#' && c[i + 1][j] != '#') {
              cout << "No" << endl;
              
              return 0;
		}
	}
    }
	 cout << "Yes" << endl;
	
	return 0;
}


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]

n,q = map(int, input().split())
#長さn個のリストを入れ子にしたリストの作成：adj
adj = [[] for i in range(n)]

#adjに繋がっている要素を上流下流関わらず全て加える。
for j in range(n-1):
    a,b=map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1) 

#加算する値を合計したリストの作成
queries = [0 for i in range(n)]
for j in range(q):
    p, x = map(int, input().split())
    queries[p-1] += x

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

#aの値，直前の値，直前のaの値
st = [(0, 0, -1)] 

#つながってる奴の一番後ろから処理していく。
#０スタート→1,2繋がってるなら2にいく。2に3が繋がってるなら次は3。
#3に繋がってるのがなければ1に戻る。
#この際，aの直前の値をタプルで保持したままリストに挿入して保管しておく。
while st:
    #stの先頭を取り出す。初期値は末尾のため-1
    l = st.pop()  
    ans[l[0]] = l[1] + queries[l[0]]
    for v in adj[l[0]]:
        if v != l[2]:
            st.append((v, ans[l[0]], l[0]))

print(*ans)

Measured memory_bytes: 65000
#include <iostream>
#define MAX 50000

int main(){
    int set[MAX];
    int i_set = 0;
    int n, m;
    std::cin >> n >> m;

    while(n != 0 && m != 0){

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

        int max = -1;
        for(int i=0; i<n; i++){
            for(int j=i+1; j<n; j++){
                if((item[i] + item[j]) <= m){
                    if((item[i] + item[j]) > max){
                        max = item[i] + item[j];
                    }
                }
            }
        }

        set[i_set] = max;
        i_set += 1;
        std::cin >> n >> m;
    }

    for(int k=0; k<i_set; k++){
        if(set[k] == -1){
            std::cout << "NONE\n";
        }
        else{
            std::cout << set[k] << '\n';
        }
    }

    return 0;
}


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

int main() {
  int k;
  cin >> k;
  
  vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << a.at(k-1) << endl;
}


Measured memory_bytes: 256
check :: String -> Int -> Bool
check [] _ = True
check (x:xs) n
  | n `mod` 2 == 0 = if x `elem` "LUD" then check xs (n+1) else False
  | otherwise      = if x `elem` "RUD" then check xs (n+1) else False

main = do
  s <- getLine
  putStrLn $ if check s 1 then "Yes" else "No"


Measured memory_bytes: 380
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	_ = iScan()
	s := Scan()
	ans := 0
	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			for k := 0; k < 10; k++ {
				f := 0
				for _, v := range s {
					m := stringToInt(string(v))
					if f == 0 && m == i {
						f++
					} else if f == 1 && m == j {
						f++
					} else if f == 2 && m == k {
						f++
					}
				}
				if f == 3 {
					ans++
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1880
A,B,K = gets.strip.split.map(&:to_i)

(K/2).times do
  if A.odd?
    A = A - 1
    A = A / 2
    B = B += A
  else
    A = A / 2
    B = B += A
  end
  if B.odd?
    B = B - 1
    B = B / 2
    A = A += B
  else
    B = B / 2
    A = A += B
  end
end

if K.odd?
  if A.odd?
    A = A - 1
    A = A / 2
    B = B + A
  else
    A = A / 2
    B = B + A
  end
end

puts "#{A}\s#{B}"

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define exp pow(10,-9)
#define F first
#define S second
#define PB push_back 
#define MP make_pair
#define daman ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lowercase(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define uppercase(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
main(){
	daman
	int n;
	cin>>n;
	
	int ans = 1000-n%1000;
	if(n%1000 == 0)
		ans = 0;
	
	cout<<ans<<"\n";
}

Measured memory_bytes: 3664
# -*- coding: utf-8 -*-

import sys
from collections import Counter
from math import sqrt

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def factorize(num: int) -> dict:
    """ 素因数分解 """
    d = Counter()
    # 終点はルート切り捨て+1
    for i in range(2, int(sqrt(num))+1):
        cnt = 0
        # 素因数分解：小さい方から割れるだけ割って素数をカウント
        while num % i == 0:
            num //= i
            d[i] += 1
        # 1まで分解したら終了
        if num == 1:
            break
    # 最後に残ったnumは素数(ただし1^1は1^0なので数に入れない)
    if num != 1:
        d[num] += 1
    return d

N = INT()

print('{0}: '.format(N), end='')
ans = []
for k, v in sorted(factorize(N).items()):
    for i in range(v):
        ans.append(k)
print(*ans)



Measured memory_bytes: 6064
#!/usr/bin/env python
#pyrival orz
import os
import sys
from io import BytesIO, IOBase

"""
    for _ in range(int(input())):
    n,m=map(int,input().split())
    n=int(input())
    a = [int(x) for x in input().split()]
"""

def main():
    def dist(s,t):
        if len(s)>len(t):
            return len(s)
        return sum(s[i]!=t[i] for i in range(len(s)))
    t=input()
    s=input()
    ans=len(s)
    for i in range(len(t)):
        ans=min(ans,dist(s,t[i:]))
        # print(s,t[i:],dist(s,t[i:]))

    print(ans)

# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 73488
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long
LL I, O, T, J, L, S, Z;
LL ans;
int main() {
	std::cin >> I >> O >> T >> J >> L >> S >> Z;
	ans += (I / 2) * 2;
	ans += (L / 2) * 2;
	ans += (J / 2) * 2;
	ans += O;
	LL sum = 0;
	if (I&&L&&J) {
		sum += ((I - 1) / 2) * 2;
		sum += ((L - 1) / 2) * 2;
		sum += ((J - 1) / 2) * 2;
		sum += O;
		sum += 3;
	}
	std::cout << std::max(ans,sum) << std::endl;
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#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 LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

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

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


int main(void) {
	int n;
	bool flag = true;
	vector<string> w(101);

	cin >> n;

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

	FOR(i, 1, n-1) {
		FOR(j, i + 1, n) {
			if (w[i] == w[j]) {
				flag = false;
			}
		}
	}

	FOR(i, 1, n - 1) {
		if (w[i][w[i].size() - 1] != w[i + 1][0]) {
			flag = false;
		}
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;;
	}

	return 0;
}

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

int par[10010];
int find(int x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
}
bool same(int x, int y) {
    return find(x) == find(y);
}
void unit(int x, int y) {
    x = find(x);
    y = find(y);
    if (!same(x, y)) par[y] = find(x);
}

int main() {
    int n, q;
    cin >> n >> q;

    rep(i, n) par[i] = i;

    int C[q], X[q], Y[q];
    rep(i, q) cin >> C[i] >> X[i] >> Y[i];

    // cout << endl;
    rep(i, q) {
        if (C[i]==0) unit(X[i], Y[i]);
        else cout << same(X[i], Y[i]) << endl; //<< " " << par[X[i]] << " " << par[Y[i]] << endl;
    }

    return 0;
}




Measured memory_bytes: 4196
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,m,s[5]={},f,x[10]={};
  char c[5]={},xx[10]={};
  cin >> n >> m;
  if(m==0) {
    if(n==1) {
      cout << 0 << endl;
      return 0;
    }
    if(n==2) {
      cout << 10 << endl;
      return 0;
    }
    if(n==3) {
      cout << 100 << endl;
      return 0;
    }
  }
  string ans="";
  ans+='1';
  for(int i=1; i<n; i++) {
    ans+="0";
  }
  for(int i=0; i<m; i++) {
    cin >> s[i] >> c[i];
    if(x[s[i]]&&xx[s[i]]!=c[i]) {
      cout << -1 << endl;
      return 0;
    }
    x[s[i]]=1,xx[s[i]]=c[i];
    if(n!=1&&s[i]==1&&c[i]=='0') {
      cout << -1 << endl;
      return 0;
    }
  }
  for(int i=0; i<m; i++) {
    ans[s[i]-1]=c[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int A = sc.nextInt();
		sc.close();
		int cnt = 0;
		while(H > 0){
			H -= A;
			cnt++;
		}
		System.out.println(cnt);

	}

}

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

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  int total = 100 * A, sugar = 0;
  for (int a = 0; a <= F; a += A * 100) {
    for (int b = 0; a + b <= F; b += B * 100) {
      int w = a + b;
      if (w > 0) {
        for (int c = 0; w + c <= F && c * 100 <= w * E; c += C) {
          int d = min(F - w - c, ((w * E - c * 100) / 100) / D * D);
          int s = c + d;
          int t = w + s;
          if (s * total > sugar * t) {
            total = t;
            sugar = s;
          }
        }
      }
    }
  }
  cout << total << " " << sugar << endl;
  return 0;
}


Measured memory_bytes: 256
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break

    comb = set()
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            for k in range(j+1, n+1):
                if i == j or j == k or i == k:
                    continue
                elif i + j + k == x:
                    sort_9 = sorted((i, j, k))
                    comb.add(tuple(sort_9))

    print(len(comb))



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

int comp( const void *c1, const void *c2 );

int main(void){
	int n;
	scanf("%d",&n);
	int a[n];
	int b[n];
	int i;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		b[i] = a[i];
	}
	qsort( a, n, sizeof(int), comp );//a[]はソート済み
	//b[i]を比較する。
	for(i=0;i<n;i++){
		if(b[i] >= a[n/2]){
			printf("%d\n",a[(n/2)-1]);
		}else{
			printf("%d\n",a[n/2]);
		}
	}
	return 0;
}


/* 比較関数 */
int comp( const void *c1, const void *c2 )
{
  int tmp1 = *(int *)c1;
  int tmp2 = *(int *)c2;

  if( tmp1 < tmp2 )  return -1;
  if( tmp1 == tmp2 ) return  0;
  if( tmp1 > tmp2 )  return  1;
}

Measured memory_bytes: 3692
import math

def get_pwr(i, k):
  if i < k:
    return math.ceil(math.log2(k/i))
  else:
    return 0

n, k = map(int, input().split(' '))
print(sum(1/(n*(2**get_pwr(i, k))) for i in range(1, n+1)))


Measured memory_bytes: 2940
#include <cstdio>
#include <set>

using namespace std;

int main() {
    int n, m;

    scanf("%d%d", &n, &m);

    multiset<int> prices;

    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        prices.insert(x);
    }

    for (int i = 0; i < m; ++i) {
        auto it = prices.end();
        it--;

        int x = *it / 2;

        prices.erase(it);
        prices.insert(x);
    }

    long long sum = 0;

    for (const auto &item : prices) {
        sum += (long long) item;
    }

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

    return 0;
}

Measured memory_bytes: 4864
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    char a;
    cin >> a;
    if (a=='a' || a=='i' || a=='u' || a=='e' || a=='o') cout << "vowel" << endl;
    else cout << "consonant" << endl;
    
    //cout << ans << endl;
}

Measured memory_bytes: 256
from math import gcd


def main():
    k = int(input())
    ans = 0

    for a in range(1, k + 1):
        for b in range(1, k + 1):
            for c in range(1, k + 1):
                ans += gcd(gcd(a, b), c)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 69212
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
using namespace std;
const int MaxN = 1e3;

int a[MaxN + 5];

int main()
{
	int a,b,c,x,y,n,sum,ans;
	while(~scanf("%d %d %d %d %d",&a,&b,&c,&x,&y))
	{
		ans = 0;
		sum = x;
		n = y;
		if(a + b > 2*c)
		{
			ans += min(sum,n)*2*c;
			x -= min(sum,n);
			y -= min(n,sum);
		}
		if(a > 2*c)
		{
			ans += x*2*c;
			x = 0;
			y -= x;
		}
		if(y < 0) y = 0;
		if(b > 2*c)
		{
			ans += y*2*c;
			y = 0;
			x -= y;
		}
		if(x < 0) x = 0;
		ans += a * x;
		ans += b * y;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long[] p) {
    return p.sum - (p.reduce!max / 2);
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long[] p = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        p[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, p);
    else
        solve(N, p).writeln;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 

int  A(int x){
    if(x>=0)return x;
    else return -x;
}

ll inv(ll x) {
	ll res = 1;
	ll k = N - 2;
	ll y = x%N;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = (y%N)*(y%N) % N;
		k /= 2;
	}
	return res;
}

unsigned long long popCount64bitB(unsigned long long x) 
{ 
    x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) 
      +  (x & 0x5555555555555555UL); 
    x = ((x & 0xccccccccccccccccUL) >> 2) 
      +  (x & 0x3333333333333333UL); 
    x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) 
      +  (x & 0x0f0f0f0f0f0f0f0fUL); 
    x = ((x & 0xff00ff00ff00ff00UL) >> 8) 
      +  (x & 0x00ff00ff00ff00ffUL); 
    x = ((x & 0xffff0000ffff0000UL) >> 16) 
      +  (x & 0x0000ffff0000ffffUL); 
    x = ((x & 0xffffffff00000000UL) >> 32) 
      +  (x & 0x00000000ffffffffUL); 
    return x; 
} 



int main(void){
    string s;
    cin>>s;
    if(s[2]==s[3]){
        if(s[4]==s[5])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 384
using System;

//３つの整数a, b, cを読み込み、
//それらが a < b < cの条件を満たすならば"Yes"を、満たさないならば"No"を出力するプログラムを作成して下さい。 

class Program
{
    static void Main()
    {
        var x = Console.ReadLine().Split(' ');
        int a = int.Parse(x[0]);
        int b = int.Parse(x[1]);
        int c = int.Parse(x[2]);
        Console.WriteLine("{0}", (a < b)&& (b<c) ? "Yes" : "No");
    }
}


Measured memory_bytes: 7860
# author:  Taichicchi
# created: 27.09.2020 18:22:26

import sys

ls = list(map(int, input().split()))
ls.sort()
cnt = 0

for i in [0, 1]:
    c = (ls[2] - ls[i]) // 2
    cnt += c
    ls[i] += 2 * c


if (ls[0] == ls[1]) & ((ls[2] - 1) == ls[1]):
    cnt += 1
elif (ls[0] == (ls[2] - 1)) | (ls[1] == (ls[2] - 1)):
    cnt += 2

print(cnt)


Measured memory_bytes: 9180
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll    long long
#define PR    pair<ll, ll>

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    ll n;
    cin >> n;
    ll balance = 100;
    for (ll i = 1; i <= 1000000; i++) {
        double tmp = 1.0 / 100.0;
        double fmp = balance;
        double zmp = tmp * fmp;
        balance += (ll)zmp;
        if (balance >= n) {
            cout << i << '\n';
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include<utility>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<cfloat>
#include<functional>
#include<string>
#include<numeric>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<cctype>
#include<iterator>
#include <stdio.h>
#include <string.h>
#include <sstream>
// #include <bits/stdc++.h>
//#include<conio.h>
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define MEGA_MIND ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define M_PI 3.14159265358979323846
#define mod 1000000007
#define endl "\n"
using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;


const int N = 5e5 + 5, inf = 2e9;

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


	dp[1][1] = a[1];
	dp[1][2] = b[1];
	dp[1][3] = c[1];
	

	for (int i = 2; i <= n ; i++)
	{
		dp[i][1] += max(dp[i - 1][2], dp[i - 1][3]) + a[i];
		dp[i][2] += max(dp[i - 1][1], dp[i - 1][3]) + b[i];
		dp[i][3] += max(dp[i - 1][1], dp[i - 1][2]) + c[i];
	}

	cout << max(dp[n][1], max(dp[n][2], dp[n][3])) << endl;
	return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<int>(1000,10000)(rng)

ll binpow(ll a, ll b)
{
    if (b == 0)
        return 1;
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
        return res * a;
    return res;
}

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

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    for (int x=1800;1;x-=200)
    {
        if (n>=x)
        {
            cout<<(2000-x)/200;
            return 0;
        }
    }
    return 0;
}

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

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

	int K;
	int mod;
	int ans=1;
	set<int> s;

	cin >> K;
	mod=7%K;
	while(s.count(mod)==0){
		if(mod==0){
			cout << ans << endl;
			return 0;
		}

		s.insert(mod);
		mod=(mod*10+7)%K;
		ans++;
	}

	cout << -1 << endl;

	return 0;
}



Measured memory_bytes: 50384
A, B = map(int, input().split())
def calc(A, B):
  Amin = A/0.08
  if (Amin - int(Amin)) != 0.:
    Amin = int(Amin)+1
  else:
    Amin = int(Amin)
  Amax = int((A+1)/0.08)
  Arange = set(range(Amin, Amax))
  Bmin = B/0.1
  if (Bmin - int(Bmin)) != 0.:
    Bmin = int(Bmin)+1
  else:
    Bmin = int(Bmin)
  Bmax = int((B+1)/0.1)
  Brange = set(range(Bmin, Bmax))
  intersection = Arange & Brange
  print(-1) if len(intersection) == 0 else print(min(intersection))
calc(A, B)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
using namespace std;
const int INF=(int)1e9+10;
const int MOD=(int)1e9+7;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b;
    cin>>a>>b;
    set<int> s;
    s.insert(1);
    s.insert(2);
    s.insert(3);
    s.erase(a);
    s.erase(b);
    cout<<*s.begin();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

signed main() {
  int n;
  cin >> n;
  int a[n];
  rep(i,n) cin >> a[i];
  sort(a, a+n);
  
  int s = a[n-1], p = (n-2)/2, q = n%2;
  rep(i,p) s += 2 * a[n-2-i];
  if(q == 1) s += a[n-2-p];
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 4704
n = int(input())
l = list()
for i in range(n): l.append(str(sorted(input())))
d = {}
for i in l:
    d.setdefault(i, 0)
    d[i] += 1
cnt = 0
for i in d.values():
    cnt += i * (i - 1) // 2
print(cnt)

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n >>k;
	VL a(n+1);
	rep(i, n) cin >>a[i];
	if(k > n) {
		rep(i, n) cout << n <<" "; cout <<"\n";
		return 0;
	}
	VL sk(n+1);
	rep(q, k) {
		fill(all(sk), 0);
		rep(i, n){
			int st = max<ll>(0, i-a[i]);
			int ed = min<ll>(n, i+a[i]+1);
			sk[st] +=1;
			sk[ed] -=1;
		}
		rep(i, n) sk[i+1] += sk[i];
		//rep(i, n) cout << sk[i] << " "; dbg("q=",q);
		a = sk;
		if(count(sk.begin(), sk.begin()+k, n)==n) break;
		if(q*n >20000000) break;
	}
	rep(i, n) cout << sk[i] <<" ";
	cout <<"\n";
	return 0;
}


Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
int main(){
  int M;
  cin >> M;
  vector<long long> d(M);
  vector<long long> c(M);
  for(int i = 0; i < M; i++){
    cin >> d.at(i) >> c.at(i);
  }
  long long sum1 = 0, sum2 = 0;
  for(int i = 0; i < M; i++){
    sum1 += d.at(i)*c.at(i);
    sum2 += c.at(i);
  }
  if(sum1 % 9 == 0) sum1 = sum1 / 9 - 1;
  else sum1 = sum1 / 9;
  cout << sum1 + sum2 - 1 << endl; 
}

Measured memory_bytes: 3328
package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	fmt.Scan(&n)
	fmt.Scan(&s)
	var ans int
	var x string
	var y string
	var z string

	for _, r := range s {
		x = y
		y = z
		z = string(r)
		if x+y+z == "ABC" {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	a, b, k := nextInt(), nextInt(), nextInt()

	if a < k {
		k -= a
		a = 0
	} else {
		a -= k
		fmt.Println(a, b)
		return
	}

	if b < k {
		fmt.Println(0, 0)
	} else {
		b -= k
		fmt.Println(a, b)
	}
}

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

int main() {
  long long n;
  cin>>n;
  long long a,b,c;
  a=1;
  b=1;
  c=1;
  for(long long i=0;i<n;i++){
    a=(a*10)%1000000007;
  }
  for(long long i=0;i<n;i++){
    b=(b*9)%1000000007;
  }
  for(long long i=0;i<n;i++){
    c=(c*8)%1000000007;
  }
  long long d;
  d=0;
  d=(a+c-(2*b)%1000000007)%1000000007;
  if(d<0){
    d=1000000007+d;
  }
  cout<<d;
}

Measured memory_bytes: 3616
s = gets.chomp.chars
t = gets.chomp.chars
cnt_s = ('a'..'z').map { |c| s.count(c) }.sort
cnt_t = ('a'..'z').map { |c| t.count(c) }.sort

if cnt_s == cnt_t
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 22780