akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    string a, b; cin >> a >> b;
    if(a.size() == b.size()){
        if(a == b) cout << "EQUAL" << endl;
        else{
            for(ll i=0; i<a.size(); i++){
                if(a[i]-'0' == b[i]-'0') continue;
                cout << ((a[i]-'0' > b[i]-'0') ? "GREATER" : "LESS") << endl;
                break;
            }
        }
    }
    else cout << ((a.size() > b.size()) ? "GREATER" : "LESS")<< endl;
}

Measured memory_bytes: 256
// 何個含まれるか
import 'dart:io';

void main() {
  String abc = stdin.readLineSync(); // 文字列入力
  int count;
  count = 0;
  for (int i = 0; i < 3; i++) {
    if (abc[i] == "1") count++;
  }
  print(count);
}


Measured memory_bytes: 13144
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;

#define LL long long
#define N 100010

char ch[N];
bool flag = 1;

int main() {
    scanf("%s",ch+1);
    int len = strlen(ch + 1);
    for(int i = 1 ; i <= len ; i++) {
        if(i % 2 == 1) {
            if(ch[i] == 'R' || ch[i] == 'U' || ch[i] == 'D') continue;
            else {
                flag = 0;
                break;
            }
        }
        if(i % 2 == 0) {
            if(ch[i] == 'L' || ch[i] == 'U' || ch[i] == 'D') continue;
            else {
                flag = 0;
                break;
            }
        }
    }
    if(flag) puts("Yes");
    else puts("No");
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,ma,mb;
    cin>>n>>ma>>mb;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    int dp[401][401];
    fill(dp[0],dp[401],INF);
    dp[0][0]=0;
    for(int i=0;i<n;i++){
        for(int j=400;j>=0;j--){
            for(int k=400;k>=0;k--){
                if(j+a[i]<=400&&k+b[i]<=400){
                    dp[j+a[i]][k+b[i]]=min(dp[j+a[i]][k+b[i]],dp[j][k]+c[i]);
                }
            }
        }
    }
    int ans=INF;
    int ta=ma,tb=mb;
    while(ta<=400&&tb<=400){
        ans=min(ans,dp[ta][tb]);
        ta+=ma;
        tb+=mb;
    }
    cout<<((ans!=INF)?ans:-1)<<endl;
}


Measured memory_bytes: 896
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/


//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

    int t = 0;
    while(c > 0){
        c = c - b;
        t++;
    }
    
    int ao = 0;
    while(a > 0){
        a = a - d;
        ao++;
    }
    if(t <= ao){
        cout << "Yes";
    }else{
        cout << "No";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

struct segtree {
    vector<int> data;
    int size;
    segtree(int n) {
        size=1;
        while(size<n) size<<=1;
        data=vector<int>(size<<1,0);
    }
    void add(int i,int x) {
        data[i+=size]+=x;
        while(i>1) data[i>>=1]+=x;
    }
    int getsum(int l,int r) {
        int res=0;
        for(l+=size,r+=size; l<r; l>>=1,r>>=1) {
            if(l&1) res+=data[l++];
            if(r&1) res+=data[--r];
        }
        return res;
    }
};
signed main() {
    int n,q;
    cin>>n>>q;
    segtree seg(n);
    while(q--) {
        int com,x,y;
        cin>>com>>x>>y;
        if(com) {
            cout<<seg.getsum(x-1,y)<<endl;
        } else {
            seg.add(x-1,y);
        }
    }
    return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define     mod             1000000007
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            "\n" 
#define     ll              long long int 
#define     vi              vector<int> 
#define     vvi             vector<vector<int>>
using namespace std;

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


void solve(){
	ll n;
	cin>>n;
	vector<ll> v(n);
	ll sum = 0;
	unordered_map<ll,ll> mp;

	for(int i=0;i<n;i++) {
		cin>>v[i];
		sum += v[i];
		mp[v[i]]++;
	}
	ll q;
	cin>>q;
	while(q--){
		ll b,c;
		cin>>b>>c;
		mp[c] += mp[b];
		sum -= mp[b]*b;
		sum += mp[b]*c;
		mp[b] = 0;
		cout<<sum<<endl;
	}


}
 

int32_t main()
{

   
    IOS;

    solve();

}

Measured memory_bytes: 7832
n = int(input())
A = [int(x) for x in input().split()]
cnt = 0
for i in range(n):
    minj = i
    for j in range(i,n):
        if A[j] < A[minj]:
            minj = j
    if i != minj:
        A[i],A[minj] = A[minj],A[i]
        cnt += 1

print(*A)
print(cnt)


Measured memory_bytes: 5612
from heapq import heappush, heappop
import math
n, m = map(int, input().split())
a = list(map(int, input().split()))
hq = []
for i in range(n):
    a[i] *= -1
    heappush(hq, a[i])
for i in range(m):
    b = math.floor(-1*heappop(hq)/2)
    heappush(hq, b*-1)
print(sum(hq)*-1)


Measured memory_bytes: 14536
#include <stdio.h>
int main(void){
    int N,i,max=0,min=0,ans;

    scanf("%d",&N);

    int A[N];

    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
        if(i==0){
            max=A[i];
            min=A[i];
        }
        
        
        if(A[i]>max)    max=A[i];
        if(A[i]<min)    min=A[i];
    }
    
    ans=max-min;
    
    printf("%d\n",ans);
    
    
 return 0;   
}


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

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int cnt[101] = {0, };
    int n, k; cin >> n >> k;
    for (int i = 0; i < k; i++) {
        int d; cin >> d;
        for (int j = 0; j < d; j++) {
            int x; cin >> x;
            cnt[x]++;
        }
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (!cnt[i]) ans++;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3656
// ABC110_A
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値

int main() {
    // input
    ll A, B, C;
    cin >> A >> B >> C;
    
    // calculation
    ll max_num = max({A, B, C});
    cout << max_num*10 + (A+B+C - max_num) << "\n";
    return 0;
}


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


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

    vector<pair<long long, int>> fs;
    for (long long i = 2; i * i <= N; ++i) {
        int x = 0;
        while (N % i == 0) {
            N /= i;
            ++x;
        }
        fs.emplace_back(i, x);
    }
    if (N != 1) {
        fs.emplace_back(N, 1);
    }

    int ans = 0;
    for (auto p : fs) {
        int x = p.second;
        int b = 1;
        while (b <= x) {
            x -= b;
            ++b;
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 19256
#n = int(input())
#m = int(input())
#k = int(input())
#n, m = map(int, input().split())
r, g, b, n = map(int, input().split())
#a = list(map(int, input().split()))
#table = []
'''
for i in range h:
    temp = list(map(int, input().split()))
    table.append(temp)
'''
count = 0
for i in range(n//r+1):
    for j in range((n-r*i)//g+1):
        if (n-r*i-g*j)%b == 0:
            count +=1
print(count)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);
#define mp make_pair
#define pb push_back

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

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
	if(n==0) return (ll)1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
ll modinv(ll a, ll m) {
	if(m==0)return (ll)1;
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll 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;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////

int main() {
ll n;
cin>>n;
ll a[n+1];
rep(i,n){
	cin>>a[i];
}
sort(a+1,a+n+1);
ll sum=0;
ll sum2=0;

deque<ll> dq{};
deque<ll> dq2{};
dq.push_back(a[1]);
dq2.push_back(a[n]);
ll p=2;
ll q=n;

while(1){
	int fin=0;
for(int i=1;i<=4;i++){
if(p==q){fin=1;
if(i%2==1)break;
}
if(i==1){dq.push_front(a[q]); q--;}
if(i==2){dq.push_back(a[q]); q--;}
if(i==3){dq.push_front(a[p]); p++;}
if(i==4){dq.push_back(a[p]); p++;}
if(fin) break;
}

if(fin) break;
}


if(dq.size()==n-1){
	sum+=max(abs(dq[0]-a[p]), abs(dq[n-2]-a[p]));
}

for(ll i=0;i<dq.size()-1;i++){
sum+=abs(dq[i]-dq[i+1]);
}




p=1;
q=n-1;


while(1){
	int fin=0;
for(int i=1;i<=4;i++){
if(p==q){fin=1;
if(i%2==1)break;
}
if(i==1){dq2.push_front(a[p]); p++;}
if(i==2){dq2.push_back(a[p]); p++;}
if(i==3){dq2.push_front(a[q]); q--;}
if(i==4){dq2.push_back(a[q]); q--;}
if(fin) break;
}

if(fin) break;
}

if(dq2.size()==n-1){
	sum2+=max(abs(dq2[0]-a[p]), abs(dq2[n-2]-a[p]));
}

for(ll i=0;i<dq2.size()-1;i++){
sum2+=abs(dq2[i]-dq2[i+1]);
}




cout<<max(sum,sum2)<<endl;
}




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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<char,char> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;



int main(){
    int a,b,c;cin >> a >> b >> c;
    if(a==b&&b==c) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
const int maxn = 444;
char g[maxn][maxn];
int h,w;
bool vis[maxn][maxn];
int64_t cntb,cntw;
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
int64_t ans;
void dfs(int x,int y) {
    vis[x][y] = 1;
    if(g[x][y] == '#') {
        cntb++;
    }else {
        cntw++;
    }
    for(int i=0;i<4;++i) {
        int nx = dx[i]+x;
        int ny = dy[i]+y;
        if(nx>=1 && nx<=h && ny>=1 && ny<=w && !vis[nx][ny] && g[nx][ny] != g[x][y]) {
            dfs(nx,ny);
        }
    }
}
int main() {
    cin>>h>>w;
    for(int i=1;i<=h;++i) {
        cin>>g[i]+1;
    }
    for(int i=1;i<=h;++i) {
        for(int j=1;j<=w;++j) {
            if(g[i][j] == '#' && !vis[i][j]) {
                cntb = cntw = 0;
                dfs(i,j);
                ans += cntb * cntw;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n,m,X,Y;
    cin >> n >> m >> X >> Y;
    vector<int> x(n);
    vector<int> y(m);
    for(int i=0; i<n; i++){
        cin >> x[i];
    }
    for(int i=0; i<m; i++){
        cin >> y[i];
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    int xmax = x[n-1];
    int ymin = y[0];
    string ans;
    if(xmax < ymin && xmax < Y && ymin > X){
        ans = "No War";
    }else{
        ans = "War";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        BigInteger ans = BigInteger.ONE;
        BigInteger M = new BigInteger("1000000000000000000");
        List<BigInteger> arr = new ArrayList<>();
        for(int i=0; i<n; ++i){
            BigInteger temp = new BigInteger(fs.next());
            if(temp.compareTo(BigInteger.ZERO) == 0){
                System.out.println(0);
                return;
            }
            arr.add(temp);
        }
        StringBuilder sb = new StringBuilder();
        for(int i=0; i<n; ++i){
            ans = ans.multiply(arr.get(i));
            //System.out.println(sb.toString() + " " + ans + " " + M);
            if(ans.compareTo(M) > 0){
                System.out.println(-1);
                return;
            }
        }
        System.out.println(ans);

    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 59592
N = int(input())
A = list(map(int,input().split()))

cnt = len([1 for i in range(N) if A[i] < 0])
SUM = sum(map(abs,A))
MIN = min(map(abs,A))

if cnt%2 == 0:
    print(SUM)
else:
    print(SUM-2*MIN)

Measured memory_bytes: 14208
#include <iostream>

using namespace std;

int main()
{
	int h, w, n, m;

	cin >> h;
	cin >> w;
	cin >> n;

	m = h > w ? h : w;

	int ans = n % m == 0 ? n / m : n / m + 1;

	cout << ans << endl;


	return  0;
}

Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int i, count, r;
    char[] ch;
    String str;

    for(;;){
      str = sc.next();
      if("#".equals(str))break;
      ch = new char[str.length()];
      ch[0] = str.charAt(0);
      r = 0; count = 0;
      if((ch[0] >= 'h' && ch[0] <= 'p') || ch[0] == 'u' || ch[0] == 'y')r = 1;

      for(i = 1;i < str.length();i++){
        ch[i] = str.charAt(i);
        if((ch[i] >= 'h' && ch[i] <= 'p') || ch[i] == 'u' || ch[i] == 'y'){
          if(r == 0)count++;
          r = 1;
        }else{
          if(r == 1)count++;
          r = 0;
        }
      }
      out.println(count);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 20004
N = int(input())
H = list(map(int, input().split()))

flag = 1
min_val = min(H)
for i in range(N-1):
  if H[i]-H[i+1] > 1:
    flag = 0
    break
  elif H[i]-H[i+1] == 1:
    if H[i+1] < min_val:
      flag = 0
      break
    min_val = H[i+1]
if flag == 1:
  print('Yes')
else:
  print('No')
  

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

typedef struct List {
	struct List *next;
	char *str;
	long long count;
} list;

int hash_string(char* s)
{
	long long x = 0;
	int i;
	for (i = 0; s[i] != 0; i++)	x += 1 << ((s[i] - 'a') * 2);
	return x % 10007;
}

int anagram(char* s1, char* s2)
{
	int i, count[2][26] = {}, flag = 1;
	for (i = 0; s1[i] != 0; i++) count[0][s1[i] - 'a']++;
	for (i = 0; s2[i] != 0; i++) count[1][s2[i] - 'a']++;
	for (i = 0; i < 26; i++) if (count[0][i] != count[1][i]) break;
	if (i == 26) return 1;
	else return 0;
}

int main()
{
	int i, N;
	char s[100001][11] = {};
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%s", s[i]);

	int k;
	long long sum = 0;
	list *p, *hash[10007] = {}, data[100001];
	for (i = 1; i <= N; i++) {
		k = hash_string(s[i]);
		for (p = hash[k]; p != NULL; p = p->next) {
			if (anagram(s[i], p->str) == 1) break;
		}
		if (p == NULL) {
			data[i].str = s[i];
			data[i].count = 1;
			data[i].next = hash[k];
			hash[k] = &(data[i]);
		} else (p->count)++;
	}
	for (k = 0; k < 10007; k++) {
		for (p = hash[k]; p != NULL; p = p->next) sum += p->count * (p->count - 1) / 2;
	} 
	printf("%lld\n", sum);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

class UF {
private:
	std::vector<int> parent;
	std::vector<int> level;
	vector<int> num_member;

public:
	// コンストラクタ　※注意※　0～nまでのn+1個を作ります
	UF(int n) {
		for (int i = 0; i <= n; i++) {
			parent.push_back(i); //
			level.push_back(1);  // 木の深さ
			num_member.push_back(1);
		}
	}
	// 木の根を求める
	int root(int x) {
		if (parent[x] == x)return x;
		else return parent[x] = root(parent[x]);
	}

	// 同じ集合に属するメンバーの数を求める
	int numOfmember(int x) {
		if (parent[x] == x) return num_member[x];
		else return num_member[x] = numOfmember(parent[x]);
	}

	// xとyの属する集合を合併
	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) return; // 元々合併済みの場合
		if (level[rx] < level[ry]) {
			num_member[ry] = numOfmember(ry) + numOfmember(rx);
			parent[rx] = ry;
		}
		else {
			num_member[rx] = numOfmember(ry) + numOfmember(rx);
			parent[ry] = rx;
			if (level[rx] == level[ry]) level[rx]++;
		}
	}
	// xとyが同じ集合に属するか否か
	bool same(int x, int y) {
		return root(x) == root(y); // rootが同じなら同じ集合に含まれる
	}
};


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

	int N, M; cin >> N >> M;
	stack<P> bridge;
	for (int i = 0; i < M; i++) {
		P tmp; cin >> tmp.first >> tmp.second;
		bridge.push(tmp);
	}

	
	stack<ll> ans;
	UF islands(N);
	ll satisfy = 0;
	ans.push(0);

	
	while (!bridge.empty()) {
		P newbridge = bridge.top();
		bridge.pop();

		if (!islands.same(newbridge.first, newbridge.second)) {
			satisfy += ll(islands.numOfmember(newbridge.first)) * ll(islands.numOfmember(newbridge.second));
			islands.unite(newbridge.first, newbridge.second);
		}
		ans.push(satisfy);
		
	}


	/*
	stack<ll> tmp = ans;
	while (!tmp.empty()) {
		cout << tmp.top() << " ";
		tmp.pop();
	}
	*/
	
	ll maxSatisfy = ll(N) * ll((N - 1)) / 2;
	ans.pop();
	while (!ans.empty()) {
		cout << maxSatisfy - ans.top() << endl;
		ans.pop();
	}
	
	
	

	return 0;
}

Measured memory_bytes: 3564
function Main(input) {
  input = input.trim()
  input = input.split("\n");
  var A = input[0].split("");
  var B = input[1].split("");
  if(A[0]==B[2]&&A[1]==B[1]&&A[2]==B[0]) console.log("YES")
  else console.log("NO")
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
    string card,str1,str2;
    int m,h;
    
    while(true){
        cin >> card >> m;
        if (card=="-") break;
        for (int i=0; i<m; i++){
            cin >> h;
            str1 = card.substr(0,h);
            str2 = card.substr(h,h-card.size());
            card = str2 + str1;
        }
        cout << card << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 3152
package main

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

func solve() {
	s := getString()
	n := len(s)
	k := getInt()

	m := make(map[string]bool)
	subStrs := make([]string, 0, n*k)
	for i := range s {
		for j := 0; j < k && i+j < n; j++ {
			subStr := s[i : i+j+1]
			if _, ok := m[subStr]; !ok {
				m[subStr] = true
				subStrs = append(subStrs, subStr)
			}
		}
	}
	sort.Strings(subStrs)

	ans := subStrs[k-1]
	fmt.Fprintln(wr, ans)
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k;
	cin>>k;
	string s;
	cin>>s;
	if(s.size()>k)
	{
		s.resize(k);
		s+="...";
		cout<<s;
	}
	else
		cout<<s;

return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

long int n,k;
vector<long int> v;

bool isPossible(long int maxHeight){
  long int cut = 0;
  for(auto ele : v){
    long int cnt = (ele + maxHeight - 1) / maxHeight;
    cut += (cnt - 1);
  }
  return cut <= k;
}

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   cin>>n>>k;

   v.resize(n);

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

   long int ans = 0, be = 1, en = 1e10;

   while(be <= en){
    long int mid = (be + en) / 2;
    if(isPossible(mid)){
      ans = mid;
      en = mid - 1;
    }
    else
      be = mid + 1;
   }

   cout<<ans;
   return 0;
}

Measured memory_bytes: 4784
#include <iostream>
#include<algorithm>
using namespace std;
const int maxn = 100;
int a[maxn];
int b[maxn];
int c[maxn];
int d[maxn];
int n,m,q;
int tmp[maxn];//临时数组用来存储选出的数
int ans = -1;
int vis[maxn]={0};
void dfs(int k,int s )//从m个数里选n个数,注意这些数字可能想同
{


       if(k>n)
    {
         int sum = 0;
         //sort(tmp+1,tmp+n+1);
       // for(int i=1;i<=n;i++) cout<<tmp[i];
       //  cout<<endl;
          for(int i=1;i<=q;i++)
         {
            if(tmp[b[i]]-tmp[a[i]]==c[i])
            {
                sum+=d[i];
            }
         }
         if(sum>ans) ans = sum;
        return ;
    }
    for(int i=s;i<=m;i++)
    {
        tmp[k] = i;
        dfs(k+1,i);
        tmp[k] = 0;
    }
}
int main()
{
   cin>>n>>m>>q;
   //cin>>n>>m;
    for(int i=1;i<=q;i++)
    {
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    dfs(1,1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3632
function Main(input) {
    var N = parseInt(input[0], 10);
    var sum = 0;

    for (var i = 1; i <= N; i++) {
        if (i % 3 !== 0 && i % 5 !== 0) {
            sum += i;
        }
    }

    console.log(sum);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 35096
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
from functools import reduce
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
def lcm_base(a, b):
    return (a * b) // gcd(a, b)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def main():
  N = int(readline())
  graph = [[] for _ in range(N+1)]
  m = map(int, read().split())
  AB = list(zip(m,m))
  
  for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)
  
  root = 1
  parent = [0] *(N+1)
  order = []
  stack = [root]
  Q = deque(stack)
  while Q:
    x = Q.popleft()
    order.append(x)
    for y in graph[x]:
      if y == parent[x]:
        continue
      parent[y] = x
      Q.append(y)
  color = [-1] * (N+1)
  for x in order:
    ng = color[x]
    c = 1
    for y in graph[x]:
      if y == parent[x]:
        continue
      if c == ng:
        c += 1
      color[y] = c
      c += 1
  ans = []
  for a, b in AB:
    if parent[a] == b:
      ans.append(color[a])
    else:
      ans.append(color[b])
  K = max(ans)
  print(K)
  print('\n'.join(map(str, ans)))
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 49728
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define inf1 LONGLONG_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<#x<<"is "<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
vector<int>adj [T];
			/*brownsands IIITA*/

void solve()
{  int n,i,ans=0;string s;
   cin >>n >>s;
   for(i=0;i<n-2;i++)
   {
      if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
      {
         i+=2;
         ans++;
      }
   }
   cout<<ans;
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
            //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
               }		
} 
               
			
 

				
		
		




Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long ans=0;
	int n,x,pre=0;
	scanf("%d",&n);
	while(n--){
		scanf("%d",&x);
		if(pre&&x) x--,ans++;
		pre=x&1;
		ans+=x>>1;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cstring>
#include <set>
#include <map>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int a[3]={};

int main(){
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]+a[1] == a[2]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}

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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll N, M;
  cin >> N >> M;
  vec<ll> X(M);
  REP(i, M) cin >> X[i];

  sort(ALL(X));
  vec<ll> interval(M - 1);
  REP(i, M - 1) { interval[i] = X[i + 1] - X[i]; }
  sort(ALL(interval));
  ll res = 0;
  REP(i, M - N) { res += interval[i]; }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4676
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}

const int INF = 100000; 

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

    int lower = max(a, c);
    int upper = min(b, d);

    cout << max(upper - lower, 0) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
#define lli long long int
#define llu unsigned long long int
#define fr(va, beg, end) for (lli va = beg; va < end; va++)
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
// cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;
// gcd function
// __gcd(a, b)
// for max of n elements
// cout<<max({a,b,c,d})<<endl;

lli input(lli n, vector<lli> &ve);
lli input(lli n, vector<lli> &ve) {
    lli val;
    for (lli i = 0; i < n; i++) {
        cin >> val;
        ve.pb(val);
    }
    return 0;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    lli n, w, a, b;
    cin >> n >> w;
    vector<lli> v, wt;
    fr(i, 0, n) {
        cin >> a >> b;
        wt.pb(a);
        v.pb(b);
    }

    // dp[i][j] defines max value to select from first i values with atmost
    // weight j

    vector<lli> p(w + 1, 0);
    vector<vector<lli>> dp(n + 2, p);

    for (lli i = 1; i <= n; i++) {
        for (lli j = 1; j <= w; j++) {
            if (wt[i - 1] <= j) {
                dp[i][j] =
                    max(dp[i - 1][j], dp[i - 1][j - wt[i - 1]] + v[i - 1]);
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }

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

Measured memory_bytes: 81024
#include <cstdio>
#include <iostream>
using namespace std;
const int N=300005;
char st[N];int mqz[N],mqy[N];
int main()
{
	int n;scanf("%d",&n);
	scanf("%s",st+1);
	for (int i=1;i<=n;i++)
	{
		mqz[i]+=mqz[i-1];
		if (st[i]=='W') mqz[i]++;
	}
	for (int i=n;i>=1;i--)
	{
		mqy[i]+=mqy[i+1];
		if (st[i]=='E') mqy[i]++;
	}
	int ans=n;
	for (int i=1;i<=n;i++)
	{
		int maxx=(mqz[i-1]+mqy[i+1]);
		ans=min(ans,maxx);
	}
	printf("%d",ans);
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

const long long MAX = 2e5+100;
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 COM(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;
}

ll n;
vector<vector<ll>> g;
P dp[MAX];

P ide(){
    return P(0, 1);
}

P f1(P a, P b){
    return P(a.first+b.first, (a.second*b.second%MOD)*COM(a.first+b.first, b.first)%MOD);
}

P f2(P a){
    return P(a.first+1, a.second);
}

void dfs1(ll at, ll from = -1){
    dp[at] = ide();
    zep(i, 0, g[at].size()){
        ll nx = g[at][i];
        if(nx != from){
            dfs1(nx, at);
            dp[at] = f1(dp[at], f2(dp[nx]));
        }
    }
}

void dfs2(ll at, ll from = -1, P x = P(0, 1)){
    dp[at] = f2(f1(dp[at], x));

    ll m = g[at].size();
    P l[m], r[m];
    zep(i, 0, m){l[i] = r[i] = (g[at][i] == from)? x : f2(dp[g[at][i]]);}
    rep(i, 1, m-1){l[i] = f1(l[i], l[i-1]);}
    rrep(i, m-2, 0){r[i] = f1(r[i], r[i+1]);}

    zep(i, 0, m){
        ll nx = g[at][i];
        if(nx != from){
            P tmp = ide();
            if(i > 0){tmp = f1(tmp, l[i-1]);}
            if(i < m-1){tmp = f1(tmp, r[i+1]);}
            dfs2(nx, at, f2(tmp));
        }
    }
}

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

    cin >> n;
    g.resize(n);
    zep(i, 0, n-1){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    dfs1(0);    
    dfs2(0);

    zep(i, 0, n){print(dp[i].second)}
    return 0;
}

Measured memory_bytes: 28784
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL p=1e9+7;
LL n;
inline LL pw(LL x, LL y){
	LL ans=1;
	while(y){
		if(y&1)(ans*=x)%=p;
		x=x*x%p; y>>=1;
	}
	return ans;
}
int main(){
	scanf("%lld",&n);
	LL pw3=1,ans=0;
	for(LL i=1; i<=n; ++i){
		pw3=pw3*3%p;
		LL tmp=pw3*n%p*(n-i+1)%p;
		LL inv=pw(tmp,p-2);
		(ans+=inv)%=p;
	}
	printf("%lld",ans);
	return 0;
}

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

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){


    char c;
    cin >> c;

    if( c >= 'a' ){
        cout << 'a' << endl;
    }
    else{
        cout << 'A' << endl;
    }

    return 0;
}

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

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

using namespace std;

	int d, n;
int main() 
{
	scanf("%d %d", &d, &n);
	int da = 1;
	printf("%d", n + (n / 100));
	for(int i = 1; i <= d; i++) 
		printf("00");
	printf("\n");
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int mod = (int)1e9 + 7;
        int[][] dp = new int[s.length() + 1][13];
        dp[0][0] = 1;
        for(int i = 0; i < s.length(); i++) {
          char c = s.charAt(i);
          for(int j = 0; j < 13; j++) {
            if (c == '?') {
              for(int k = 0; k < 10; k++) {
                int next = (j * 10 + k) % 13;
                dp[i+1][next] = (dp[i+1][next] + dp[i][j]) % mod;
              }
            } else {
              int num = c - '0';
              int next = (j * 10 + num) % 13;
              dp[i+1][next] = (dp[i+1][next] + dp[i][j]) % mod;
            }
          }
        }
        System.out.println(dp[s.length()][5]);
    }
}


Measured memory_bytes: 32852
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)
#define RREPC(i, a) RREP(i, a, 0)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
  // INFILE();
  int w, h, n;
  cin >> w >> h >> n;

  int x0 = 0, y0 = 0, x1 = w, y1 = h;

  vector<vector<int>> v(n);
  for (auto &row : v) {
    row.resize(3);
    scan(row);
  }

  for (const auto &row : v) {
    switch (row[2]) {
    case 1:
			if (row[0] > x0) {
				x0 = row[0];
			}
      break;
    case 2:
			if (row[0] < x1) {
				x1 = row[0];
			}
      break;
    case 3:
			if (row[1] > y0) {
				y0 = row[1];
			}
      break;
    case 4:
			if (row[1] < y1) {
				y1 = row[1];
			}
      break;
    }
  }

	cout << ((x1 - x0 < 0) ? 0 : x1 - x0) * ((y1 - y0 < 0) ? 0 : y1 - y0) << endl;
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int[] b = new int[n + 1];
		for (int i = 1; i < n; i++)
			b[i] = sc.nextInt();

		int[] a = new int[n + 1];

		a[1] = b[1];
		a[n] = b[n - 1];
		for (int i = 2; i < n; i++)
			a[i] = Math.min(b[i - 1], b[i]);

		int ans = 0;
		for (int i = 1; i < n + 1; i++)
			ans = ans + a[i];
		System.out.println(ans);

	}

	static class FastScanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}

}

Measured memory_bytes: 21076