akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int table[100][100];

int main(void){
    int sum2,sum,i,j,r,c;

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

    for(i = 0;i < r;i++){
        for(j = 0;j < c;j++){
            scanf("%d",&table[i][j]);
        }
    }

    sum2 = 0;
    for(i = 0;i < r;i++){
        sum = 0;
        for(j = 0;j < c;j++){
            sum += table[i][j];
            printf("%d ",table[i][j]);
        }
        sum2 += sum;
        printf("%d\n",sum);
    }

    for(i = 0;i < c;i++){
        sum = 0;
        for(j = 0;j < r;j++)
            sum += table[j][i];
        printf("%d ",sum);
    }
    printf("%d\n",sum2);
    return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <functional>
#include <bitset>
#include <queue>

#include <boost/range/irange.hpp>
using boost::irange;

#include <boost/utility/string_ref.hpp>
using string_view = boost::string_ref;

#include <boost/function_output_iterator.hpp>

using namespace std;

struct shop_t {
    int64_t price;
    int64_t stock;
};


int64_t f(int64_t x)
{
    auto y = (x + 1) / 2 % 2 == 0 ? 1 : 0;
    return (x + 1) % 2 == 0 ? y : y ^ x;
}

int64_t f(int64_t a, int64_t b)
{
    if(b == 0) return 0;
    return f(a-1) ^ f(b);
}

int main()
{
    int64_t A,B;
    cin >> A >> B;

    cout << f(A, B) << '\n';
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define endl "\n"
using Edge = pair<int,ll>;
using Graph = vector<vector<Edge>>;
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(void){
  while(true){
    int n,x; cin >> n >> x;
    if(n==0 && x==0) return 0;

    int ans = 0;
    FOR(i,1,n){
      FOR(j,i+1,n){
        FOR(k,j+1,n){
          if(i==j || j==k || k==i) continue;

          if(i+j+k==x) ++ans;
        }
      }
    }
    cout << ans << endl;
  }
  
}





Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

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

int main()
{
    int H, W, Ch, Cw, Dh, Dw;
    cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
    Ch--; Cw--; Dh--; Dw--;

    vector<string> S(H);
    rep(i, H) cin >> S[i];

    vector<vector<int>> dis(H, vector<int>(W, 1e9));
    deque<P> dq;
    dis[Ch][Cw] = 0;
    dq.push_back({Ch, Cw});
    while (!dq.empty()) {
        int y = dq.front().first, x = dq.front().second;
        dq.pop_front();
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                if (i == 0 && j == 0) continue;
                int px = 1;
                if (abs(i) + abs(j) == 1) px = 0;
                int tx = x + j, ty = y + i;
                if (tx < 0 || tx >= W || ty < 0 || ty >= H || S[ty][tx] == '#') continue;
                if (dis[ty][tx] <= dis[y][x] + px) continue;
                dis[ty][tx] = dis[y][x] + px;
                if (px) dq.emplace_back(ty, tx);
                else dq.emplace_front(ty, tx);
            }
        }
    }

    int ans = dis[Dh][Dw];
    cout << (ans == 1e9 ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 9528
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int a[1<<20];

int m[1<<20];
int mb[20][1<<20];

int dp[1<<20];

void solve() {
    m[0] = a[0];
    for (int i = 1; i < (1<<n); i++) {
        for (int j = 0; j < n; j++) {
            if (((i>>j)&1) == 0) continue;
            int v = a[i];
            for (int k = 0; k < n; k++) {
                if (k == j || ((i>>k)&1) == 0) continue;
                v = max(v, mb[j][i^(1<<k)]);
            }
            mb[j][i] = v;
            m[i] = max(m[i], mb[j][i]);
            m[i] = max(m[i], m[i^(1<<j)]);
        }
    }

    for (int i = 1; i < (1<<n); i++) {
        for (int j = 0; j < n; j++) {
            if (((i>>j)&1) == 0) continue;
            dp[i] = max(dp[i], dp[i^(1<<j)]);
        }
        int v = 0;
        for (int j = 0; j < n; j++) {
            if (((i>>j)&1) == 0) continue;
            v = max(v, mb[j][i] + m[i^(1<<j)]);
        }
        dp[i] = max(dp[i], v);
    }

    int v = 0;
    for (int i = 1; i < (1<<n); i++) {
        v = max(v, dp[i]);
        cout << v << endl;
    }
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    solve();
}


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

using namespace std;
typedef long long ll;

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

/* memo
int no[tate][yoko]
*/

int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll S = 0;
    if (K > A) {
        S += A;
        K -= A;
    } else {
        S += K;
        cout << S << endl;
        return 0;
    }

    if (K > B) {
        K -= B;
    } else {
        cout << S << endl;
        return 0;
    }

    if (K > C) {
        S -= C;
        K -= C;
    } else {
        S -= K;
        cout << S << endl;
        return 0;
    }

        cout << S << endl;
}



Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

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

typedef long long ll;
typedef long long int lli;

int main() {
	ll N, T, res;
	res = 0;
	cin >> N >> T;
	vector<ll> t;
	for (ll i = 0; i < N; i++) {
		ll ti;
		cin >> ti;
		t.push_back(ti);
	}

	for (ll i = 0; i < N; i++) {
		ll start = t[i];
		ll endP = t[i] + T;
		if (i != N - 1) {
			if (endP > t[i + 1]) {
				res += t[i + 1] - start;
			}
			else {
				res += T;
			}
		}
		else {
			res += T;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 2420
fun main(args: Array<String>) {
    val (N) = readLine()!!.split(" "). map { it.toInt() }
    var dp1 = IntArray(3)
    for (i in 0 until N) {
        val dp2 = IntArray(3)
        val h = readLine()!!.split(" "). map { it.toInt() }
        for (j in 0 until 3) {
            for (k in 0 until 3) {
                if (i != 0 && j == k) continue
                dp2[j] = Math.max(dp2[j], dp1[k] + h[j])
            }
        }
        dp1 = dp2
    }
    println(dp1.max())
}

Measured memory_bytes: 65584
#include<iostream>
using namespace std;
int main(){
    long long n,w;
    cin>>n>>w;
    long long val[n],weight[n];
    for(long long i=0;i<n;i++)
        cin>>weight[i]>>val[i];
    long long dp[n+1][w+1];
    for(long long i=0;i<=n;i++)
        dp[i][0] = 0;
    
    for(long long i=0;i<=w;i++)
        dp[0][i] = 0;
    for(long long i=1;i<=n;i++){
        for(long long j=1;j<=w;j++){
            if(weight[i-1]<=j)
                dp[i][j] = max(dp[i-1][j-weight[i-1]]+val[i-1],dp[i-1][j]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    cout<<dp[n][w]<<endl;
}

Measured memory_bytes: 82488
#include <iostream>
#include <string.h>
using namespace std;

int char2int(char ch) {
    if (ch == 'A') return 1;
    if (ch == 'C') return 2;
    if (ch == 'G') return 3;
    if (ch == 'T') return 4;
    return 0;
}

int string2hash(char str[]) {
    int length = strlen(str);
    int sum = 0;
    int phase = 1;
    for (int i = 0; i < length; ++i) {
        sum += phase * char2int(str[i]);
        phase *= 5;
    }
    return sum;
}

int find(char str[], int dict[]) {
    int hash = string2hash(str);
    if (dict[hash] == 1) return 1;
    else return 0;
}

void insert(char str[], int dict[]) {
    int hash = string2hash(str);
    if (dict[hash] == 0) dict[hash] = 1;
}

int dict[16777216] = {0};

int main() {

    int n;
    cin >> n;

    for (int i = 0; i < n; ++i) {
        char command[12];
        char str[12];
        cin >> command >> str;
        if (command[0] == 'i') {
            insert(str, dict);
        } else {
            if (find(str, dict) == 1) {
                cout << "yes" << endl;
            } else {
                cout << "no" << endl;
            }
        }
    }
    return 0;
}

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

int main(void) {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

    if(x + r > W) {
        cout << "No" << endl;
        return 0;
    }
    if(x - r < 0) {
        cout << "No" << endl;
        return 0;
    }
    if(y + r > H) {
        cout << "No" << endl;
        return 0;
    }
    if(y - r < 0) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    return 0;
}

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


int main()
{
   int n,i,j,k,h,w; cin>>h>>w;
   char maze[h][w];
   for(i=0;i<h;i++)
   {
       cin>>maze[i];
   }
   int dp[h][w];
   memset(dp,0,sizeof(dp));
   dp[0][0]=1;
   for(i=0;i<h;i++)
   {
       for(j=0;j<w;j++)
       {
           if(i==0 && j==0) continue;
           if(maze[i][j]=='.')
           {
               dp[i][j]=(dp[i][j]+(i-1>-1 ? dp[i-1][j]:0))%mod;
               dp[i][j]=(dp[i][j]+(j-1>-1 ? dp[i][j-1]:0))%mod;
           }
       }
   }
   cout<<dp[h-1][w-1]<<endl;
}


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

int A[100005];

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int N, M;
    cin >> N >> M;

    for(int i=1; i<=M; i++)
    {
        int L, R;
        cin >> L >> R;

        A[L]++, A[R+1]--;
    }

    int ans = 0;

    for(int i=1; i<=N; i++)
    {
        A[i] += A[i-1];
        ans += (A[i] == M);
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#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 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();
    ll n; cin >> n;
    vi alf;
    while(n>0){
        alf.push_back(n%26);
        n /= 26;
        if(*alf.rbegin() == 0) n--;
    }
    for(ll i=alf.size()-1; i>=0; i--){
        if(alf[i] == 0) cout << "z";
        else cout << (char)('a'+alf[i]-1);
    }
    cout << endl;
}

Measured memory_bytes: 3640
#include <stdio.h>

int main()
{
    int x, y;

    for (int i = 1;; i++)
    {
        scanf("%d %d", &x, &y);
        if ((x == 0) && (y == 0))
        {
            break;
        }
        else if (x > y)
        {
            printf("%d %d\n", y, x);
        }
        else
        {
            printf("%d %d\n", x, y);
        }
    }

    return 0;
}


Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MAX int(2 * 1e5 + 5)

int n;
bool visit[MAX];

llong judge( llong A[],llong tmp){
    int left = 0,right = n -1 ;
    llong ans = 0;
    while(1){
        if(left >= right) break;
        while(visit[right]){
            right --;
            if( left >= right) break;
        }
        while(A[left] + A[right] < tmp){
            left += 1;
            if( left >= right) break;
        }
        if( A[left ] + A[right] == tmp){
            llong init = A[left];
            while(visit[left] and init == A[left]){
                left ++;
                if(left >= right) break;
            }
            if( init == A[left]){
                if(left >= right) break;
                ans += 1;
                visit[left] = true;
                visit[right] = true;
                left += 1;
            }
        }
        right --;
    }
    return ans;
}



int main(){
    cin >> n;
    llong A[MAX];
    REP(i,n) scanf("%lld",&A[i]);
    sort(A,A+n);
    REP(i,n) visit[i] = false;
    llong tmp = 1;
    REP(i,45) tmp *=2;
    llong ans = 0;
    while(tmp > 0){
        tmp/=2;
        ans += judge(A,tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2048
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int main()
{
    int n;
    cin >> n;
    if(n/10 == 9){
        cout << "Yes" << endl;
    }
    else if(n % 10 == 9){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<cassert>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	int ans = inf;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (i != j) {
				for (int z = 0; z < 3; z++) {
					if (i != z&&j != z) {
						ans = min(ans, abs(a[i] - a[j]) + abs(a[j] - a[z]));
					}
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int c = Integer.parseInt(str[2]);
    System.out.println(b-a==c-b?"YES":"NO");
  }
}

Measured memory_bytes: 32672
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;
using i64=long long int;

int main() {
    std::string S;
    cin >> S;
    int ans = 10000;

    for (int i = 0; i < S.size() - 2; ++i) {
        ans = min(ans, abs(atoi(S.substr(i, 3).c_str()) - 753));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
  int n,i,j,b=0,m=0,a;
  scanf("%d",&n);
  for(i=1; i<=n; i++){
    if(i%10==0)m+=1;
    a=i;
    for(j=0; j<m; j++){
      if(a%10==3){
    b=1;
    break;
      } 
      a/=10;
    }
    if(i%3==0||b)printf(" %d",i);
    b=0;
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main() {
    vector< vector<bool> > ok(101, vector<bool>(101, true));
    vector< vector<long> > hres(101, vector<long>(101, -1));
    int N;
    int x = 0, y = 0;
    long h = 0;
    long h0 = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int xx, yy;
        long hh;
        cin >> xx >> yy;
        cin >> hh;
        for (int j = 0; j < 101; j++) {
            for (int k = 0; k < 101; k++) {
                if (ok[j][k]) {
                    long htemp = hh + (long)abs(xx - j) + (long)abs(yy - k);
                    if (hh == 0) {
                        if (htemp > hres[j][k]) {
                            continue;
                        } else if (htemp < hres[j][k]) {
                            ok[j][k] = false;
                            continue;
                        }
                    }
                    if (hres[j][k] == -1) hres[j][k] = htemp;
                    if (hres[j][k] != htemp) {
                        ok[j][k] = false;
                        continue;
                    }
                    x = j; y = k; h = htemp;
                }
            }
        }
    }
    cout << x << " " << y << " " << h << "\n";
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int R=1,C=1,H[2000010]={0};
int N[2000010]={-1000};
//??????????????\??????
void prih(){
  int i,j=1;printf("\n");
  for(i=1;i<C;i++){
    if(i==1<<j){
      printf("\n");
      j++;
    }
    printf("%d ",N[H[i]]);
  }
  printf("\n\n");
}
int hyouka(int a,int b){//printf("%d %d\n",a,b);
  if(b==0)return 0;
  if(C<b)return 1;
  if(C<a)return 0;
  return N[H[a]]>N[H[b]]?1:0;
}
void hin(int a){
  int i=C++;
  H[0]=R;
  for(N[R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;//prih();//printf("%d\n",i);
}
int hout(){
  int rt=H[1],i=0,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=hyouka(i*2,i*2+1)?H[j=i*2]:H[j=i*2+1];
  H[i/2]=k;//prih();
  return rt;
}/*
//???????????????????°???????????????????
int hout(){
  int rt=H[1],nt=1,i=0,k=H[--C];
  while(nt-i){
    H[i=nt]=k;
    if(i*2  <C&&N[  k  ]>N[H[i*2  ]])H[i]=H[nt=i*2  ];
    if(i*2+1<C&&N[H[nt]]>N[H[i*2+1]])H[i]=H[nt=i*2+1];
  }
  return rt;
  }//*/
int main(){
  int a;
  char s[100];
  while(scanf("%s",s),s[2]-'d'){//prih();
    if(s[2]=='s'){
      scanf("%d",&a);
      hin(a);
    }
    else printf("%d\n",N[hout()]);
  }//prih();
  return 0;
}

Measured memory_bytes: 12980
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long h;

	std::cin >> h;

	long long n = 1;
	long long ans = 0;

	while (h != 0) {
		ans += n;
		n *= 2;
		h /= 2;
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <queue>
using namespace std;
int main(void){
	long long int x,t;
	cin>>x>>t;
	if(x<t) cout<<"0"<<endl;
	else cout<<x-t<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
  #include<stdlib.h>
  #define MAX 100005
  #define NIL -1

  struct Node {
    int parent,left,right;
  };

  struct Node T[MAX];
  int n,D[MAX],H[MAX];

  void setDepth(int e,int d){
    if(e==NIL)return;
    D[e]=d;
    setDepth(T[e].left,d+1);
    setDepth(T[e].right,d+1);
  }

  int setHeight(int u){
    int h1=0,h2=0;
    if(T[u].left!=NIL) h1=setHeight(T[u].left)+1;
    if(T[u].right!=NIL) h2=setHeight(T[u].right)+1;
    return H[u]=(h1>h2?h1:h2);
  }
  int getSibling(int u){
    if(T[u].parent==NIL)return NIL;
    if(T[T[u].parent].left!=u&&T[T[u].parent].left!=NIL)return T[T[u].parent].left;
    if(T[T[u].parent].right!=u&&T[T[u].parent].right!=NIL)return T[T[u].parent].right;
   return NIL;
  }


  void print(int u){
    int i,c;
    printf("node %d: ",u);
    printf("parent = %d, ",T[u].parent);
    printf("sibling = %d, ",getSibling(u));
    int deg=0;
    if(T[u].left!=NIL)deg++;
    if(T[u].right!=NIL)deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ",D[u]);
    printf("height = %d, ",H[u]);

    if(T[u].parent==NIL)printf("root\n");
    else if(T[u].left==NIL&&T[u].right==NIL) printf("leaf\n");
    else  printf("internal node\n");
  }

  int main(){
    int e,l,r,root=0,i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
      T[i].parent=NIL;
    }
    for(i=0;i<n;i++){
       scanf("%d",&e);
       scanf("%d",&l);
       scanf("%d",&r);
       T[e].left=l;
       T[e].right=r;
       if(l!=NIL)T[l].parent=e;
       if(r!=NIL)T[r].parent=e;
    }
    for(i=0;i<n;i++){
      if(T[i].parent==NIL)root=i;
    }
    setDepth(root,0);
    setHeight(root);
    for(i=0;i<n;i++)print(i);
    return 0;
  }



Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
    string a, b, s;
    double n, m, k, r, pi = 3.1416, x = 2.0;
    cin>>r;
    cout<<setprecision(10)<<fixed<<(x* pi * r)<<"\n";
	return 0;
}


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

using namespace std;

typedef long long ll;

const int MAX_N = 160;

int N, M;
ll P;

ll solve_trival(int n, int m) {
    ll F[MAX_N][MAX_N]; memset(F, 0, sizeof(F));
    F[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= m; j++) {
            (F[i + 1][0] += F[i][j]) %= P;
            (F[i + 1][j + 1] += F[i][j]) %= P;
        }
    }
    ll res = 0;
    for (int i = 0; i <= m; i++) (res += F[n][i]) %= P;
    return res;
}

void solve() {
    static ll curr[MAX_N][MAX_N][MAX_N], old[MAX_N][MAX_N][MAX_N];
    curr[0][0][N + 1] = 1;
    for (int i = 1; i <= N; i++) {
        memcpy(old, curr, sizeof(curr));
        memset(curr, 0, sizeof(curr));
        for (int j = 0; j < i; j++) {
            for (int k = 0; k < i; k++) {
                for (int l = 1; l <= N + 1; l++) {
                    {
                        int nj = k + 1, nk = j;
                        if (j <= k) {
                            (curr[nj][nk][l - 1] += old[j][k][l]) %= P;
                        } else {
                            int t = (M + 1) / 2, nl = l;
                            if (j >= t) {
                                nl = min(nl, t - nj + 1);
                            }
                            (curr[nj][nk][nl] += old[j][k][l]) %= P;
                        }
                    }
                    {
                        int nj = 0, nk = j;
                        if (j <= k) {
                            (curr[nj][nk][N + 1] += old[j][k][l]) %= P;
                        } else {
                            (curr[nj][nk][l] += old[j][k][l]) %= P;
                        }
                    }
                }
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i <= N; i++)
        for (int j = 0; j <= N; j++)
            for (int k = 1; k <= N + 1; k++)
                (ans += curr[i][j][k]) %= P;
    printf("%lld\n", ans);
}

int main() {
    scanf("%d%d%lld", &N, &M, &P);
    if (!(M & 1)) {
        ll ans = solve_trival((N + 1) / 2, M / 2) * solve_trival(N / 2, M / 2) % P;
        printf("%lld\n", ans);
    } else {
        solve();
    }
}


Measured memory_bytes: 64384
#include <stdio.h>

#define NMAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
int M[NMAX][NMAX];

void dijkstra(void){

  int i,j,u,minv;
  int d[NMAX],color[NMAX];

  for(i = 0;i < n;i++){
    d[i] = (1<<21);
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;

  while(1){
    minv = (1<<21);
    u = -1;
    for(i = 0;i < n;i++){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }

    if(u == -1){
      break;
    }

    color[u] = BLACK;

    for(i = 0;i < n;i++){
      if(color[i] != BLACK && M[u][i] != (1<<21)){
	if(d[i] > d[u] + M[u][i]){
	  d[i] = d[u] + M[u][i];
	  color[i] = GRAY;
	}
      }
    }
  }

  for(i = 0;i < n;i++){
    printf("%d ",i);
    printf("%d\n",(d[i] == (1<<21) ? -1 : d[i]));
  }
}

int main(void){
  int i,j,k,c,u,v;
  scanf("%d",&n);

  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      M[i][j] = (1<<21);
    }
  }

  for(i = 0;i < n;i++){
    scanf("%d%d",&u,&k);
    for(j = 0;j < k;j++){
      scanf("%d%d",&v,&c);
      M[u][v] = c;
    }
  }

  dijkstra();

  return 0;
}

  
	    
    



Measured memory_bytes: 2036
#include<stdio.h>

main()
{
	int a,b,c,d,i,n;

	while(scanf("%d",&n)!=EOF){
		i=0;
		for(a=0;a<=9;a++){
			for(b=0;b<=9;b++){
				for(c=0;c<=9;c++){
					for(d=0;d<=9;d++){
						if(a+b+c+d==n)
							i++;
					}
				}
			}
		}
		printf("%d\n",i);
	}
	return(0);
}

Measured memory_bytes: 0
a,b = map(int,input().split())
if b == 1:
    print(0)
elif a >= b:
    print(1)
else:
    dum = b - a
    ans = 1
    syo,amari = divmod(dum,a-1)
    if amari != 0:
        ans += 1
    ans = ans + syo
    print(ans)


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
struct PH{
  template<class T, class U>
  size_t operator()(const pair<T,U>& x) const{
	return hash<T>()(x.first) ^ hash<U>()(x.second);
  }
};

LL dp[1010][1010];
LL fact[1010];

LL powm(LL x, LL y){
  if(y == 0) return 1;
  return powm(x*x%MOD, y/2) * (y%2==1?x:1) % MOD;
}

unordered_map<LL,LL> memo;
LL inv(LL x){
  if(memo.count(x)) return memo[x];
  return memo[x] = powm(x, MOD-2);
}

LL CH(LL n, LL m){
  return fact[n] * inv(fact[n-m] * fact[m] % MOD) % MOD;
}

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

  fact[0] = 1;
  REP(i,1001)
	fact[i+1] = fact[i] * (i+1) % MOD;
  
  LL N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;

  dp[A][N] = 1;
  for(int i=A;i<=B;++i){
	REP(n,N+1)
	  dp[i+1][n] = dp[i][n];

	LL tmp = 1;
	for(int j=1;j<=D&&i*j<=N;++j){
	  (tmp *= CH(i*j-1, i-1)) %= MOD;
	  if(j < C) continue;
	  
	  for(int n=i*j;n<=N;++n)
		(dp[i+1][n-i*j] += dp[i][n] * CH(n,i*j) % MOD
		 * tmp % MOD) %= MOD;
	}
  }

  cout << dp[B+1][0] << endl;

  return 0;
}


Measured memory_bytes: 17992
using System;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[] h=new int[9];
		for(int i=0;i<n;i++){h[s[i]/400<9?s[i]/400:8]++;}
		int ans=0;
		for(int i=0;i<8;i++){ans+=h[i]>0?1:0;}
		if(ans==0){ans=1;h[8]--;}
		Console.WriteLine("{0} {1}",ans,ans+h[8]);
	}
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define maxn 200010
using namespace std;
typedef long long ll;
int N,K;
int p[maxn];
double ans[maxn];
int main(void)
{
    cin>>N>>K;
    for(int i =1 ;i <= N;i ++)
    {
        cin>>p[i];
        ans[i] = ans[i-1] + ((double)p[i]+1.0)/2;
    }
    int l = 0,r = 0;
    double ret = 0;
    for(int l = 0;l + K <= N;l ++)
    {
        ret = max(ret,ans[l+K] - ans[l]);
    }

    printf("%lf\n",ret);
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
    int N;
    string s,t;
    cin >> N >> s >> t;
    vector<int> cnt(26,0);
    cnt[s[0]-'a'] = 1;
    int i;
    for(i=1;i<N-1;i++)cnt[s[i]-'a'] = (cnt[s[i]-'a']+cnt[t[i]-'a'])%1000000007;
    cout << cnt[t[N-1]-'a'] << endl;
}


Measured memory_bytes: 3332
# _*_ coding:utf-8 _*_
#  Atcoder_ExaWizards2019_Contest-B
#  TODO https://exawizards2019.contest.atcoder.jp/tasks/exawizards2019_b

def solveProblem(peoples,retuString):
	redOrBlueList = list()
	for i in range(0,peoples,+1):
		if retuString[i] == 'R':
			redOrBlueList.append(1)
		elif retuString[i] == 'B':
			redOrBlueList.append(-1)
	if sum(redOrBlueList) > 0:
		answer = "Yes"
	else:
		answer = "No"
	return answer


if __name__ == '__main__':
	N = int(input().strip())
	s = input().strip()
	solution = solveProblem(N,s)
	print("{}".format(solution))


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

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

  string ans = "Yes";

  for (int i = 1; i < N; i++) {
    if (vec.at(i) - 1 >= vec.at(i - 1)) {
      vec.at(i) -= 1;
    }
    else if (vec.at(i) == vec.at(i - 1)) {
      continue;  
    }
    else {
      ans = "No";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
int mai(int m,int n,int k) {
	int ans = 1;
	for (; n; n >>= 1, m = (long long)m*m%k)
		if (n & 1)
			ans = (long long)ans*m%k;
	return ans;
}
int cnt(int n) {
	int ans = 0;
	while (n) {
		if (n & 1)ans++;
		n >>= 1;
	}
	return ans;
}
int help(int n) {
	int op = 0;
	while (n) {
		op++;
		n %= cnt(n);
	}
	return op;
}
void solve() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int sum = 0;
	rep(i, 0, n) {
		if (s[i] == '1') {
			sum++;
		}
	}
	ll t1 = 0, t2 = 0;
	int pos = n - 1;
	rep(i, 0, n) {
		if (s[i] == '1') {
			if (sum > 1) {
				t1 += mai(2, pos, sum - 1);
				t1 %= (sum - 1);
			}
			if (sum < n) {
				t2 += mai(2, pos, sum + 1);
				t2 %= (sum + 1);
			}
		}
		pos--;
	}
	
	vector<ll> res(n+1);
	rep(i, 0, n+1)res[i] = help(i);
	rep(i, 0, n) {
		if (s[i] == '1') {
			if (sum - 1 == 0) {
				cout << 0 << endl;
			}
			else if (sum - 1 == 1) {
				cout << 1 << endl;
			}
			else if (sum - 1 == 2) {
				if (i != n - 1) {
					if (s[n - 1] == '1') {
						cout << 2 << endl;
					}
					else {
						cout << 1 << endl;
					}
				}
				else {
					cout << 1 << endl;
				}
			}
			else {
				ll t1c = t1;
				t1c -= mai(2, n - i - 1, sum - 1);
				t1c %= (sum - 1);
				if (t1c < 0)t1c = (t1c + sum - 1);
				cout << 1 + res[t1c] << endl;
			}
		}
		else {
			ll t2c = t2;
			t2c += mai(2, n - i - 1, sum + 1);
			t2c %= (sum + 1);
			cout << 1 + res[t2c] << endl;
		}
	}
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}







Measured memory_bytes: 5136
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
typedef pair<LL,pair<mp,int> > inf;
#define val FIR
#define from SEC.FIR.FIR
#define tim SEC.FIR.SEC
#define to SEC.SEC 
priority_queue<inf,vector<inf>,greater<inf> > q;
int n;
LL dp[51][2501];
vector<pair<int,mp> >  g[51];
int m,s;
int c[51],d[51];
int main(){
	fastio;
	cin>>n>>m>>s;
	s=min(s,2500);
	rb(i,1,m){
		int u,v,a,b;
		cin>>u>>v>>a>>b;
		g[u].PB(II(v,II(a,b)));
		g[v].PB(II(u,II(a,b)));
	}
	rb(i,1,n)
		cin>>c[i]>>d[i];
	
	rb(i,2,n)
	{
		LL res=1000000000000000000ll;
		rep(K,51)
			rep(L,2501)
				dp[K][L]=res;
		rep(j,2500)
			dp[i][j]=0,q.push(II(0,II(II(i,j),i)));
	while(!q.empty()){
		inf now=q.top();
		q.pop();
		int x,y,z;
		x=now.from;
		y=now.tim;
		z=now.to;
		if(now.val!=dp[x][y]) continue;
		if(dp[x][max(0,y-c[x])]>dp[x][y]+d[x]){
			dp[x][max(0,y-c[x])]=dp[x][y]+d[x];
			q.push(II(dp[x][max(0,y-c[x])],II(II(x,max(0,y-c[x])),z)));
		}
		for(auto it:g[x]){
				LL nval;int nx,ny,nz;
				nx=it.FIR;
				ny=y+it.SEC.FIR;
				ny=min(2500,ny);
				nz=z;
				nval=dp[x][y]+it.SEC.SEC;
				if(nval<dp[nx][ny]){
					dp[nx][ny]=nval;
					q.push(II(nval,II(II(nx,ny),nz)));
				}
		}
	}
	rep(j,s+1){
			res=min(res,dp[1][j]);
		}
		if(res<0){
			while(1);
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 7372
import java.io.*;
import java.lang.*;
import java.util.*;
import java.math.*;

class Solver extends Main{
	int cnv(String[] st,String ch){
		Boolean upd=false;
		String[] cpy=new String[st.length-1];
		int cnt=0;
		
		for(int i=0; i<st.length; i++){
			if(!st[i].equals(ch)){
				upd=true;
			}
		}
		
		while(upd==true){
			upd=false;
			cpy=new String[st.length-1];
			
			for(int i=0; i<st.length-1; i++){
				if(st[i+1].equals(ch)){
					cpy[i]=ch;
				}else{
					cpy[i]=st[i];
				}
			}
			st=cpy;
			for(int j=0; j<st.length; j++){
				if(!st[j].equals(ch)){
					upd=true;
				}
			}
			cnt++;
		}
		return cnt;
	}
}//Solver_end

class Main{
	static int imax=Integer.MAX_VALUE;
	static long lmax=Long.MAX_VALUE;
	
	public static void main(String[] args) throws FileNotFoundException{
		
		Scanner sc=new Scanner(System.in);
		String[] st=readlnS(sc,"");
		List<String> chr=new LinkedList<String>();
		int mn=imax;
		int x=0;
		
		for(int i=0;i<st.length; i++){
			if(chr.contains(st[i])==false){
				chr.add(st[i]);
			}
		}
		
		for(int i=0;i<chr.size(); i++){
			Solver slv=new Solver();
			x=slv.cnv(st,chr.get(i));
			if(mn>x) mn=x;
		}
		
		puts(mn);
		
	}//main_end
	
	//utility
	static int readI(Scanner sc){
		return Integer.parseInt(sc.nextLine().trim());
	}
	static long readL(Scanner sc){
		return Long.parseLong(sc.nextLine().trim());
	}
	static String readS(Scanner sc){
		return sc.nextLine().trim();
	}
	static int[] readlnI(Scanner sc, String dl){
		return Arrays.stream(sc.nextLine().trim().split(dl)).mapToInt(Integer::parseInt).toArray();
	}
	static long[] readlnL(Scanner sc, String dl){
		return Arrays.stream(sc.nextLine().trim().split(dl)).mapToLong(Long::parseLong).toArray();
	}
	static String[] readlnS(Scanner sc, String dl){
		return sc.nextLine().trim().split(dl);
	}
	@SuppressWarnings("unchecked")
	static <T> void puts(T... args){
		for(int i=0; i<args.length-1; i++){
			System.out.printf("%s ",args[i]);
		}
		System.out.println(args[args.length-1]);
	}
	static void puts(int[] ary){
		for(int i=0; i<ary.length-1; i++){
			System.out.printf("%d ",ary[i]);
		}
		System.out.println(ary[ary.length-1]);
	}
	static void puts(long[] ary){
		for(int i=0; i<ary.length-1; i++){
			System.out.printf("%d ",ary[i]);
		}
		System.out.println(ary[ary.length-1]);
	}
	static void bs(){
		System.out.println("");
	}
	static void tblSort(int[][] tbl){
		Arrays.sort(tbl, new Comparator<int[]>(){
			@Override
			public int compare(int[] a, int[] b){
				if(a[0]==b[0]){
					return b[1]-a[1];
				}else{
					return b[0]-a[0];
				}
			}
		});
	}
}


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

int main(){
    int n,m;cin>>n>>m;
    int a[n];
    for(int i=0;i<n;++i)cin>>a[i];
    priority_queue<int> Q;
    for(int i=0;i<n;++i)Q.push(a[i]);
    for(int i=0;i<m;++i){
        int t=Q.top();Q.pop();
        t/=2;Q.push(t);
    }
    long long ans=0;
    for(int i=0;i<n;++i){
        ans+=Q.top();Q.pop();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1276
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let q: usize = it.next().unwrap().parse().unwrap();
    let mut g = vec![vec![]; n];
    for _ in 1..n {
        let a: usize = it.next().unwrap().parse::<usize>().unwrap() - 1;
        let b: usize = it.next().unwrap().parse::<usize>().unwrap() - 1;
        g[a].push(b);
        g[b].push(a);
    }
    let mut dp = vec![0; n];
    for _ in 0..q {
        let p: usize = it.next().unwrap().parse::<usize>().unwrap() - 1;
        let x: u32 = it.next().unwrap().parse().unwrap();
        dp[p] += x;
    }
    let mut stack = vec![(0, 0)];
    while let Some((v, p)) = stack.pop() {
        for &u in &g[v] {
            if u != p {
                dp[u] += dp[v];
                stack.push((u, v));
            }
        }
    }
    let mut out = String::new();
    for a in dp {
        out.push_str(&format!("{} ", a));
    }
    out.pop();
    println!("{}", out);
}

fn main() {
    run();
}


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

int main(void){
    int a,b,c,k,mabc,sum;
    cin>>a>>b>>c>>k;
    mabc = max(max(a,b),c);
    sum = mabc;
    for(int i=1;i<=k;i++){
        sum *= 2;
    }
    cout<<(sum+a+b+c-mabc)<<endl;
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
r, s, p = gets.split.map(&:to_i)
t = gets.chomp
ans = t.count('r') * p + t.count('s') * r + t.count('p') * s
(n - k).times do |i|
  if t[i] == t[i + k]
    t[i + k] = 'x'
    if t[i] == 'r'
      ans -= p
    elsif t[i] == 's'
      ans -= r
    elsif t[i] == 'p'
      ans -= s
    end
  end
end
puts ans

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

int main()
{
    long long x,a,b;
    bool btf = false;
    cin >> x;

    long long i,j;
    for (i = -1000; i <= 1000; i++)
    {
        for (j = -1000; j <= 1000; j++)
        {
            if(powl(i,5) - powl(j,5) == x)break;
        }
        if(j != 1001)break;
    }
    
    cout << i << " " << j << endl;
}


Measured memory_bytes: 3688
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;
int main()
{
  ll N, M;
  while(cin >> N >> M, N || M) {
    vector<P> vp(N);
    ll sum = 0;
    FOR(i,0,N) {
      int d, p; cin >> d >> p;
      vp[i] = P(p, d);
      sum += p * d;
    }
    sort(vp.rbegin(), vp.rend());
    FOR(i,0,N) {
      int p = vp[i].first;
      int d = vp[i].second;
      if(M >= d) {
        M -= d;
        sum -= d * p;
      } else {
        sum -= M * p;
        break;
      }
    }
    cout << sum << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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


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

    string S;
    cin >> S;
    ll s_len = S.length();
    S = S + "a";
    ll ans = 0;
    ll cnt_A = 0;
    ll i = 0;
    while(i < s_len){
        if(S.substr(i, 2) == "BC"){
            ans += cnt_A;
            i = i + 2;
        }else if(S[i] == 'A'){
            cnt_A += 1;
            i++;
        }else{
            cnt_A = 0;
            i++;
        }
    }

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


Measured memory_bytes: 788
from collections import deque
s = deque(list(input()))

ans = 0
while len(s) > 1:
  if s[0] != s[-1]:
    if s[0] == 'x':
      s.append('x')
    elif s[-1] == 'x':
      s.appendleft('x')
    else:
      print(-1)
      exit()
    ans += 1
  else:
    s.pop()
    s.popleft()
       
print(ans)

Measured memory_bytes: 4920
s = input()
t = input()
m = 1000
num = 0
for i in range(len(s)- len(t) +1):
    num = len(t)
    for j in range(len(t)):
        if s[i+j] == t[j]:
            num -= 1
    m = min(m, num)

print(str(m))



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

using namespace std;

#define F first
#define S second
#define MAX_N 1e5+10

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vbl;

int main() {
  int n;
  cin >> n;
  ll a[n];
  ll dpT[n][n], dpJ[n][n];
  for (int i = 0 ; i < n ; i++) {
    cin >> a[i];
    dpT[i][0] = a[i];
    dpJ[i][0] = -a[i];
  }

  for (int k = 1 ; k < n ; k++) {
    for (int i = 0 ; i+k < n ; i++) {
      dpT[i][k] = max(a[i]+dpJ[i+1][k-1],a[i+k]+dpJ[i][k-1]);
      dpJ[i][k] = min(dpT[i+1][k-1]-a[i],dpT[i][k-1]-a[i+k]);
    }
  }

  cout << dpT[0][n-1] << endl;

  return 0;
}

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

using namespace std;

using int64 = long long;

vector<int> ReadIntVector(int n) {
  vector<int> xs(n);
  for (int i = 0; i < n; i++) cin >> xs[i];
  return xs;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n, x;
  cin >> n >> x;
  vector<int> ls = ReadIntVector(n);

  int current = 0;
  int count = 1;
  for (int i = 0; i < n; i++) {
    current += ls[i];
    if (current <= x) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

int linearSearch(vector<int> arr, int key) {
	REP(i, arr.size()) {
		if(arr.at(i) == key) return i;
	}
	return -1;
}

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

	int n;
	cin >> n;
	vector<int> S(n);
	REP(i, n) cin >> S.at(i);
	int q;
	cin >> q;
	vector<int> T(q);
	REP(i, q) cin >> T.at(i);

	int cnt = 0;
	REP(i, q) {
		if(linearSearch(S, T[i]) != -1) cnt++;
	}
	cout << cnt << endl;
}



Measured memory_bytes: 3252
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a <= b) {
            System.out.println(a);
        } else {
            System.out.println(a - 1);
        }
    }
}


Measured memory_bytes: 21588