akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;
//26

struct st{int x, y, z;};
st a[10000];
signed main(){
	int n, m;
	scanf("%lld%lld", &n, &m);
	rep(i,n){
		int x, y, z;
		scanf("%lld%lld%lld", &x, &y, &z);
		a[i] = (st){x, y, z};
	}
	
	int ans = -INF;
	rep(i,8){
		vector<int> vec;
		rep(j,n){
			int cnt = 0;
			if(i & (1<<0))cnt += a[j].x;
			else cnt -= a[j].x;
			if(i & (1<<1))cnt += a[j].y;
			else cnt -= a[j].y;
			if(i & (1<<2))cnt += a[j].z;
			else cnt -= a[j].z;
			vec.pb(cnt);
		}
		sort(all(vec), greater<int>());
		int res = 0;
		rep(j,m)res += vec[j];
		chmax(ans, res);
	}
	printf("%lld\n", ans);
	return 0;
}





Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
//const long long mod = 998244353;

void S(int n, int b, std::vector<int> *w, long long*c) {
	for (int i = 0; i < w[n].size(); i++) {
		if (w[n][i] != b) {
			c[w[n][i]] += c[n];
			S(w[n][i], n, w, c);
		}
	}
}

int main() {
	int N, Q;
	scanf("%d %d", &N, &Q);
	std::vector<int> *w = new std::vector<int>[N];
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--;
		b--;
		w[a].push_back(b);
		w[b].push_back(a);
	}
	long long *c = new long long[N];
	for (int i = 0; i < N; i++)c[i] = 0;
	for (int i = 0; i < Q; i++) {
		int p, x;
		scanf("%d %d", &p, &x);
		c[p - 1] += x;
	}
	S(0, -1, w, c);
	for (int i = 0; i < N; i++) {
		printf("%lld ", c[i]);
	}
	return 0;
}

Measured memory_bytes: 30464
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;


class UnionFind {
    int n;
public:
    vector<int> uni;
    explicit UnionFind(int n) : uni(static_cast<u32>(n), -1) , n(n){};

    int root(int a){
        if (uni[a] < 0) return a;
        else return (uni[a] = root(uni[a]));
    }

    bool unite(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] += uni[b];
        uni[b] = a;
        return true;
    }
};

int main() {
    ll n, m;
    cin >> n >> m;
    vector<pair<int, int>> v(m);
    for (int i = 0; i < m; ++i) {
        scanf("%d %d", &v[i].first, &v[i].second);
    }
    vector<ll> ans(m);
    reverse(v.begin(), v.end());
    ans[0] = n*(n-1)/2;
    UnionFind uf(n);
    for (int i = 0; i < m - 1; ++i) {
        ll k = ans[i];
        int a, b; tie(a, b) = v[i];
        a--; b--;
        if(uf.root(a) != uf.root(b)){
            k -= uf.uni[uf.root(a)]*uf.uni[uf.root(b)];
            uf.unite(a, b);
        }
        ans[i+1] = k;
    }
    for (int i = 0; i < m; ++i) {
        cout << ans[m-i-1] << "\n";
    }
    return 0;
}


Measured memory_bytes: 3328
#include <cctype>
#include <cstdio>

int main() {
  char ch;
  int alpha[26] = {};

  while (scanf("%c", &ch) != EOF) {
    ch = tolower(ch);
    alpha[ch - 'a']++;
  }

  for (int i = 0; i < 26; i++) {
    printf("%c : %d\n", 'a' + i, alpha[i]);
  }

  return 0;
}


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

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

  int ans=0;
  for(int i=1; i<n; i++){
    vector<char> a,b,c;
    for(int j=0; j<i; j++)a.push_back(s[j]);
    for(int j=i; j<n; j++)b.push_back(s[j]);
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    set_intersection(a.begin(),a.end(),b.begin(),b.end(),back_inserter(c));
    set<char> d;
    for(int j=0; j<c.size(); j++)d.insert(c.at(j));
    int f=d.size();
    ans=max(ans,f);
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);


int main(){
  string s;
  cin >> s;
  ll sum1=0,sum2=0;
  rep(i,s.size()){
    if(s[i]=='0')sum1++;
    else sum2++;
  }
  cout << min(sum1,sum2)*2 << endl;
    
}


Measured memory_bytes: 512
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
import std.bitmanip;

struct BitMatrix
{
    int H, W;
    BitArray[] val;

    this(int n, int m) {
        H = n;
        W = m;
        val.length = H;
        foreach (ref row; val) {
            row = BitArray(new bool[W]);
        }
    }

    ref BitArray opIndex(size_t i) {
        return val[i];
    }
}

int gauss_jordan(ref BitMatrix A, bool is_extended = false)
{
    int rank = 0;

    foreach (col; 0..A.W) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        foreach (row; rank..A.H) {
            if (A[row][col]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;

        swap(A[pivot], A[rank]);

        foreach (row; 0..A.H) {
            if (row != rank && A[row][col]) A[row] ^= A[rank];
        }
        ++rank;
    }

    return rank;
}

bool linear_equation(BitMatrix A, bool[] b)
{
    auto n = A.H, m = A.W;
    auto M = BitMatrix(n, m + 1);

    foreach (i; 0..n) {
        foreach (j; 0..m) M[i][j] = A[i][j];
        M[i][m] = b[i];
    }

    auto rank = gauss_jordan(M, true);

    foreach (row; rank..n) if (M[row][m]) return false;
    return true;
}

void solve()
{
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(ulong[]);
    auto S = readln.chomp;

    auto A = BitMatrix(61, N);
    int j;
    foreach_reverse (i, c; S) {
        if (c == '0') {
            foreach (k; 0..61) A[k][j] = !!(AS[i] & (1L<<k));
            ++j;
        } else {
            bool[] b;
            foreach (k; 0..61) b ~= !!(AS[i] & (1L<<k));
            if (!linear_equation(A, b)) {
                writeln(1);
                return;
            }
        }
    }
    writeln(0);
}

void main()
{
    auto T = readln.chomp.to!int;
    foreach (_; 0..T) solve();
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

vector<pair<ll,int>> factorize(ll n) {
    vector<pair<ll,int>> ans;
    for (ll i = 2; i*i <= n; ++i) {
        if (n%i) continue;
        ans.emplace_back(i,0);
        while (n%i == 0) {
            n /= i;
            ans.back().second++;
        }
    }
    if (n != 1) ans.emplace_back(n,1);
    return ans;
}

int calc(int a) {
    int res = 0;
    while (a > 0) {
        a -= res;
        if (a <= res) return res;
        res++;
    }
    return res;
}

int main() {
    ll n;
    cin >> n;

    int ans = 0;
    auto f = factorize(n);
    for (auto x : f) ans += calc(x.se);

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

Measured memory_bytes: 3620
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void){

  string s;
  int flag=1;
  cin>>s;
  int i=1;
  while(s.length()>2){
    if(s[i-1]==s[i+1]){
      i++;
      if(i==s.length()-1) break;
    }
    else{
      s.erase(i,1);
      flag^=1;
      i=1;
    }
  }

  if(flag==0) cout<<"First\n";
  else cout<<"Second\n";
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<map>
using namespace std;

int main(void){
  string s;
  int res = 0, n = 0;
  while(getline(cin,s)){
    for(int i = 0 ; i < s.size() ; i ++){
      if('0' <= s[i] && s[i] <= '9'){
	n = n * 10 + s[i] - '0';
      }else{
	res += n;
	n = 0;
      }
    }
  }
  cout<<res<<endl;
}

Measured memory_bytes: 1176
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int[] a = new int[] { 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 };

        // 主処理
        int result = a[k - 1];

        // 出力
        System.out.println(result);
        sc.close();
    }
}


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

int main() {
	int x,y;
  	cin >> x >> y;
	int ans = 2e9;
	for (int i = 0;i < 2;i++) {
		for (int j = 0;j < 2;j++) {
			int now = 0;
			int nx=x,ny=y;
			if (i) {nx=-x;now++;}
			if (j) {ny=-y;now++;}
			if (ny-nx >= 0) {
				now += ny-nx;
				ans = min(ans,now);
			}
		}
	}
	cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<double> vec(N);
  for (int i=0; i < N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  double V = (vec.at(0) + vec.at(1))/2;
  for (int i=2; i < N; i++){
    V = (V + vec.at(i))/2;
  }
  cout << V << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] T = new int[N];
        int sum = 0;
        for (int i = 0; i < N; i++) {
            T[i] = scan.nextInt();
            sum += T[i];
        }
        int M = scan.nextInt();
        for (int i = 0; i < M; i++) {
            int p = scan.nextInt();
            int x = scan.nextInt();
            System.out.println(sum - (T[p-1] - x));
        }
    }
}


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

const ll MOD = 1000000007;
const ll MAX = 1000000;
const ll INF = 1001001001;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long nCk(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    COMinit();
    int n, k; cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = 0;
    for(int i = k - 1; i < n; i++){
        ans += nCk(i, k-1) * a[i];
        ans %= MOD;
    }
    for(int i = 0; i < n - k + 1; i++){
        ans += MOD - nCk(n - i - 1, k - 1) * a[i] % MOD;
        ans %= MOD;
    }
    //cout << tmp << endl;
    cout << (MOD + ans) % MOD << endl;
}


Measured memory_bytes: 27508
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

ll A,B,C,D;
int P,Q,R,N,ans=1e9;
ll c=0,a=0,bc=0;
vector<char> S;
vector<int> vec(100);
vector<ll> lvec;
string s;

int main(){
  cin>>N;
  int mae=0,ato=0;

  for(int i=0;i<N;i++)
  	cin>>vec.at(i);

  vec.resize(N);

  for(int i=0;i<N-1;i++){
  	mae+=vec.at(i);
  	for(int j=i+1;j<N;j++){
  		ato+=vec.at(j);
  	}
  	//cout<<mae<<" "<<ato<<endl;
  	ans=min(ans,abs(ato-mae));
  	ato=0;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d", $n, $k);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));

// 訪れた頂点のメモ
$s = [];

// 訪れた順番的なもの
$ord = array_fill(0, $n + 1, -1);
// NOTE: vが1startなので、n+1

$v = 1;

// ord[v]が-1でない <==> 訪れたことがある
while ($ord[$v] == -1) {

    // sのサイズを見れば訪れた順番もわかる
    $ord[$v] = count($s);

    $s[] = $v;

    // 次に行くところA[$v]
    $v = $A[$v - 1];
}


// ループを抜けた後のcount($s)が、重複
// 周期
$c = count($s) - $ord[$v];

// 例外の数
$ext = $ord[$v];

/* print_r($s); */
/* print_r($ord); */
/* echo "v: $v, c: $c, ext: $ext", PHP_EOL; */

if ($k < $ext) {
    echo $s[$k];
} else {
    $k -= $ext;
    $k %= $c;
    echo $s[$ext + $k];
}


Measured memory_bytes: 44256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  map<int,int> setplan;
  rep(i,N){
    int x;cin >> x; 
    ++setplan[x];
  }
  int M;cin >> M;
  map<int,int> setprob;
  rep(i,M){
    int x;cin >> x;
    ++setprob[x];
  }
  bool sat = true;
  for(const PII& p : setprob){
    if(setplan[p.first] < p.second)sat = false;
  }
  YESNO(sat);
  return 0;
}


Measured memory_bytes: 19072
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
//#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
//#include <array>
#include <valarray>
#include <stdio.h>
//#include <random>
//#include <windows.h>
//#pragma comment(lib, "winmm.lib")
#include <algorithm>

using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

long long  int nCm(long long int n, long long int m) {
	if (m == 1) {
		return n;
	}
	else {
		return n*nCm(n - 1, m - 1) / m;
	}
}

long long int npm(long long int n, long long int m) {
	if (m == 1) {
		return n;
	}
	else
		if (m == 0) {
			return 1;
		}
		else {
			return n*npm(n, m - 1);
		}
}



llint ketasu(llint a) {//桁数
	llint k = 1;
	while (true) {

		if ((a - a % 10) / 10 == 0) { break; }
		++k;
		a = (a - a % 10) / 10;
	}
	return k;
}


llint keta(llint a) {//最上位
	llint b = a;
	while (true) {

		if ((a - a % 10) / 10 == 0) { break; }
		a = (a - a % 10) / 10;
		b = a;
	}
	return b;
}

llint keta2(llint a, llint c) {//桁数目の桁
	llint b = a;
	for (llint i = 1; i<c; ++i) {

		if ((a - a % 10) / 10 == 0) { break; }
		a = (a - a % 10) / 10;
		b = a;
	}
	return b % 10;
}

llint pow10n(llint a) {//10^n
	llint s = 1;
	for (llint i = 0; i < a; ++i) {
		s *= 10;
	}
	return s;
}

llint ue(llint a, vector<bool> f) {//10返る　＝ない
	while (a <= 9) {
		if (f[a]) {
			break;
		}
		++a;
	}
	return a;
}

llint sita(llint a, vector<bool> f) {//-1返る　＝ない
	while (a >= 0) {
		if (f[a]) {
			break;
		}
		--a;
	}
	return a;
}

llint tuyoi(vector<bool> f) {//-1返る　＝ない
	llint a = 9;
	while (true) {
		if (f[a]) {
			break;
		}
		--a;
	}
	return a;
}


llint yowai(vector<bool> f) {//-1返る　＝ない
	llint a = 0;
	while (true) {
		if (f[a]) {
			break;
		}
		++a;
	}
	return a;
}

int main()
{
	int N, A, B;
	string S;
	cin >> N >> A >> B >> S;
	int sumab = 0;
	int sumb = 0;
	for (int i = 0; i < N; ++i) {
		if (S[i] == 'a') {
			if (sumab < A + B) {
				sumab++;
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
		else
			if(S[i] == 'b') {

				if (sumab < A + B&&sumb <  B) {
					sumab++;
					sumb++;
					cout << "Yes" << endl;
				}
				else {
					cout << "No" << endl;
				}
		}
			else {
				cout << "No" << endl;
		}
	}

}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
	int n;
	cin >> n;
	vector<ll> aOdd;
	vector<ll> aEven;
	vector<ll> ans;
	for (int i = 1; i <= n; i++) {
		ll num;
		cin >> num;
		if (i % 2 != 0) {
			aOdd.push_back(num);
		}
		else {
			aEven.push_back(num);
		}
	}

	if (n % 2 != 0) {
		for (int i = aOdd.size()-1; i >= 0; i--) {
			ans.push_back(aOdd[i]);
			cout << aOdd[i];
			cout << " ";
		}
		for (int j = 0; j < aEven.size(); j++) {
			ans.push_back(aEven[j]);
			cout << aEven[j];
			cout << " ";
		}	 
	}
	else {
		for (int i = aEven.size() - 1; i >= 0; i--) {
			ans.push_back(aEven[i]);
			cout << aEven[i];
			cout << " ";
		}
		for (int j = 0; j < aOdd.size(); j++) {
			ans.push_back(aOdd[j]);
			cout << aOdd[j];
			cout << " ";
		}
	}
	return 0;
}


Measured memory_bytes: 5480
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<int, int>  pii;
typedef pair<ld, ld>  pld;
ll const mod = 1e9+7;
ll cnt[100][2];
ll pw[100];
ll n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    
    cin >> n;
    pw[0] = 1;
    for(ll i = 1; i <= 75; ++i)
        pw[i] = pw[i-1]*2%mod;
    ll ans = 0;
    while(n--){
        ll x;
        cin >> x;
        for(ll i = 0; i < 70; ++i){
            ll bit = x%2;
            ans += cnt[i][bit^1]*pw[i]%mod;
            ans %= mod;
            cnt[i][bit]++;

            x /= 2;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
  int a, b, H, i;
  string s;
  cin >> a >> b >> s;

  if (count(s.begin(), s.end(), '-')!=1 || s.size()!=a+b+1) {
    printf("No\n");
    return 0;
  }

  for (i=0; i<s.size(); i++) {
    if (s[i]=='-') H=i;
  }
  
  if (H==a) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+100;
bool dp[N]={true,}; int n;
int main(){
    scanf("%d",&n); int m;
    for(int i=1;i<=n;++i){
        scanf("%d",&m);
        dp[m]|=dp[m-1];
    }
    m=n;
    while(m>=0&&!dp[m]) m--;
    if(m==0) printf("-1\n");
    else printf("%d\n",n-m);
}

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

int main()
{
	string s, t;
	cin >> s >> t;

	if ((t.length()==s.length()+1)&&(strncmp(s.c_str(),t.c_str(),s.length())==0)&&(t[s.length()]>='a')&&(t[s.length()]<='z'))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}







Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a;i < b;i++)
#define F first
#define S second
#define pb push_back
#define mk make_pair
#define debug(a) cerr << #a << " = " << a << endl;
#define debug2(a,b) cout << #a << " = " << a << " --- " << #b << " = " << b << endl;
#define debugP(a) cout << a.F << " " << a.S << endl;
#define debugV(v, n) { rep( i, 0, n ) { if(i) printf(" "); printf("%d", v[i]); } printf("\n"); }
#define debugM(mat,n,m) rep( i, 0, n ){ rep( j, 0, m ) { if(j) printf(" "); printf("%d", mat[i][j]); } printf("\n"); }
#define all(c) (c).begin(),(c).end()
typedef long long int ll;
typedef pair<ll,ll> ii;
const int INF = 0x3f3f3f3f;


int main(){
	int x;
  	cin >> x;
  	if(x) puts("0");
  	else puts("1");
 	return 0;
}

Measured memory_bytes: 3584
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
#include <algorithm>
#include <pthread.h>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <thread>
#include <math.h>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for(int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    ios::sync_with_stdio(NULL);
    cin.tie(NULL); cout.tie(NULL);
    long double L;  cin >> L;
    double Ans = (L/3)*(L/3)*(L/3);
    printf("%.12F",Ans);
    return 0;
}

Measured memory_bytes: 256
s = input()

for i in range(len(s)):
    if i%2 == 0:
        if s[i] == "R" or s[i] == "U" or s[i] == "D":
            ans = "Yes"
        else:
            ans = "No"
            break
    elif i%2 == 1:
        if s[i] == "L" or s[i] == "U" or s[i] == "D":
            ans = "Yes"
        else:
            ans = "No"
            break

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926

typedef long long int ll;

//ll chk[55];
ll num[55];
//ll num2[55];
//ll num[ten5];
//ll num2[ten5];
//char cmap[10][10];
//priority_queue<long long int> pq;   //big at front
//stack<int> stk;
//vector<pair<ll,ll>> vint;
//vector<ll> vtime;
//deque<ll> deq[55];
//list<int> li;
//set<int> sint;
//set<ll> sll;
//map<ll,ll> mp;


int main()
{
    //double ans=0.0,half;
    //float f,g,h;
    long long int sum,sum2,n1,n2,n3;
    long long int m,n,o,i,j,k=1;
    long long int a,a1,a2,a3,a4,a5,a6;
    sum=sum2=n1=n2=n3=0;
    a=a1=a2=a3=a4=a5=a6=0;
    //string s,s1;
    //char now,pre,c;
    cin>>n;
    for(i=0;i<n;i++) cin>>num[i];
    for(i=1;i<n-1;i++)
    {
        a=a1=num[i];
        for(j=-1;j<=1;j++)
        {
            a=max(a,num[i+j]);
            a1=min(a1,num[i+j]);
        }
        if(num[i]!=a&&num[i]!=a1)
        {
            sum++;
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,h[251];
  cin>>n;
  for(int i=1;i<=n;i++)cin>>h[i];
  for(int i=1;i<=n;i++){
    cout<<"node "<<i<<": key = "<<h[i]<<", ";
    if(i!=1)cout<<"parent key = "<<h[i/2]<<", ";
    if(2*i<=n)cout<<"left key = "<<h[i*2]<<", ";
    if(2*i+1<=n)cout<<"right key = "<<h[i*2+1]<<", ";
    cout<<endl;
  }
  return 0;
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

int N, M;
auto l = [](int lhs, int rhs) { return lhs < rhs; };
priority_queue<int, vector<int>, decltype(l)> pq(l);

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

    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        pq.push(a);
    }

    i64 sum = 0;
    for (int i = 0; i < M; i++)
    {
        int amax = pq.top();
        pq.pop();
        pq.push(amax / 2);
    }

    for (int i = 0; i < N; i++)
    {
        sum += pq.top();
        pq.pop();
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

vll a;
vvll g;
vll ans;

void dfs(ll cur, ll par, vll& v) {
    ll at = -1;
    ll it = lower_bound(v.begin(), v.end(), a[cur]) - v.begin();
    if(it == v.size()) {
        v.push_back(a[cur]);
    }
    else {
        at = v[it];
        v[it] = a[cur];
    }
    ans[cur] = v.size();
    for(auto i : g[cur]) {
        if(i == par) continue;
        dfs(i, cur, v);
    }
    if(at == -1) {
        v.pop_back();
    }
    else {
        v[it] = at;
    }
}

void solve() {
    ll n;
    cin >> n;
    a = vll(n);
    for(ll i = 0; i < n; i++) cin >> a[i];
    g = vvll(n);
    for(ll i = 0; i < n-1; i++) {
        ll u, v;
        cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    ans = vll(n);
    vll tv;
    dfs(0, -1, tv);
    for(auto i : ans) cout << i << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int dp[2222][2222][2][2];
string S;
int K;

int calc(int x,int y){
    fill_n(***dp,2222*2222*2*2,INT_MIN);
    dp[0][0][0][0]=0;
    for(int i=0;i<S.size();i++){
        for(int j=0;j<=K;j++){
            for(int k=0;k<2;k++){
                for(int l=0;l<2;l++){
                    chmax(dp[i][j+1][k^1][l],dp[i][j][k][l]);
                    chmax(dp[i][j+1][k][l^1],dp[i][j][k][l]);

                    int a=x,b=y;
                    if(k)a*=-1;
                    if(l)b*=-1;

                    if(S[i]=='U')chmax(dp[i+1][j][k][l],dp[i][j][k][l]+a);
                    if(S[i]=='D')chmax(dp[i+1][j][k][l],dp[i][j][k][l]-a);
                    if(S[i]=='R')chmax(dp[i+1][j][k][l],dp[i][j][k][l]+b);
                    if(S[i]=='L')chmax(dp[i+1][j][k][l],dp[i][j][k][l]-b);
                }
            }
        }
    }

    int res=0;

    rep(i,K+1)rep(j,2)rep(k,2)chmax(res,dp[S.size()][i][j][k]);
    return res;
}

signed main(){

    cin>>S>>K;

    int ans=0;
    for(int i=-1;i<=1;i+=2){
        for(int j=-1;j<=1;j+=2){
            chmax(ans,calc(i,j));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 157496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

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

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

int main(){
  ll n,ans;
  ans=0;
  cin>>n;
  vector<ll> L(n);
  rep(i,0,n) cin>>L.at(i);
sort(L.begin(), L.end());
reverse(L.begin(), L.end());
  rep(i,0,n-2){
    rep(j,i+1,n-1){
      if(L.at(i)>=L.at(j)+L.at(j+1)) break;
      if(L.at(j)>=L.at(i)+L.at(j+1)) break;
      rep(k,j+1,n){
        if(L.at(i)>=L.at(j)+L.at(k)) break;
        if(L.at(j)>=L.at(i)+L.at(k)) break;
        ans+=1;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
/*
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
 |                                                                 |
 |   author : thanos1399     Language : C ++                         | 
 |   college : MSIT                                                | 
 | _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |  
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
using namespace std ;
#define TEST            int t ; cin>>t; while(t--)
#define line            cout<<endl;
#define loop(i,a,b)     for(long long int i=a;i<b;i++)
#define loopIn(i,a,b)   for(long long int i=a;i<=b;i++)
#define MAX_SIZE        1000000
#define ff              first
#define ss              second
#define pb              push_back
#define ll              long long int  
#define mp              make_pair
#define vt              vector<tup>
#define vtt             vector<vt >
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];


void Sieve( int *prime , int n){
	for(int i=0;i<n;i++){
		prime[i] = 0;
	}
	for(int i=2;i<n;i++){
		prime[i] = 1 ;
	}
	for(int i=4;i<n;i+=2){
		prime[i] = 0;
	}
	for(int i=3;i<n;i++){
		if(prime[i]==1){
		for(int j=i*i;j<n;j+=i){
			prime[j] = 0;
		}
	}
  }
  return ;
}


bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 

int main(){
	//input();
	string s ;
	cin>>s;
	bool flag = false ;
	for(int i=0;i<s.length();i++){
		if(s[i]=='7'){
			flag = true ;
			break;

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

	
}


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
// template starts
typedef long long int ll;
ll fact(ll n, ll p){
	ll ans = 1;
	for(ll i = 1; i <= n; i++){
		ans *= i;
		ans %= p;
	}
	return ans;
}
ll power(ll x, ll n, ll p){
	ll res = 1;
	if(n == 1) return x%p;
	if(n%2 == 1) res = x%p;

	ll temp = power(x,n/2,p);
	return res*((temp*temp)%p)%p;
}
ll inv(ll a, ll p){
	return power(a,p-2,p);
}
ll nCr(ll n, ll r, ll p){
	if(r > n) return 0;
	ll t1 = fact(n,p);
	ll t2 = inv(fact(r,p),p);
	ll t3 = inv(fact(n-r,p),p);

	return (((t1*t2)%p)*t3)%p;
}
vector<vector<ll> > multiply(vector<vector<ll> > &a, vector<vector<ll> > &b, ll p){
	int r1,c1,r2,c2;
	r1 = a.size(); c1 = a[0].size();
	r2 = b.size(); c2 = b[0].size();

	vector<vector<ll> > result(r1,vector<ll>(c2,0));

	if(c1 != r2) return result;

	for(int i = 0; i < r1; i++){
		for(int j = 0; j < c2; j++){
			for(int k = 0; k < c1; k++){
				result[i][j] += a[i][k]*b[k][j];
				result[i][j] %= p;
			}
		}
	}
	return result;
}

vector<vector<ll> > power(vector<vector<ll> >&a,ll n, ll p){
	int r = a.size();
	vector<vector<ll> > result(r,vector<ll>(r,0));
	for(int i = 0; i < r; i++) result[i][i] = 1;

	while(n > 0){
		if(n%2 == 1){
			result = multiply(result,a,p);
		}
		n /= 2;
		a = multiply(a,a,p);
	}
	return result;
}
// template ends here

void solve(){
	// code starts from here
	ll A, B ,C;
	cin >> A >> B >> C;
	cout << C  << " "<< A  << " " << B<< endl;
}

int main(){
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	int T;
	//cin >> T;
	 T = 1;
	while(T--){
		solve();
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define m_p			make_pair
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define sz(x)       (int)x.size()
#define f			first
#define debug		cout<<"##########3"<<endl
#define mod			1000000007
#define ll			long long int
#define lMax		LLONG_MAX
// queue<int> , prefix_sum(a,a+n) , reverse(a,a+n) , priority_queue <int> max heap , priority_queue <int, vector<int>, greater<int> > min heap;
// == precedence gretaer then &
ll n,m;
string s,s1,s2;
priority_queue <long long int> pq;
map<ll, char> mp;
vector<pair<int,int> > inc;
vector<pair<int,int> > de;
ll arr[300005],barr[300005];
//EG
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
	int i,j,k,z,ans=0,c=0,x=0,y=0;
	
	cin>>n;
	rep(i,0,n){
		cin>>arr[i];
		barr[arr[i]]=i+1;
	}
	rep(i,1,n+1)
	cout<<barr[i]<<" ";
 	return 0;
}

Measured memory_bytes: 3712
// Anve$hi $hukla
#include <bits/stdc++.h>
using namespace std;
struct ${$(){ios_base::sync_with_stdio(false);cin.tie(NULL);}}$;

typedef long long LL;
const int Maxn = 200005;

int main() {
	string s, t;
	int N;
	cin >> N;
	cin >> s >> t;
	int ans = 2 * N;
	for(int i = 1; i <= N; i++) {
		if(s.substr(N - i, i) == t.substr(0, i)) {
			ans = 2 * N - i;
		}
	}   
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;


int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int result;
    if (b < c || d < a) {
        cout << 0 << endl;
        return 0;
    }

    result = min(b, d) - max(a, c);
    cout << result << endl;
    return 0;
}


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



int main()
{
    int n;
    cin >> n;
  vector<int> a(n);
  vector<int> b(100000,0);
  for(int i=0;i<n;i++){
    cin >> a[i];
	b[a[i]]++;
  }
  
  int maxcount=0;
  for(int i=0;i<100000;i++){
    int sum = b[i];
    if (i>0)sum+=b[i-1];
    if (i<n-1)sum+=b[i+1];
    if (sum > maxcount)maxcount=sum;
  }


    cout <<  maxcount ;
    
    return 0;
}






Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		List<Integer> azi = new ArrayList<Integer>();
		int answer = 0;

		for (int i = 1; i <= N; i++) {
			azi.add(L + i - 1);
		}

		Collections.sort(azi);

		if (azi.contains(0) && L != 0) {
			for (int i = 0; i < N; i++) {
				answer += azi.get(i);
			}
		} else if (azi.get(azi.size() - 1) < 0) {
			for (int i = 0; i < N - 1; i++) {
				answer += azi.get(i);
			}
		} else {
			for (int i = 1; i < N; i++) {
				answer += azi.get(i);
			}
		}
		System.out.println(answer);
	}
}


Measured memory_bytes: 23892
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int n, c, ci, si, ti, t[100001]={}, tc[100001][30]={}, x=0;

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

	for(int i=0; i<n; i++){
		scanf("%d %d %d", &si, &ti, &ci);
		ci--;
		for(int j=si; j<=ti; j++){
			tc[j][ci]=1;
		}
	}

	for(int i=1; i<=100000;i++){
		for(int j=0; j<c; j++){
			t[i]=t[i]+tc[i][j];
		}
	}

	for(int i=1; i<=100000; i++){
		if(x<t[i]){
			x=t[i];
		}
	}

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

	return 0;

}

Measured memory_bytes: 12288
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<cmath>
#include<functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void sort(int &a,int &b)
{
	if(a>b)
		swap(a,b);
}
void open(const char *s)
{
#ifndef ONLINE_JUDGE
	char str[100];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
	sprintf(str,"%s.out",s);
	freopen(str,"w",stdout);
#endif
}
int rd()
{
	int s=0,c;
	while((c=getchar())<'0'||c>'9');
	do
	{
		s=s*10+c-'0';
	}
	while((c=getchar())>='0'&&c<='9');
	return s;
}
int upmin(int &a,int b)
{
	if(b<a)
	{
		a=b;
		return 1;
	}
	return 0;
}
ll upmax(ll &a,ll b)
{
	if(b>a)
	{
		a=b;
		return 1;
	}
	return 0;
}
int op[1000010];
int a[1000010];
ll f[1000010][5];
int main()
{
	char s[2];
	int n;
	scanf("%d",&n);
	int i;
	for(i=1;i<=n;i++)
	{
		if(i>1)
		{
			scanf("%s",s);
			if(s[0]=='+')
				op[i]=1;
			else
				op[i]=2;
		}
		else
			op[i]=1;
		scanf("%d",&a[i]);
	}
	memset(f,0x80,sizeof f);
	f[0][0]=0;
	for(i=0;i<=n;i++)
	{
		upmax(f[i][1],f[i][2]);
		upmax(f[i][0],f[i][1]);
		if(i==n)
			continue;
		if(op[i+1]==1)
		{
			upmax(f[i+1][0],f[i][0]+a[i+1]);
			upmax(f[i+1][1],f[i][1]-a[i+1]);
			upmax(f[i+1][2],f[i][2]+a[i+1]);
		}
		else
		{
			upmax(f[i+1][0],f[i][0]-a[i+1]);
			upmax(f[i+1][1],f[i][0]-a[i+1]);
			upmax(f[i+1][1],f[i][1]+a[i+1]);
			upmax(f[i+1][2],f[i][1]+a[i+1]);
			upmax(f[i+1][2],f[i][2]-a[i+1]);
		}
	}
	printf("%lld\n",f[n][0]);
	return 0;
}

Measured memory_bytes: 45184
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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


int main() {
	int a, b;
	cin >> a >> b;
	if (a < b) {
		rep(i, b) cout << a;
	}
	else {
		rep(i, a) cout << b;
	}
	cout << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

int countDivisorNum(int n) {
    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (n % i == 0) {
            count++;
        }
    }
    return count;
}

int main() {
    int n;
    cin >> n;
    int ans = 0;

    for (int i = 1; i <= n; i += 2) {
        if (countDivisorNum(i) == 8) {
            ans++;
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
C - *3 or /2
https://abc100.contest.atcoder.jp/tasks/abc100_c

"""
import sys
from sys import stdin
input = stdin.readline


def solve(data):
    ans = 0
    for d in data:
        while d % 2 == 0:
            ans += 1
            d //= 2
    return ans


def main(args):
    N = int(input())
    data = [int(i) for i in input().split()]
    ans = solve(data)
    print(ans)

if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 4084
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#define INF 2147483647
#define lli long long int
#define rep(i,n) for(i=0;i<(n);i++); 

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

class Team{
	public:
		int id = 0;
		int solve = 0;
		int time = 0;
		vector<int> check;
		
		void setP(int num,int id){
			for (int i = 0; i < num; i++){
				check.push_back(0);
			}
			this->id = id + 1;
		}
};

bool compare(Team maxT,Team T){
	if (maxT.solve < T.solve){
		return true;
	}else if(maxT.solve > T.solve){
		return false;
	}else{
		if (maxT.time > T.time){
			return true;
		}else if (maxT.time < T.time){
			return false;
		}else{
			if (maxT.id > T.id){
				return true;
			}else{
				return false;
			}
		}
	}
}

void sort_Team(vector<Team> &T){
	int i,j;
	Team maxT;
	//rep(i,T.size()){
	int maxj;
	for (int i = 0; i < T.size(); i++){
		//rep(j,T.size()){
		maxj = i;
		maxT.id = 51;
		maxT.solve = 0;
		maxT.time = INF;
		for (int j = i; j < T.size(); j++){
			if(compare(maxT,T[j])){
				maxT = T[j];
				maxj = j;
			}
		}
		Team tmp = T[i];
		T[i] = T[maxj];
		T[maxj] = tmp;
	}
}

void print_result(vector<Team> T){
	int i;
	//rep(i,T.size()){
	for (int i = 0; i < T.size(); i++){
		cout << T[i].id << " " << T[i].solve << " " << T[i].time << endl;
	}
}

int main() {
	while(1){
		int t,p,r; cin >> t >> p >> r;
		if (t + p + r == 0) break;
		vector<Team> T(t);

		for (int i = 0; i < t; i++){
			T[i].setP(r,i);
		}
		for (int i = 0; i < r; i++){
			int tID,pID,time;
			string msg;
			cin >> tID >> pID >> time >> msg;

			if (msg == "CORRECT"){
				if (T[tID-1].check[pID-1] != 1){
					T[tID-1].time += T[tID-1].check[pID-1] * (-1200) + time;
					T[tID-1].solve++;
					T[tID-1].check[pID-1] = 1;
				}
			}else if(msg == "WRONG"){
				if (T[tID-1].check[pID-1] != 1){
					T[tID-1].check[pID-1]--;
				}
			}
		}
		sort_Team(T);
		print_result(T);
	}

	return 0;
}

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

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

    for(int b=-150;b<150;b++){
        for(int a=b+1;a<151;a++){
            if(pow(a,5)-pow(b,5)==x){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 4060
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "y");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    auto t = new long[](n);
    foreach (ref e; t)
        e = lread();
    long lcm = t[0];
    foreach (e; t[1 .. $])
    {
        lcm /= gcd(lcm, e);
        lcm *= e;
    }
    lcm.writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    while(getline(cin,str)){
    int point=0;
    bool flag=1;
    for(int i=0;i<str.size();i++){
        if(str[i]==' '||str[i]=='.'||str[i]==','){
            if(i-point>2&&i-point<7){
                if(!flag)cout<<" ";
                for(int j=point;j<i;j++)cout<<str[j];
                flag=false;
            }
            point=i+1;
        }
    }
    cout<<endl;
    }
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
bool mark[N];
void sieve()
{
    int i,j;
    memset(mark,true,sizeof(mark));
    for(i=4;i<N;i+=2)
        mark[i]=false;
    for(i=3;i*i<N;i+=2)
    {
        if(mark[i])
        {
            for(j=i*i;j<N;j+=i*2)
                mark[j]=false;
        }
    }
    mark[1]=false;

}
int main()
{
    sieve();
    int i,n;
    sf(n);
    while(!mark[n])
        n++;
    cout<<n;
}


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


using namespace std;
using namespace __gnu_pbds;


#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;





int main() {

ios_base::sync_with_stdio(false);
cin.tie(NULL);
    
    int t=1;
    //cin>>t;
    while(t--){
        int n;cin>>n;
        LL ans=0;
        vector <long long> v(n+1,1);
        for(int i=2;i<=n;i++)
            {   
                for(int j=i;j<=n;j+=i)
                    {
                        v[j]+=1;
                    }
            }
        for(int i=1;i<=n;i++)
            {
                ans = (ans+i*1ll*v[i]);
            }
        cout<<ans<<" ";
    }



return 0;
}

Measured memory_bytes: 81296