akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,h;
    cin>>a>>b>>h;
    cout<<((a+b)*h)/2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vector<int> A, B;
string S, T;
int X, t;
void input() {
  int x, y, z;
  cin >> X >> t;
  ;
}
void solve() {
  cout << max(0LL, X - t) << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include "stdio.h"

int main()
{

  int i,j,a,b;

  scanf("%d %d\n",&a,&b);

  int s[a][b],t[b],u[a];

  for ( i = 0; i < a; i++)
  {
    for (j = 0; j <b ; j++)
    {
        if (j!=b-1)
        {
          scanf("%d ", &s[i][j]);
        }

        if (j==b-1)
        {
          scanf("%d\n", &s[i][j]);
        }
    }
  }

for (i = 0; i < b; i++)
{
  scanf("%d\n",&t[i]);
}

for (i = 0; i < a; i++)
{
  u[i]=0;
}


for (i = 0; i < a; i++)
{
  for (j = 0; j < b; j++)
  {
  u[i]+=s[i][j]*t[j];
  }
  printf("%d\n",u[i] );
}





  return 0;
}



Measured memory_bytes: 2104
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline


class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)

    def add(self, i, x=1):
        i += 1
        while i <= self.n:
            self.data[i] += x
            i += i & -i

    def get_sum(self, i):
        i += 1
        x = 0
        while i > 0:
            x += self.data[i]
            i -= i & -i
        return x

    # Return sum for [l, r)
    def get_sum_range(self, l, r):
        return self.get_sum(r - 1) - self.get_sum(l - 1)


def main():
    N, Q = map(int, readline().split())
    C = list(map(int, readline().split()))
    LR = map(int, read().split())

    prev = [-1] * (N + 1)
    ps = [[] for _ in range(N)]
    for i, c in enumerate(C):
        if prev[c] != -1:
            ps[prev[c]].append(i)
        prev[c] = i

    qs = [[] for _ in range(N)]
    for i, (l, r) in enumerate(zip(*[iter(LR)] * 2)):
        qs[l - 1].append((r - 1, i))

    ans = [0] * Q
    bit = BIT(N)

    for l in range(N - 1, -1, -1):
        for r in ps[l]:
            bit.add(r)
        for r, i in qs[l]:
            ans[i] = (r - l + 1) - bit.get_sum(r)

    print('\n'.join(map(str, ans)), sep='\n')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 292920
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;
 
int main(){    
  int L;
  cin >> L;
  // long long l=ceil(L/3);
  float l = (float)L/3;

  cout << fixed << setprecision(10) << l*l*l << endl;
  /*
  if(L%3 == 0){
    cout << l*l*l << endl;
    return 0;
  }
  if(L%3 == 1){
    cout << l*(l+1)*l << endl;
    return 0;
  }
  if(L%3 == 2){
    cout << l*(l+1)*(l+1) << endl;
    return 0;
  }
  */
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // std::cout << std::setprecision(10) << std::fixed;
    int n,k,i,j;
    cin>>n>>k;
    int a[n+1];
    int dp[k+1];
    for(i=0;i<=k;i++)
        dp[i]=0;
    for(i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(i=1;i<=k;i++)
    {
        // cout<<"i is"<<i<<endl;
        for(j=1;j<=n;j++)
        {
            // cout<<"j is"<<j<<endl;
            if(a[j]<=i)
            {
                // cout<<"in first if"<<endl;
                if(dp[i-a[j]]==0)
                {
                    dp[i]=1;
                    break;
                }
            }
            else
                break;
        }
        // cout<<"dp"<<i<<" is "<<dp[i]<<endl;
    }
    if(dp[k]==1)
        cout<<"First";
    else
        cout<<"Second";
}

Measured memory_bytes: 640
#include<stdio.h>
#define N 100

int main(void) {
	int n, x, count = 1, l[N], d[N];
	d[0] = 0;
	scanf("%d %d", &n, &x);
	for (int i = 0; i < n; i++) {
		scanf("%d", &l[i]);
	}
	for (int i = 1; i <= n; i++) {
		d[i] = d[i - 1] + l[i - 1];
		if (d[i] <= x)count++;
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	long long ans;
	cin >> ans;
	ans--;
	int minP =2;
	for(int i =0; i < N-1; i++) {
		int a;
		cin >> a;
		if(a == minP) {
			minP++;
			continue;
		}
		if(a < minP) continue;
		ans +=(a-1)/minP;
	}
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int  n;
    cin>>n;
    int a[n];
    int counter=0;
for(int i=1;i<=n;i++){
    cin>>a[i];
}
for(int i=1;i<=n-2;i++){
    if((a[i+1]>a[i]&& a[i+1]<a[i+2])||(a[i+1]<a[i] && a[i+1]>a[i+2])){
        counter=counter+1;
    }
}
cout<<counter<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
typedef long long ll;

int A,B,K;

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

    cin>>A>>B>>K;
    vector<int> CD;
    FORD(i,min(A,B),1)if( A%i==0 && B%i==0 )CD.pb(i);
    cout<<CD[K-1]<<'\n';

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 2e9;
const ll inf64 = 7e18l;
string s;
struct node {
	vector<int> cnt;
	node(): cnt(26) {}
};
vector<node> tree;
void work(int t) {
	for (int c = 0; c < 26; ++c) {
		tree[t].cnt[c] = tree[2 * t].cnt[c] + tree[2 * t + 1].cnt[c];
	}
}
void build(int t, int nl, int nr) {
	if (nl == nr) {
		tree[t].cnt[s[nl] - 'a'] = 1;
		return; 
	}
	int mid = nl + (nr - nl) / 2;
	build(2 * t, nl, mid);
	build(2 * t + 1, mid + 1, nr);
	work(t);
}
void update(int t, int nl, int nr, int ind, char prev, char val) {
	if (nl > ind || nr < ind) {
		return;
	}
	if (nl == nr) {
		--tree[t].cnt[prev - 'a'];
		++tree[t].cnt[val - 'a'];
		return;
	}
	int mid = nl + (nr - nl) / 2;
	update(2 * t, nl, mid, ind, prev, val);
	update(2 * t + 1, mid + 1, nr, ind, prev, val);
	work(t);
}
vector<int> query(int t, int nl, int nr, int l, int r) {
	if (nl > r || nr < l) {
		return vector<int>(26);
	}
	if (nl >= l && nr <= r) {
		return tree[t].cnt;
	}
	int mid = nl + (nr - nl) / 2;
	vector<int> q1 = query(2 * t, nl, mid, l, r);
	vector<int> q2 = query(2 * t + 1, mid + 1, nr, l, r);
	for (int c = 0; c < 26; ++c) {
		q1[c] += q2[c];
	}
	return q1;
}
	

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	cin >> s;
	tree.resize(4 * n);
	build(1, 0, n - 1);
	int q;
	cin >> q;
	while (q--) {
		int type;
		cin >> type;
		if (type == 1) {
			int ind;
			char c;
			cin >> ind >> c;
			--ind;
			char prev = s[ind];
			update(1, 0, n - 1, ind, prev, c);
			s[ind] = c;
		} else {
			int l, r;
			cin >> l >> r;
			--l;
			--r;
			vector<int> cnt = query(1, 0, n - 1, l, r);
			int ans = 0;
			for (int val : cnt) {
				if (val != 0) {
					++ans;
				}
			}
			cout << ans << '\n';
		}
	}
 	return 0;
}


Measured memory_bytes: 266396
N = input()
T = map(int, raw_input().split())
V = map(int, raw_input().split())

VL = [V[i] for i in xrange(N)]
VL.append(0)
for i in xrange(N-1, -1, -1):
    VL[i] = min(VL[i], VL[i+1] + T[i])

v1 = 0
v2 = 0
ans = 0

for i in xrange(N):
    t1 = 0
    v2 = v1

    hi = T[i] * 1.0
    lo = 0
    for _ in xrange(100):
        mid = (hi + lo) / 2
        tt = t1 + mid
        vv = v2 + mid
        if tt <= T[i] and vv <= V[i] and vv - (T[i] - tt) <= VL[i+1]:
            lo = mid
        else:
            hi = mid

    t1 += hi
    v2 = v1 + t1
    ans += (v1 + v2) / 2.0 * t1

    hi = (T[i] - t1) * 1.0
    lo = 0
    for _ in xrange(100):
        mid = (hi + lo) / 2
        tt = mid
        if t1 + tt <= T[i] and v2 - (T[i] - t1 - tt) < VL[i+1]:
            lo = mid
        else:
            hi = mid

    t2 = hi
    ans += v2 * t2

    v3 = v2 - (T[i] - t1 - t2)
    ans += (v2 + v3) / 2.0 * (T[i] - t1 - t2)

    v1 = v3

print "%.09f" % ans


Measured memory_bytes: 33004
#pragma region template 1.2

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a) \
    REP(i, (a).size()) { cout << (a[i]) << (i == (a).size() - 1 ? "\n" : " "); }
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

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

    string s = to_string(N);
    if (s[0] == '7' or s[1] == '7' or s[2] == '7')
    {
        OUT("Yes");
    }
    else
    {
        OUT("No");
    }
}

Measured memory_bytes: 3692
parseInt(x) = parse(Int,x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  N,M = readline() |> split |> parseArray
  A = readline() |> split |> parseArray

  sort!(A)
  D = eye(Int,M,2)
  l=1
  for line in readlines()
  	B,C = line |> split |> parseArray
    D[l,1] = B
    D[l,2] = C
	l += 1  
  end
  #print("C")
  LIS::Array{Int64} = []
  #print("C")
  bkFlag = 0
  D = sortrows(D, by=x->x[2],rev=true)
  for x in 1:l-1
    for y in 1:D[x,1]      
      if length(LIS) > N
        bkFlag = 1
        break    
      end
      push!(LIS,D[x,2])
    end
    if bkFlag == 1
      #print("break")
      break
    end
  end
  ans = 0
  #print("\naaaaaaaaaaaaaaaaa\n")
  
  #print(length(LIS))
  for x in 1:min(length(A),length(LIS))
    #print(A[x],LIS[x],x,"\n")
    if A[x] < LIS[x]
      #print("if")
      A[x] = LIS[x]
    end
  end

  print(sum(A))
end
main()


Measured memory_bytes: 165736
package main

import "fmt"

func main() {
	var b, ret string
	fmt.Scan(&b)
	switch b {
	case "A":
		ret = "T"
	case "T":
		ret = "A"
	case "C":
		ret = "G"
	case "G":
		ret = "C"
	}
	fmt.Println(ret)

}

Measured memory_bytes: 512
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;


int main() {
	int n;
	string s;
	cin >> n >> s ;
	int i = 0;
	int ans = 0;
	int ans1 = 0;
	int ans2 = 0;
	while (i < n && s.at(i) == '.') i++;
	while (i < n) {
		if (s.at(i) == '.') {
			ans1 += 1;
			if (ans1 > ans2) {
				ans += ans2;
				ans1 = 0;
				ans2 = 0;
			}
		}
		else {
			ans2 += 1;
		}
		i++;
	}
	cout << ans+min(ans1,ans2) << endl;
}

Measured memory_bytes: 640
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [[0] * m for i in range(n)]
for i in range(n):
    a[i] = list(map(int, input().split()))

count = 0
for i in range(n):
    for j in range(m):
        a[i][j] *= b[j]
    if sum(a[i]) + c > 0:
        count += 1

print(count)


Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))
end = sorted(a)[1]

for i in range(end+1, 0, -1):
  x = 0
  for j in a:
    if j % i != 0:
      x += 1
    if x >= 2:
      break
  if x <= 1:
    print(i)
    break

Measured memory_bytes: 14076
#include <bits/stdc++.h>
using namespace std;
int arr[3];
pair<int,int> lowest2()
{
    vector<int> bb;
    bb.push_back(arr[0]);
    bb.push_back(arr[1]);
    bb.push_back(arr[2]);
    sort(bb.begin(),bb.end());
    return {bb[0],bb[1]};
}
int main()
{
    cin >> arr[0] >> arr[1] >> arr[2];
    int f = 0;
    while(true)
    {
        if(arr[0] == arr[1] && arr[1] == arr[2])
            break;
        f++;
        pair<int,int> lo = lowest2();
        if(max(arr[0],max(arr[1],arr[2])) - lo.second >= 1)
        {
            for(int i = 0;i < 3;i++)
            {
                if(lo.second == arr[i])
                {
                    arr[i]++;
                    break;
                }
            }
            for(int i = 0;i < 3;i++)
            {
                if(lo.first == arr[i])
                {
                    arr[i]++;
                    break;
                }
            }
        } else {
            for(int i = 0;i < 3;i++)
            {
                if(lo.first == arr[i])
                {
                    arr[i] += 2;
                    break;
                }
            }
        }
    }
    cout << f;
    return 0;
}


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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素


int main(){
    int n,k;
    cin>>n>>k;
    ll ans=1;
    while(n>=k) {
        n/=k;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import fractions
A, B, C, D = list(map(int, input().split()))


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


a = (A-1) // C
b = B // C
c = (A-1) // D
d = B // D
x = lcm(C, D)
e = (A-1) // x
f = B // x

print(B - A + 1 - ((b - a) + (d - c) - (f - e)))


Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int tmp = 10;
    int ans = 9;
    if (N < tmp) {
         cout << N << endl;
         return 0;
    }
    int digit = 10;
    rep(i, 100) {
        tmp = digit - 1;
        rep(j, 9) {
            if (N < tmp) {
                cout << ans-1 << endl;
                return 0;
            }
            tmp += digit;
            ans++;
            //dump(tmp);
        }
        digit *= 10;
    }


    return 0;
}


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

using namespace std;

#define INF 1<<15

int main(){
	int N;
	int dp[100001];
	int opt[26];
	string w[100001];
	
	scanf("%d",&N);
	for(int i=0;i<N;i++) cin >> w[i];
	for(int i=0;i<N+1;i++) dp[i]=INF;
	dp[0]=0;
	for(int i=0;i<26;i++) opt[i]=INF;//alphabet's number
	
	for(int i=1;i<N+1;i++){
		int c=w[i-1].front() - 'a';
		opt[c]=min(opt[c],dp[i-1]);
		dp[i]=opt[c]+1;
	}
	printf("%d\n",dp[N]);
}


Measured memory_bytes: 10156
N = int(input())
X = [0]*N
Y = [0]*N
H = [0]*N
for i in range(N):
    X[i],Y[i],H[i] = map(int, input().split())

# print(N, X, Y, H)

point = []
for n in range(N):
    if H[n] != 0:
        point = [X[n], Y[n], H[n]]
        break

ans = []
same = True
for i in range(101):
    for j in range(101):
        same = True
        height = point[2] + abs(point[0] - i) + abs(point[1] - j)
        for n in range(N):
            x = X[n]
            y = Y[n]
            h = H[n]
            candidate = max(height - abs(x - i) - abs(y - j), 0)
            if candidate != h:
                same = False
                break
        if same:
            ans = [i, j, height]
            break
    if same:
        break

if same:
    print(*ans)


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

using namespace std;
using ll = long long;

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

    int d;
    cin >> d;
    vector<int> c(26), t(d);
    vector<vector<int>> s(d, vector<int>(26));
    for(int i = 0; i < 26; ++i) cin >> c[i];
    for(int j = 0; j < d; ++j)
        for(int i = 0; i < 26; ++i) cin >> s[j][i];
    for(int j = 0; j < d; ++j) {
        cin >> t[j];
        t[j]--;
    }

    int score = 0;
    vector<vector<int>> blank(d, vector<int>(26, 1));

    for(int j = 0; j < d; ++j) {
        score += s[j][t[j]];
        for(int i = 0; i < 26; ++i) {
            if(i == t[j]) {
                blank[j][i] = 0;
            } else {
                if(j != 0) blank[j][i] = blank[j - 1][i] + 1;
                score -= c[i] * blank[j][i];
            }
        }
    }

    int m;
    cin >> m;
    int d_, q, dt;
    for(int k = 0; k < m; ++k) {
        cin >> d_ >> q;
        d_--;
        q--;

        score -= s[d_][t[d_]];
        score += s[d_][q];

        if(d_ != 0) blank[d_][t[d_]] = blank[d_ - 1][t[d_]] + 1;
        else blank[d_][t[d_]] = 1;
        score -= c[t[d_]] * blank[d_][t[d_]];
        dt = d_ + 1;
        while(t[dt] != t[d_] && dt < d) {
            score += c[t[d_]] * blank[dt][t[d_]];
            blank[dt][t[d_]] = blank[dt - 1][t[d_]] + 1;
            score -= c[t[d_]] * blank[dt][t[d_]];
            dt++;
        }

        score += c[q] * blank[d_][q];
        blank[d_][q] = 0;
        dt = d_ + 1;
        while(t[dt] != q && dt < d) {
            score += c[q] * blank[dt][q];
            blank[dt][q] = blank[dt - 1][q] + 1;
            score -= c[q] * blank[dt][q];
            dt++;
        }

        t[d_] = q;

        // for(int j = 0; j < d; ++j) printf("%d ", t[j] + 1);
        // printf("\n");
        // for(int j = 0; j < d; ++j) {
        //     for(int i = 0; i < 26; ++i) {
        //         printf("%d ", blank[j][i]);
        //     }
        //     printf("\n");
        // }
        // printf("\n");

        printf("%d\n", score);
    }

    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=(n)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b);
#define mins(a,b) a=min(a,b);
#define max3(a,b,c) max(a,max(b,c)) 
#define mix3(a,b,c) mix(a,mix(b,c))
#define pairi pair<int,int>

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;

int main(){
   
    int n;cin>>n;
    vd p(n+1);repa(i,1,n+1)cin>>p[i];
    
    vvd dp(n+1,vd(n+1,0));
    dp[0][0]=1.0;

    rep(i,n)rep(j,n){
        dp[i+1][j] += dp[i][j]*(1-p[i+1]);
        dp[i+1][j+1] += dp[i][j]*p[i+1];
    }

    // rep(i,n+1)rep(j,n+1)cerr<<"dp["<<i<<"]["<<j<<"] = "<<dp[i][j]<<endl;

    double ans=0;
    repa(i,(n+1)/2,n+1)ans+=dp[n][i];

    printf("%.10f\n",ans);
    
    return 0;
}

Measured memory_bytes: 70656
s = [int(i) for i in input()]

x0 = 100*s[0]+10*s[1]+s[2]
if x0 > 753:
    sa = x0 - 753
else:
    sa = 753 - x0

min = sa

for i in range(1, len(s)-2):
    x = 100*s[i]+10*s[i+1]+s[i+2]
    if x > 753:
        sa = x - 753
    else:
        sa = 753 - x
    if sa < min:
        min = sa

print(min)

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

int main(){
   int n;
   cin>>n;
   long long a[n+1];
   for(int i=0;i<n;i++) cin>>a[i];
   long long pmax=a[0];
   long long ans=0;
   for(int i=1;i<n;i++){
    if(a[i]>pmax){
        pmax=a[i];
    }else if(a[i]<pmax){
        ans+=pmax-a[i];
    }
   }
   cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5152
def scoring():
    n = int(raw_input())
    if n is 0:
        return
    scores = [int(raw_input()) for _ in range(n)]
    scores.sort()
    if len(scores) < 2:
        return 0
    score = sum(scores[1:-1]) / (n-2)
    return score

while True:
    score = scoring()
    if score is None:
        break
    print score
        

Measured memory_bytes: 6344
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

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

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

    ofstream w_file("abc145_f.txt", ios::out);

    ll N, K;
    cin >> N >> K;
    vector<ll> H;
    H.push_back(0);
    Rep (i, N) {
        ll h;
        cin >> h;
        H.push_back(h);
    }

    mat dp(N+1, vec(N+1, inf));
    dp[0][0] = 0;

    Rep (i, N) {
        Rep (j, N) {
            for (ll k = j+1; k <= N; k++) {
                chmin(dp[i+1][k], dp[i][j] + max((ll)0, H[k]-H[j]));
            }
        }
    }

    Rep (i, N+1) {
        Rep (j, N+1) {
            w_file << dp[i][j] << " ";
        }
        w_file << "\n";
    }

    ll ans = inf;
    Rep (i, N+1) {
        chmin(ans, dp[N-K][i]);
    }

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

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

#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int, int>;

const int MAX = 300005;

int op(int a, int b) { return max(a, b); }

int e() { return (int)(-1); }

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    segtree<int, op, e> seg(MAX);

    rep(i, N) {
        int x = seg.prod(max(0, A[i] - K), min(MAX, A[i] + K + 1));
        seg.set(A[i], max({seg.get(A[i]), x + 1, 1}));
    }

    cout << seg.all_prod() << endl;
}

Measured memory_bytes: 9616
import numpy as np
import sys
buf = sys.stdin.buffer

H,W = map(int,buf.readline().split())
# 周りに壁を、0,1化、壁を0で持つ
grid = np.zeros((H+2,W+2),dtype=np.bool)
grid[1:-1,1:] = (np.frombuffer(buf.read(H*(W+1)),dtype='S1') == b'.').reshape((H,W+1))

# x軸方向の集計
def F(transpose):
  x = grid
  if transpose:
    x = (x.T).copy()
  x = np.ravel(x) # to 1D array
  L = len(x)
  
  left_zero = -np.arange(L) # 左の壁のindexの-1倍
  left_zero[x] = 0
  np.minimum.accumulate(left_zero, out=left_zero)
  
  right_zero = np.arange(L) # 逆順ソートした上で左の壁のindex
  right_zero[x[::-1]] = 0
  np.maximum.accumulate(right_zero, out=right_zero)
  
  y = left_zero
  y += L-right_zero[::-1]
  
  return y.reshape(grid.T.shape).T if transpose else y.reshape(grid.shape)
  
answer = (F(False) + F(True)).max()-5
print(answer)


Measured memory_bytes: 145468
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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(void) {
    char c;
    cin >> c;

    printf("%c\n", c + 1);
    
    return 0;
}


Measured memory_bytes: 256
/**
 * author  : UshanGhosh
 * created : 2020-08-27 14:45:30
**/ 

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

#define    ll      long long
#define    pii     pair<int,int>
#define    vii     vector<int>
#define    vcc     vector<char>
#define    pll     pair<long long, long long>
#define    mem     memset
#define    sof     sizeof
#define    co1     __builtin_popcountll
#define    PB      push_back
#define    UB      upper_bound
#define    LB      lower_bound
#define    MP      make_pair
#define    TS      to_string
#define    F       first
#define    S       second
#define    pi      acos(-1)
#define    mod     1e9+7
#define    inf     1e18
#define    endl    '\n'

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    while(t--){
        long long a,b,c,d,e,f,i,j,k,m,n,o,x,y;
        cin>>a>>b>>c;
        a = abs(a);
        ll ans;
        if((a/c)>b){
            ans = a-c*b;
        } 
        else{
            b-=(a/c);
            if(b%2==0) ans = a%c;
            else ans = c-a%c;
        }
        cout<<ans<<"\n";
    }
}

Measured memory_bytes: 3644
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
using namespace std;
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb(X) push_back(X)
#define x first
#define y second
#define all(x) (x).begin(), (x).end()
#define bbb 0;
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
typedef long long ll;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef pair <int,int> P;
typedef pair <int,P> PP;
typedef pair <P,int> P2;
//ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int MAXN = 100007;
 
struct UF
{
	int par[MAXN],rank[MAXN];
	
	void init(int n)
	{
		for(int i=0;i<n;i++)
		{
			par[i]=i;
			rank[i]=1;
		}
	}
	int find(int x)
	{
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}
	void unite(int x,int y)
	{
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y])
		{
			par[x]=y;
		}
		else
		{
			par[y]=x;
			if(rank[x]==rank[y]) rank[x]++;
		}
	}
	bool same(int x,int y)
	{
		return find(x)==find(y);
	}
};
UF uf;
vector <PP> edge;
P2 p1[MAXN];
P2 p2[MAXN];
 
int main()
{
	INIT
	int n;
	cin>>n;
	rep (i,0,n)
	{
		int a, b;
		cin >> a >> b;
		p1[i]=P2(P(a,b),i);
		p2[i]=P2(P(b,a),i);
	}
	sort(p1,p1+n);
	sort(p2,p2+n);
	for(int i=0;i+1<n;i++)
	{
		P p=p1[i].first,q=p1[i+1].first;
		int ct=min(abs(p.first-q.first),abs(p.second-q.second));
		edge.push_back(PP(ct,P(p1[i].second,p1[i+1].second)));
	}
	for(int i=0;i+1<n;i++)
	{
		P p=p2[i].first,q=p2[i+1].first;
		int ct=min(abs(p.first-q.first),abs(p.second-q.second));
		edge.push_back(PP(ct,P(p2[i].second,p2[i+1].second)));
	}
	sort(edge.begin(),edge.end());
	ll Ans=0;
	uf.init(n+2);
	for(int i=0;i<edge.size();i++)
	{
		P p=edge[i].second;
		if(!uf.same(p.first,p.second))
		{
			uf.unite(p.first,p.second);
			Ans+=edge[i].first;
		}
	}
	cout<<Ans;
	return bbb;
}


Measured memory_bytes: 7412
def get_reward(x, r, s, p):
    if x == "r":
        return p
    if x == "s":
        return r
    if x == "p":
        return s


def rotate(x):
    if x == "r":
        return "s"
    if x == "s":
        return "p"
    if x == "p":
        return "r"


N, K = [int(i) for i in input().split(" ")]
R, S, P = [int(i) for i in input().split(" ")]
T = list(input())

total = 0

for i, x in enumerate(T):
    if i <= K-1:
        total += get_reward(x, R, S, P)
        continue
    if T[i-K] != x:
        total += get_reward(x, R, S, P)
        continue
    if N > i+K and T[i+K] == x:
        T[i] = rotate(x)


print(total)


Measured memory_bytes: 49648
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 300300;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int n, m;
int tag[maxn];
inline void add(int a,int b) {
	const int N = std::max(a, b) + 1;
	++ tag[1], --tag[std::abs(b - a) + 1];
	for(int i = std::abs(b - a) + 1;i < N;) {
		const int A = a / i, B = b / i;
		int nxt = std::min<int>(i <= a ? a / A + 1 : N, i <= b ? b / B + 1 : N);
		if(A != B) ++ tag[i], -- tag[nxt];
		i = nxt;
	}
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	rep(i, 1, n) {
		int l, r;
		l = m, r = m;
		cin >> l >> r;
		add(l - 1, r);
	}
	rep(i, 1, m) {
		cout << (tag[i] += tag[i - 1]) << '\n';
	}
	std::cerr << double(clock()) / CLOCKS_PER_SEC << '\n';
}


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

int main(){
  
  int K, S;
  cin >> K >> S;
  
  int count = 0;
  for (int i = 0; i < min(K, S) + 1; i++){
    for (int j = 0; j < min(K, S) + 1; j++){
      int k = S - (i + j);
      if ((0 <= k) && (k <= K))
        count++;
    }
  }
  
  cout << count << endl;
  
}



Measured memory_bytes: 256
N,K=map(int,input().split())
G=[[] for i in range(N)]
a=[0 for i in range(N-1)]
b=[0 for i in range(N-1)]
for i in range(N-1):
    a[i],b[i]=map(int,input().split())
    a[i]-=1;b[i]-=1
    G[a[i]].append(b[i])
    G[b[i]].append(a[i])
d=[[-1 for i in range(N)] for j in range(N)]
for i in range(N):
    q=[i]
    d[i][i]=0
    while(len(q)>0):
        r=q[-1];q.pop()
        for p in G[r]:
            if d[i][p]!=-1:
                continue
            d[i][p]=d[i][r]+1
            q.append(p)
#dia=max([max([d[i][j] for i in range(N)]) for j in range(N)])
if K%2==0:
    t=[[d[i][j] for i in range(N)] for j in range(N)]
    D=K//2
    ans=[0 for i in range(N)]
    for i in range(N):
        for j in range(N):
            if t[i][j]>D:
                ans[i]+=1
    print(min(ans))
else:
    t=[[min([d[a[i]][j],d[b[i]][j]]) for j in range(N)] for i in range(N-1)]
    ans=[0 for i in range(N-1)]
    D=(K-1)//2
    for i in range(N-1):
        for j in range(N):
            if t[i][j]>D:
                ans[i]+=1
    print(min(ans))

Measured memory_bytes: 118744
from copy import copy
from collections import deque
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()
first = deque(L)
count = 0
for i in range(N-2):
    l = first.pop()
    second = copy(first)
    for j in range(1,N-i-1):
        m = second.pop()
        n = len(second) - bisect.bisect_right(second,l-m)
        if n > 0:
            count += n
        else:
            break
print(count)

Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000'000'007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

ll n,m;

struct edge{
    ll to,cost;
};

vector<vector<edge> > vec;
vector<ll> f;

void dfs(ll c,ll p,ll cos){
    if(f[c] > cos) f[c] = cos;
    rep(i,vec[c].size()){
        if(vec[c][i].to != p){
            if(cos + vec[c][i].cost < f[vec[c][i].to]){
                dfs(vec[c][i].to,c,cos+vec[c][i].cost);
            }
        }
    }
}

int main(){
    
    cin >> n >> m;
    vec.resize(n);
    f.resize(n);
    int a,b,c;
    edge e1,e2;
    rep(i,m){
        cin >> a >> b >> c;
        a--;b--;
        e1.to = b;e1.cost = c;
        e2.to = a;e2.cost = c;
        vec[a].pb(e1);
        vec[b].pb(e2);
    }

    ll ans = 0;

    rep(i,n){
        rep(j,n) f[j] = INF;
        dfs(i,-1,0);
        rep(j,vec[i].size()){
            if(vec[i][j].cost > f[vec[i][j].to]){
                ans++;
            }
        }
    }
    cout << ans/2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1e9 + 7;

ll H, W, A;
ll res;

int main(){
	cin >> H >> W;
	for (ll i = 0; i != H; ++i) {
		for (ll j = 0; j != W; ++j) {
			cin >> A;
			res += A * (i + 1)*(j + 1)*(W - j)*(H - i);
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3108
# -*- coding: utf-8 -*-

# input
A = input()
B = input()
C = input()

# solve
turn = 'a'
while True:
    if turn == 'a':
        if A:
            turn = A[0]
            A = A[1:]
        else:
            ans = 'A'
            break
    elif turn == 'b':
        if B:
            turn = B[0]
            B = B[1:]
        else:
            ans = 'B'
            break
    else:
        if C:
            turn = C[0]
            C = C[1:]
        else:
            ans = 'C'
            break

# output
print(ans)


Measured memory_bytes: 3064
/* 
   AOJ 1194
   Vampire

*/

#include<stdio.h>
#include<math.h>
#define MAX_X 21
int hights_m[MAX_X];
int hights_p[MAX_X];

double solve(double r)
{
  int i, prev = 0;
  double ans = (double)((hights_p[0] < hights_m[20])? hights_p[0] : hights_m[20] );
  double x, y, l;
  for(i = 1; i < MAX_X; i++)
    {

      prev = hights_m[i - 1];
      if(MAX_X - i > r -1 )
	continue;
      y = (double)((prev > hights_m[i])? hights_m[i]: prev);
      x = (double)(i - MAX_X);
      l = y - sqrt(r * r - x * x) + r;
      ans = (double)((l < ans)? l: ans);
    }
  prev = hights_m[MAX_X - 1];
  for(i = 0; i < MAX_X - 1; i++)
    {
      if(i > r - 1)
	break;
      y = (double)((prev > hights_p[i])? hights_p[i]: prev);
      x = (double)i;
      l = y - sqrt(r * r - x * x) + r;
      ans = (double)((l < ans)? l: ans);
      prev = hights_p[i];
    }
  return ans;
}
  


int main(void)
{
  int n, r, i, j, right, left, hight;

  while(scanf("%d %d", &r, &n), n != 0 || r != 0)
    {
      for(i = 0; i < MAX_X; i++)
	{
	  hights_m[i] = 0;
	  hights_p[i] = 0;
	}
      for(i = 0; i < n; i++)
	{
	  scanf("%d %d %d", &left, &right, &hight);
	  for(j = left; j < right; j++)
	    {
	      if(j < 0)
		if(hights_m[MAX_X + j] < hight)
		  hights_m[MAX_X + j] = hight;
		else
		  ;
	      else
		if(hights_p[j] < hight)
		  hights_p[j] = hight;
	    }
	}
      printf("%.4lf\n", solve((double)r));
    }
  return 0;
}

Measured memory_bytes: 640
import sys


def main():
    x, y, z, k = [int(n) for n in input().split()]
    va = sorted([int(n) for n in input().split()], reverse=True)
    vb = sorted([int(n) for n in input().split()], reverse=True)
    xy = min(x*y, k)
    vab = (sorted([a + b for a in va for b in vb], reverse=True))[:xy]
    vc = sorted([int(n) for n in input().split()], reverse=True)
    xyz = min(x*y*z, k)
    print(*((sorted([ab + c for ab in vab for c in vc], reverse=True))[:xyz]), sep="\n")


main()


Measured memory_bytes: 142460
def make_divisors(n):
    lower_divisors = []
    upper_divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)

    upper_divisors.reverse()
    return lower_divisors + upper_divisors

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())

ans = []
used_list = []

def solve(n, used_list):
  if n == 1:
    return len(used_list)
  div_list = make_divisors(n)[1:]
  for i in div_list:
    z_kouho = factorization(i)
    if i not in used_list and len(z_kouho) == 1:
      used_list.append(i)
      return solve(int(n/i),used_list)
  
  return len(used_list)
      
print(solve(n, used_list))

Measured memory_bytes: 9540
n = int(input())
W = list(map(int,input().split(' ')))
Wtot = sum(W)
a0 = 0
i = 0
while i < len(W):
    a_tmp=a0
    a0 += W[i]
    if a0 > Wtot/2:
        ans = min(abs(a0*2-Wtot),abs(a_tmp*2-Wtot))
        break
    else:
        i += 1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


int a,b,c,d[100005] = {},n,m;
string s,t;

int main(){

    cin >> n >> a >> b;

    PS(min(a,b));

    if(n - (a+b) > 0){
        P(0);
    }else{
        P(-(n - (a+b)));
    }
   
    
    
	return  0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

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

int main(){

    int n, k;
    cin >> n >> k;

    int ans = 0;
    while (n != 0)
    {
        n /= k;
        ans ++;
    }
    cout << ans << endl;

}

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

using namespace std;

# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }


#define M_DEBUG if (1)

/******************************************************************************
	Main
******************************************************************************/
int main()
{
	string s="";
	cin >> s;
	assert(s.length() == 6);

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


Measured memory_bytes: 256
#include <cstdio>
#include <string>

// class List
// {
//     int* data_;
//     int begin_;
//     int end_;
// public:
//     List()
//     {
//         data_  = new int[2000000];
//         begin_ = 1999999;
//         end_   = 1999999;
//     }
//     void Insert(int X)
//     {
//         --begin_;
//         data_[begin_] = X;
//     }
//     void Delete(int X)
//     {
//         int Index = end_;
//         for(int i = begin_; i < end_; ++i){
//             if(X == data_[i]){
//                 Index = i;
//                 break;
//             }
//         }
//         if(Index == end_) return;
//         for(int i = Index; i < end_; ++i){
//             data_[i] = data_[i+1];
//         }
//         end_--;
//     }
//     void DeleteFirst()
//     {
//         begin_++;
//     }
//     void DeleteLast()
//     {
//         end_--;
//     }
//     void Show()const
//     {
//         printf("%d", data_[begin_]);
//         for(int i = begin_ + 1; i < end_; ++i){
//             printf(" %d", data_[i]);
//         }
//         printf("\n");
//     }
// };

int main()
{
    // List list;
    int* data_ = new int[2000001];
    int begin_ = 2000000;
    int end_   = 2000000;

    int n;
    std::scanf("%d\n", &n);
    char com[1024];
    for(int i = 0; i < n; ++i){
        std::fgets(com, 1024, stdin);
        if(com[6] == 'F'){
            // list.DeleteFirst();
            begin_++;
        }else
        if(com[6] == 'L'){
            // list.DeleteLast();
            end_--;
        }else{
            int v = 0;
            for(int j = 7; com[j] >= '0' && com[j] <= '9'; ++j){
                v = v*10 + (com[j] - '0');
            }
            if(com[0] == 'i'){
                // list.Insert(v);
                --begin_;
                data_[begin_] = v;
            }else{
                // list.Delete(v);
                int Index = end_;
                for(int i = begin_; i < end_; ++i){
                    if(v == data_[i]){
                        Index = i;
                        break;
                    }
                }
                if(Index == end_) continue;
                for(int i = Index; i < end_; ++i){
                    data_[i] = data_[i+1];
                }
                end_--;
            }
        }
    }
    // list.Show();
    printf("%d", data_[begin_]);
    for(int i = begin_ + 1; i < end_; ++i){
        printf(" %d", data_[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 6644
#include<bits/stdc++.h>
#define all(x) x.begin(),x.end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD=1e9+7;
const ll LINF=1e18;
const int INF=0x3f3f3f3f;
const int MAXN=100050;

ll ans,k;
vector<ll>G[MAXN];
void dfs(ll now,ll fa,ll dep,ll us){
	int sum=0;
	ans*=(k-min(dep,2ll)-us);
	ans%=MOD;
	for(ll i=0;i<G[now].size();i++){
		if(G[now][i]==fa)continue;
		
		dfs(G[now][i],now,dep+1,sum);
		sum++;
	}
}
void solve(int T){
	ll n,u,v;
	scanf("%lld %lld",&n,&k);
	ans=1;
	for(int i=1;i<n;i++){
		scanf("%lld %lld",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1ll,0,0,0);
	printf("%lld\n",ans);
}
signed main(){
	int t=1;
	//scanf("%lld",&t); 
	for(int i=1;i<=t;i++){
		solve(i);
	}
}

Measured memory_bytes: 13872