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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;

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

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

    if (a > b) {
        print(a - 1);
    } else {
        print(a);
    }

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    repall (i, vec)
        cout << i << ' ';
    cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


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

def solve_function(N):
    if N % 2 == 1:
        return 0

    n = 10
    ans = 0
    while True:
        if n > N:
            break
        ans += N//n
        n *= 5
    return ans

if solve_function(N):
    print(solve_function(N))
else:
    print(0)

Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n;
    cin >>n;
    unordered_map<string, ll> m;
    rep(i,0,n)
    {
        string s;
        cin >> s;
        m[s]++;
    }

    ll _max(-LL_MAX);
    for (auto i: m)
        _max = max(_max, i.second); 

    //multimap<ll, string> ord;
    vector<string> ans;
    for (auto i: m)
        if (_max==i.second) ans.push_back(i.first);
        //if (_max==i.second) ord.emplace(i.second, i.first);

    sort(ans.begin(), ans.end());

    for (auto c: ans)
        cout << c << endl;
    return 0;
}


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

struct UnionFind{
	vector<int> par;
	vector<long> sizes;
	UnionFind(int N) : par(N), sizes(N){
		for (int i = 0; i < N; ++i){
			par[i] = i;
			sizes[i] = 1;
		} 
	}
	int root(int x){return par[x] == x ? x : root(par[x]);}
	void unite(int x, int y){
		int rx = root(x);
		int ry = root(y);
		if (rx != ry){
			int sx = sizes[rx];
			int sy = sizes[ry];
			if (sx < sy){
				par[rx] = ry;
				sizes[ry] += sx;
			}
			else{
				par[ry] = rx;
				sizes[rx] += sy;
			}
		}
	}
	long size(int x){return sizes[root(x)];}
	bool same(int x, int y){return root(x) == root(y);}
};

int main(){
	int a[100010], b[100010], m, x, y;
	long n, c[100010];
	cin >> n >> m;
	for (int i = 0; i < m; ++i) cin >> a[i] >> b[i];
	UnionFind tree(n);
	c[m] = n*(n-1)/2;
	for (int i = m-1; i >= 0; --i){
		x = a[i] - 1; y = b[i] - 1;
		if (tree.same(x, y)){
			c[i] = c[i+1];
		}
		else{
			c[i] = c[i+1] - tree.size(x)*tree.size(y);
			tree.unite(x, y);
		}
	}
	for (int i = 1; i <= m; ++i){
		cout << c[i] - c[0] << endl;
	}
}

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


Measured memory_bytes: 2044
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; i++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	char a[6]; rep(i, 6)cin >> a[i];
	if (a[0] == a[5] && a[1] == a[4] && a[2] == a[3]) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;
}

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

int main(){
    int N, M; cin >> N >> M;
    int L=0;
    int R=100000;
    rep(i, M){
        int a,b;
        cin >> a >> b;
        L = max(L, a);
        R = min(R, b);
    }

    cout << max(R-L+1, 0) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back
 
 
int main(){
    int x;
    int n=10;

    while(cin>>x){

        int count=0;

        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                for(int k=0;k<n;k++){
                    for(int l=0;l<n;l++){
                        if(i+j+k+l==x){
                            count++;
                            // cout<<i<<" "<<j<<" "<<k<<" "<<l<<endl;
                        }
                    }
                }
            }
        }

        cout<<count<<endl;
    }


}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll A, B, C, x, y, a[300005], b[300005], c[300005], sum=0;
ll counter=0;
priority_queue<int,vector<int>,greater<int> >f;
int cmp(ll a, ll b){return a>b?1:0;}
int main()
{
      ios::sync_with_stdio(), cin.tie(0), cout.tie(0);
      cin >> x >> y >> A >> B >> C;
      for (int i=0; i<A; i++){cin >> a[i];}
      for (int j=0; j<B; j++) cin >>b[j];
      for (int k=0; k<C; k++) cin>> c[k];
      sort(a,a+A, cmp);
      sort(b, b+B, cmp);
      sort(c, c+C, cmp);
      for (int i=0; x>0&&i<A; i++)
      {
            sum+=a[i];
            f.push(a[i]);
            counter++;
            x--;
      }
      for (int i=0; y>0&&i<B; i++)
      {
            sum+=b[i];
            f.push(b[i]);
            counter++;
            y--;
      }
      ll temp_flag=0;
      for (int i=0; x>0||y>0; i++)
      {
            sum+=c[i];
            f.push(c[i]);
            counter++;
            temp_flag++;
            if (x>0) x--;
            else if (y>0) y--;
      }
      for (int i=temp_flag; i<C; i++)
      {
            if (c[i]>f.top())
            {
                  sum=sum-f.top()+c[i];
                  f.pop();
                  f.push(c[i]);
            }
            else break;
      }
      cout << sum << endl;
      return 0;
}


Measured memory_bytes: 6264
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

bool isomorphic(string s, string t){
   int n = (int)(s.size());
   for (int i = 0; i < n; ++i)
   {
      for (int j = i; j < n; ++j)
      {
         if(s[i] == s[j] and t[i] == t[j])continue;
         if(s[i] != s[j] and t[i] != t[j])continue;
         return 0;
      }
   }
   return 1;
}

void solve(){
   
   cin >> n;

   string s = "a";

   if(n == 1){
      cout << s;
      exit(0);
   }

   vector<string> ms;
   ms.push_back(s);
   for (int i = 1; i < n; ++i)
   {
      vector<string> nxt;
      for(auto it: ms){
         char mx = *max_element(it.begin(), it.end());
         for (int j = 0; j <= mx-'a'+1; ++j)
         {
            nxt.push_back(it+(char)(j+'a'));
         }
      }
      ms = nxt;
   }
   
      for(auto it: ms)
         cout << it << endl;

}

int32_t main(){_

   int t = 1;
   //cin >> t;

   while(t--){
     solve();
   }
   

   return 0;
}

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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int h, w, n; cin >> h >> w >> n;
  int m = max(h, w);
  cout << (n + m - 1) / m << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

def main():
    n = int(input())
    T = list(map(int, input().split()))
    m = int(input())
    P =[]
    X =[]
    for i in range(m):
        p,x = map(int, input().split())
        P.append(p)
        X.append(x)

    total = sum(T)
    for i in range(m):
        print(total - (T[P[i]-1] - X[i]))


if __name__ == '__main__':
    main()


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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) (a).begin(),(a).end()

template<typename T1, typename T2> inline void chkmin(T1 & x, const T2 & y) {if (y < x) x = y;}
template<typename T1, typename T2> inline void chkmax(T1 & x, const T2 & y) {if (x < y) x = y;}

#define int ll

const int N = 17;
const int INF = 1e18 + 228;
int n;
int x[N], y[N], p[N];
bool used[N];
int q[N];
int topQ;
int dp[N][N];
int cost[N][N];

void read() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> p[i];
	}
}

int calcCost(int L, int R, int mask) {
	if (cost[L][R] != INF) return cost[L][R];
	int ans = 0;
	for (int i = L + 1; i < R; i++) {
		int add = INF;
		int ind = q[i - 1];
		if (L >= 1) {
			int l = q[L - 1];
			chkmin(add, abs(y[ind] - y[l]));
		}
		if (R <= topQ) {
			int r = q[R - 1];
			chkmin(add, abs(y[ind] - y[r]));
		}
		for (int bit = 0; bit < n; bit++) {
			if ((mask >> bit) & 1) {
				chkmin(add, abs(x[ind] - x[bit]));
			}
		}
		chkmin(add, min(abs(x[ind]), abs(y[ind])));
		ans += p[ind] * add;
	}
	cost[L][R] = ans;
	return ans;
}

int calcDp(int k, int mask) {
	if (topQ == 0) return 0;
	if (topQ <= k) return 0;
	sort(q, q + topQ, [&] (int a, int b) {
		return y[a] < y[b];
	});
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			dp[i][j] = INF;
			cost[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	for (int pos = 1; pos <= topQ; pos++) {
		for (int cnt = 1; cnt <= min(pos, k); cnt++) {
			for (int prev = 0; prev < pos; prev++) {
				if (dp[prev][cnt - 1] == INF) continue;
				chkmin(dp[pos][cnt], dp[prev][cnt - 1] + calcCost(prev, pos, mask));
			}
		}
	}
	int ans = INF;
	for (int i = 0; i <= topQ; i++) {
		if (dp[i][k] == INF) continue;
		chkmin(ans, dp[i][k] + calcCost(i, topQ + 1, mask));
	}
	return ans;
}

int calc(int mask, int k) {
	k -= __builtin_popcount(mask);
	if (k < 0) return INF;
	fill(used, used + n, false);
	for (int i = 0; i < n; i++) {
		if (x[i] == 0) used[i] = true;
		if (!((mask >> i) & 1)) continue;
		for (int bit = 0; bit < n; bit++) {
			if (x[i] == x[bit]) {
				used[bit] = true;
			}
		}
	}
	topQ = 0;
	for (int i = 0; i < n; i++) {
		if (used[i]) continue;
		q[topQ++] = i;
	}
	return calcDp(k, mask);
}

int solve(int k) {
	int ans = INF;
	for (int mask = 0; mask < (1 << n); mask++) {
		int fans = calc(mask, k);
		chkmin(ans, fans);
	}
	return ans;
}

int ans[N];

void run() {
	for (int i = 0; i <= n; i++) {
		ans[i] = solve(i);
	}
}

void write() {
	for (int i = 0; i <= n; i++) {
		cout << ans[i] << "\n";
	}
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(20), cout.setf(ios::fixed);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 3604
#Counting Sort

def CountingSort(A, B, k):
    C = [0] * (k + 1)

    #C[i]に出現数を記録する
    for i in range(len(A)):
        C[A[i]] += 1

    for i in range(1, k+1):
        C[i] = C[i] + C[i-1]

    for i in reversed(range(len(A))):
        B[C[A[i]]-1] = A[i]
        C[A[i]] -= 1

    return B

n = int(input())
A = list(map(int, input().split()))
B = [0] * len(A)
k = 10000

B = CountingSort(A, B, k)

result = ''

for b in B:
    result += str(b) + ' '

print(result[:-1])


Measured memory_bytes: 224508
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

struct restaurant {
  int number;
  std::string city;
  int score;
  bool operator<(restaurant const & another) const {
    if (city != another.city) {
      return city < another.city;
    }
    else {
      return score > another.score;
    }
  }
};

int main() {
  int n;
  std::cin >> n;
  std::vector<restaurant> rs(n);
  for(int i = 0; i < n; ++i) {
    rs.at(i).number = i+1;
    std::cin >> rs.at(i).city >> rs.at(i).score;
  }
  std::sort(rs.begin(), rs.end());
  for (auto & r : rs)
    std::cout << r.number << std::endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      
        String aaa = br.readLine();
        int num5 = Integer.parseInt(aaa);
            
        CalcAdd calcAdd = (num) -> {
            return num * num * num;
        };
        System.out.println(calcAdd.calc(num5));
    }
}

interface CalcAdd{
    int calc(int num);
}




Measured memory_bytes: 30468
#include <iostream>
#include <cstdio>
#include <iomanip>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(unsigned int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

bool sorter(pair<pair<int,int>,int> a,pair<pair<int,int>,int> b){
    // solved
    if(a.first.first > b.first.first){
        return true;
    }else if(a.first.first == b.first.first){
        //time
        if(a.first.second < b.first.second){
            return true;
        }else if(a.first.second == b.first.second){
            return a.second < b.second;
        }else{
            return false;
        }
    }else{
        return false;
    }
}
int main(){
    while(true){
        int T,P,R;
        cin >> T >> P >> R;
        if(T==0) break;
        // solved , time , id
        vector<pair<pair<int,int>,int> > S(T);
        rep(i,T) S[i].second = i+1;
        // pena
        vector<vector<int> > PE(T,vector<int>(P));
        rep(i,R){
            int tID,pID,time;string message;
            cin >> tID >> pID >> time >> message;
            tID--;pID--;
            if(message == "CORRECT"){
                S[tID].first.first += 1;
                S[tID].first.second += PE[tID][pID]*1200 + time;
            }else{
                PE[tID][pID]++;
            }
        }
        sort(all(S),sorter);
        rep(i,T){
            cout << S[i].second << " " << S[i].first.first << " " << S[i].first.second << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1240
// https://ynucpc.github.io/blog/2018/04/15/cp_vscode/
// http://www.atmarkit.co.jp/ait/articles/1509/08/news019.html

#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rep3(i,n,m) for(ll i=(n);i<(ll)(m);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
// #define max(a, b) ((a) > (b) ? (a) : (b))
// #define min(a, b) ((a) < (b) ? (a) : (b)) 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int _stoi(string s, int tmp=10){
	istringstream stm(s);
	int res;
	stm >> res;
	return res;
}
double _stod(string s, int tmp=10){
	istringstream stm(s);
	double res;
	stm >> res;
	return res;
}
template<typename T>string to_string(const T& n){
	std::ostringstream stm;
	stm << n;
	return stm.str();
}

// 降順ソート: sort(A, A+N, greater<>());
// min: *min_element(A, A+N)
// argmin: min_element(A, A+N)-A

ll gcd(ll a, ll b){
	if (a==0){
		return b;
	}else{
		return gcd(b%a, a);
	}
}


int main(){	
	// ll A; cin >> A;
	// cout << "hello" << _stoi("14") << max({1,3}) << endl;
	string S;
	cin >> S;
	int s = _stoi(S.substr(0, 4)+S.substr(5,2)+S.substr(8,2));
	if (s<=20190430)cout << "Heisei" << endl;
	else cout << "TBD" << endl;


}








Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>


int main() {
	std::string n; std::cin >> n;
	if (n.size() == 1) {
		std::cout << std::stoi(n) << '\n';
	}
	else if (std::all_of(std::next(n.begin()), n.end(), [](const char c) {return c == '9'; })) {
		std::cout << 9 * (n.size() - 1) + n.front() - '0' << '\n';
	}
	else {
		std::cout << 9 * (n.size() - 1) + n.front() - '0' - 1 << '\n';
	}
}


Measured memory_bytes: 504
import java.util.*;
// スペードが'S'、ハートが'H'、クラブが'C'、ダイヤが'D'で表されています。整数はそのカードのランク(1 〜 13)
public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        int[][] data = new int[4][13];
        
        for(int i=0;i<n;i++){
            String[] s = sc.nextLine().split(" ");
            int num = Integer.parseInt(s[1])-1;
            switch (s[0]) {
                case "S":
                    data[0][num]=1;
                    break;
                case "H":
                    data[1][num]=1;
                    break;
                case "C":
                    data[2][num]=1;
                    break;
                case "D":
                    data[3][num]=1;
                    break;
            }
        }
        for(int i=0;i<4;i++){
            for(int j=0;j<13;j++){
                if(data[i][j]==0) {
                    switch (i) {
                        case 0:
                            System.out.println("S "+(j+1));
                            break;
                        case 1:
                            System.out.println("H "+(j+1));
                            break;
                        case 2:
                            System.out.println("C "+(j+1));
                            break;
                        case 3:
                            System.out.println("D "+(j+1));
                            break;
                    }
                    
                }
            }
        }
        
    }
}


Measured memory_bytes: 26096
#include <stdio.h>

int main(void){
int x,y;
scanf("%d %d", &x, &y);

while(x !=0 || y !=0){
if(x < y){
  printf("%d %d\n", x, y);
}else {
  printf("%d %d\n",y, x);
}
scanf("%d %d" ,&x, &y);

}
return 0;
}

Measured memory_bytes: 596
n = input()
i = 1
num = []
while i <= n:
    if i % 3 == 0:
        num.append(i)
        i +=1
    else:
        x = i
        while x > 0:
            if x % 10 == 3:
                num.append(i)
                break
            elif x / 10 == 3:
                num.append(i)
                break
            else:
                x /=  10                
        i += 1
print("{}".format(str(num)).replace("["," ").replace("]","").replace(",",""))

Measured memory_bytes: 6652
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
 
using namespace std;
 
#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007
 
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;
 
int N,M,K;
 
 
 
ll dfs(int n, int s){
  if(n==N) return max(1, s);
  ll res = 0;
  for(int i=1;i<=M;i++){
    res += dfs(n+1, s+i);
  }
  return res;
}
 
int main(){
  while(cin >> N >> M >> K && N+M+K){
    cout << fixed << setprecision(12) << dfs(0, -K)/(double)pow(M, N) << endl;
  }
  return 0;
}


Measured memory_bytes: 3248
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
# debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)

s = ins()
assert len(s) == 1


def solve():
    if s.islower():
        return "a"
    else:
        return "A"


print(solve())


Measured memory_bytes: 8976
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M;
	while(cin>>N>>M) {
		cout<<(N==M ? "Yes":"No")<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
import math
K = int(input())

GCD = [[1 for x in range(K+1)] for y in range(K+1)]

for x in range(1, K+1):
  for y in range(1, K+1):
    GCD[x][y] = math.gcd(x, y)

# print(GCD)

ans = 0
for a in range(1, K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      ans += GCD[GCD[a][b]][c]

print(ans)

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

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)

int INF = 10e8;
int n;
string s[50];
char alpha[26];
int c[26];

void cnum(string st){
    int tmpc[26];
    REP(i, 26) tmpc[i] = 0;

    REP(i, st.size()){
        REP(j, 26){
            if(st[i] == alpha[j]){
                tmpc[j] += 1;
                break;
            }
        }
    }

    REP(i, 26){
        c[i] = min(c[i], tmpc[i]);
    }
}

int main(){
    REP(i, 26) alpha[i] = char('a'+i);

    cin >> n;
    REP(i, n) cin >> s[i];
    REP(i, 26) c[i] = INF;
    REP(i, n) cnum(s[i]);

    REP(i, 26){
        REP(j, c[i]) cout << alpha[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
        int n,x;
        cin >> n >> x;

        int m,min=1000;
        for(int i=0;i<n;i++){
                cin >> m;
                x-=m;
                if(m<min) min=m;
        }

        int ans=n;
        ans+=x/min;

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(std::string s){
    string ans;
    REP(i, s.size()) {
        if (s[i] == '0') ans.push_back('0');
        else if (s[i] == '1') ans.push_back('1');
        else if (s[i] == 'B') {
            if (ans.size() == 0) continue ;
            ans.pop_back();
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

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

	ll S, W;
	cin >> S >> W;

	cout << (S <= W ? "unsafe" : "safe") << endl;

	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

#define int64_t ll
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int j=1;j<=n;++j){
  ll num=j;
  for(int64_t i = 2; i * i <= num; i++) {
    while(num % i == 0) {
      ret[i]++;
      num /= i;
    }
  }
  if(num != 1) ret[num]++;
  }
  return ret;
}

//ここから
int cnt;
int n;

void dfs(string s,bool check){
  if(s!=""&&stoll(s)>n)return;
  if(check==true)++cnt;
  else {
    bool ok1=false,ok2=false,ok3=false;
    rep(i,s.size()){
      if(s[i]=='3')ok1=true;
      if(s[i]=='5')ok2=true;
      if(s[i]=='7')ok3=true;
    }
    if(ok1&&ok2&&ok3)check=true;
    if(check)++cnt;
  }
  dfs(s+"3",check);
  dfs(s+"5",check);
  dfs(s+"7",check);
}

void solve(){
  cin>>n;
  cnt=0;
  dfs("",false);
  cout<<cnt;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	//cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>

using namespace std;



int main(int argc, char *argv[])
{
	int n, m;
	static int a[31];
	//input
	cin >> n >> m;
	for (int i = 0; i < n; i++){
		int ki;
		cin >> ki;
		for (int j = 0; j < ki; j++){
			int ai;
			cin >> ai;
			a[ai]++;
		}
	}




	//calc
	int ans = 0;
	for (int i = 1; i <= 30; i++){
		if (a[i] >= n){
			ans++;
		}
	}




	//ans
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
inf=10**11
A,B,Q=map(int,input().split())
s=[-inf]+[int(input()) for _ in range(A)]+[inf]
t=[-inf]+[int(input()) for _ in range(B)]+[inf]
x=[[i,int(input())] for i in range(Q)]

x.sort(key=lambda x:x[1])
i,s_i,t_i=0,0,0
ans=[]

for i in range(Q):
    while(1):
        if x[i][1]>=s[s_i]:
            s_i+=1
        else:
            break
    while(1):
        if x[i][1]>=t[t_i]:
            t_i+=1
        else:
            break
    ans.append([x[i][0],x[i][1],s[s_i-1],s[s_i],t[t_i-1],t[t_i]])
ans.sort(key=lambda x:x[0])
for i in range(Q):
    xx=ans[i][1]
    Nb_s0=ans[i][2]
    Nb_s1=ans[i][3]
    Nb_t0=ans[i][4]
    Nb_t1=ans[i][5]

    p1=abs(Nb_s0-xx)
    p2=abs(Nb_s1-xx)
    p3=abs(Nb_t0-xx)
    p4=abs(Nb_t1-xx)
    q1=abs(Nb_t0-Nb_s0)
    q2=abs(Nb_t0-Nb_s1)
    q3=abs(Nb_t1-Nb_s0)
    q4=abs(Nb_t1-Nb_s1)
    print(min(p1+q1,p2+q2,p1+q3,p2+q4,p3+q1,p4+q4,p3+q2,p4+q3))

Measured memory_bytes: 143960
N = int(input())
b = list(map(int, input().split()))

c = b[:]
ans = []
jdg = True

while c:
    temp = []
    for i in range(len(c)):
        if i + 1 - c[i] == 0:
            temp.append([c[i], i])
    if not temp:
        jdg = False
        break
    l = max(temp)
    c = c[:l[1]] + c[l[1]+1:]
    ans.append(l[0])

if jdg:
    ans.reverse()
    print(*ans, sep='\n')
else: print(-1)

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

using namespace std;

typedef long long int ll;

#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f(i,s,n) for(int i=s;i<n;i++)

int main() {
	
	fastIO
	ll n,ct=0;
	cin>>n;
	ll a[n];
	f(i,0,n)
	cin>>a[i];
	sort(a,a+n);
	f(i,0,n){
	    f(j,i+1,n){
	        f(k,j+1,n){
	            if(a[i]+a[j]>a[k])
	            ct++;
	            else
	            break;
	        }
	    }
	}
	cout<<ct;
	return 0;
}

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

int main(){
	int N[10];

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

	sort(&N[0], &N[0]+10, greater<int>());

	cout << N[0] << endl;
	cout << N[1] << endl;
	cout << N[2] << endl;

	return 0;
}

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

int main() {
  char s;
  cin >> s;
  
  if(s == 'A'){
    cout << "T" << endl;
  }
  if(s == 'T'){
    cout << "A" << endl;
  }
  if(s == 'G'){
    cout << "C" << endl;
  }
  if(s == 'C'){
    cout << "G" << endl;
  }
}


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

int main(){
    int a, b;
    char op;
    cin >> a >> op >> b;

    if (op == '+'){
        cout << a + b << endl;
    }
    else
    {
        cout << a - b << endl;
    }
    
}

Measured memory_bytes: 3568
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)

tmp = 10 ** 9
ans = 1
for i in range(1,N):
  if abs(a[0]/2 - a[i]) < tmp:
    tmp = abs(a[0]/2 - a[i])
    ans = a[i]

    
s = str(a[0]) + " " + str(ans)
print(s)
 

Measured memory_bytes: 14060
rtimes = []

24.times.each do
  rn, rt = gets.strip.split(" ")
  rtimes << [rn, rt.to_f]
end

semifinals = []
rests = []

for t in (0..2)
  race = rtimes[(t * 8), 8].sort{|a, b| a[1] <=> b[1]}
  semifinals << race.shift
  semifinals << race.shift
  rests += race
end

rests.sort!{|a, b| a[1] <=> b[1]}
semifinals << rests.shift
semifinals << rests.shift

semifinals.each{|rn, rt| printf("%s %.2f\n", rn, rt)}

Measured memory_bytes: 6156
#include<iostream>
using namespace std;
int hyou1[1500001]={},hyou2[1500001]={};
int main(){
  int n,m;
  while(cin>>n>>m,n){
    for(int i=0;i<1500001;i++)hyou1[i]=0,hyou2[i]=0;
    int a[1500],b[1500];
    for(int i=0;i<n;i++)cin>>a[i],hyou1[a[i]]++;
    for(int i=0;i<m;i++)cin>>b[i],hyou2[b[i]]++;
    for(int i=0;i<n;i++){
      int sum=a[i];
      for(int j=i+1;j<n;j++){
        sum+=a[j];
        hyou1[sum]++;
      }
    }
    for(int i=0;i<m;i++){
      int sum=b[i];
      for(int j=i+1;j<m;j++){
        sum+=b[j];
        hyou2[sum]++;
      }
    }
    int ans=0;
    for(int i=0;i<1500001;i++){
      ans+=hyou1[i]*hyou2[i];
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 14800
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;

ll xs[] = {-1, 1, 0, 0};
ll ys[] = {0, 0, -1, 1};

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll t, m;
	cin >> t >> m;
	string a[t];
	for(ll i=0; i<t; i++)
		cin >> a[i];
	sort(a, a+t);
	for(ll i=0; i<t; i++)
		cout << a[i];
	return 0;
}

Measured memory_bytes: 3664
import java.util.*;
import java.math.*;

public class Main{

    final static int maxn = (int) 1e5 + 7;

    static int[] a = new int[maxn];

    static int[] tree = new int[maxn << 2];

    static int n;

    static void build(int l, int r, int node) {
        if(l == r) {
            tree[node] = a[l];
            return;
        }
        int mid = (l + r) >> 1;
        build(l, mid, node<<1);
        build(mid + 1, r, node << 1 | 1);
        tree[node] = Math.max(tree[node<<1], tree[node<<1|1]);
    }

    static int query(int l, int r, int node, int ql, int qr) {
        if(ql <= l && qr >= r) return tree[node];
        int mid = (l + r) >> 1;
        int res = 0;
        if(ql <= mid) res = Math.max(res, query(l, mid, node<<1, ql, qr));
        if(qr > mid)  res = Math.max(res, query(mid+1, r, node<<1|1, ql, qr));
        return res;
    }

    static long get_left(int k, int l, int r) {
        long ans = -1;
        while(l <= r){
            int mid = (l + r) >> 1;
            if(query(1, n, 1, mid, r) > a[k]) {
                ans = mid;
                l = mid + 1;
            }
            else r = mid - 1;
        }
        return ans;
    }

    static long get_right(int k, int l, int r) {
        long ans = -1;
        while(l <= r){
            int mid = (l + r) >> 1;
            if(query(1, n, 1, l, mid) > a[k]) {
                ans = mid;
                r = mid - 1;
            }
            else l = mid + 1;
        }
        return ans;
    }

    public static void main(String[] args){
        Scanner cin = new Scanner(System.in);
        while(cin.hasNext()) {
            n = cin.nextInt();
            for(int i=1; i<=n; i++) a[i] = cin.nextInt();
            build(1, n, 1);
            long ans = 0;
            for(int i=1; i<=n; i++) {
                long pl1 = get_left(i, 1, i-1);
                long pl2 = pl1 == -1 ? -1 : get_left(i, 1, (int)pl1 - 1);
                long pr1 = get_right(i, i+1, n);
                long pr2 = pr1 == -1 ? -1 : get_right(i, (int)pr1 + 1, n);
                if(pl1 != -1 && pl2 != -1 && pr1 != -1 && pr2 != -1) ans += a[i] * ((pl1 - pl2) * (pr1 - i) + (i - pl1) * (pr2 - pr1));
                if(pl1 != -1 && pl2 != -1 && pr1 != -1 && pr2 == -1) ans += a[i] * ((pl1 - pl2) * (pr1 - i) + (i - pl1) * (n - pr1 + 1));
                if(pl1 != -1 && pl2 != -1 && pr1 == -1 && pr2 == -1) ans += a[i] * ((pl1 - pl2) * (n - i + 1));

                if(pl1 != -1 && pl2 == -1 && pr1 != -1 && pr2 != -1)  ans += a[i] * (pl1 * (pr1 - i) + (i - pl1) * (pr2 - pr1));
                if(pl1 != -1 && pl2 == -1 && pr1 != -1 && pr2 == -1) ans += a[i] * (pl1 * (pr1 - i) + (i - pl1) * (n - pr1 + 1));
                if(pl1 != -1 && pl2 == -1 && pr1 == -1 && pr2 == -1) ans += a[i] * (pl1 * (n - i + 1));

                if(pl1 == -1 && pl2 == -1 && pr1 != -1 && pr2 != -1) ans += a[i] * (i * (pr2 - pr1));
                if(pl1 == -1 && pl2 == -1 && pr1 != -1 && pr2 == -1) ans += a[i] * (i * (n - pr1 + 1));
            }
            System.out.println(ans);
        }
    }

}



















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


Measured memory_bytes: 128
//#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=1e9+7;
const int maxn=3e5+100;
const int N=2e5+100;
const int M=500+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}


map<pii,int>mp;
int main()
{
#ifdef local
    freopen("in.txt","r",stdin);
#endif // local
    IOS;cout.tie(0);
    int n;cin>>n;
    rep1(i,n)
    {
        double x;cin>>x;
        ll a=llround(x*1e9);
        int u=0,v=0;
        while(a%2==0) a/=2,u++;
        while(a%5==0) a/=5,v++;
        mp[pii(u,v)]++;
    }
    ll ans=0;
    for(auto p1:mp)
    {
        for(auto p2:mp)
        {
            if((p1.X.X+p2.X.X>=18)&&(p1.X.Y+p2.X.Y>=18))
            {
                if(p1==p2) ans+=(ll)p1.Y*(ll)(p1.Y-1);
                else ans+=(ll)p1.Y*(ll)p2.Y;
            }
        }
    }
    cout<<ans/2<<endl;
    return 0;
}



Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int  n,i,j,k,x,H,xx;
    cin>>n;
    long long int   X[n],Y[n],h[n];
    int indx=0;
    for(i=0; i<n; i++)
    {
        cin>>X[i]>>Y[i]>>h[i];
        if(h[i] > 0)
        {
            indx= i;
        }
    }

    for(i=0; i<=100; i++)
    {
        for(j=0; j<=100; j++)
        {
            H=h[indx]+abs(X[indx]-i)+abs(Y[indx]-j);
            bool its_ok=true;
            for(k=0; k<n; k++)
            {
                xx=(H-abs(X[k]-i)-abs(Y[k]-j));
                if(xx<0)   xx=0;

                if(xx!=h[k])
                {
                    its_ok=false;
                    break;
                }
            }
            if(its_ok)
            {
                cout<<i<<' '<<j<<' '<<H<<endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3616
import sys
input = sys.stdin.readline
N=int(input())
A=[]
C=[]
D=[]
for i in range(N):
    a,b=map(int,input().split())
    c,d=min(a,b),max(a,b)
    A.append((c,d))
    C.append(c)
    D.append(d)
A.sort()
#print(A,C,D,si,ti)
if N==1:
    print(0)
    sys.exit()
ans=(max(C)-min(C))*(max(D)-min(D))
cur=max(C)
ma=min(D)
T=10**19
for a,b in A:
    if a>ma:
        T=min(T,cur-ma)
        break
    T=min(T,cur-a)
    cur=max(cur,b)
print(min(ans,(max(D)-min(C))*T))

Measured memory_bytes: 85852
#include <iostream>

using namespace std;

int main() {
  int h[10000];
  int i;
  for (i = 0; ; i++) {
    cin >> h[i];
    if (h[i] == 0) {
      break;
    }
  }
  for (int j = 0; j < i; j++) {
    cout << "Case " << j + 1 << ": " << h[j] << endl;
  }
}


Measured memory_bytes: 3028
N, M = map(int, input().split())
AB = [list(map(lambda x : int(x) - 1, input().split())) for _ in range(M)]

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

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

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

		if x == y:
			return

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

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

uf = UnionFind(N)
for a, b in AB:
	uf.union(a, b)

ans = min(uf.parents)
print(-ans)


Measured memory_bytes: 47172