akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vii;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll A[110];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	ll n, x;
	cin >> n >> x;
	for(int i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	sort(A, A + n);
	ll sum = 0;
	int ans = 0;
	int i;
	for(i = 0; i < n; i++)
	{
		// if(sum > x)
			// break;
		sum += A[i];
		if(sum > x)
			break;
		ans += 1;
	}
	// cout << "sum = " << sum <<  " i = " << i << endl;

	if(i == n && sum < x)
	{
		// cout << "Inside this" << endl;;
		ans -= 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int n,e[1001][1001],dp[1001][1001];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=2;i++){
        for(int j=1;j<=n;j++){
            scanf("%d",&e[i][j]);
        }
    }
    for(int i=1;i<=2;i++){
        for(int j=1;j<=n;j++){
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])+e[i][j];
        }
    }
    printf("%d\n",dp[2][n]);
    return 0;
}

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

using ll = long long;
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<ll> a;
    for (int i = 0; i < n; i++) {
        ll ai;
        cin >> ai;
        a.emplace(ai);
    }
    while (m--) {
        ll top = a.top();
        a.pop();
        a.emplace(top / 2);
    }
    ll ans = 0;
    while (!a.empty()) {
        ans += a.top();
        a.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int>num(N, 0);
  for (int i = 0; i < N; i ++) {
    int a;
    cin >> a;
    num[a] ++;
  }
  vector<int>oth(N, 0);
  int kj = 2;
  if (N % 2 == 0) kj = 1;
  if (N % 2) oth[0] = 1;
  while (kj < N) {
    oth[kj] = 2;
    kj += 2;
  }
  for (int i = 0; i < N; i ++) {
    if (num[i] != oth[i]) {
      cout << 0 << endl;
      return 0;
    }
  }
  int n = N / 2;
  long long ans = 1;
  long long mod = 1e9 + 7;
  for (int i = 0; i < n; i ++) {
    ans *= 2;
    ans %= mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i,a,n) for(ll i=a;i<(ll)(n);i++)

int main(){
    int N,M;
    cin>>N>>M;
    vector<int> a(M, 0);
    rep(i, N){
        int K;
        cin>>K;
        rep(j, K){
            int A;
            cin>>A;
            a[A-1]++;
        }
    }

    int count = 0;
    rep(i, M){
        if(a[i] == N) count++;
    }

    cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define PI 3.14159265359

//　解けなかった

int main(){
    int x; cin >> x;
    int result = 1;

    repr(i, 2, 33){
        int tmp = i*i;
        while(tmp <= x){
            result = max(result, tmp);
            tmp *= i;
        }
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 3624
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    
from sys import stdin
imput = stdin.readline
n,m = map(int, input().split())  # 3個の数字の入力を受け取る
uf = UnionFind(n)
#print(uf.parents)

num_list = []
for i in range(m):
    num_list.append(list(map(int,input().split())))
#print(num_list)
for i in range(m):
    #print(num_list[i][0])
    #print(num_list[i][1])
    uf.union(num_list[i][0]-1, num_list[i][1]-1)
    #print(uf.parents)
print(uf.group_count()-1)

Measured memory_bytes: 29308
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    string s,t;
    cin>>s;
    cin>>t;
    s += s;

    if (s.find(t) != string::npos)
        cout << "Yes\n";
    else
        cout<<"No\n";

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  long h, w;
  std::vector<std::string> xs;
  Solver() {
    S002 r;
    r >= h >= w >h>= xs;
  }
  void solve() {
    for(std::string& s : xs) {
      printf("%s\n", s.c_str());
      printf("%s\n", s.c_str());
    }
  }
};
 
int main() {
  for(;;) std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 256
n = int(input())

k = 2
while True:
    t = k * (k - 1) // 2
    if t >= n:
        break
    else:  # t < n
        k += 1

if t == n:
    m = [[None for _ in range(k - 1)] for _ in range(k - 1)]
    v = 1
    for r in range(k - 1):
        for c in range(r + 1):
            m[r][c] = v
            v += 1

    print('Yes')
    print(k)

    for i in range(k - 1):
        s = list()
        for c in range(i + 1):
            s.append(m[i][c])

        cnt = len(s)
        j = 0
        while cnt < k - 1:
            s.append(m[i + 1 + j][i])
            j += 1
            cnt += 1

        s = [k - 1] + s
        print(*s)

    s = list()
    cnt = 0
    j = 0
    while cnt < k - 1:
        s.append(m[j][j])
        j += 1
        cnt += 1

    s = [k - 1] + s
    print(*s)

else:
    print('No')

Measured memory_bytes: 9224
#include <bits/stdc++.h>
#define ll long long
#define lsb(x) (x & -x)

using namespace std;

struct Tower {
    ll cost;
    int w, s;

    bool operator< (const Tower &other) const {
        if((w + s) == (other.w + other.s))
            return s > other.s;
        return (w + s) > (other.w + other.s);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    int n;
    cin >> n;
    vector<Tower> v(n + 1, {0, 0, 0});
    int lim = 0;
    for(int i = 1; i <= n; i ++) {
        cin >> v[i].w >> v[i].s >> v[i].cost;
        lim = max(lim, v[i].s);
    }
    sort(v.begin() + 1, v.end());

    vector<vector<ll>> dp(1 + n, vector<ll> (1 + lim, 0));
    for(int i = 0; i < n; i ++) {
        for(int j = v[i + 1].w; j <= lim; j ++)
            dp[i + 1][min(j - v[i + 1].w, v[i + 1].s)] = max(dp[i + 1][min(j - v[i + 1].w, v[i + 1].s)], dp[i][j] + v[i + 1].cost);
        dp[i + 1][v[i + 1].s] = max(dp[i + 1][v[i + 1].s], v[i + 1].cost);

        for(int j = 0; j <= lim; j ++)
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
    }

    ll ans = 0;
    for(int i = 0; i <= lim; i ++)
        ans = max(ans, dp[n][i]);
    cout << ans;

    return 0;
}


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

#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define v(t) vector<t>
#define vv(t) vector<vector<t>>
#define vn(t,n,val) vector<t>(n,val)
#define vvn(t,r,c,val) vector<vector<t>>(r, vector<t>(c,val))
#define vvv(t) vector<vector<vector<t>>>
#define vvvn(t,l,b,h,val) vector<vector<vector<t>>>(l,vector<vector<t>>(b,vector<t>(h)))

int main() {
	sp;

	////////////////To Remove//////////////
	// freopen("../../input.txt", "r", stdin);
	// freopen("../../output.txt", "w", stdout);
	///////////////////////////////////////


	int n,m;
	cin>>n>>m;
	vector<long long> a(n);
	for(auto& x: a) cin>>x;

	// sort(a.rbegin(), a.rend());

	long long sum = accumulate(a.begin(), a.end(), 0ll);

	// if((m <= n) && (a[m-1] >= sum/(4ll*m)))cout<<"Yes";
	// else cout<<"No";

	int count = 0;
	double limit = sum/(4.0*m);
	for(auto& x: a){
		if(x < limit) count++;
	} 

	if(n-count >= m) cout<<"Yes";
	else cout<<"No"; 

  	return 0;
}

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

int main() {

	string s, t; cin >> s >> t;

	string z = t.substr(0, s.size());


	string ans = "No";

	if (s == z) ans = "Yes";
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    int n, m;
    cin >> n >> m;
    if (n == m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys


INF = sys.maxsize // 10


def determine_dest(n, k, bs):
    source = 0
    path_from_source = [0]
    dist_from_source = [INF] * n
    dist_from_source[source] = 0
    cur = source
    start_cycle_vertex = None
    len_cycle = None
    dist_to_cycle = None
    for _ in range(n + 1):
        ne = bs[cur]
        # print(cur, ne, file=sys.stderr)
        if dist_from_source[ne] >= INF:
            dist_from_source[ne] = dist_from_source[cur] + 1
            path_from_source.append(ne)
            cur = ne
        else:
            # cycle detected
            start_cycle_vertex = ne
            dist_to_cycle = dist_from_source[ne]
            len_cycle = dist_from_source[cur] - dist_to_cycle + 1
            break
    if k < dist_to_cycle:
        return path_from_source[k]
    else:
        rest_k = k - dist_to_cycle
        rem = rest_k % len_cycle
        return path_from_source[dist_to_cycle + rem]
        


def main():
    n, k = (int(z) for z in input().split())
    bs = [int(b) - 1 for b in input().split()]
    res = determine_dest(n, k, bs) + 1
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 32196
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = pi*r*r;
        double length = 2*pi*r;
        System.out.printf("%f %f",area,length);
        sc.close();
    }
}


Measured memory_bytes: 28276
N= input()
 
n= int(N)
first = 9
sencond = 900
thrid = 90000
sum =0
if  len(N) ==1 :
    sum = n
elif len(N) ==2 :
    sum = first 
elif len(N) ==3 :
    sum = first + (n- 99)
elif len(N) ==4 :
    sum = first + sencond
elif len(N) ==5 :
    sum = first +  sencond + (n- 9999) 
elif len(N) ==6 :
    sum = first +  sencond + thrid
print(sum)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
long double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998626034825342117;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
int main() {
    int N; cin >> N;
    string S; cin >> S;
    vector<int>red(N);
    vector<int>white(N);
    rep(i, N) {
        if (S.at(i) == 'R')red[i]++;
        else white[i]++;
        if (i != 0) {
            red[i] += red[i - 1];
            white[i] += white[i - 1];
        }
    }
    vector<int>ans(N + 1);
    rep(i, N)ans[i] = max(white[i] , red[N - 1] - red[i]);
    ans[N] = red[N - 1];
    sort(ans.begin(), ans.end());
    cout << ans[0] << endl;
}

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

using namespace std;
const int N = 1e5 + 3;
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif
	int n;
	scanf("%d", &n);
	printf("%lld\n", 1LL * n * (n - 1) / 2);
	return 0;
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O #-}

import Control.Monad
import Control.Monad.ST
import Data.List
import Control.Monad.Trans.State.Strict
import Data.Char (isSpace)
import Data.Maybe (fromJust,fromMaybe)
import qualified Data.ByteString.Lazy.Char8 as B

import Data.Array.ST
import Data.Array.Unboxed
type Dist s = STUArray s (Int,Int) Int

type Parser a = StateT B.ByteString Maybe a

parseInt :: Parser Int
parseInt = StateT (B.readInt . B.dropWhile isSpace)

parseInt2 :: Parser (Int,Int)
parseInt2 = liftM2 (,) parseInt parseInt

parseInt3 :: Parser (Int,Int,Int)
parseInt3 = liftM3 (,,) parseInt parseInt parseInt

parse :: Parser ((Int,Int), [(Int,Int,Int)])
parse = do
    (n,m)<-parseInt2
    rs<-replicateM m parseInt3
    return ((n,m),rs)

main=do
    ((n,m),rs)<-fromJust.evalStateT parse <$> B.getContents
    let da = wf n rs :: UArray (Int,Int) Int
    print $ length $ filter (\(a,b,c)-> da! (a,b) < c) rs
--
wf::Int->[(Int,Int,Int)]->UArray (Int,Int) Int
wf n rs = runST $ do
    d <- newArray ((1,1),(n,n)) (maxBound`div`2) :: ST s (STUArray s (Int,Int) Int)
    forM_ [1..n] $ \v -> writeArray d (v,v) 0
    forM_ rs $ \(u,v,l) -> writeArray d (u,v) l >> writeArray d (v,u) l
    forM_ [(k,i,j)|k<-[1..n],i<-[1..n],j<-[1..n]] $ \(k,i,j) -> do
        dc <- readArray d (i,j)
        dn <- (+) <$> readArray d (i,k) <*> readArray d (k,j)
        when (dc > dn) $ writeArray d (i,j) dn
    freeze d


Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int H,W,N;

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

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

    int mini=a[0],maxval=0,cnt=0;

    for (int i = 1; i < N; ++i) {
        if(a[i]<mini) mini=a[i];
        if(a[i]-mini>maxval){
            maxval=a[i]-mini;
            cnt=1;
        }else if(a[i]-mini==maxval){
            cnt++;
        }
    }
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<set>
#include<algorithm>

using namespace std;

//Tµ½¢¯ÀmAT·f[^n
int n,m;

int m_data[200][2];		//Tµ½¢¯ÀÌÀWf[^
int dxdy[200][2];		//¶[Ì¯©ç©½Ï»Ê
int n_data[1000][2];	//Ê^ÉÊé¯

set<pair<int,int> > star;

int main_x, main_y;		//¶[Ì¯ÌÀWçµ¢
int ans_x,ans_y;		//¦ÆÈé¶[Ì¯

int main()
{
	for(;;){
		int temp;
		int t_x, t_y;
		bool notFind = false;
		cin >> m;
		
		if(m == 0){
			break;
		}
		
		//Tµ½¢¯À
		for(int i = 0; i < m; i++){
			cin >> m_data[i][0];
			cin >> m_data[i][1];
		}
		
		cin >> n;
		
		//T·éó
		for(int i = 0; i < n; i++){
	
			cin >> n_data[i][0];		//x
			cin >> n_data[i][1];		//y
			star.insert(make_pair(n_data[i][0],n_data[i][1]));
		}
		 
		//Tµ½¢¯ÀÌêÔ¶Ì¯ð©Â¯é
		
		temp = m_data[0][0];
		main_x = m_data[0][0];
		main_y = m_data[0][1];
		
		for(int i = 0; i < m; i++){
			if(m_data[i][0] < temp){
				temp = main_x = m_data[i][0];
				main_y = m_data[i][1];
			}
		}
		
		//»ê¼êÌ¯ÉÎ·éÏ»ÊðZo
		for(int i = 0; i < m; i++){
			dxdy[i][0] = -1*(main_x - m_data[i][0]);
			dxdy[i][1] = -1*(main_y - m_data[i][1]);
		}
		
		//·×ÄÌ¯ÉÎµÄÏ»Êð©Ä¢­
		for(int i = 0;i < n;i++){
			for(int j = 0; j < m; j++){
				t_x = n_data[i][0] + dxdy[j][0];
				t_y = n_data[i][1] + dxdy[j][1];
				if(star.count(make_pair(t_x,t_y)) == 0){
					notFind = true;
					break;
				}
			}
			if(notFind == false){
				ans_x = n_data[i][0];
				ans_y = n_data[i][1];
			}
			notFind = false; 
		}
		printf("%d %d\n",ans_x-main_x,ans_y-main_y);
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
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;
}
const int MOD = 1000000007;

int main() {
    long long A, B, K;
    cin >> A >> B >> K;
    if(A >= K) {
        cout << A - K << " " << B << endl;
    } else if(A + B >= K) {
        cout << 0 << " " << A + B - K << endl;
    } else {
        cout << 0 << " " << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
	struct point{
		double x,y;
	}P1,P2,Q,R,O;
	double m;

	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&P1.x,&P1.y,&P2.x,&P2.y,&Q.x,&Q.y) != EOF){
		if(P1.x != P2.x && P1.y != P2.y){
			m = (P2.y-P1.y)/(P2.x-P1.x);
			O.x = (m/(m*m+1.0))*(m*P1.x+Q.x/m+Q.y-P1.y);
			O.y = m*(O.x-P1.x)+P1.y;
			R.x = 2*O.x-Q.x;
			R.y = 2*O.y-Q.y;
		}else if(P1.x != P2.x && P1.y == P2.y){
			R.x = Q.x;
			R.y = 2*P1.y-Q.y;
		}else if(P1.x == P2.x && P1.y != P2.y){
			R.x = 2*P1.x-Q.x;
			R.y = Q.y;
		}else{
			R.x = 2*P1.x-Q.x;
			R.y = 2*P1.y-Q.y;
		}
		printf("%lf %lf\n",R.x,R.y);
	}

	return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define loopf(i,a,b) for(int i = a;i < b;i++)
#define loopb(i,a,b) for(int i = a;i >= b;i--)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
  


int32_t main()
{
    fast

   int test=1;
   //cin>>test;

  while(test--)
  {

  int n,m,ans=0;
  cin>>n>>m;
  if(m>=2)
  {
    ans+=(m*(m-1))/2;
  }
  if(n>=2)ans+=(n*(n-1))/2;

  cout<<ans;
  //while loop ending 
  }


  return 0;
  }

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <cstdio>
#include <list>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
string strin(){string s;cin>>s;return s;}
char chin(){char c;cin>>c;return c;}
ll lin() {ll x;scanf("%lld",&x);return x;}


int main(){
    int n=in(),tmp=0,cnt=0;
    rep(i,n){
        int x=in();
        if(tmp<=x)cnt++;
        tmp=max(tmp,x);
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from itertools import chain

# import numpy as np
# from itertools import combinations as comb
# from bisect import bisect_left, bisect_right, insort_left, insort_right
# from collections import Counter

MOD = 1000000007  # type: int
OFFSET = 10 ** 100


def k_in_n(k, n):
    """0〜n までの数からちょうど k 個の数を選ぶ時の最大最小"""
    minimum = (k * (k - 1)) // 2
    maximum = (k * (2 * n - k + 1)) // 2
    return (minimum, maximum)


def solve(N: int, K: int):
    keep = None  # まだ加算されていない範囲
    answer = 0
    for k in range(K, N + 2):
        if keep is None:
            keep = k_in_n(k, N)
        else:
            minmax = k_in_n(k, N)
            if minmax[0] + OFFSET <= keep[1]:
                keep[0] -= OFFSET
                keep[1] = minimum[1]
            else:
                answer = (answer + keep[1] - keep[0] + 1) % MOD
                keep = minmax

    if keep is not None:
        answer = (answer + keep[1] - keep[0] + 1) % MOD
    return answer


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # N, K = map(int, input().split())
    # N, K = input().strip()
    # N, K = int(input())
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    answer = solve(N, K)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9240
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int MOD = 1e9+7;

int main() {
  int n;
  cin >> n;
  vector<pair<int, bool>> a(n*2);
  rep(i, n*2) {
    cin >> a[i].first;
    a[i].second = (i < n ? 1 : 0);
  }
  sort(a.begin(), a.end());
  int rem = (a[0].second ? 1 : -1);
  ll ans = 1;
  for (int i = 1; i < n*2; i++) {
    if (a[i].second) {
      if (rem >= 0)
        rem++;
      else {
        (ans *= -rem) %= MOD;
        rem++;
      }
    } else {
      if (rem <= 0)
        rem--;
      else {
        (ans *= rem) %= MOD;
        rem--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>

using namespace std;

int main(){
  string S;
  string key = "keyence", tmp;
  bool flag = false;
  cin >> S;
  if (S == key) flag = true;
  else{
    for (int i=0; i<S.size(); i++){
      for (int j=i; j<S.size() + 1; j++){
		tmp = S.substr(0, i) + S.substr(j, S.size() - j);
        if (tmp == key){
			flag = true;
          	break;
        }
      }
      if (flag) break;
    }
  }
  
  cout << (flag ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  int N = (int)S.size();
  int kj = N / 2;
  int ans = 0;
  for (int i = 0; i < N; i ++) {
    if (S[i] == 'p') ans ++;
  }
  cout << kj - ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>

#define ll long long

using namespace std;

/*   Every goose should go to prison!!!!!
     ██▀▀▄  ██     ██
▄███▀██░░░▌ ██     ██
█████████████████████████████
    ▐██░░░▐ ██     ██
    ▌██░░░░▐██     ██
█████████████████████████████
   ▐░██░▐▒▒▒██▒▒▒▀▀██
   ▐░██░▐▄▒▒██▒▒▒▒▒██▄
█████████████████████████████
     ██▄▄▄▄▄██▄▄▄▄▄██▄▄▄▀▄
     ██    ▌██▌▌   ██
█████████████████████████████
     ██  ▄▄▌██▌▌   ██ */

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll h, n;
    cin >> h >> n;
    ll a = 0;
    for(ll i = 0; i < n; ++i) {
        ll t;
        cin >> t;
        a += t;
    }
    cout << ((a >= h)? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll n,ans;
	string s;

	cin >> s;

	if (s[2] == s[3] && s[4] == s[5])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <climits>
#include <math.h>
#include <utility>
using namespace std;

typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) a.begin(),a.end()

int main() {
	vs s(3);
	rep(i, 3)cin >> s.at(i);
	rep(i, 3) {
		cout << char(s.at(i).at(0) - 32);
	}
	cout << endl;
	return 0;
}


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

int main(){
    int h, w;
    while(true){
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(i % 2 == 0 && j % 2 == 0 || i % 2 == 1 && j % 2 == 1){
                    cout << "#";
                }
                else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
  int n,m,p[100000+1],y[100000+1];
  vector<int> num_list[100000];
  scanf("%d%d",&n,&m);
 for(int i=0;i<m;i++){
   scanf("%d%d",&p[i],&y[i]);
   num_list[p[i]-1].push_back(y[i]);
 }
 for(int i=0;i<n;i++){
   sort(num_list[i].begin(),num_list[i].end());
 }
 for(int i=0;i<m;i++){
   printf("%06d",p[i]);
   int tmp =1+ lower_bound(num_list[p[i]-1].begin(),num_list[p[i]-1].end(),y[i])-num_list[p[i]-1].begin();
   printf("%06d\n",tmp);
 }
}


Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s=="SAT")
    {
        cout<<"1"<<endl;
    } else if(s=="SUN")
    {
        cout<<"7"<<endl;
    }else  if(s=="MON")
    {
        cout<<"6"<<endl;
    } else if(s=="TUE")
    {
        cout<<"5"<<endl;
    } else if(s=="WED")
    {
        cout<<"4"<<endl;
    } else if(s=="THU")
    {
        cout<<"3"<<endl;
    } else if(s=="FRI")
    {
        cout<<"2"<<endl;
    }
}


Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val m = 10
  val f = Array.fill(n * m)(sc.nextInt())
  val p = Array.fill(n * (m+1))(sc.nextInt())

  var ans = Long.MinValue
  for (s <- 1 until 1 << m) {
    var ansSub = 0L
    for (i <- 0 until n) {
      val count = (0 until m).count(j => ((s >> j) & f(i*m + j)) == 1)
      ansSub += p(i*(m+1) + count)
    }

    ans = ans.max(ansSub)
  }

  println(ans)
}

Measured memory_bytes: 58004
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int x = sc.nextInt();
      	String ans ="Yes";
      	if(500*k < x){
          ans = "No";
        }
		System.out.println(ans);
		sc.close();
	}
}

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

int main(){
  ll d,g;
  cin>>d>>g;
  vector<ll> p(d),c(d),comp(d);
  rep(i,d){
    cin>>p[i]>>c[i];
    comp[i]=100*(i+1)*p[i]+c[i];
  }
  ll ans=1e9;
  for(ll bit=0;bit<(1<<d);bit++){
    ll sum=0;
    ll num=0;
    ll redi=-1;
    for(ll i=0;i<d;i++){
      if(bit & (1<<i)){
        sum+=comp[i];
        num+=p[i];
      }else{
        redi=i;
      }
    }
    if(sum>=g){
      ans=min(ans,num);
      continue;
    }
    if(redi!=-1){
      ll need=(g-sum+(redi+1)*100-1)/((redi+1)*100);
      if(need<=p[redi]){
        ans=min(ans,num+need);
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cassert>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
 
using namespace std;
 
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int a;
  string s;
  cin >> a >> s;

  if (a < 3200) {
    cout << "red" << endl;
  } else {
    cout << s << endl;
  }
 
  return 0;
}


Measured memory_bytes: 888
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int H,W,N; cin >> H >> W >> N;
	vector<vector<int>> X(H);
	rep(i,N) {
		int x,y; cin >> x >> y;
		--x; --y;
		X[x].emplace_back(y);
	}
	int right = -1;
	rep(i,H) {
		bool check = false;
		for (auto j : X[i]) {
			if (j <= right) {
				cout << i << ln;
				return 0;
			}
			if (j == right+1) check = true;
		}
		if (!check) right++;
	}

	cout << H << ln;
}


Measured memory_bytes: 11304
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REP(i,a,b) for(ll i=(a);i<(b);++i)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main() {
    ll N,C=1;
    string S;
    cin >> N;
    cin >> S;
    REP(i,1,N){
        if(S[i]!=S[i-1]){
            C++;
        }
    }
    cout << C<< endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    int n;
    cin>>n;
    vector<int> as(n);
    rep(i, n) cin>>as[i];

    int q;
    cin>>q;
    rep(i, q) {
        int k;
        cin>>k;
        cout<<distance(as.begin(), lower_bound(as.begin(), as.end(), k))<<endl;
    }
}


Measured memory_bytes: 3272
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    ll n,k;cin >> n >>k;
    vl v(n);
    ll ans=inf;
    rep(i,n)cin >> v[i];
    rep(i,n-k+1){
        if(v[i]<=0&&v[i+k-1]>=0){
            ll a=min(abs(v[i]),v[i+k-1]);
            ll b=max(abs(v[i]),v[i+k-1]);
            ans=min(a*2+b,ans);
        }
        if(v[i+k-1]<0){
            ans=min(ans,abs(v[i]));
        }
        if(v[i]>0){
            ans=min(ans,v[i+k-1]);
        }
    }
    cout << ans <<endl;
}

Measured memory_bytes: 1024
#include <iostream> 
#include <iomanip> 
#include <vector> 
#include <algorithm> 
#include <numeric> 
#include <functional> 
#include <cmath> 
#include <queue> 
#include <stack> 

#define Ford(i,a,b) for (int i=(a);i<(b);i++) 
#define For(i,n) Ford(i,0,n) 
typedef long long ll; 

using namespace std;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int out = min(b/a , c);
  cout<<out<<endl;
  return 0;
}

Measured memory_bytes: 256
import           Control.Monad (replicateM)
import           Data.Function (on)
import           Data.List     (groupBy, sortBy, foldl', sortOn)
import           Data.Ord      (comparing)

import Data.IntMap.Strict (IntMap, alter, singleton, toAscList)
import qualified Data.IntMap.Strict as M (empty, insert)

main :: IO ()
main = do
  [_n, m] <- map read . words <$> getLine
  pys <- replicateM m $ (\[p, y] -> (p, y)) . map read . words <$> getLine
  mapM_ putStrLn $ f pys

type Prefecture = Int
type Year = Int
type City = Int

f :: [(Prefecture, Year)] -> [String]
f =
  map (\(i, p, j) -> pad6 (show p) ++ pad6 (show j)) .
  sortOn (\(i, p, j) -> i) .
  concatMap (zipWith (\j (i, (p, y)) -> (i, p, j)) [1..]) .
  groupBy ((==) `on` (\(i, (p, y)) -> p)) .
  sortOn snd .
  zip [1..]


-- f = undefined . fmap (map (\(j, (y, i)) -> (j, i)) . zip [1..] . toAscList) . makeMap

-- makeMap :: [(Prefecture, Year)] -> IntMap (IntMap City)
-- makeMap =
--   foldl' (\mp (i, (p, y)) -> alter (Just . maybe (singleton y i) (M.insert y i)) p mp) M.empty .
--   zip [1..]

{-
C022_scrambled 以降 TLE
f =
  map (\(i, p, j) -> pad6 (show p) ++ pad6 (show j)) .
  sortBy (comparing $ \(i, p, j) -> i) .
  concatMap (zipWith (\j (i, (p, y)) -> (i, p, j)) [1..]) .
  groupBy ((==) `on` (\(i, (p, y)) -> p)) .
  sortBy (comparing snd) .
  zip [1..]
-}

pad6 :: String -> String
pad6 = reverse . take 6 . (++ repeat '0') . reverse


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

int main() {
    int k, s, ans = 0;
    cin >> k >> s;
    rep(i, k + 1) rep(j, k + 1) {
        if(0 <= s - i - j && s - i - j <= k) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
s=0
if N==1:
    print(0)
else:
    for i in range(N-1):
        if A[i+1]<A[i]:
            s=s+A[i]-A[i+1]
            A[i+1]=A[i]
    print(s)

Measured memory_bytes: 32112
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n, t; cin >> n >> t;
    int ans = INF;
    list(i,n){
        int c, T; cin >> c >> T;
        if(T <= t) ans = min(c, ans);
    }

    if(ans == INF) cout << "TLE\n";
    else cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>
#include <map>
#include <list>
#include <cstdlib>

using namespace std;

typedef pair<int, int> P;

#define MAX 20

int main()
{
	while(1) {
		int as[MAX+1];
		multiset<int> msa;
		int a, L;
		bool end;
		int ans_j, ans_i, ans_a;

		scanf("%d %d", &a, &L);
		if(!a && !L) break;

		as[0] = a;
		for(int i = 1; i <= MAX; i++) {
			msa.clear();
			int min = 0, max = 0;
			for(int dig = 0; dig < L; dig++) {
				msa.insert(a % 10);
				a /= 10;
			}

			for(multiset<int>::iterator it = msa.begin(); it != msa.end(); it++) {
				min *= 10;
				min += *it;
			}
			for(multiset<int>::reverse_iterator rit = msa.rbegin(); rit != msa.rend(); rit++) {
				max *= 10;
				max += *rit;
			}
			a = max - min;

			end = false;
			for(int j = 0; j < i; j++) {
				if(as[j] == a) {
					end = true;
					ans_j = j;
					ans_i = i;
					ans_a = a;
					break;
				}
			}
			if(end) break;
			else as[i] = a;
		}
		printf("%d %d %d\n", ans_j, ans_a, ans_i - ans_j);
	}

	return 0;
}

Measured memory_bytes: 1188
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[N];
        long sum = 0;
        PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
            sum += A[i];
            pq.add(A[i]);
        }
        sc.close();

        for(int i = 0; i < M; i++){
            int a = pq.poll();
            sum -= a;
            sum += a/2;
            pq.add(a/2);
        }

        System.out.println(sum);
    }
}

Measured memory_bytes: 62856
inp = input().split(" ")
N = int(inp[0])
K = int(inp[1])

keys = list(range(1, 100001))
arr = {i:0 for i in keys}

for i in range(N):
	inp = input().split(" ")
	a = int(inp[0])
	b = int(inp[1])
	arr[a] += b

for i in keys:
	K -= arr[i]
	if K <= 0:
		print(i)
		break

Measured memory_bytes: 16236
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  int D[N][2];
  for(int i=0;i<N;i++){
    cin >> D[i][0] >> D[i][1];
  }
  bool ok=false;
  int j=0;
  for(int i=0;i<N;i++){
    if(D[i][0]==D[i][1]){
      j++;
    }else{
      j=0;
    }
    if(j>=3) ok=true;
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

int a[15][15], c[15];

signed main()
{
	IO_OP;
	
	int n, m, x, mn = INF;
	cin >> n >> m >> x;
	for(int i = 0; i < n; i++) {
		cin >> c[i];
		for(int j = 0; j < m; j++)
			cin >> a[i][j];
	}
	for(int i = 0; i < (1 << n); i++) {
		vi v(m);
		int cost = 0;
		for(int j = 0; j < n; j++) {
			if(i >> j & 1) {
				for(int k = 0; k < m; k++)
					v[k] += a[j][k];
				cost += c[j];
			}
		}
		if(*min_element(ALL(v)) >= x) {
			mn = min(mn, cost);
		}
	}
	if(mn == INF) mn = -1;
	cout << mn << endl;
	
}





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

typedef long long ll;

main()
{
    int n;
    cin >> n;
    if(n >= 400 && n <= 599){
        cout << "8";
    }
    else if(n >= 600 && n <= 799){
        cout << "7";
    }
    else if(n >= 800 && n <= 999){
        cout << "6";
    }
    else if(n >= 1000 && n <= 1199){
        cout << "5";
    }
    else if(n >= 1200 && n <= 1399){
        cout << "4";
    }
    else if(n >= 1400 && n <= 1599){
        cout << "3";
    }
    else if(n >= 1600 && n <= 1799){
        cout << "2";
    }
    else{
        cout << "1";
    }



}





///promy_pompom
//hello world


Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			String A = in.next();
			String B = in.next();
			String C = in.next();
			char turn = 'a';
			int countA = 0;
			int countB = 0;
			int countC = 0;
			while(true) {
				if(turn == 'a') {
					if(countA == A.length()) {
						out.println('A');
						break;
					}
					turn = A.charAt(countA);
					countA++;
				}else if(turn == 'b') {
					if(countB == B.length()) {
						out.println('B');
						break;
					}
					turn = B.charAt(countB);
					countB++;
				}else{
					if(countC == C.length()) {
						out.println('C');
						break;
					}
					turn = C.charAt(countC);
					countC++;
				}
			}
		}
	}
	
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, a, b;
    string s;

    cin >> n >> a >> b >> s;

    int al = 0, fo = 0;
    REP(i, n)
    {
        bool res = false;

        if (s[i] == 'c')
        {
            res = false;
        }

        if (s[i] == 'b')
        {
            res = fo < b && al < a + b;
            fo += res;
            al += res;
        }

        if (s[i] == 'a')
        {
            res = al < a + b;
            al += res;
        }

        cout << (res ? "Yes" : "No") << endl;
    }

    return 0;
}

Measured memory_bytes: 848