akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define endl "\n"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll N = 2e5 + 10, inf = 1e18 + 10, mod = 1e9 + 7;
ll t[4 * N], c[4 * N], x[N], d[N], L[N], R[N], ans;
vector <int> a[N];
void push(int v, int tl, int tr)
{
    if(c[v])
    {
        t[v] += c[v];
        if (tl != tr){
            c[v + v] += c[v];
            c[v + v + 1] += c[v];
        }
        c[v] = 0;
    }
}
ll ma(int v, int tl, int tr, int l, int r)
{
    push(v, tl, tr);
    if(l <= tl && tr <= r)return t[v];
    else if(tr < l || r < tl)return -inf;
    else
    {
        int mid = (tl + tr) / 2;
        return max(ma(v + v, tl, mid, l, r), ma(v + v + 1, mid + 1, tr, l, r));
    }
}
void up(int v, int tl, int tr, int l, int r, ll val)
{
    push(v, tl, tr);
    if(l <= tl && tr <= r)
    {
        c[v] += val;
        push(v, tl, tr);
    }
    else if(tr < l || r < tl)return;
    else
    {
        int mid = (tl + tr) / 2;
        up(v + v, tl, mid, l, r, val);
        up(v + v + 1, mid + 1, tr, l, r, val);
        t[v] = max(t[v + v], t[v + v + 1]);
    }
}
main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("prices.in", "r", stdin);
    //freopen("prices.out", "w", stdout);
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        cin >> L[i] >> R[i] >> x[i];
        if (x[i] > 1e9) return 0;
        a[L[i]].pb(i);
        a[R[i]].pb(-i);
    }
    for(int i = 1; i <= n; i++)
    {
        for(auto j : a[i])
        {
            if(j > 0)up(1, 0, n, 0, i - 1, x[j]);
        }
        d[i] = ma(1, 0, n, 0, i - 1);
        up(1, 0, n, i, i, d[i]);
        for(auto j : a[i])
        {
            if(j < 0)
            {
                up(1, 0, n, 0, L[-j] - 1, -x[-j]);
            }
        }
        ans = max(ans , d[i]);
    }
    cout << ans;
}


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

int main(){
	string s,t; cin>>s>>t;
	int k=s.length();
	int ans=0;
	rep(i,k){
		if(s[i]!=t[i]) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3908
#include<bits/stdc++.h> 
using namespace std;
#define ll long long
#define mod 1000000007ll
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define db(x) cout << #x << " = " << x << '\n'
#define sep cout << "\n********************************************\n"
#define fast  ios_base::sync_with_stdio(false), cin.tie(NULL)
int main(int argc, char const *argv[])
{
    fast;
    ll cur = 100, n, ans = 0;
    cin >> n;
    while (cur < n)
    {
    	ans ++;
    	cur += cur / 100;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int ans;
    static int count;

    public static void main(String[] args) {
        int times = sc.nextInt();

        for (int i = 0; i < times; i++) {

            count = 0;



            int num = sc.nextInt();



            KAKESAN(num, false);



            System.out.println(count);
        }
    }

    static void KAKESAN(int num, boolean endFlg) {
        ans = 0;
        int disit = String.valueOf(num).length();

        if (disit == 1) {
            endFlg = true;
        }

        if (!endFlg) {
            for (int j = 0; j < disit - 1; j++) {

                String numStringA = String.valueOf(num).substring(0, j + 1);
                String numStringB = String.valueOf(num).substring(j + 1, disit);

                int tmp = Integer.parseInt(numStringA)
                        * Integer.parseInt(numStringB);

                if (tmp > ans) {
                    ans = tmp;
                }
            }
            count++;
            KAKESAN(ans, false);
        }
    }
}

Measured memory_bytes: 31456
from collections import deque
H, W = map(int, input().split())
G = [input() for _ in range(H)]
dist = [0]*(H*W)
bn = 0
B = deque()
geta = W
for i, g in enumerate(G):
    for j, f in enumerate(g):
        if f == '#':
            bn += 1
            B.append(i*geta + j)
visited = set(B)
while bn < H*W:
    if not B:
        break
    dh, dw = divmod(B.pop(), geta)
    dhw = dh * geta + dw
    for di, dj in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        ni, nj = dh + di, dw + dj
        if not (0 <= ni <= H - 1) or not (0 <= nj <= W - 1):
            continue
        nij = ni * geta + nj
        if nij in visited or G[ni][nj] == '#':
            continue
        visited.add(nij)
        dist[nij] = 1 + dist[dhw]
        B.appendleft(nij)
print(max(dist))

Measured memory_bytes: 136572
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
res = 0


def resolve():
    def dfs(v, p):
        global res
        for u in edge[v]:
            if u == p:
                continue
            col[u] = C.pop()
            res += min(col[v], col[u])
            dfs(u, v)

    n = int(input())
    edge = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = map(int, input().split())
        edge[a - 1].append(b - 1)
        edge[b - 1].append(a - 1)
    C = list(map(int, input().split()))
    C.sort()

    col = [0] * n
    col[0] = C.pop()
    dfs(0, -1)
    print(res)
    print(*col)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 22152
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
template <class T> void chmax(T& x, T y) { if (x < y) x = y; }
Int dp[2010][2010];
int main() {
    int N; cin >> N;
    vector<Int> A(N); for (auto &a : A) cin >> a;
    vector<pair<Int, Int>> items;
    for (int i = 0; i < N; i++) {
        items.emplace_back(A[i], i);
    }
    sort(rbegin(items), rend(items));
    dp[0][0] = items[0].first * abs(items[0].second - (N-1));
    dp[0][1] = items[0].first * abs(items[0].second - 0);
    for (int i = 0; i + 1 < N; i++) {
        Int val = items[i+1].first;
        Int pos = items[i+1].second;
        for (int j = 0; j <= i + 1; j++) {
            chmax(dp[i+1][j], dp[i][j] + val * abs(pos - (N-1-(i+1-j))));
            chmax(dp[i+1][j+1], dp[i][j] + val * abs(pos - j));
        }
    }
    Int ans = 0;
    for (int i = 0; i <= N; i++) {
        ans = max(ans, dp[N-1][i]);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 26340
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
long long A[200000];
map<long long, int> C;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> A[i];
  rep(i, N-1) A[i+1] += A[i];
  C[0] = 1;
  long long s = 0;
  rep(i, N) {
    s += C[A[i]]++;
  }
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 14336
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <string>
#include <utility>
using namespace std;

int n,k,t;
int x[100010];
pair <int, int> d[100010];

int main(){
	cin >> t;
	for (int j = 0; j < t;j++){
		cin >> n >> k;
		int dist;
		for (int i = 0; i < n; i++){
			cin >> x[i];
		}
		if (n == 1) cout << 0 << endl;
		else{
			dist = x[n - 1] - x[0];
			for (int i = 0; i < n - 1; i++){
				d[i].second = i;
				d[i].first = x[i + 1] - x[i];
			}
			sort(d, d + n);
			reverse(d, d + n);
			if (k > 1){
				for (int i = 0; i < k - 1; i++){
					dist = dist - d[i].first;
				}
			}
			if (dist <= 0)cout << 0 << endl;
			else cout << dist << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4212
N, K = gets.chomp.split(" ").map(&:to_i)
A = gets.chomp.split(" ").map(&:to_i)

history = [0]
visited = {0 => 0}

fix = nil
repeat = []
i = 0
idx = 0
while idx < K do
  i = A[i] - 1

  if visited[i] != nil then
    repeat = history[visited[i]..-1]
    fix = history[0..visited[i]-1]
    break
  end

  idx += 1
  history << i
  visited[i] = idx
end

if idx == K then
  puts history.last + 1
  return
end

k = K - fix.size
puts repeat[k % repeat.size] + 1


Measured memory_bytes: 39156
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;


int main(int argc, char const *argv[]) {
    long long n,k;cin>>n>>k;
    vector<long long> a(n);
    for(int i=0;i<n;++i)cin>>a[i];
    for(int i=0;i<n-1;++i){
        if(a[i]+a[i+1]>=k){
            cout<<"Possible"<<endl;
            for(int s=1;s<i+1;s++)cout<<s<<endl;
            for(int s=n-1;s>i+1;s--)cout<<s<<endl;
            cout<<i+1<<endl;
            return 0;
        }
    }
    cout<<"Impossible"<<endl;
    return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a;
    float sum = 0.0;
    for(int i=0; i<n; i++){
        cin >> a;
        sum += (double)(1.0 / a);
    }
    cout << (1.0 / sum) << endl; 
    
    return 0;
}

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

def main():
    n = input()
    sum_n = 0

    for i in n:
        sum_n += int(i)
    
    if int(n) % sum_n == 0:
        print('Yes')
    else:
        print('No')
    
if __name__ == '__main__':
    main()

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

using namespace std;

const int MAX { 110 };

int as[MAX];

void solve(int N)
{
    sort(as, as + N);

    cout << as[N - 1] - as[0] << endl;
}

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

    for (int i = 0; i < N; ++i)
        cin >> as[i];

    solve(N);

    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
int main()
{
	int n;
	scanf("%d",&n);
	int h,m,s;
	s=n%60;
	m=n/60%60;
	h=n/60/60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
} 


Measured memory_bytes: 2764
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<62)-10e15;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;
 
LL N;
vector<vector<LL>> A;
 
LL ans = 0;
 
void solve(){
	vector<vector<LL>> A_shortest(A);
	//ワーシャルフロイド
	//A_shortestには各点同士の最短経路の長さが入る
	for(int k=1;k<=N;k++){
		for(int i=1;i<=N;i++){
			for(int j=1;j<=N;j++){
				A_shortest[i][j] = min(A_shortest[i][j],A_shortest[i][k]+A_shortest[k][j]);
			}
		}
	}
	for(int i=1;i<=N;i++){
		for(int j=i+1;j<=N;j++){
			//点iとjの距離について見ていく
			//1つでもA[i][j]==A_shortest[i][k]+A_shortest[k][j]
			//を満たすようなkが存在すれば点iとj間の距離はノーカンにする
			bool add_flag = true;
			for(int k=1;k<=N;k++){
				if(A[i][j]==A_shortest[i][k]+A_shortest[k][j] && (i!=k && j!=k))add_flag = false;
				if(A[i][j]>A_shortest[i][k]+A_shortest[k][j]){
					ans = -1;
					return;
				}
			}
			if(add_flag) ans+=A[i][j];
		}
	}
}
 
int main(){
    cin >> N;
    A = vector<vector<LL>>(N+1,vector<LL>(N+1));
    for(int i=1;i<=N;i++){
    	for(int j=1;j<=N;j++) cin>>A[i][j];
    }
 
    solve();
 
    cout << ans << endl;
    return 0;
}

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

// dp[i][j][k][m] :=  i: 上位 i 桁目まで決定
//                    j: small(数字を自由に選べる)か
//                    k: started(数字を書き込んだ)か
//                    m: {3,5,7} を選んだかのflag
//                    としたときの753数の数
int dp[11][2][2][8];

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

  string n;
  cin >> n;

  int len = n.size();
  dp[0][0][0][0] = 1;
  for (int i = 0; i < len; ++i)
  {
    for (int j = 0; j < 2; ++j)
    {
      for (int k = 0; k < 2; ++k)
      {
        for (int m = 0; m < 8; ++m)
        {
          if (!dp[i][j][k][m]) continue;

          if (j == 1)                  // small ([0, 9] から数字を選べる)か
          {
            if (k == 0)                // not started (数字を書き込んでいない)か
              dp[i + 1][1][0][0] += dp[i][1][0][0];                // nothing

            dp[i + 1][1][1][m | 1] += dp[i][1][k][m];              // +3
            dp[i + 1][1][1][m | 2] += dp[i][1][k][m];              // +5
            dp[i + 1][1][1][m | 4] += dp[i][1][k][m];              // +7
          }
          else                         // not small ([0, d] から数字を選べる)か
          {
            int d = n[i] - '0';

            if (k == 0)                // not started (数字を書き込んでいない)か
              dp[i + 1][1][0][0] += dp[i][0][0][0];                // nothing

            if (d == 3) dp[i + 1][0][1][m | 1] += dp[i][0][k][m];  // +3
            if (3 < d)  dp[i + 1][1][1][m | 1] += dp[i][0][k][m];  // +3
            if (d == 5) dp[i + 1][0][1][m | 2] += dp[i][0][k][m];  // +5
            if (5 < d)  dp[i + 1][1][1][m | 2] += dp[i][0][k][m];  // +5
            if (d == 7) dp[i + 1][0][1][m | 4] += dp[i][0][k][m];  // +7
            if (7 < d)  dp[i + 1][1][1][m | 4] += dp[i][0][k][m];  // +7
          }
        }
      }
    }
  }

  int ans = dp[len][0][1][7] + dp[len][1][1][7];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
using namespace std;

const int MAX_N = 100005;

typedef pair<int, int> pii;
typedef long long i64;

class Edge {
public:
  int nxt, to;
} e[MAX_N << 4];

int head[MAX_N], cnt, num[MAX_N];

void addedge(int u, int v) {
  e[++cnt] = (Edge){head[u], v}, head[u] = cnt;
  e[++cnt] = (Edge){head[v], u}, head[v] = cnt;
}

int N, X[MAX_N], Y[MAX_N];

map<int, int> idx;
map<int, int>::iterator iter;
vector<pii> intv[MAX_N], node[MAX_N];

void work(int dx, int dy) {
  idx.clear();
  
  int tot = 0;
  for (int i = 1; i <= N; ++i) {
    if (idx.count(X[i]) == 0)
      idx[X[i]] = ++tot;
    node[idx[X[i]]].push_back(make_pair(Y[i], i));
  }

  for (int i = 1; i <= tot; ++i)
    sort(node[i].begin(), node[i].end());

  for (iter = idx.begin(); iter != idx.end(); ++iter) {
    if (idx.count(iter->first - dx) == 0) continue;
    int pre = idx[iter->first - dx];
    
    for (pii v : node[iter->second]) {
      int l = lower_bound(node[pre].begin(), node[pre].end(), make_pair(v.first - dy, 0)) - node[pre].begin();
      int r = upper_bound(node[pre].begin(), node[pre].end(), make_pair(v.first + dy, N + 1)) - node[pre].begin();
      
      if (l >= r) continue;
      intv[pre].push_back(make_pair(l, r - 1));
      addedge(v.second, node[pre][l].second);
      num[v.second] += r - l;
    }
  }

  for (iter = idx.begin(); iter != idx.end(); ++iter) {
    int x = iter->second, l = 0, r = -1;
    sort(intv[x].begin(), intv[x].end());
    
    for (pii v : intv[x]) {
      if (v.first <= r) r = v.second;
      else {
	for (int i = l + 1; i <= r; ++i)
	  addedge(node[x][i].second, node[x][i - 1].second);
	l = v.first, r = v.second;
      }
    }
    for (int i = l + 1; i <= r; ++i)
      addedge(node[x][i].second, node[x][i - 1].second);    
  }

  for (int i = 1; i <= tot; ++i)
    node[i].clear(), intv[i].clear();
}

i64 res = 0;

bool vis[MAX_N];

void dfs(int x) {
  vis[x] = 1, res += num[x];
  for (int i = head[x]; i; i = e[i].nxt)
    if (!vis[e[i].to])
      dfs(e[i].to);
}

int main() {
  int a, b;
  
  scanf("%d%d%d", &N, &a, &b);
  for (int i = 1, x, y; i <= N; ++i) {
    scanf("%d%d", &x, &y);
    X[i] = x + y, Y[i] = x - y;
  }

  int d = max(abs(X[a] - X[b]), abs(Y[a] - Y[b]));

  work(d, d);
  
  for (int i = 1; i <= N; ++i) swap(X[i], Y[i]);
  
  work(d, d - 1);

  dfs(a);

  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 19200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

#define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()
#define sz(x) ((long long)x.size())
#define arr array

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e10;


void pre(){



}

string s;
int k,n;
int dp[105][105][2];
bool vis[105][105][2];

int go(int pos,int cnt,int flg){
    if(cnt > k)
        return 0;
    if(pos >= n){
        return cnt == k;
    }
    if(vis[pos][cnt][flg])
        return dp[pos][cnt][flg];
    vis[pos][cnt][flg] = true;
    int limit = 9;
    if(flg) limit = s[pos]-'0';
    int ans=0;
    for(int d=0;d<=limit;d++){
        int isNonZero = (d == 0) ? 0 : 1;
        if(flg and d == limit){
            ans += go(pos+1,cnt + isNonZero,1);
        }else{
            ans += go(pos+1,cnt + isNonZero,0);
        }
    }
    return dp[pos][cnt][flg] = ans;
}

void solve(){  

    cin >> s >> k;
    n = s.size();
    int ans = go(0,0,1);
    cout << ans << endl;

}   

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input00.txt","r",stdin);
    #endif
    IOS;
    pre();
    ll T = 1;   
    //cin>>T;
    ll tt = 1;
    while(T--){  
        //cout << "Case #" << tt << ": "; 
        tt++;
        solve();
    }
    return 0;
}

Measured memory_bytes: 3724
# ABC 114 D - 756
from collections import defaultdict
def factorize(n):
    """
    引数の値を素因数分解したリストを返す

    Parameters
    ----------
    n : int
        素因数分解したい自然数

    Returns
    -------
    retlist : list
        素因数分解後の値のリスト
    """
    retlist = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            while temp%i==0:
                temp //= i
                retlist.append(i)

    if temp!=1:
        retlist.append(temp)

    if retlist==[]:
        retlist.append(n)

    return retlist

n=int(input())
div=[]
for i in range(1,n+1):
    t=factorize(i)
    div+=t

d = defaultdict(int)
for dd in div:
    d[dd]+=1

fact_3=0
fact_5=0
fact_15=0
fact_25=0
fact_75=0

for ddd in d.values():
    if 2<=ddd<4:
        fact_3+=1
    elif 4<=ddd<14:
        fact_5+=1
    elif 14<=ddd<24:
        fact_15+=1
    elif 24<=ddd<74:
        fact_25+=1
    elif 74<=ddd:
        fact_75+=1

fact_3 = fact_75+fact_25+fact_15+fact_5+fact_3
fact_5 = fact_75+fact_25+fact_15+fact_5
fact_15 = fact_75+fact_25+fact_15
fact_25 = fact_75+fact_25
fact_75 = fact_75

ans = 0
ans += (fact_5*(fact_5-1)*(fact_3-2))//2
ans += fact_15*(fact_5-1)
ans += fact_25*(fact_3-1)
ans += fact_75

print(ans)


Measured memory_bytes: 3316
N,Y = map(int,input().split())
x=-1
y=-1
z=-1
for i in range(N+1):
    for j in range(N-i+1):
        bet=Y-(10000*i+5000*j+1000*(N-i-j))
        if bet == 0:
            x=i
            y=j
            z=N-i-j
            break
        
d=[x,y,z]
print(d[0])
print(d[1])
print(d[2])

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


int main(int argc, char *argv[]){
  int N_num, A_num, B_num;
  cin >> N_num >> A_num >> B_num;
  
  int s, counter;
  counter=0;  
    
  for(int i=1; i<=N_num; i++){
    s = i/10000+(i/1000)%10+(i/100)%10+(i/10)%10+i%10;
    if (s>=A_num && s<=B_num){
      counter += i;
    }
  }
  cout << counter << endl;
  
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define pb push_back
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

int main(){
    string str;
    cin>>str;
    vint vec;
    int startpos=0;
    int count=0;
    int flagA=0;
    ll sum=0;
    rep(i,str.size()){
        if(str[i]=='A'){
            if(flagA==0){
                flagA=1;
                startpos=count;
            }
            count++;
        }
        else if(str.substr(i,2)=="BC"){
            sum+=(ll)(count-startpos);
            /*
            reps(i,startpos,count){
                vec[i]++;
            }
            */
            i++;

        }
        else{
            flagA=0;
            startpos=count;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 640
//============================================================================
// Name        : abc128A.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

int main() {
	int A, P;
	cin >> A >> P;
	int ans = (P + 3 * A) / 2;
	cout << ans << endl;
	return 0;
}


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

int N, M, X[100000], A[100000], B[100000], Y[100000];
bitset<100000> used, visited, checked;
vector<int> edges[100000];

struct UnionFind {
    vector<int> par;
    vector<int> sz;
    vector<int64_t> wt;
    vector<int> es;

    UnionFind(int n=0){
        if(n>0) initialize(n);
    }

    void initialize(int n){
        par.resize(n);
        sz.resize(n);
        wt.resize(n);
        es.resize(n);
        for(int i=0; i<n; i++){
            par[i] = i;
            sz[i] = 1;
            wt[i] = X[i];
            es[i] = 0;
        }
    }

    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(sz[x] < sz[y]){
            par[x] = y;
            sz[y] += sz[x];
            wt[y] += wt[x];
            es[y] += es[x];
        }else{
            par[y] = x;
            sz[x] += sz[y];
            wt[x] += wt[y];
            es[x] += es[y];
        }
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    int64_t weight(int x){
        return wt[find(x)];
    }

    void add_edge(int x){
        x = find(x);
        es[x]++;
    }

    int result_edge(int x){
        x = find(x);
        int ret = es[x];
        es[x] = 0;
        return ret;
    }
};

int main(){
    cin >> N >> M;
    for(int i=0; i<N; i++) cin >> X[i];
    for(int i=0; i<M; i++){
        cin >> A[i] >> B[i] >> Y[i];
        A[i]--; B[i]--;
        edges[A[i]].push_back(i);
        edges[B[i]].push_back(i);
    }

    vector<int> order;
    for(int i=0; i<M; i++) order.push_back(i);
    sort(order.begin(), order.end(), [&](int a, int b){ return Y[a] < Y[b];});

    int ans = 0;
    UnionFind uf(N);
    for(int i : order){
        uf.unite(A[i], B[i]);
        int64_t weight = uf.weight(A[i]);
        uf.add_edge(A[i]);

        if(weight >= Y[i]){
            ans += uf.result_edge(A[i]);
        }
    }

    ans = M - ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9852
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  string s,t;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<char>());
  for(int i=0;i<min(s.size(),t.size());i++){
    if(s[i]<t[i]){
      cout<<"Yes";
      return 0;
    }
    if(s[i]>t[i]){
      cout<<"No";
      return 0;
    }
  }
  if(s.size()<t.size()) cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
typedef pair<int , int > pii;
#define MOD 1000000007
#define MOD1 998244353
#define ff first
#define ss second
#define bn cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define sz(a) int((a).size())
#define o(a) cout << a
#define MAX6 1000006
#define int ll
#define all(x) x.begin(), x.end()
#define ppii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define viii vector<ppii>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define MAX5 300005
#define MAX7 10000007
#define rep(i,a,b)  for (__typeof((b)) i=(a);i<=(b);i++)
#define nrep(i,b,a)  for (__typeof((b)) i=(b);i>=(a);i--)
#define mem(a) memset(a,0,sizeof(a))
#define memneg(a) memset(a,-1,sizeof(a))
//#define se second
#define LN 14
#define LIM 22
#define MAX_ALPHA 26
const long long INF64 = 1e18;
const ll INF = 1e9;
const double PI = acos(-1);
#define ld long double
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
inline void max_self(ll &a, ll b)
{
  a = max(a,b);
}
 
inline void min_self(ll &a,ll b)
{
  a = min(a,b);
}
 
inline void add_self(ll &a, ll b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
inline void sub_self(ll &a, ll b) {
  a -= b;
  if (a < 0) a += MOD;
}
 
inline int mul(int a, int b) {
  return (int) ((long long) a * b % MOD);
}
 
 
ll gcd(ll a,ll b)
{
  if(b == 0)
    return a;
  else 
    return gcd(b, a%b);
}
 
 
int countDigits(int x)
{
  int cnt = 0;
  while(x)
  {
    x /= 10;
    cnt++;
  }
  return cnt;
}
 
 
ll binExpo(ll a,ll b)
{
  ll res = 1;
  while(b)
  {
    if(b&1)
      res = (res * a)%MOD;
    a = (a * a)%MOD;
    b /= 2;
  }
  return res%MOD;
}
 
int sum(int a) {
    int result = 0;
    while (a > 0) {
        result += a % 10;
        a /= 10;
    }
    return result;
}

const int nax = 1e5 + 5;

int dist[nax];
int vis[nax];
int indegree[nax];

vector<int > g[nax];

void dfs(int u)
{
  vis[u] = 1;
  for(auto child : g[u])
  {
    max_self(dist[child], dist[u] + 1);
    --indegree[child];
    if(indegree[child] == 0)
      dfs(child);
  }
}

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

  int n, m;
  cin>>n>>m;
  rep(i, 0, m-1)
  {
    int u, v;
    cin>>u>>v;
    u--, v--;
    g[u].pb(v);
    indegree[v]++;
  }

  rep(i, 0, n-1)
  {
    if(!vis[i] and indegree[i] == 0)
    {
      dfs(i);
    }
  }
  int ans = 0;
  rep(i, 0, n-1)
  {
    max_self(ans, dist[i]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			a.begin(), a.end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define	MAX_QWORD		((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<int, int>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// 枝定義
struct Edge
{
	int	from;
	int	to;
	int dist;
	Edge(int a, int b, int c) {
		from = a;
		to = b;
		dist = c;
	}
};

// dfs
vector<vector<P>>	G;
vector<int>			pos;
bool dfs(int from)
{
	int nosPos = pos[from];
	for (auto to : G[from]) {
		if (pos[to.first] == INF) {
			pos[to.first] = nosPos + to.second;
			if (!dfs(to.first)) {
				return false;
			}
		} else {
			int dist = pos[to.first] - nosPos;
			if (dist != to.second) {
				return false;
			}
		}
	}

	return true;
}

// メイン
int main()
{
	int N, M;
	cin >> N >> M;
	vector<Edge>	edgeList;
	REP(i, M) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		edgeList.emplace_back(a, b, c);
		edgeList.emplace_back(b, a, c * -1);
	}

	// グラフ作成
	G.clear();
	G.resize(N);
	for (int j = 0; j < 2 * M; j++) {
		const auto &edgeOne = edgeList[j];
		G[edgeOne.from].emplace_back(edgeOne.to, edgeOne.dist);
	}
		
	// 手繰る
	string ans = "Yes";
	pos.resize(N, INF);
	for (int j = 0; j < 2 * M; j++) {
		const auto &edgeOne = edgeList[j];
		if (pos[edgeOne.from] == INF) {
			pos[edgeOne.from] = 0;
			if (!dfs(edgeOne.from)) {
				ans = "No";
				break;
			}
		}
	}
		
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 17772
def main():
    M, K = map(int, input().split())
    if K >= 2 ** M:
        print(-1)
        exit()
    
    if K == 1 and M == 1:
        print(-1)
        exit()
    
    if M == 0 and K >= 1:
        print(-1)
        exit()
    
    if M == 0:
        print(0,0)
        exit()
    
    if K == 0 and M == 1:
        print(0,0,1,1)
        exit()

    ans = []
    for i in range(2**M):
        if i == K:
            continue
        ans.append(i)
    ans.append(K)

    for i in range(2**M-1,-1,-1):
        if i == K:
            continue
        ans.append(i)
    ans.append(K)

    print(*ans)

    


if __name__ == "__main__":
    main()

Measured memory_bytes: 59268
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <tr1/unordered_map>
#include <map>

using namespace std;
typedef unsigned long long ULL;

int arr[10];
int N;
ULL hashval() {
    ULL val = 0;
    for(int i = 0; i < N; ++i) {
        val <<= 4;
        val += arr[i];
    }
    return val;
}
void restorehash(ULL hash) {
    for(int i = N-1; i >= 0; --i) {
        arr[i] = hash & 0x0f;
        hash >>= 4;
    }
}

void enumerate(map<ULL,int> &seen) {
    queue<pair<ULL,int> > q;
    q.push(make_pair(hashval(),0));
    while(!q.empty()) {
        ULL hash = q.front().first;
        int turn = q.front().second;
        q.pop();
        seen[hash] = turn;
        if(turn == 4) continue;
        restorehash(hash);
        for(int left = 0; left < N; ++left) {
            for(int right = left+1; right < N; ++right) {
                reverse(arr+left, arr+right+1);
                ULL new_hash = hashval();
                if(seen.count(new_hash)) {
                    reverse(arr+left, arr+right+1);
                    continue;
                }
                seen[new_hash] = turn+1;
                q.push(make_pair(new_hash, turn+1));
                reverse(arr+left, arr+right+1);
            }
        }
    }
}

int main() {
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) {
        scanf("%d", arr+i);
    }
    map<ULL,int> seen, seen_rev;
    enumerate(seen);
    sort(arr, arr+N);
    enumerate(seen_rev);
    int ans = N-1;
    for(map<ULL,int>::iterator it = seen.begin(); it != seen.end(); ++it) {
        if(seen_rev.count(it->first)) {
            //cout << it->second << ' ' << seen_rev[it->first] << endl;
            ans = min(ans, it->second + seen_rev[it->first]);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}


int main(){
  ll A; cin >> A;
  ll B, C; scanf("%lld.%lld", &B, &C);
  B = B * 100 + C;
  ll ans = A * B;
  cout << ans / 100 << endl;


  return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>	
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#define INF 2000000000000000
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define mk make_pair
#define en endl
#define RE return 0
#define int ll
#define P pair<int,int>
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}
int lcm(int a,int b){if(a==0){return b;} return a/gcd(a,b)*b;}

struct UnionFind{
	
	std::vector<int> data;
	
	UnionFind(int size): data(size, -1) {}
	
	bool unite(int x, int y){
		x=root(x);
		y=root(y);
		if( x != y ){
			if( data[y] < data[x] ) std::swap(x, y);
			data[x] += data[y];
			data[y] = x;
		}
		return x!=y;
	}

	bool find(int x, int y){
		return root(x) == root(y);
	}
	
	int root(int x){
		return (data[x] < 0)? x : data[x]=root(data[x]);
	}
	
	int size(int x){
		return -data[root(x)];
	}
};

map<P,int> mp;

signed main(){
	int n,k,l;
	cin>>n>>k>>l;
	
	UnionFind uf_1=UnionFind(n+1);
	UnionFind uf_2=UnionFind(n+1);
	
	for(int i=0; i<k; i++){
		int a,b; cin>>a>>b;
		uf_1.unite(a, b);
	}
	for(int i=0; i<l; i++){
		int a,b; cin>>a>>b;
		uf_2.unite(a, b);
	}
	for(int i=1; i<=n; i++){
		mp[mk(uf_1.root(i), uf_2.root(i))]++;
	}
	for(int i=1; i<=n; i++){
		cout<<mp[mk(uf_1.root(i), uf_2.root(i))]<<" ";
	}
	
	cout<<en;
}




Measured memory_bytes: 15104
def bfs(queue, visited):
  while len(queue) > 0:
    y, x = queue.pop(0)
    for delta_y, delta_x in [[1,0],[-1,0],[0,1],[0,-1]]:
      new_y , new_x = y + delta_y, x + delta_x 
      if new_y < 0 or new_x < 0 or new_y >= h or new_x >= w:
        continue 
      if c[new_y][new_x] == "." and visited[new_y][new_x] == -1:
        visited[new_y][new_x] = visited[y][x] +1
        queue.append([new_y, new_x])
  return visited


h, w= map(int, input().split())
c = [list(input()) for _ in range(h)]

cnt = 0
for tate in c:
    for yoko in tate:
        if yoko == ".":
            cnt +=1

visited = [[-1]*w for _ in range(h)]
queue = []
sy, sx = 0, 0
visited[sy][sx] = 0 
queue.append([sy,sx])
visited = bfs(queue, visited)

if visited[h-1][w-1] == -1:
    print(-1)
else:
    print(cnt-visited[h-1][w-1]-1)

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

void d(vector<vector<int>> v,int h){
	for(int i=0;i<h;i++){
		for(int j=0;j<v[i].size();j++){
			cout<<v[i][j]<<" ";
		}
		cout<<"\n";
	}
	cout<<"\n";
}

int main (){
	int h;
	while(cin>>h && h){
		vector<vector<int>> v(h,vector<int>(5));
		for(int i=0;i<h;i++)for(int j=0;j<5;j++)cin>>v[i][j];
		int ans=0;
		while(1){
			int flag=true;
			for(int i=0;i<h;i++){
				int chain;
				for(int j=0;j<5;j++){
					chain=1;
					while(j+1<5 && v[i][j]!=-1 && v[i][j]==v[i][j+1]){
						chain++;
						j++;
					}
					if(chain>=3){
						flag=false;
						ans+=chain*v[i][j];
						for(int k=0;k<chain;k++){
							v[i][j-chain+k+1]=-1;
						}
						break;
					}
				}
			}
			//d(v,h);
			for(int p=0;p<h;p++){
				for(int i=0;i<5;i++){
					for(int j=h-1;j>=1;j--){
						if(v[j][i]==-1){
							for(int k=j;k>=1;k--)swap(v[k][i],v[k-1][i]);
						}
					}
				}
			}

			//d(v,h);
			if(flag)break;
		}
		cout<<ans<<endl;
	}


}

/*
5 8 105
8 5 105
1 2 24
99 98 24
12 13 26
1 22 23
1 13 201
13 16 112
2 24 50
1 82 61
1 84 125
1 99 999
99 1 999
98 99 999
1 99 11
99 1 12
0 0 0
*/


Measured memory_bytes: 3148
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<bitset>
#include<stack>
#include<stdio.h>
#include<math.h>
#include<fstream>
using namespace std;

int main()
{
	string right = "CODEFESTIVAL2016";
	string wrong;
	cin >> wrong;
	int cnt = 0;
	for (int i = 0; i < right.length(); i++)
		if (right[i] != wrong[i])
			cnt++;
	cout << cnt << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<vector<ll>>> vvvll;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================





int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================


	int a, b, c;
	cin >> a >> b >> c;

	if (a < c && c < b)
	{
		cout << "Yes" << endl;
		return 0;
	}
	else if (b < c && c < a)
	{
		cout << "Yes" << endl;
		return 0;
	}
	else
	{
		cout  << "No";
	}







}





Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split())
apple = []
nokori = [0] * 3
nokori[1] = X
nokori[2] = Y

a = list(map(int, input().split()))
for p in a:
    apple.append([p, 1])

a = list(map(int, input().split()))
for p in a:
    apple.append([p, 2])

a = list(map(int, input().split()))
for p in a:
    apple.append([p, 0])

apple = sorted(apple, key=lambda x: -x[0])

ans = 0
siroCnt = 0
ato = X + Y
siro = 0
for ap in apple:
    if ato == siroCnt:
        break

    if nokori[ap[1]] > 0:
        ans += ap[0]
        nokori[ap[1]] -= 1
        ato -= 1

    if ap[1] == 0:
        siro += ap[0]
        siroCnt += 1


print(ans + siro)


Measured memory_bytes: 61376
until (str = gets.chomp) == "0 0" do
    n, s = str.split.map(&:to_i)
    res = 0
    [0,1,2,3,4,5,6,7,8,9].combination(n) do |arr|
        res += 1 if arr.inject(:+) == s
    end
    p res
end

Measured memory_bytes: 8696
#include<bits/stdc++.h>
using namespace std;
int n,q,i;
int a[1000];
main()
{
	cin>>n;
	for(i=0;i<n;i++)cin>>a[i];
	cin>>q;
	for(i=0;i<q;i++)
	{
		int b,e,t;cin>>b>>e>>t;
		swap_ranges(a+b,a+e,a+t);
	}
	for(i=0;i<n;i++)cout<<(i?" ":"")<<a[i];
	cout<<endl;
}


Measured memory_bytes: 3108
N,D = map(int,input().split())
X = [list(map(int, input().split())) for j in range(N)]

count_ = 0
for j in range(0,N):
  for i in range(0,N):
    sum_ = 0
    for d in range(D):
      sum_+=(X[i][d]-X[j][d])**2
    if (sum_**0.5)%1==0: count_+=1
print(int((count_-N)/2))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
#include<map>
#include<algorithm>
using namespace std;
typedef long long int ll;
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; }
#define all(a)  (a).begin(),(a).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define vll vector<ll>
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i]>>y[i];
const ll INF =1LL << 62;
int main(){
  int A,B,C,D,E;
  cin >> A >> B >> C >> D >> E;
  int a=(A+9)/10*10,b=(B+9)/10*10,c=(C+9)/10*10,d=(D+9)/10*10,e=(E+9)/10*10;
  int ans=min({A+b+c+d+e,a+B+c+d+e,a+b+C+d+e,a+b+c+D+e,a+b+c+d+E});
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            var X = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            
            var pair = new Dictionary<int, int>();

            for (int i = 0; i < N; i++) {
                pair.Add(i + 1, X[i]);
            }

            //Valueの値によってソートする
            var pair_new = pair.OrderBy(x => x.Value);

            //Console.WriteLine(pair_new);

            var r = new List<int>();

            //string ans = "";

            foreach (var v in pair_new) {
                r.Add(v.Key);
            }

            Console.WriteLine(string.Join(" ", r));

        }
    }
}


Measured memory_bytes: 35552
fun main(args : Array<String>) {
    var (n, x, y) = readLine()!!.split(" ").map { it.toInt() }
    val dd = IntArray(n){0}

    x -= 1
    y -= 1

    for (i in 0..n-2) {
        for (j in i+1..n-1) {
            val d1 = j-i
            var d2 = Int.MAX_VALUE

            if (i <= x) {
                if (j <= y) {
                    d2 = (x-i) + 1 + (y-j)
                } else {
                    d2 = (x-i) + 1 + (j-y)
                }
            } else {
                if (j <= y) {
                    d2 = (i-x) + 1 + (y-j)
                } else {
                    d2 = (i-x) + 1 + (j-y)
                }
            }

            if (i <= x && y <= j) {
                d2 = x-i + 1 + j-y
            } else if (i <= x && j < y) {
                d2 = x-i + 1 + y-j
            }

            dd[Math.min(d1, d2)]++
        }
    }

    for (i in 1..n-1) {
        println(dd[i])
    }
}

Measured memory_bytes: 37876
#include <iostream>
#include <vector>
#include <bitset>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
const int MAX_N = 540010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string S;
int A[MAX_N];

bitset<540000> B[6];
vi V[6] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 0, 1}, {2, 1, 0}};
int to[6] = {4, 2, 5, 0, 3, 1};
int I[6], rI[6];
int Q[15][MAX_N];
int ans[MAX_N];
int inv[MAX_N];

int find_idx(int a) {
	rep(i, 0, 6) {
		if(B[i][a]) return i;
	}
	return -1;
}

void idx_move(int x, int y, int a) {
	B[x][a] = 0;
	B[y][a] = 1;
};

void solve() {
	cin >> N;
	cin >> S;
	// N = 12;
	// rep(i, 0, 200000) {
	// 	int v = rand() % 2;
	// 	if(v == 0) S += 'R';
	// 	else S += 'S';
	// }
	int T = sz(S);
	
	int BN = 1;
	rep(i, 0, N) BN *= 3;
	rep(q, 0, N) {
		int pow3 = 1;
		rep(i, 0, q) pow3 *= 3;
		rep(i, 0, 6) {
			B[i].reset();
			I[i] = i;
			rI[i] = i;
		}
		rep(i, 0, pow3) B[0][i] = 1;

		rep(i, 0, T) {
			if(S[i] == 'R') {
				int v = Q[q][i];
				int idx = find_idx(v);
				int ridx = I[idx];
				int c = V[ridx][2];
				idx_move(idx, rI[to[ridx]], v);
				Q[q + 1][i] = c * pow3 + v;
			}
			else {
				swap(rI[0], rI[1]);
				swap(rI[2], rI[3]);
				swap(rI[4], rI[5]);
				rep(i, 0, 6) {
					I[rI[i]] = i;
				}
			}
		}
		rep(i, 0, pow3) {
			int v = ans[i];
			int idx = find_idx(v);
			int ridx = I[idx];
			rep(j, 0, 3) {
				ans[j * pow3 + i] = V[ridx][j] * pow3 + v;
			}
		}
	}
	rep(i, 0, BN) {
		inv[ans[i]] = i;
	}
	rep(i, 0, BN) {
		cout << inv[i] << " ";
	}
	cout << "\n";
}

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



Measured memory_bytes: 18360
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  int n, t;
  cin >> n >> t;
  vector<pair<int, int>> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;
  sort(p.begin(), p.end());

  int dp[n + 1][t];
  bool select[n][t];
  rep(j, t) dp[0][j] = 0;
  rep(i, n) {
    rep(j, t) {
      select[i][j] = false;
    }
  }

  FOR(i, 1, n + 1) {
    rep(j, t) {
      dp[i][j] = dp[i - 1][j];
      if (j < p[i - 1].first) continue;
      if (dp[i - 1][j - p[i - 1].first] + p[i - 1].second > dp[i - 1][j]) {
        dp[i][j] = dp[i - 1][j - p[i - 1].first] + p[i - 1].second;
        select[i - 1][j] = true;
      }
    }
  }

  bool selected[n];
  rep(i, n) selected[i] = false;
  int ct = t - 1;
  repr(i, n - 1) {
    if (select[i][ct]) {
      selected[i] = true;
      ct -= p[i].first;
    }
  }

  int ans = dp[n][t - 1];
  int maxb = 0;
  rep(i, n) {
    if (selected[i]) continue;
    maxb = max(maxb, p[i].second);
  }
  ans += maxb;
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 44288