akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

int main() {
  ll K, A, B;
  cin >> K >> A >> B;
  
  if(K < A+1){
    cout << 1 + K << endl;
    return 0;
  }

  if(B-A-2<=0){
    cout << 1 + K << endl;
    return 0;
  }

  if((K-A+1)%2 == 0){
    cout << A + (K-A+1)/2 * (B-A) << endl;
    return 0;
  }

  cout << A + 1 + (K-A)/2 * (B-A) << endl;
}


Measured memory_bytes: 256
import bisect

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

BC = [0] * n  # BC[i] = B[i]以上の全てのBを使って作れるBCの組み合わせ
pairs = 0
for i in range(n-1, -1, -1):
    b = B[i]
    idx = bisect.bisect_right(C, b)
    pairs += n - idx
    BC[i] = pairs

ans = 0
for a in A:
    idx = bisect.bisect_right(B, a)
    if idx == n:
        continue
    ans += BC[idx]

print(ans)


Measured memory_bytes: 23360
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int s_int(string s){
    return atoi(s.c_str());
}
vector<int> v(4,0);
bool ok = 0;
void solve(int now, int cnt, vector<bool> ope){
    if(cnt == 4){
        if(now == 7 && ok == 0){
            rep(i,4){
                if(i < 3){
                    if(ope[i] == 0) cout << v[i] << "+";
                    else cout << v[i] << "-";
                }else cout << v[i] << "=7" << endl;
            }
            ok = 1;
            return ;
        }
    }else{
        vector<bool> ope1,ope2;
        ope1 = ope;
        ope2 = ope;
        ope1.push_back(0);
        ope2.push_back(1);
        solve(now + v[cnt], cnt + 1, ope1);
        solve(now - v[cnt], cnt + 1, ope2);
    }
}
int main(){
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    rep(i,4) v[i] = s_int(s.substr(i,1));
    vector<bool> ope;
    solve(v[0],1, ope);
    return 0;
}

Measured memory_bytes: 3636
class Shop:
    price = 0
    number = 0

    def __init__(self,price,number):
        self.price = price
        self.number = number


n,m = [int(i) for i in input().split()]

shopList = []

for i in range(n) :
    a,b = [int(j) for j in input().split()]
    shopList.append(Shop(a,b))

shopList.sort(key = lambda x: x.price)

cost = 0
total = 0

for i in shopList:
    #print([i.price, i.number])
    if(total + i.number < m):
        cost += i.price * i.number
        total += i.number
    else:
        cost += i.price * (m - total)
        break;

print(cost)


Measured memory_bytes: 28300
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <random>
#include <string.h>//文字列の代入に使う                                                                                                                                                                         
#include <bits/stdc++.h>//piの利用で必要(M_PI)                                                                                                                                                                  
#include <algorithm>


int main() {


  int N;
  int temp;//bnを入れる変数                                                                                                                                                                                     
  //  vector<vector<int>> A(3, vector<int>(3));                                                                                                                                                                 
  //  vector<vector<int>> Bingo(3, vector<int>(3, 0));//あたりの位置を記録                                                                                                                                      
  std::vector<int> A(9);
  std::vector<int> Bingo(9, 0);//あたりの位置を記録                                                                                                                                                             
  for(int i = 0; i < 9; i++) {
      std::cin >> A.at(i);
  }

  std::cin >> N;
  for(int i = 0; i < N; i++) {
    std::cin >> temp;
    auto itr = std::find(A.begin(), A.end(), temp);
    if(itr != A.end()) {
      //配列のインデックスを取得するために"itr"を変換                                                                                                                                                           
      int wanted_index = std::distance(A.begin(), itr);
      Bingo.at(wanted_index) = 1;
    }
  }
  if(Bingo.at(0) == 1 && Bingo.at(1) == 1 && Bingo.at(2) == 1) std::cout << "Yes" << std::endl;
  else if(Bingo.at(0) == 1 && Bingo.at(1) == 1 && Bingo.at(2) == 1) std::cout << "Yes" << std::endl;
  else if(Bingo.at(3) == 1 && Bingo.at(4) == 1 && Bingo.at(5) == 1) std::cout << "Yes" << std::endl;
  else if(Bingo.at(6) == 1 && Bingo.at(7) == 1 && Bingo.at(8) == 1) std::cout << "Yes" << std::endl;
  else if(Bingo.at(0) == 1 && Bingo.at(3) == 1 && Bingo.at(6) == 1) std::cout << "Yes" << std::endl;
  else if(Bingo.at(1) == 1 && Bingo.at(4) == 1 && Bingo.at(7) == 1) std::cout << "Yes" << std::endl;
  else if(Bingo.at(2) == 1 && Bingo.at(5) == 1 && Bingo.at(8) == 1) std::cout << "Yes" << std::endl;
  else if(Bingo.at(0) == 1 && Bingo.at(4) == 1 && Bingo.at(8) == 1) std::cout << "Yes" << std::endl;
  else if(Bingo.at(2) == 1 && Bingo.at(4) == 1 && Bingo.at(6) == 1) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.length()-1]==b[0]&&b[b.length()-1]==c[0])cout<<"YES";
    else cout<<"NO";
 
    return 0;
}

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

int n;
#define MAX 502

int c[MAX];
int s[MAX];
int f[MAX];

int main() {
	cin >> n;
	for (int i = 0; i+1 < n; i++) {
		scanf("%d%d%d", &c[i], &s[i], &f[i]);
	}
	for (int i = 0; i < n; i++) {
		int star = s[i];
		for (int j = i; j+1 < n; j++) {
			star = max(star, s[j]);
			star += f[j] - 1;
			star /= f[j];
			star *= f[j];
			star += c[j];
		}
		cout << star << endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[][] ab = Enumerable.Repeat(0, nm[1]).Select(_ => Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray()).ToArray();
        int res = 0;
        for (int i = 0; i < ab.Length; i++)
        {
            UnionFind uf = new UnionFind(nm[0]);
            for (int j = 0; j < ab.Length; j++)
            {
                if (i != j) uf.Union(ab[j][0], ab[j][1]);
            }
            if (uf.AllParents().Length != 1) res++;
        }
        Console.WriteLine(res);
    }
}

class UnionFind
{
    int[] data;
    public UnionFind(int count)
    {
        data = Enumerable.Range(0, count).ToArray();
    }
    public void Union(int x, int y)
    {
        int xp = Parent(x);
        int yp = Parent(y);
        if (xp != yp)
        {
            data[yp] = xp;
        }
    }
    public bool IsSameGroup(int x, int y) => Parent(x) == Parent(y);
    public int[] AllParents() => data.Where((x, y) => x == y).ToArray();
    public int Parent(int x)
    {
        form(x);
        return data[x];
    }
    private void form(int x)
    {
        while (data[x] != data[data[x]])
        {
            data[x] = data[data[x]];
        }
    }
}


Measured memory_bytes: 13524
#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>;
using vpl=vector<pl>;
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};
const ll ddx[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const ll ddy[8]={ 1, 0,-1, 0, 1,-1, 1,-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;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll h,w,k;cin >> h >>w >>k;
    vvl v(h,vl(w));
    rep(i,h){
        rep(j,w){
            char x;cin>>x;
            v[i][j]=x-'0';
        }
    }
    ll ans=inf;
    rep(bit,1<<(h-1)){
        ll x=__builtin_popcount(bit)+1;
        vl cnt(x,0);
        ll cut=x-1;
        vvl g(x);
        ll r=0,rr=0;
        bool dame=false;
        while(r<h){
            g[rr].pb(r);
            if(bit&(1<<r))rr++;
            r++;
        }
        rep(i,w){
            ll check=false;
            rep(j,x){
                for(auto z:g[j]){
                    cnt[j]+=v[z][i];
                    if(cnt[j]>k)check=true;
                }
            }
            if(check){
                rep(j,x)cnt[j]=0;
                rep(j,x){
                    for(auto z:g[j]){
                        cnt[j]+=v[z][i];
                    }
                    if(cnt[j]>k)dame=true;
                }
                cut++;
            }
        }
        if(dame)continue;
        chmin(ans,cut);
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ii {
    int a, b;
    bool operator < (ii o) const {
        return tie(a, b) < tie(o.a, o.b);
    }
};
struct iii {
    int a, b, c;
    bool operator < (iii o) const {
        return tie(a, b, c) < tie(o.a, o.b, o.c);
    }
};

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 1000005;

bool seen[MAXN];

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    int N;
    cin >> N;
    int now = 0;
    for (int i = 0; i < N; i++) {
        now = (10*now + 7) % N;
        if (now == 0) {
            cout << i+1 << "\n";
            break;
        } else if (seen[now]) {
            cout << "-1\n";
            break;
        }
        seen[now] = 1;
    }
    
}


Measured memory_bytes: 4608
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

	int n; cin >> n;
	vector<int> v[3*100000];
	for (int i = 0; i < n - 1; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	vector<int> fdis(n, INF), sdis(n, INF);
	queue<int> q;
    fdis[0]=0;sdis[n-1]=0;
	q.push(0);//点　距離
	while (!q.empty()) {
		int p = q.front(); q.pop();
		//if (fdis[p] != INF) continue;
		for (int i = 0; i < (int)v[p].size(); i++) {
			if (fdis[v[p][i]] != INF) continue;
			fdis[v[p][i]] = fdis[p] + 1;
			q.push(v[p][i]);
		}
	}
	q.push(n-1);//点　距離
	while (!q.empty()) {
		int p = q.front(); q.pop();
		//if (sdis[p] != INF) continue;
		for (int i = 0; i <(int) v[p].size(); i++) {
			if (sdis[v[p][i]] != INF) continue;
			sdis[v[p][i]] = sdis[p] + 1;
			q.push(v[p][i]);
		}
	}
	int fen = 0,snuke=0;
	for (int i = 0; i < n; i++) {
       // cout<<fdis[i]<<" "<<sdis[i]<<endl;
		if (fdis[i] <= sdis[i]) fen++;
		else snuke++;
	}
    //cout<<fen<<" "<<snuke<<endl;
	if (fen > snuke) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
	return 0;
}


Measured memory_bytes: 11392
import std.stdio, std.algorithm, std.range, std.conv, std.string;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

void main() {
	int n;
	scanf("%d", &n);
	int[] x = new int[n*2];
	int[] c = new int[n*2];
	foreach (color; 0..2) {
		foreach (i; 0..n) {
			int a, b;
			scanf("%d%d", &a, &b);
			x[b] = a; c[b] = color;
		}
	}
	int ans = 0;
	int[] set = new int[n*2];
	foreach (y; 0..n*2) {
		if (c[y] == 0) {
			set[x[y]] = 1;
		} else {
			foreach_reverse (i; 0..x[y]) {
				if (set[i]) {
					ans++;
					set[i] = 0;
					break;
				}
			}
		}
	}
	writeln(ans);
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main()
{
    int n;
    string a,b,c;
    cin >> n >> a >> b >> c;
    int ans = 0;
    for(int i = 0;i < n;i++)
    {
        if(a[i] == b[i] && b[i] == c[i])
        {
            continue;
        }
        else if(a[i] != b[i] && b[i] != c[i] && a[i] != c[i])
        {
            ans += 2;
        }
        else if(a[i] == b[i] && b[i] != c[i] || a[i] != b[i] && b[i] == c[i] || a[i] == c[i] && a[i] != b[i])
        {
            ans++;
        }
    }
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int ans=0,a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	ans+=a;
	ans+=b*5;
	ans+=c*10;
	ans+=d*50;
	ans+=e*100;
	ans+=f*500;
	cout<<(ans>=1000)<<endl;
}


Measured memory_bytes: 3128
#include<iostream>
using namespace std;
int main(){
	int K,S;
	cin>>K>>S;
	int count=0;
	for(int i=0;i<=K;i++){
		for(int j=0;j<=K;j++){
			if(S<(i+j)){
				break;
			}else if((S-(i+j))>K){
				continue;
			}else{
				count++;
			}
		}
	}
	cout<<count<<endl;
	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<pii> a;
    REP(i,n){
        int32 ai;
        cin >> ai;
        a.emplace_back(ai, i);
    }
    sort(ALL(a));
    int32 ans = 0;
    REP(i,n){
        if((i - a[i].second + n * 2) % 2 == 1)ans++;
    }
    cout << ans / 2 << endl;
    return 0;
}

Measured memory_bytes: 2420
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;

int main(){
    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;
    if(s==u){
        cout << a-1 << " " << b << endl;
    }
    else{
        cout << a << " " << b-1 << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	if (a < b)
	{
		printf("a < b\n");
	}
	else if(a==b)
	{
		printf("a == b\n");
	}
	else
	{
		printf("a > b\n");
	}
	return 0;
}

Measured memory_bytes: 2576
#include <stdio.h>

int main(){
	
	int num1, num2, sum;
	int digit = 0;
	
	while(scanf("%d %d", &num1, &num2) != EOF){
	
	sum = num1 + num2;
	
	while(sum > 0){
		digit++;
		sum = sum / 10;
	}

	printf("%d\n", digit);
	
	digit = 0;
	}
	
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<cstdio>
#include<iomanip>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
    ll a, b, x;
    cin >> a >> b >> x;
    ll l = (a-1)/x+1;
    //cout << l << endl;
    if(a==0){
        l=0;
    }
    //cout << l << endl;
    ll r = b/x+1;
    cout << r-l << endl;
    return 0;
}

Measured memory_bytes: 256
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 303;
const int MOD = 998244353;

int n, s;
int a[MAX];
int dyn[MAX][MAX * MAX][4];

int calcBad(int idx, int sum, int mask) {
    if (idx >= n) {
        return mask == 3 && sum * 2 >= s;
    }
    if (dyn[idx][sum][mask] != -1)
        return dyn[idx][sum][mask];
    
    int ans = 0;
    // Use as 1
    ans += calcBad(idx + 1, sum + a[idx], mask);
    if (ans >= MOD) ans -= MOD;

    // Use as 2
    ans += calcBad(idx + 1, sum, mask | 1);
    if (ans >= MOD) ans -= MOD;

    // Use as 3
    ans += calcBad(idx + 1, sum, mask | 2);
    if (ans >= MOD) ans -= MOD;

    return dyn[idx][sum][mask] = ans;
}

int dp[MAX][8];

int calcAll(int idx, int mask) {
    if (idx >= n)
        return mask == 7;
    if (dp[idx][mask] != -1)
        return dp[idx][mask];
    
    int ans = 0;
    // Use as 1
    ans += calcAll(idx + 1, mask | 1);
    if (ans >= MOD) ans -= MOD;

    // Use as 2
    ans += calcAll(idx + 1, mask | 2);
    if (ans >= MOD) ans -= MOD;

    // Use as 3
    ans += calcAll(idx + 1, mask | 4);
    if (ans >= MOD) ans -= MOD;
    
    return dp[idx][mask] = ans;
}

int main(void) {
//	in = fopen("D.in", "rt");
	
	fscanf(in, "%d", &n);
	for (int i = 0; i < n; i++)
	    fscanf(in, "%d", &a[i]);
	
	sort(a, a + n);
	s = 0;
	for (int i = 0; i < n; i++)
	   s += a[i];
	
	int ans = 0;

	memset(dp, -1, sizeof(dp));
//	fprintf(stderr, "all: %d\n", calcAll(0, 0));
	ans += calcAll(0, 0);

    memset(dyn, -1, sizeof(dyn));
//	fprintf(stderr, "bad: %d\n", calcBad(0, 0, 0));
	ans -= (calcBad(0, 0, 0) * 3LL) % MOD;
    if (ans < 0) ans += MOD;
    
	
    fprintf(out, "%d\n", ans);
	
	return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

double dp(int i, int j, int k, const int n){
  static double mm[301][301][301];
  static bool used[301][301][301] = {1};

  if((i|j|k)&INT_MIN) return 0;
  
  if(used[i][j][k]) return mm[i][j][k];
  else used[i][j][k] = true;

  mm[i][j][k] = (i*dp(i-1,j,k,n) + j*dp(i+1,j-1,k,n) + k*dp(i,j+1,k-1,n) + n) / (i+j+k);
  return mm[i][j][k];
}

int main(){
  int n; cin >> n;
  int c[3] = {};
  for(int i = 0; i < n; ++i){
    int x; cin >> x;
    c[x-1]++;
  }
  cout << setprecision(10) << dp(c[0], c[1], c[2], n) << endl;
  return 0;  
}


Measured memory_bytes: 227712
import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for(int i = 0; i < n; i++) a[i] = sc.nextInt();
		for(int i = 0; i < n; i++) {
			if(i != 0) System.out.print(" ");
			System.out.print(a[n - i - 1]);
		}
		System.out.println();
	}
}


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

int main(){
  int H,W = 0;
  cin >> H >> W;
  vector<string> s(H);
  vector<int> dx = {1,0,-1,0,1,-1,1,-1};
  vector<int> dy = {0,1,0,-1,1,-1,-1,1};
  int bomb = 0;
  for(int i=0;i<H;i++)
    cin >> s.at(i);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(s.at(i).at(j)=='#'){
        cout << '#';
        if(j==W-1)
          cout << endl;
      }
      else if(s.at(i).at(j)=='.'){
        for(int dir = 0;dir<8;dir++){
          int nx = i+dx.at(dir);
          int ny = j+dy.at(dir);
          if(nx<0||ny<0||nx>=H||ny>=W)
            continue;
          else if(s.at(nx).at(ny)=='#')
            bomb++;
        }
        cout << bomb;
        bomb = 0;
        if(j==W-1)
          cout << endl;
      }
    }  
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int a,b,c,x,ans=0;
	cin>>a>>b>>c;
	for(int i=1;i<=a;i++)
	{
		cin>>x;
		if(x<b||x>=c) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
#define FOR(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	rep(i,9){
		rep(j,9){
			printf("%dx%d=%d\n",i+1,j+1,(i+1)*(j+1));
		}
	}
	return 0;
}

Measured memory_bytes: 0
a = gets.chomp.split(" ").map(&:to_i)
b = gets.chomp.split(" ").map(&:to_i)
c = gets.chomp.split(" ").map(&:to_i)
n = gets.chomp.to_i
nums = []
n.times { nums << gets.to_i }

(0...n).each do |i|
  if a.include?(nums[i])
    a[a.index(nums[i])] = "*"
  elsif b.include?(nums[i])
    b[b.index(nums[i])] = "*"
  elsif c.include?(nums[i])
    c[c.index(nums[i])] = "*"
  end
end

if a[0] == "*" && a[1] == "*" && a[2] == "*"
  puts "Yes"
elsif b[0] == "*" && b[1] == "*" && b[2] == "*"
  puts "Yes"
elsif c[0] == "*" && c[1] == "*" && c[2] == "*"
  puts "Yes"
elsif a[0] == "*" && b[0] == "*" && c[0] == "*"
  puts "Yes"
elsif a[1] == "*" && b[1] == "*" && c[1] == "*"
  puts "Yes"
elsif a[2] == "*" && b[2] == "*" && c[2] == "*"
  puts "Yes"
elsif a[0] == "*" && b[1] == "*" && c[2] == "*"
  puts "Yes"
elsif a[2] == "*" && b[1] == "*" && c[0] == "*"
  puts "Yes"
else
  puts 'No'
end

Measured memory_bytes: 3836
package main

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

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()
	s := make([]int, n)
	ans := k
	max := 0
	for i := range s {
		s[i] = nextInt()
		ans += s[i]
		if i >= k {
			ans -= s[i-k]
		}
		if max < ans {
			max = ans
		}
		debugf("%d ", ans)
	}
	debugf("\n")

	_, _ = fmt.Fprintf(writer, "%.12f", float64(max)/float64(2))
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 5376
#include<stdio.h>
int main(void) 
{
  int a,b;
  scanf("%d %d",&a,&b);
  
  if(a>b)
    printf("a > b\n");
 
  else if( a < b)
    printf("a < b\n");
 
  else
    printf("a == b\n");
 
  return 0;
}

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

using namespace std;

typedef long long ll;
const int N=2e5+10;


int n,m[2];
vector <int> v[2][N];


map <ll,int> ma;
int h[2][N];


int q[N];
void BFS(int type,int st){
    int top=1,bot=1;
    q[1]=st;
    while (top<=bot){
        int x=q[top++];
        for(auto y:v[type][x]) if (!h[type][y]){
            h[type][y]=h[type][st];
            q[++bot]=y;
        }
    }
}
int main(){
    scanf("%d%d%d",&n,m,m+1);;
    for(int type=0;type<=1;type++){
        while (m[type]--){
            int x,y;
            scanf("%d%d",&x,&y);
            v[type][x].push_back(y);
            v[type][y].push_back(x);
        }
        int n1=0;
        for(int i=1;i<=n;i++) if (!h[type][i]) {
            h[type][i]=++n1;
            BFS(type,i);
        }
    }
    for(int i=1;i<=n;i++) ma[1LL*h[0][i]*N+h[1][i]]++;
    for(int i=1;i<=n;i++) printf("%d ",ma[1LL*h[0][i]*N+h[1][i]]);
}


Measured memory_bytes: 28288
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int a,b;cin >> a >>b;
	cout<<6-a-b<<endl;
	return 0;
}

Measured memory_bytes: 256
//C - Lining Up: 40Min --------------------
//Assunto: 
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

ll modPow(ll x, ll n, ll m) {
    if(n == 0) return 1 % m;
    ll u = modPow(x, n/2, m);
    u = (u*u) % m;
    if(n % 2 == 1) u = (u*x) % m;
    return u;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n, ante, i;
    bool ans = true;
    ll ansF;

    cin >> n;
    vector<int> a(n);
    loop(i, 0, n) cin >> a[i];
    ante = n-1;
    i = n-1;
    sort(all(a));
    if(n % 2 != 0 and a[0] != 0) ans = false;
    while(i > 0) {
        if(a[i] != ante) ans = false;
        i--;
        if(a[i] != ante) ans = false;
        i--;
        ante -= 2;
    }
    if(!ans) cout << "0\n";
    else {
        n /= 2;
        ansF = modPow(2, n, MOD) % MOD;
        cout << ansF << "\n";
    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define N 100
using namespace std;
string s[N];
int n,y;

int dfs(int x){
  int res;
  if('0'<=s[y][x]&&s[y][x]<='9')
    return s[y][x]-'0';
  if(s[y][x]=='+'){
    res=0;
    while(x+2<=s[y+1].size())
      y++,res+=dfs(x+1);
  }
  if(s[y][x]=='*'){
    res=1;
    while(x+2<=s[y+1].size())
      y++,res*=dfs(x+1);
  }
  return res;
}

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=0;i<N;i++)s[i]="";
    for(int i=0;i<n;i++)
      cin>>s[i];
    y=0;
    cout<<dfs(0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int H[310];
long long int DP[310][310];

int main(){
	int N, K;
	cin >> N >> K;
	for(int i = 1; i <= N; i++){
		cin >> H[i];
	}
	for(int i = 1; i < 310; i++){
		for(int j = 0; j < 310; j++){
			DP[i][j] = INF;
		}
	}
	N += 1;
	for(int i = 1; i <= N; i++){
		for(int j = 0; j <= K; j++){
			for(int k = 1; k <= i; k++){
				if(j + k - 1 > K){
					break;
				}
				DP[i][j + k - 1] = min(DP[i][j + k - 1], DP[i - k][j] + max(0LL, H[i] - H[i - k]));
			}
		}
	}
	cout << DP[N][K] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define maxn 3010
#define ll long long
#define mod 998244353
using namespace std;
int f[maxn][maxn * 2], C[maxn][maxn];
int main()
{
	int n, x;
	scanf("%d%d", &n, &x);
	for (int i = 0; i <= n; i++)
	{
		C[i][0] = 1;
		for (int j = 1; j <= i; j++)
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
	}
	f[0][0] = 1;
	for (int i = 0; i <= n - 1; i++)
		for (int j = 0; j <= x; j++)
		{
			f[i + 1][j + 1] = (f[i + 1][j + 1] + f[i][j]) % mod;
			f[i + 1][j + 2] = (f[i + 1][j + 2] + f[i][j]) % mod;
		}
	int res = 0;
	for (int i = 0; i <= n; i++)
	{
		int tmp = 0;
		for (int j = 0; j <= x - 1; j++)
			tmp = (tmp + f[i][j]) % mod;
		for (int j = x + 1; j <= 2 * i; j += 2)
		{
			int need = (j - x + 1) / 2;
			if (2 * need <= i && x - 1 - 2 * need >= 0) tmp = (tmp + f[i - 2 * need][x - 1 - 2 * need]) % mod;
			if (2 * need > i && (x - 1) % 2 == 0 && (x - 1) / 2 + need == i) tmp = (tmp + 1) % mod;
		}
		res = (res + (ll)tmp * C[n][i] % mod) % mod;
	}
	printf("%d\n", res);
}

Measured memory_bytes: 104960
// https://atcoder.jp/contests/agc024/tasks/agc024_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  VL ps(N);
  rep(i, N) cin >> ps[i];

  // sort_length[num]: num の位置から後方に続く num-1
  // 以下を無視したソート列の長さ
  VL sort_length(N + 1);

  {
    repr(i, N) {
      if (ps[i] == N) {
        sort_length[N] = 1;
      } else {
        sort_length[ps[i]] = sort_length[ps[i] + 1] + 1;
      }
    }
  }

  ll res = N;

  // num を先頭に持ってくる場合の数.
  // num が 0 -> 何も先頭に持ってこない
  // num が N -> 何も後方に持ってこない
  rep(num, N + 1) {
    ll _res = 0;
    _res += num;  // num と、num 未満の数全てを先頭に持ってくる
    // 残りは、 （残り - num+1 以上のソート配列）を後方に持ってくる
    if (num < N) {
      _res += (N - num - sort_length[num + 1]);
    }

    chmin(res, _res);
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 3456
<?php
  
fscanf(STDIN,"%d",$n);
$a_li = explode(" ",trim(fgets(STDIN)));

$count = 0;
$index = 1;
for($i=0;$i<$n;$i++){
	if($index != $a_li[$i]){
      unset($a_li[$i]);
      $flag = true;
      $index--;
      $count++;
    }
    $index++;
}
if(count($a_li) == 0){
  echo "-1\n";
}else{
  echo $count."\n";
}

Measured memory_bytes: 18932
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);
 
vector<set<int>> edges;
vi used, cnt, start;

void dfs(int v, int idx){
    used[v] = true;

    for(auto & nv : edges[v]){
        if(not used[nv]){
            dfs(nv, idx);
            cnt[idx]++;
            break;
        }
    }
}

int main(void){
    int n; cin >> n;
    start = vi(2); for(auto & e : start) cin >> e, e--;
    edges = vector<set<int>>(n);

    rep(loop, n - 1){
        int a, b; cin >> a >> b;
        a--, b--;

        edges[a].insert(b);
        edges[b].insert(a);
    }

    used = vi(n);
    rep(i, 2) used[start[i]] = true;

    cnt = vi(2, 1);

    while(1){
        bool ok = false;
        rep(i, 2){
            if((int)edges[start[i]].size() == 1){
                int nv = *begin(edges[start[i]]);
                if(used[nv]) break;

                edges[start[i]].erase(nv);
                edges[nv].erase(start[i]);
                used[nv] = true;
                start[i] = nv;
                cnt[i]++;

                ok = true;
            }
        }
        if(not ok) break;
    }

    rep(i, 2){
        dfs(start[i], i);
    }

    if(cnt[0] == cnt[1] and cnt[0] + cnt[1] == n){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 19040
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[200010];
    rep(i, N) cin >> A[i];
    int M = INF;
    int ans = 0;
    rep(i, N) {
        if (M > A[i]) {
            ans++;
            M = A[i];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cmath>
using namespace std;
int n,m;
int main()
{
	scanf("%d %d",&n,&m);
	if(m<=0&&n+m-1>=0) printf("%d",(n+2*m-1)*n/2);
	else if(abs(m)<abs(n+m-1)) printf("%d",(n+2*m-1)*n/2-m);
	else printf("%d",(n+2*m-1)*n/2-(n+m-1));
}

Measured memory_bytes: 128
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    // 一行読み込み、空白で分解してusize２つパースする
    //let N = get!(usize);
    let mut V: Vec<i32> = (0..5).map(|_| read()).collect();
    let k: i32 = read();
    for i in 0..5 {
        for j in 0..5 {
            if V[j] - V[i] > k {
                println!(":(");
                return;
            }
        }
    }

    println!("Yay!");
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>

using namespace std;

typedef long long ll;

ll N, K;
ll a[5000 + 10];

ll dp[5000 + 10][5000 + 10];

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a, a + N);

	dp[0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < K; j++) {
			dp[i + 1][j] += dp[i][j];
			if (j + a[i] < K) {
				dp[i + 1][j + a[i]] += dp[i][j];
			}
		}
	}

	int ans = N;
	for (int i = 0; i < N; i++) {

		ll dplast[5000 + 10] = {};
		for (int j = 0; j < K; j++)dplast[j] = dp[N][j];
		for (int j = 0; j < K; j++) {
			//dpを一回さし戻す
			if (j + a[i] < K)dplast[j + a[i]] -= dplast[j];
			if (j >= K - a[i] && dplast[j]) {
				ans--;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 196096
def multi_int_input():
    return map(int, input().split())
  
multi_input = multi_int_input()
takahashi, aoki, K = multi_input
if K > takahashi:
  sum_result = K - takahashi - aoki
  if sum_result > 0:
    print("0 0")
  else:
    print("0 {}".format(-sum_result))
else:
  sum_result = takahashi - K
  print("{0} {1}".format(sum_result, aoki))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ___                      \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define endl '\n'
#define pii pair<int, int>
#define MAX INT_MAX
#pragma GCC optimize("Ofast")
#define int long long
const int MOD = (1e9 + 7);
using namespace std;
#define vvi vector<vector<int>>
signed main()
{
	___ 
	int n,m;
	cin>>n>>m;
	pii gate[m];
	for(int i=0;i<m;i++){
		cin>>gate[i].first>>gate[i].second;
	}
	int arr[n+2];
	memset(arr,0,sizeof(arr));
	for(int i=0;i<m;i++){
		arr[gate[i].first]+=1;
		arr[gate[i].second+1]-=1;

	}
	for(int i=1;i<=n+1;i++){
		arr[i]+=arr[i-1];
	}
	int cnt=0;
	for(int i=0;i<=n;i++) if(arr[i]==m) cnt++;
	cout<<cnt<<endl;
}

Measured memory_bytes: 3968
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan =new Scanner(System.in);
        String s=scan.next();
        char[] str= new char[100];
        int finalnumber;
        for(int i=0;i<s.length();i++)
        {
            str[i]=s.charAt(i);
        }
        finalnumber=s.length();
        System.out.print(str[0]);
        System.out.print(finalnumber-2);
        System.out.println(str[finalnumber-1]);
    }
}


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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  int x, y, z;
  cin >> x >> y >> z;

  printf("%d %d %d\n", z, x, y);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(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 repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int a,b;
	int ans=0;
	cin >>a>>b;
	if(a >=13){
		ans = b;
	}else if (a>= 6){
		ans = b / 2;
	}else{
		ans = 0;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  //ios::sync_with_stdio(false);
  int n,q;
  cin>>n>>q;
  string s;
  cin>>s;
  rep(i,s.size()-1 ){
    if(s[i+1]=='C' && s[i]=='A'){
      s[i]='a';
    }
  }
  int m[100001]={0};
  rep(i,s.size() ){
    if(s[i]=='a'){
      if(i!=0) m[i+1]=m[i]+1;
      else m[1]=1;
    }else{
      if(i!=0) m[i+1]=m[i];
      else m[1]=0;
    }
  }
  rep(i,q){
    int a,b;
    cin>>a>>b;
    b--;
    cout<<m[b]-m[a-1]<<endl;
  }

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int k,x;
    cin >> k >> x;
    if(500*k >= x)puts("Yes");
    else puts("No");

    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    ll n;
    vector<int>a;
    vector<int>b;
    vector<int>c;
    cin>>n;
    ll cnt=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        a.push_back(x);

    }
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        b.push_back(x);

    }
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        c.push_back(x);

    }
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    for(int i=0;i<n;i++){
        ll pos1=lower_bound(a.begin(),a.end(),b[i])-a.begin();
        ll pos2=c.end()-upper_bound(c.begin(),c.end(),b[i]);
        cnt+=pos1*pos2;
    }
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 1784
# AC128 B - Guidebook
# 2019/11/1

N, *SP = [s.split() for s in open(0)]
SP = {(s[0], int(s[1])):index for index, s in enumerate(SP)}
# print(N, SP)
SP_values = list(SP.keys())
# print(SP_values)
# sorted(SP_values, key=lambda x:(x.values[0], -x.values[1]))
SP_values.sort(key=lambda x:(x[0], -x[1]))
# print(SP_values)

for i in SP_values:
    print(int(SP[i])+1)

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

using namespace std;

void dfs(int x,int y);

string data[8];

int main(){
	int n;
	int x,y;
	
	cin >> n;
	
	for(int d=1;d<=n;++d){
		for(int i=0;i<8;++i){
			cin >> data[i];
		}
		
		cin >> x;
		cin >> y;
		
		--x;
		--y;
		data[y][x] = '0';
		
		dfs(x,y);
		
		cout << "Data " << d << ":" << endl;
		
		for(int i=0;i<8;++i){
			cout << data[i] << endl;
		}
	}
}

void dfs(int x,int y){
	int nx,ny;
	for(int i=-3;i<=3;++i){
		if(x+i >= 0 && x+i < 8)nx = x+i;
		else nx = x;
		if(y+i >= 0 && y+i < 8)ny = y+i;
		else ny = y;

		if(i==0)continue;
		if(data[y][nx] == '1'){
			data[y][nx] = '0';
			dfs(nx,y);
		}
		if(data[ny][x] == '1'){
			data[ny][x] = '0';
			dfs(x,ny);
		}
	}
}

Measured memory_bytes: 1208