akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

const int INF = 987654231;

int N, M, X;
vector<int> cost;
vector<vector<int>> vec;
int solve(int current, vector<int> &A)
{
	if (current >= N) {
		for (int i = 0; i < M; i++)
			if (A[i] < X)
				return INF;
		return 0;
	}

	vector<int> B = A;
	for (int i = 0; i < M; i++)
		B[i] += vec[current][i];

	int ret = min(solve(current + 1, A), solve(current + 1, B) + cost[current]);
	return ret;
}

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

	cost = vector<int>(N);
	vec = vector<vector<int>>(N, vector<int>(M));
	for (int i = 0; i < N; i++)
	{
		cin >> cost[i];
		for (int j = 0; j < M; j++)
			cin >> vec[i][j];
	}

	vector<int> A(M, 0);
	int ret = solve(0, A);
	if (ret == INF)
		cout << -1 << endl;
	else
		cout << ret << endl;
}

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

int main(){
    string s;
    cin >> s;
    if(s[0] == 'S'){
        cout << "Cloudy" << endl;
    }
    if(s[0] == 'C'){
        cout << "Rainy" << endl;
    }
    if(s[0] == 'R'){
        cout << "Sunny" << endl;
    }

    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 2e5 + 10;

ll sum[N],a[N];
vector<ll> factor[N];

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	f(i,1,n+1){
		cin >> a[i];
	}
	vector<int> res;
	f(i,1,n+1){
		for(int j=i;j<=n;j+=i){
			factor[j].pb(i);
		}
	}
	// f(i,1,n+1){
	// 	for(auto &el : factor[i]){
	// 		cout << el << " ";
	// 	}
	// 	cout << "\n";
	// }
	for(int i=n;i>=1;i--){
		if(sum[i]%2 != a[i]%2){
			res.pb(i);
			for(auto &el : factor[i]){
				sum[el]++;
			}
		}
	}
	f(i,1,n+1){
		if(sum[i]%2 != a[i]%2){
			cout << "-1\n";
			return 0;
		}
	}
	sort(all(res));
	cout << (int)res.size() << '\n';
	for(auto &el : res){
		cout << el << ' ';
	}
	return 0;
}

Measured memory_bytes: 37500
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a, b, x;
    cin >> a >> b >> x;
    cout << b/x - (a == 0 ? -1 : (a-1)/x) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

vector<vector<int>> G(100010);
vector<bool> visited(100010);
vector<int> score(100010);

int ans;
int id;

void dfs(int cv, vector<int> &c){
    visited[cv] = true;

    score[cv] = c[id++];

    for(auto nv : G[cv]){
        if(!visited[nv]){
            dfs(nv, c);
        }
    }

    return ;
}

void dfs2(int cv){
    visited[cv] = true;

    for(auto nv : G[cv]){
        if(!visited[nv]){
            ans += min(score[cv], score[nv]);
            dfs2(nv);
        }
    }

    return ;
}

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

    for(int i=0; i<n-1; i++){
        int a, b; cin>>a>>b;
        a--, b--;
        G[a].eb(b);
        G[b].eb(a);
    }

    vector<int> c(n);
    for(int i=0; i<n; i++) cin>>c[i];
    sort(c.begin(), c.end(), greater<int>());

    dfs(0, c);

    for(int i=0; i<n; i++) visited[i] = false;

    dfs2(0);

    cout << ans << endl;
    for(int i=0; i<n; i++){
        cout << score[i] << " \n"[i == n - 1];
    }
}

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

int main()
{
	int n,c,k,cn,in,Ans,a[100010];
	cin>>n>>c>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	Ans = 1;
	in = a[0];
	cn = 1;
	for(int i=1;i<n;i++){
		if(in+k<a[i] || cn==c){
			Ans+=1;
			in = a[i];
			cn =1;
		}
		else cn++;
		
	}
	cout<<Ans<<endl;
	return 0;
}


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

int main() {
	int n, d;
	cin>>n>>d;
	vector<int> node[15];
	for (int i=0; i<n; i++)
		for (int j=0; j<d; j++) {
			int x; cin>>x;
			node[i].push_back(x);
		}
	int ans = 0;
	for (int i=0; i<n; i++)
		for (int j=i+1; j<n; j++) {
			int dist = 0;
			for (int k=0; k<d; k++)
				dist += (node[i][k]-node[j][k])*(node[i][k]-node[j][k]);
			int sq = sqrt(dist);
			if (sq * sq == dist)
				ans++;
		}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int N; cin>>N;
  ll s = 0;
  ll a,mi,ma;
  REP(i,N){
    cin >> a;
    s += a;
    if(i==0 || a<mi){ mi = a;}
    if(i==0 || a>ma){ ma = a;}
  }
  printf("%Ld %Ld %Ld\n",mi,ma,s);
}


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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

vector<bool> used, used2;
int H, W, K;
vector<string> c;
int ans;

void solve(){
	int con = 0;
	
	for(int i = 0; i < H; i++){
		if(used[i]) continue;
		for(int j = 0; j < W; j++){
			if(used2[j]) continue;
			if(c[i][j] == '#') con++; 
		}
	
	}
	
	if(con == K) ans++;
}

void rec2(int depth = 0){
	
	if(depth == W) {
		solve();
		
		return;
	}
	
	used2[depth] = true;
	rec2(depth+1);
	used2[depth] = false;
	rec2(depth+1);
}

void rec(int depth = 0){
	
	if(depth == H) {
		rec2();
		
		return;
	}
	
	used[depth] = true;
	rec(depth+1);
	used[depth] = false;
	rec(depth+1);
}

signed main(){
	cout<<fixed<<setprecision(10);
	
	cin>>H>>W>>K;
	
	c.resize(H);
	used.resize(H);
	used2.resize(W);
	
	for(int i = 0; i < H; i++){
		cin>>c[i];
	}
	
	rec();
	
	cout<<ans<<endl;
	
	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
#define all(c) (c).begin(),(c).end()
const int INF = 1e9;
const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"[";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"]";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&p)
{o<<"{"<<p.first<<", "<<p.second<<"}";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj)
{o<<"{";for(auto itr=obj.begin();itr!=obj.end();++itr)o<<(itr!=obj.begin()?", ":"")<<*itr;o<<"}";return o;}
void dump() {}
template <class H, class... T>void dump(H&& head, T&&... tail)
{cout << head << (sizeof...(tail)==0 ? "\n" : " "); dump(forward<T>(tail)...);}

vector<vector<int>> G;
vector<int> col;

void dfs(int v, int c){
  if(col[v] == -1){
    col[v] = c;
  }else if(col[v] != c){
    cout << -1 << endl;
    exit(0);
  }else{
    return;
  }
  for(auto u : G[v]){
    if(u != 0) dfs(u, (c+1)%2);
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  G.assign(n,vector<int>(n));
  col.assign(n, -1);
  vector<vector<int>> dist(n, vector<int>(n,INF));
  for(int i = 0; i < n; ++i){
    string s; cin >> s;
    for(int j = 0; j < n; ++j){
      if(s[j] == '1'){
        G[i].push_back(j);
        G[j].push_back(i);
        dist[i][j] = 1;
        dist[j][i] = 1;
      }
    }
  }
  dfs(0,0);
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      for(int k = 0; k < n; ++k){
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
      }
    }
  }
  int ans = 0;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      if(dist[i][j] != INF) ans = max(ans, dist[i][j] + (i==j ? 0 : 1));
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin>>n;
  vector<int>gifts;
  int ans = 0;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    gifts.push_back(x);
  }
  sort(gifts.begin(),gifts.end());
  for(int i=0;i<n;i++){
    if(i==n-1){
        ans+=gifts[i]/2;
    }else{
        ans+=gifts[i];
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdarg>
#include <set>
#include <limits>
#include <iomanip>

using namespace std;
#define INF 2e9 + 9
#define MOD 1000000007
#define ALL(v) v.begin() , v.end()
#define Int int64_t
#define pll pair<Int,Int>
template<class T> using pql = priority_queue<T, vector<T>>;
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
#define ll(n) Int n; cin >> n;
#define LL(...) Int __VA_ARGS___; cin >> __VA_ARGS___;
#define OUT(...) cout << __VA_ARGS___;
#define RP(n, i, s) for(Int i = s ;i < n ;i++)
#define REP(n, i) for (Int i = 0; i < n; i++)
#define REPe(n, i) for (Int i = 1; i <= n; i++)
#define RPe(n, i, s) for (Int i = s; i <= n; i++)
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;
#define upd_min(miner, updater) if (miner > updater) miner = updater;

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

void ansYES(bool flag) {
    if (flag) cout << "YES" << endl; else cout << "NO" << endl;
}

struct node {
    Int to;
    Int length;
};


vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return (ret);
}

/*
vector<vector<int>> to;
vector<int> flag;
vector<int> c;


Int dfs(int from, int mae) {
    flag[from] = 1;
    Int mini = 0;
    for (auto next : to[from]) {
        if (next == mae) continue;
        if (flag[next] == 1) {
            return -1;
        } else {
            mini = min(mini, dfs(next, from));
        }
    }
    return mini;
}*/

int dx8[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

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

struct datas {
    Int max;
    Int size;
};

class ContainChecker {
protected:
    Int minx, miny, maxx, maxy;
public:
    ContainChecker(Int minx, Int miny, Int maxx, Int maxy) : minx(minx), miny(miny), maxx(maxx), maxy(maxy) {};

    bool in(Int x, Int y) {
        return (minx <= x && miny <= y && x <= maxx && y <= maxy);
    }
};

Int getHead(Int n) {
    while(n / 10 > 0){
        n /= 10;
    }
    n %= 10;
    return n;
}

int main(void) {
    Int k, n;
    cin >> k >> n;
    Int maxer = 0;
    vector<Int> a(n);
    REP(n,i){
        cin >>a.at(i);
    }
    REP(n-1,i){
        upd_max(maxer,a.at(i+1)-a.at(i));
    }
    upd_max(maxer,a.at(0)+(k-a.at(n-1)));
    cout << k - maxer << endl;
}




Measured memory_bytes: 1792
def knapsack(nums):
    n = len(nums)
    if n == 0 or n == 1:
        return 0

    if n == 2:
        return abs(nums[0] - nums[1])

    # dp[i] is min cost when reaching stone i
    dp = [0] * n
    dp[1] = abs(nums[0] - nums[1])
    for i in range(2, n):
        dp[i] = min(
            dp[i-1] + abs(nums[i-1] - nums[i]),
            dp[i-2] + abs(nums[i-2] - nums[i])
        )

    return dp[-1]


if __name__ == "__main__":
    _ = input()
    nums = [int(x) for x in input().split()]
    print(knapsack(nums))


Measured memory_bytes: 13980
def partition(data, left, right):
    pivot = int(data[right][2:])
    i = left - 1
    for j in range(left, right):
        if int(data[j][2:]) <= pivot:
            i += 1
            data[i], data[j] = data[j], data[i]
    data[i+1], data[right] = data[right], data[i+1]
    return i+1

def quick_sort(data, left, right):
    if left < right:
        new_pivot = partition(data, left, right)
        quick_sort(data, left, new_pivot-1)
        quick_sort(data, new_pivot+1, right)

#for comparison
def merge(data, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L = data[left : mid]
    R = data[mid : right]
    L.append("  10000000000")
    R.append("  10000000000")
    i = 0
    j = 0
    for k in range(left, right):
        if int(L[i][2:]) <= int(R[j][2:]):
            data[k] = L[i]
            i += 1
        else:
            data[k] = R[j]
            j += 1

def merge_sort(data, left, right):
    if left + 1 < right:
        mid = (left + right) / 2
        merge_sort(data, left, mid)
        merge_sort(data, mid, right)
        merge(data, left, mid, right)

def main():
    num = raw_input()
    pairs_quick = []
    pairs_check = []
    for i in range(int(num)):
        pair = raw_input()
        pairs_quick.append(pair)
        pairs_check.append(pair)
    
    quick_sort(pairs_quick, 0, int(num)-1)
    merge_sort(pairs_check, 0, int(num))
    if pairs_quick == pairs_check:
        print "Stable"
    else:
        print "Not stable"

    print "\n".join(pairs_quick)
    #print "\n".join(pairs_check)

if __name__ == "__main__":
    main()

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

int main(void){
  
  ll A,B,X;
  cin >> A >> B >> X;
  ll Y=B/X-A/X;
  if(A%X==0) Y++;
  cout << Y << endl;
}
  

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

int main() {
	int n;
	string s;
	cin >> n;
	cin >> s;
	int ans = 1;
	char w = s[0];
	rep(i,n-1) {
		if (w != s[i+1]) {
			ans++;
			w = s[i+1];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin>>n;
    long max=0,maxi;
    vector<long> p(n);
    for(int i=0;i<n;i++){
        long t; cin>>t;
        p[i]=t;
        if(t>max){
            max=t;
            maxi=i;
        }
    }
    long sum=0;
    for(int i=0;i<n;i++){
        if(i==maxi)
            sum+=p[i]/2;
        else
            sum+=p[i];
    }
    cout<<sum;
}

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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
const int MAX_N = 500017;
char S [MAX_N];
int dp [MAX_N] [4];
int cntLeft [MAX_N],cntRight [MAX_N];
const int INF = 1e9;

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

	{
		int cnt = 0;
		FOR(i,0,N){
			cntLeft [i] = cnt;
			if(S [i] == '1'){
				cnt++;
			}
			else{
				cnt = 0;
			}
		}
		cnt = 0;
		for(int i = N - 1;i >= 0;i--){
			cntRight [i] = cnt;
			if(S [i] == '1'){
				cnt++;
			}
			else{
				cnt = 0;
			}
		}
	}

	fill(dp [0],dp [MAX_N],-INF);
	dp [0] [0] = 0;

	FOR(i,0,N){
		if(i - 1 >= 0 && i + 1 < N && S [i - 1] == '1' && S [i] == '0' && S [i + 1] == '1'){
			chmax(dp [i + 1] [0],max({dp [i] [0],dp [i] [1],dp [i] [2],dp [i] [3]}));
			chmax(dp [i + 1] [1],dp [i] [0] + cntLeft [i]);
			chmax(dp [i + 1] [1],dp [i] [1] + cntLeft [i] - 1);
			chmax(dp [i + 1] [1],dp [i] [2] + 1);
			chmax(dp [i + 1] [2],dp [i] [0] + cntRight [i] - 1);
			if(cntLeft [i] >= 2) chmax(dp [i + 1] [2],dp [i] [1] + cntRight [i] - 1);
			chmax(dp [i + 1] [2],dp [i] [2] + cntRight [i] - 1);
			chmax(dp [i + 1] [3],dp [i] [0] + cntRight [i]);
			if(cntLeft [i] >= 2) chmax(dp [i + 1] [3],dp [i] [1] + cntRight [i]);
			chmax(dp [i + 1] [3],dp [i] [2] + cntRight [i]);
		}
		else if(S [i] == '0'){
			chmax(dp [i + 1] [0],max({dp [i] [0],dp [i] [1],dp [i] [2],dp [i] [3]}));
		}
		else{
			chmax(dp [i + 1] [0],dp [i] [0]);
			chmax(dp [i + 1] [1],dp [i] [1]);
			chmax(dp [i + 1] [2],dp [i] [2]);
			chmax(dp [i + 1] [3],dp [i] [3]);
		}
	}

	int ans = max({dp [N] [0],dp [N] [1],dp [N] [2],dp [N] [3]});
	printf("%d\n",ans);

	return 0;
}


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

int main(void){
    int n, a[100010];
    cin >> n;
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    long long sum1 = 0, sum2 = 0, cnt1 = 0, cnt2 = 0;
    for(int i=0;i<n;++i){
        if(i%2==0){
            sum1 += a[i];
            sum2 += a[i];
            if(sum1 <= 0){
                cnt1 += abs(sum1) + 1;
                sum1 = 1;
            }
            if(sum2 >= 0){
                cnt2 += abs(sum2) + 1;
                sum2 = -1;
            }
        }else{
            sum1 += a[i];
            sum2 += a[i];
            if(sum1 >= 0){
                cnt1 += abs(sum1) + 1;
                sum1 = -1;
            }
            if(sum2 <= 0){
                cnt2 += abs(sum2) + 1;
                sum2 = 1;
            }
        }
    }
    cout << min(cnt1, cnt2) << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  // 標準入力高速化のおまじない
  // scanfとの同期を切る。以降紛らわしいのでscanf使用不可。
  ios::sync_with_stdio(false);
  // // cin前の自動flashをやめる
  cin.tie(nullptr);

  int N;
  cin >> N;
  int result = N % 1000;
  if(result != 0){
    result = 1000 - result;
  }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<stack>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,k,i,j,x,y,xx,yy,vis[100005];
struct ii
{
	int x,y,id;
};
vector<ii> seq;
stack<int> stk;
bool cmp(ii x,ii y)
{
	if (x.x==0)
	{
		if (y.x==0)
		{
			return x.y<y.y;
		}
		return 1;
	}
	if (y.x==0)	return 0;
	if (x.y==m)
	{
		if (y.y==m)
		{
			return x.x<y.x;
		}
		return 1;
	}
	if (y.y==m) return 0;
	if (x.x==n)
	{
		if (y.x==n)
		{
			return x.y>y.y;
		}
		return 1;
	}
	if (y.x==n) return 0;
	if (x.y==0)
	{
		if (y.y==0)
		{
			return x.x>y.x;
		}
		return 1;
	}
	return 0;
}
int main()
{
	cin>>n>>m>>k;
	for (i=1;i<=k;i++)
	{
		cin>>x>>y>>xx>>yy;
		if (x==0||x==n||y==0||y==m) if (xx==0||xx==n||yy==0||yy==m)
		{
			seq.push_back((ii){x,y,i});
			seq.push_back((ii){xx,yy,i});
		}
	}
	sort(seq.begin(),seq.end(),cmp);
	for (i=0;i<seq.size();i++)
	{
		if (!vis[seq[i].id]) {stk.push(seq[i].id);vis[seq[i].id]=1;}
			else {
				if (seq[i].id!=stk.top()) {cout<<"NO";return 0;}
				stk.pop();
			}
	}
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 4980
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n,a; cin>>n>>a;
  int max = 50*n;
  int x[n]; rep(i,n) cin>>x[i];
  cerr << "INPUT DONE" << endl;
  ll dp[n+1][2*max+1];
  rep(i,n+1) rep(j,2*max+1) dp[i][j] = 0;
  cerr << "TABLE INITIALIZED" << endl;
  dp[0][max] = 1;
  reps(i,n){
    rep(j,2*max+1){
      dp[i][j] = dp[i-1][j];
      if(j-x[i-1]+a>=0||j-x[i-1]+a<=2*max){ // x[i]を使うとき
        dp[i][j] += dp[i-1][j-(x[i-1]-a)];
      }
    }
  }
  // rep(i,n+1){
  //   rep(j,2*max+1) cerr << dp[i][j] << ' ';
  //   cerr << endl;
  // }
  cout << dp[n][max]-1 << endl;

  return 0;
}


Measured memory_bytes: 2304
A = list(map(int,input().split(" ")))
B = list(map(int,input().split(" ")))
C = A[1]
for i in range(A[0]-1):
    ii = i + 1
    if B[ii] - B[i] < A[1]:
        C = C + B[ii] - B[i]
    else:
        C = C +A[1]
print(C)

Measured memory_bytes: 25200
using System;

namespace AOJ
{
  class Program
  {
    static void Main(string[] args)
    {
      for(int i=1;i < 10;i++){
        for(int j=1;j < 10;j++){
          Console.WriteLine("{0}x{1}={2}",i,j,i*j);
        }
      }
    }
  }
}

Measured memory_bytes: 5596
n = int(input())
S = input()

# keyは(色、jの位置)のタプル
dp = {}

ans = 0

for i in range(n - 2):
    c_i = S[i]
    for j in range(i + 1, n - 1):
        if S[j] == c_i:
            continue
        c_j = S[j]
        d_ij = j - i
        if (c_i, j) in dp:
            ans += dp[(c_i, j)]
            if j + d_ij < n:
                c_k = S[j + d_ij]
                if c_i != c_j and c_j != c_k and c_k != c_i:
                    ans -= 1
        else:
            tmp = 0
            for k in range(j + 1, n):
                c_k = S[k]
                if c_i != c_j and c_j != c_k and c_k != c_i:
                    tmp += 1
            dp[(c_i, j)] = tmp
            if j + d_ij < n:
                c_k = S[j + d_ij]
                if c_i != c_j and c_j != c_k and c_k != c_i:
                    tmp -= 1
            ans += tmp
print(ans)


Measured memory_bytes: 71616
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
using namespace std;
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;

int parent[N], siz[N];

void make_set(int v){
	parent[v] = v;
}

int find_set(int v){
	while(v!=parent[v])
		v = parent[v];
	return v;
}

void union_sets(int a, int b){
	a = find_set(a);
	b = find_set(b);
	if(a!=b){
		if(siz[a] < siz[b])
			swap(a,b);
		parent[b] = a;
		siz[a] += siz[b];
	}
}

int32_t main() 
{ 
	fast;
	memset(siz, 0, sizeof siz);
	int n,q;
	cin>>n>>q;
	for(int i=0; i<n; i++)
		make_set(i);
	while(q--){
		int t, u, v;
		cin>> t >> u >> v;
		if(t==0)
			union_sets(u,v);
		else{
			if(find_set(u) == find_set(v))
				cout<< 1 <<endl;
			else
				cout<< 0 <<endl;
			}
		}
			
} 



Measured memory_bytes: 6664
/**
 *    author:  yoseph
 *    created: 27.07.2020 11:27:18      
**/
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x;
	cin >> x;
	if (x >= 400 && x <=599)
		cout << 8 << "\n";
	else if (x >= 600 && x <= 799)
		cout << 7 << "\n";
	else if (x >= 800 && x <= 999)
		cout << 6 << "\n";
	else if (x >= 1000 && x <= 1199)
		cout << 5 << "\n";
	else if (x >= 1200 && x <= 1399)
		cout << 4 << "\n";
	else if (x >= 1400 && x <= 1599)
		cout << 3 << "\n";
	else if (x >= 1600 && x <= 1799)
		cout << 2 << "\n";
	else if (x >= 1800 && x <= 1999)
		cout << 1 << "\n";
	return 0;
}


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



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

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

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

typedef long long ll;

using namespace std;



class UnionFind
{
public:
  UnionFind(int n)
  {
    parent=vector<int>(n,-1);
  }
  int root(int a)
  {
    if(parent[a]<0)return a;
    return parent[a]=root(parent[a]);
  }
  int size(int a)
  {
    return -parent[root(a)];
  }
  bool connect(int a,int b)
  {
    int A=root(a);
    int B=root(b);
    if(A==B)return false;
    if(size(A)>size(B))swap(A,B);
    parent[B]+=parent[A];
    parent[A]=B;
    return true;
  }
private:
  vector<int> parent;

};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll>x(n),y(n);
  rep(i,n)cin>>x[i]>>y[i];
  ll res=1e9;
  if(n==1){cout<<1<<endl;return 0;}
  rep(i,n)rep(j,n){
    if(i==j)continue;
    UnionFind uf(n);
    ll p=x[i]-x[j];
    ll q=y[i]-y[j];
    rep(k,n)rep(l,n){
      if(k==l)continue;
      ll tp=x[k]-x[l];
      ll tq=y[k]-y[l];
      if((tp==p&&tq==q)||(tp==-p&&tq==-q))uf.connect(k ,l);
    }
    set<ll>se;
    rep(k,n){
      se.insert(uf.root(k));
    }
    chmin(res,(ll)se.size());

  }
  cout<<res<<endl;


  return 0;

}


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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

#define size(v) v.size()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a;
  int zero = 0, one = 0;
  while (n--) {
    int x;
    cin >> x;
    if (x >= 2) {
      a.push_back(x);
    } else {
      zero += x == 0;
      one += x == 1;
    }
  }
  sort(begin(a), end(a));
  if (zero & 1 and one == 0) {
    int mn = -1;
    if (size(a)) {
      mn = a[0];
      a.erase(begin(a));
    }
    if (size(a) >= 2 and a[size(a) - 2] == 2 and a.back() == 3) {
      swap(a[size(a) - 2], a.back());
    }
    for (auto e : a) {
      cout << e << '\n';
    }
    vector<int> b(zero);
    if (mn != -1) {
      b.push_back(mn);
    }
    next_permutation(begin(b), end(b));
    for (auto e : b) {
      cout << e << '\n';
    }
  } else {
    if (size(a) >= 2 and a[size(a) - 2] == 2 and a.back() == 3) {
      swap(a[size(a) - 2], a.back());
    }
    for (auto e : a) {
      cout << e << '\n';
    }
    vector<int> b(zero + one);
    fill(begin(b) + zero, end(b), 1);
    if (zero & 1) {
      next_permutation(begin(b), end(b));
    }
    for (auto e : b) {
      cout << e << '\n';
    }
  }
}



Measured memory_bytes: 3212
eval'N,K,*A='+`dd`.split*?,
l=[]
N.times{|i|s=0;(i...N).map{|j|l<<s+=A[j]}}
60.downto(0){|k|t=l.select{|e|e>>k&1>0};t.size<K||l=t}
p l.inject:&

Measured memory_bytes: 20336
h, w = map(int, input().split())
n = int(input())
amount = list(map(int, input().split()))
result = [[0 for i in range(w)] for j in range(h)]
down = True
total = 0
curr_col = 0
curr_index = 0
curr_color = 1
while total < w*h:
    if down:
        while curr_index < h and amount[curr_color - 1] > 0:
            result[curr_index][curr_col] = curr_color
            curr_index += 1
            amount[curr_color - 1] -= 1
            total += 1
        if curr_index == h:
            down = False
            curr_col += 1
            curr_index -= 1
        if amount[curr_color - 1] == 0:
            curr_color += 1
    else:
        while curr_index >= 0 and amount[curr_color - 1] > 0:
            result[curr_index][curr_col] = curr_color
            curr_index -= 1
            amount[curr_color - 1] -= 1
            total += 1
        if curr_index == -1:
            down = True
            curr_col += 1
            curr_index = 0
        if amount[curr_color - 1] == 0:
            curr_color += 1
for row in result:
    print(*row)

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N,K;V<int> p(3);
	string s;
	cin >> N >> K >> p[0] >> p[1] >> p[2] >> s;
	int ans = 0;
	auto f = [&](char c){
		if(c == 's') return 0;
		if(c == 'p') return 1;
		return 2;
	};
	rep(r,K){
		int pre = -1;
		for(int i=r;i<N;i+=K){
			int v = f(s[i]);
			if(v == pre){
				pre = -1;
			}else{
				ans += p[v];
				pre = v;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
N, M = map(int,input().split())
List_k = [list(map(int,input().split())) for i in range(M)]
List_p = list(map(int,input().split()))

result = 0

for i in range(2**N):
    tmp = str(format(i, 'b')).zfill(N)
    flag = 1
    for j in range(M):
        count = 0
        for k in range(List_k[j][0]):
            count += int(tmp[List_k[j][k+1]-1])
        if count % 2 != List_p[j]:
            flag = 0
            break
    if flag == 1:
        result += 1
        
print("{}".format(result))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#pragma GCC optimize ("-O2")
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <int,vt <int>,greater <int>>
using namespace std;
using namespace __gnu_pbds; 

//USE AT YOUR OWN RISK
lli tmod(lli x,lli m=mod){return (x%m+m)%m;}

template <typename T> 
void DEBUG_ARR(vt<T> a,char c)
{
	f(i,0,a.size())cout<<tmod(a[i])<<c;
	cout<<"\n";
}

//make sure x is below mod
lli power(lli x, lli y,lli m=mod) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%m; 
        y = y>>1; 
        x = (x*x)%m;  
    }
    if(res<0)
       res+=m; 
    return res; 
}


// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }


int main() 
{ 
    // fact[0]=1;
    // f(i,1,2000001)fact[i]=(i*fact[i-1])%mod;
    
    fastio;
    int t;
    // cin>>t;
    t=1;
    int temp=t;
	while(t--){
        // cout<<"Case #"<<temp-t<<": ";
        lli n,k;cin>>k;
        n=3;
        lli ans[k+1];
        memset(ans,1,sizeof ans);
        lli f[k+1];
        f(i,1,k+1)f[i]=power(k/i,n);
        lli g[k+1];
        fd(i,k,0){
            g[i]=f[i];
            for(lli j=2;j*i<=k;j++)g[i]=(g[i]-g[j*i])%mod;
        }
        lli tans=0;
        f(i,1,k+1)tans=(tans+i*g[i])%mod;
        cout<<tmod(tans);
    }   
    return 0; 	
}


Measured memory_bytes: 3652
def main():

    R, C, K = map(int, input().split())
    a = dict()
    for _ in range(K):
        r, c, v = map(int, input().split())
        a[(r-1, c-1)] = v

    dp = [[[0]*4 for _ in range(C+1)] for _ in range(2)]

    for i in range(R):
        for j in range(C):
            v = max(dp[0][j+1])
            u = 0
            if (i, j) in a: u = a[(i, j)]
            dp[1][j+1][0] = max(dp[1][j+1][0], v)
            dp[1][j+1][1] = max(dp[1][j+1][1], dp[1][j][1], dp[1][j][0] + u,  v + u)
            dp[1][j+1][2] = max(dp[1][j+1][2], dp[1][j][2], dp[1][j][1] + u )
            dp[1][j+1][3] = max(dp[1][j+1][3], dp[1][j][3], dp[1][j][2] + u )
        dp[1], dp[0] = dp[0], dp[1]

    return max(dp[0][C])

if __name__ == '__main__':
    print(main())

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

int main() {
    vector<int> v(3);
    for (int i = 0; i < 3; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    if (v[0]+v[1] == v[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      aa: [i64; n],
    }
    let mut ans = 1 << 50;
    for i in -100..101 {
        let temp = aa.iter().map(|&a| (a-i)*(a-i)).sum();
        ans = min(ans, temp);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
# 入力
h, w = map(int, input().split())
cb = []
# キャンバスを取得
for _i in range(h):
    s = input()
    cb.append(s)

# 処理
# 全ての黒マス('#')に、上下左右に隣接する黒マスが存在すれば可能
# => 上下左右が全て白マス('.')であるような黒マスが存在すれば不可能
def find_impossible_tile(cb, i, j, h, w):
    t = cb[i][j]
    # 黒マスのみをチェックする
    if t == '.':
        return False
    # 上下左右のマスをチェック
    is_black_u = (i > 0 and cb[i-1][j] == '#')
    is_black_d = (i < h - 1 and cb[i+1][j] == '#')
    is_black_l = (j > 0 and cb[i][j-1] == '#')
    is_black_r = (j < w - 1 and cb[i][j+1] == '#')
    # いずれもが黒マスでなければ真でない
    return not (is_black_u or is_black_d or is_black_l or is_black_r)
    
# 各マスをチェック
found = False
for i in range(h):
    for j in range(w):
        if find_impossible_tile(cb, i, j, h, w):
            found = True
            break
    if found:
        break
        
if not found:
    ans = 'Yes'
else:
    ans = 'No'

# 出力
print("{}".format(ans))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
vector<ll> divisor(ll n)
{
  vector<ll> div;
  for (ll i = 1; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      div.push_back(i);
      if (n / i != i)
        div.push_back(n / i);
    }
  }
  sort(div.begin(), div.end());
  return div;
}
int main()
{
ll n ;
cin >> n ;
auto v=divisor(n);
for(auto r:v){
  if(r==1)continue;
  if(r==n)continue;
  ll nn=n;
  while(nn>=r&&nn%r==0){
    nn/=r;
  }
  nn%=r;
  if(nn==1)ans++;
}
auto vv=divisor(n-1);
ans+=vv.size()-1;

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

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Exchange | diff Exchange.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Exchange.cpp && ./a.out

/*
 
 11/9/2019
 
 16:00-
 
 */

LL A,B;
int K;

void solve() {
  LL X[2]={A,B};
  int i=0;
  while(K--) {
    if(X[i]%2==1) --X[i];
    LL a=X[i]/2;
    X[i^1]+=a,X[i]-=a;
    i=i^1;
//    dump(i,X[0],X[1]);
  }
  println("%lld %lld", X[0],X[1]);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>A>>B>>K;
  solve();
  
  return 0;
}


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

int main() {
  
  int A=0, B=0, X=0;
  
  cin >> A >> B >> X;
  
  if(A<=X && X<=A+B) {
    
    cout << "YES" << endl;
  
  } else {
    
    cout << "NO" << endl;
    
  }
  
}


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

int N;
vector<pair<int, int>> edges[100005];
int visited[100005];

void dfs(int p, int dist) {
  if(visited[p]!=-1) return;
  visited[p] = dist%2;
  rep(i, edges[p].size()) {
    dfs(edges[p][i].first, (dist+edges[p][i].second)%2);
  }
}

int main() {
  cin >> N;
  rep(i, N) visited[i] = -1;
  int u,v,w;
  rep(i, N-1) {
    scanf("%d %d %d", &u, &v, &w);
    u--; v--;
    w%=2;
    edges[u].push_back(make_pair(v, w));
    edges[v].push_back(make_pair(u, w));
  }
  dfs(0, 0);
  rep(i, N) {
    printf("%d\n", visited[i]);
  }
  return 0;
}


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

int main() {
    int n, memo = 0; 
    cin >> n;
    vector<int> h(n);
    vector<int> j(n);
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    
    int num = h[n-1];
    for (int i = n - 1; i >= 0; i--)
    {
        if (h[i] - 1 > num)
        {
            cout << "No" << endl;
            return 0;
        }
        num = min(num, h[i]);
        
    }
    

    cout << "Yes" << endl;
}

Measured memory_bytes: 1024
function Main(input){
  input = input.split('\n');
  var NL = input[0].split(' ');
  var S = [];
  for(var i=0;i<Number(NL[0]);i++){
    S[i]=input[i+1];
  }
  var V = S.sort().reduce((a,b)=>a+b);
  console.log(V);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include<iostream>
#include<stdio.h>
using namespace std;

int main()
{
	int r,c,graph[101][101];
	cin >> r >> c;

	for (int i = 0; i < r + 1; i++) {
		for (int j = 0; j < c + 1; j++) {
			graph[i][j] = 0;
		}
	}

	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
				cin >> graph[i][j];
		}
		for (int j = 0; j < c; j++) {
			graph[i][c] += graph[i][j];
		}
	}

	for (int j = 0; j < c+1; j++) {
		for (int i = 0; i < r; i++) {
			graph[r][j] += graph[i][j];
		}
	}

	for (int i = 0; i < r + 1; i++) {
		for (int j = 0; j < c + 1; j++) {
			printf("%d",graph[i][j]);
			if (j != c) printf(" ");
		}
		printf("\n");
	}

	return 0;
}

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

int main(){
  int i;
  int a,b,X,Y;
  string S;
  cin >> S;
  a = 10*(S[0]-'0') + (S[1]-'0');
  b = 10*(S[2]-'0') + (S[3]-'0');
  X = ( 1<=a && a<=12 );
  Y = ( 1<=b && b<=12 );
  
  if(X && Y) cout << "AMBIGUOUS" << endl;
  else if(X && !Y) cout << "MMYY" << endl;
  else if(!X && Y) cout << "YYMM" << endl;
  else cout << "NA" << endl;
  
  //cout << a << b << X << Y;
  
  return 0;
}

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

int main(){
	int N,K;
  cin>>N>>K;
  int h[N];
  rep(i,N){
  	cin>>h[i];
  }
  ll dp[N+10];
  rep(i,N+10){
  	dp[i]=INF;
  }
  dp[0]=0;
  
  
  for(int i=1;i<N;i++){
  	for(int j=K;j>0;j--){
      if(i-j<0)continue;
      
    	dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
  }
  
  //rep(i,N)cout<<dp[i]<<" ";
  cout<< dp[N-1];
  
  
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,a,b,c,s=0,o;
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++)
    {
        for(int j=0;j<=b;j++)
        {
            for(int z=0;z<=c;z++)
			{
                o=i*500+j*100+z*50;
                if(o==x) s++;
                if(o>x) break;
            }
        }
    }
    cout<<s<<endl;
    return 0;
}

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

#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define let const auto
#define USE1(T) template <typename T>
#define USE2(T, U) template <typename T, typename U>
#define I_ inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

USE1(T) using duo = std::pair<T, T>;
USE1(T) using vec = std::vector<T>;
using ll = long long;
// clang-format off
USE2(T,U) I_ bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U) I_ bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int) I_ T in(){T x;std::cin>>x;return x;}
USE1(T=int) I_ vec<T> in(int n){vec<T> v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE1(T) I_ void pr(T&x){std::cout<<x<<'\n';}
USE2(T,...Ts) I_ void pr(T&x,Ts&&...xs){std::cout<<x<<' ';pr(std::forward<Ts>(xs)...);}
I_ int re(){int x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
I_ void wr(int x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
struct IoSetup {
  IoSetup(){
    using namespace std;
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<setprecision(10);
    cerr<<setprecision(10);
  }
} iosetup;
// clang-format on
// }}}
using namespace std;
const int inf = 1001001001;
const ll infll = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  int N = in();
  auto A = in<ll>(N);
  A.pb(0);

  ll ans = 0;
  auto p = A.begin();
  for (; p != A.end();) {
    auto q = std::find(p + 1, A.end(), 0ll);
    ans += std::accumulate(p, q, 0ll) / 2;
    p = q;
  }
  pr(ans);

  return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= 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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int N;
    cin >> N;

    vi a(N);
    REP(i, N) cin >> a[i];

    int ans = 0;
    REP(i, N) {
        if ((i+1)%2 == 1) if (a[i]%2 == 1) ans++;
    }

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


Measured memory_bytes: 3612
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {

	int n,a;
	cin>>n>>a;
	cout<<pow(n,2)-a<<endl;

	return 0;
}



Measured memory_bytes: 256
N,A,B,K = map(int, raw_input().split())


mod=998244353
fact, inv_fact = [1], [1]
fact_tmp = 1
for i in range(1, N+1):
    fact_tmp *= i
    fact_tmp %= mod
    fact.append(fact_tmp)
    inv_fact.append(pow(fact_tmp, mod-2, mod))


def ncr(n,r):
	if n < 0 or r < 0 or n < r:
		return 0
	else:
		return (fact[n] * inv_fact[r] * inv_fact[n-r]) %mod

y=0
ans=0
for x in range(N+1):
	if (K-A*x)%B==0:
		y=(K-A*x)/B
		if x>=0 and y>=0:
			ans+=(ncr(N,x))%mod*(ncr(N,y))%mod

print ans%mod


Measured memory_bytes: 77980