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

int a, b, q;
vector<long long> s, t;
vector<long long> ds, dt;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> a >> b >> q;
	s.resize(a); t.resize(b);
	for(auto &i:s) cin >> i;
	for(auto &i:t) cin >> i;
	s.insert(s.begin(), -1e18); t.insert(t.begin(), -1e18);
	s.push_back(1e18); t.push_back(1e18);
	ds.resize(a+2); dt.resize(b+2);
	for(int i=1; i<=a; ++i)
		ds[i] = min(*lower_bound(t.begin(), t.end(), s[i]) - s[i], s[i] - *(upper_bound(t.begin(), t.end(), s[i])-1));
	for(int i=1; i<=b; ++i)
		dt[i] = min(*lower_bound(s.begin(), s.end(), t[i]) - t[i], t[i] - *(upper_bound(s.begin(), s.end(), t[i])-1));
/*	for(int i=1; i<=a; ++i)
		cout << ds[i] << " \n"[i==a];
	for(int i=1; i<=b; ++i)
		cout << dt[i] << " \n"[i==b];
*/	while(q--){
		long long x; cin >> x;
		int sl = lower_bound(s.begin(), s.end(), x) - s.begin();
		int su = upper_bound(s.begin(), s.end(), x) - 1 - s.begin();
		int tl = lower_bound(t.begin(), t.end(), x) - t.begin();
		int tu = upper_bound(t.begin(), t.end(), x) - 1 - t.begin();
		cout << min({s[sl]-x+ds[sl], x-s[su]+ds[su], t[tl]-x+dt[tl], x-t[tu]+dt[tu]}) << "\n";
	}
}

Measured memory_bytes: 4448
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()
L = LI()

ans = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1,N-1):
        b = L[j]
        for k in range(j+1,N):
            c = L[k]
            if a == b or b == c or c == a:
                continue
            else:
                if a+b > c and b+c > a and c+a > b:
                    ans += 1
print(ans)


Measured memory_bytes: 68036
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N;

int main() {
    cin >> N;

    vi A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        B[i] = A[i];
    }

    sort(A.begin(), A.end(), greater<int>());

    for (int i = 0; i < N; i++) {
        if (B[i] == A[0])
            cout << A[1] << endl;
        else
            cout << A[0] << endl;
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int64_t> A(n), B(n);
    vector<array<int64_t, 2>> S(n);
    for (int i = 0; i < n; i++){
        cin >> A[i] >> B[i];
        S[i][0] = A[i] + B[i];
        S[i][1] = i;
    }

    sort(S.begin(), S.end(), greater<array<int64_t, 2>>());
    int64_t ans = 0;
    for (int i = 0; i < n; i++){
        if (i % 2 == 0)
            ans += A[S[i][1]];
        else
            ans -= B[S[i][1]];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3328
N,L = map(int,input().split())
S = 0
b = abs(L)
for i in range(1,N+1):
  a = L + i - 1
  S += a
  b = min(abs(a),b)
if -N < L:
  ans = S - b
else:
  ans = S + b
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=1<<31-1=2147483647
constexpr ll INF = (ll)1e18;//1<<63-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

constexpr ll N_MAX = 100;

ll N, K;

void input() {
	scanf("%lld%lld", &N, &K);
}

void solve() {
	if(K > (N-1)*(N-2)/2){
		p(-1);return;
	}

	if(N==2){
		//p(-1);return;
	}


	vector<ll> a((N)*(N-1)/2,0),b((N)*(N-1)/2,0);
	ll index=0;
	for(ll i=2;i<=N;i++){
		a[index]=1;
		b[index]=i;
		index++;
	}

	ll count=(N-1)*(N-2)/2;
	ll anum=2;
	ll bnum=3;
	while(count>K){
		a[index]=anum;
		b[index]=bnum;
		index++;
		count--;
		bnum++;
		if(bnum>N){
			anum++;
			bnum=anum+1;
		}
	}

	p(index);
	rep(i,index){
		cout<<a[i]<<" "<<b[i]<<endl;
	}


}

signed main() {
	input();
	solve();
	return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<int> in(n);
  for (int i = 0; i < n; i++) {
    cin >> in[i];
  }
  static long long dp[3456][3456] = {};
  for (int x = 1; x <= n; x++) {
    for (int i = 0; i + x <= n; i++) {
      int j = i + x;
      if ((n - x) % 2 == 0) {
        dp[i][j] = max(dp[i + 1][j] + in[i], dp[i][j - 1] + in[j - 1]);
      } else {
        dp[i][j] = min(dp[i + 1][j] - in[i], dp[i][j - 1] - in[j - 1]);
      }
    }
  }
  cout << dp[0][n] << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int k, q;
  cin >> k >> q;
  vi32 d(k);
  cin >> d;
  rep(qi, q) {
    int n, x, m;
    cin >> n >> x >> m;
    i64 all = n - 1;
    i64 fst = x;
    i64 lst = x;
    rep(i, k) {
      if (n - 2 - i < 0) break;
      i64 c = (n - 2 - i) / k + 1;
      lst += c * (d[i] % m);
    }
    i64 div = lst / m - fst / m;
    i64 zero = 0;
    rep(i, k) if (d[i] % m == 0) {
      if (n - 2 - i < 0) break;
      zero += (n - 2 - i) / k + 1;
    }
    i64 ans = all - div - zero;
    cout << ans << endl;
  }
}


Measured memory_bytes: 384
#include <stdio.h>
int gcd (int w,int h){
return h ? gcd(h,w % h): w;
}

int main() {
int w, h, c, g;
scanf("%d", &w);
scanf("%d", &h);
scanf("%d", &c);
g = gcd(w, h);

printf("%d\n",(w *h) / (g * g) * c);
	return 0;
}

Measured memory_bytes: 1824
def main():
  mapping = {
    "SUN": 0,
    "MON": 1,
    "TUE": 2,
    "WED": 3,
    "THU": 4,
    "FRI": 5,
    "SAT": 6,
  }
 
 
  S = input()
  print(7-mapping[S])
 
if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES
#define ios std::ios::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define PI acos(-1.0)
#define EPS 1e-9 //epsilon 10^-9, checking for equality 
#define pb push_back
#define fi first
#define se second
#define go(i,a,n) for(int i=a;i<n;i++)
#define og(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(i,n) go(i,0,n)
#define per(i,n) og(i,0,n)
#define sz(x) (x.size())
#define isort(x) sort(x.begin(),x.end())
#define dsort(x) sort(x.rbegin(),x.rend())
#define all(x) x.begin(),x.end()
#define rall(x) (x).rbegin(),(x).rend()
#define pr(x) cout<<(x)<<endl
#define exist(e,s) ((s).find(e)!=(s).end()) //Element e in structure s
#define existstr(c,s) ((s).find(c) !=string::npos) //Character in structure
#define fo(x,s) for(auto &x:s) //for all x in structure s
typedef vector<int> vi;typedef vector<ll> vll;typedef vector< vector<int> > vvi;
typedef vector< vector<ll> > vvll;typedef pair<int,int> ii;typedef pair<int, pair<int,int> > iii;
typedef pair<ll,ll> pll;typedef vector<ii> vii;typedef vector<iii> viii;typedef map<int,int> mii;
const int inf=1e9+7; //10^9 +7
inline void rvi(vi& v, int n){int temp; go(i,0,n){cin>>temp;v.pb(temp);}}
inline void rvll(vll& v, int n){ll temp;go(i,0,n){cin>>temp;v.pb(temp);}}
inline void prvi(vi&a){go(i,0,a.size()){cout<<a[i]<<" ";}cout<<endl;}
inline void prvll(vll&a){go(i,0,a.size()){cout<<a[i]<<" ";}cout<<endl;}
inline void prmii(map<int,int>& m){for(auto x:m){cout<<x.fi<<" "<<x.se<<endl;}}
inline vll prefixsum(vi& a){vll b;b.pb(a[0]);go(i,1,a.size()){b.pb(a[i]+b[i-1]);}return b;}
inline vll suffixsum(vi& a){vll b(sz(a));b[sz(a)-1]=a[sz(a)-1];og(i,0,sz(a)-1){b[i]=a[i]+b[i+1];}return b;}
inline vll prefixsum(vll& a){vll b;b.pb(a[0]);go(i,1,a.size()){b.pb(a[i]+b[i-1]);}return b;}
inline vll suffixsum(vll& a){vll b(sz(a));b[sz(a)-1]=a[sz(a)-1];og(i,0,sz(a)-1){b[i]=a[i]+b[i+1];}return b;}
void solve();
int main(){ios;solve();return 0;}
//--------SOLVE---------------------------------------------------------------------
void solve()
{
	int n;cin>>n;
	unordered_map<string,int> m;
	string prev;
	rep(i,n)
	{
		string s;
		cin>>s;
		m[s]++;
		if(i>0)
		{
			if(prev[prev.size()-1]!=s[0]||(m[s]>1))
			{
				cout<<"No"<<endl;
				return;
			}
		}
		prev=s;
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict as dd
MOD = 10 ** 9 + 7
X, Y = map(int, input().split())
if (X + Y) % 3 != 0:
    print(0)
    exit()
if 2 * Y < X or Y > 2 * X:
    print(0)
    exit()

def combination(n, k, MOD):
    if n-k < k:
        k = n-k
    ans = 1
    for x in range(n-k+1, n+1):
        ans *= x
        ans %= MOD
    d = 1
    for x in range(1, k+1):
        d *= x
        d %= MOD
    ans *= pow(d, MOD-2, MOD)
    ans %= MOD
    return ans

N = (X + Y) // 3 + 1
K = 2 * (N-1) - X + 1
print(combination(N-1, K-1, MOD))

Measured memory_bytes: 3700
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var N = NextInt();
            var a = LongList();
            var minus = a.Count(x => x < 0);
            var list = a.Select(x => Math.Abs(x)).ToList();

            if(minus % 2 == 0) {
                Console.WriteLine(list.Sum());
            } else {
                Console.WriteLine(list.Sum() - 2 * list.Min());
            }
        }
    }

    class MyMath {
        public const long mod = 1000000007;

        public static long Gcd(long a, long b) {
            return b == 0 ? a : Gcd(b, a % b);
        }

        public static List<long> Factor(long n) {
            var list = new List<long>();
            n = DivideToLimit(n, 2, list);
            n = DivideToLimit(n, 3, list);
            long sqrt = Sqrt(n);
            for (int i = 5; i <= n && i <= sqrt; i += 4) {
                n = DivideToLimit(n, i, list);
                i += 2;
                n = DivideToLimit(n, i, list);
            }
            if (n > 1) list.Add(n);
            return list;
        }

        public static long Sqrt(long n) {
            if (n < 0) return 0;
            long a = 0, tmp = 0, b = 0;
            for (int i = 62; i >= 0; i -= 2) {
                tmp = (b << 1) + 1 <= (n >> i) ? 1 : 0;
                a = a << 1 | tmp;
                n -= (((b << 1) + 1) * tmp) << i;
                b = (b << 1) + tmp + tmp;
            }
            return a;
        }

        static long DivideToLimit(long divisor, long dividend, List<long> list) {
            while (divisor % dividend == 0) {
                list.Add(dividend);
                divisor /= dividend;
            }
            return divisor;
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const ld PI = acosl(-1.0);
const int MX = (int)1e8;

void inv(int &x) {
	x = MX - x;
}

struct ST {
	vector<int> t;
	ST(int n) {
		t.resize(4 * n + 3);
	}
	void ch(int v, int tl, int tr, int pos, int val) {
		if (tl == tr) {
			t[v] = val;
		} else {
			int tm = (tl + tr) >> 1;
			if (pos <= tm) {
				ch(v + v, tl, tm, pos, val);
			} else {
				ch(v + v + 1, tm + 1, tr, pos, val);
			}
			t[v] = max(t[v + v], t[v + v + 1]);
		}
	}
	int gm(int v, int tl, int tr, int l, int r) {
		if (r < tl || l > tr) return 0;
		if (tl >= l && tr <= r) return t[v];
		int tm = (tl + tr) >> 1;
		return max(gm(v + v, tl, tm, l, r), gm(v + v + 1, tm + 1, tr, l, r));
	}
};

const int MAXN = 200 * 1000 + 7;

int pos[MAXN];

bool in(int l, int r, int x) {
	return x >= l && x <= r;
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int x1, y1, x2, y2;
	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
	int n;
	scanf("%d", &n);
	vector<pair<int, int> > pts(n);
	for (int i = 0; i < n; i++) {
		scanf("%d %d", &pts[i].first, &pts[i].second);
	}
	if (x1 > x2) {
		inv(x1);
		inv(x2);
		for (auto &x : pts) inv(x.first);
	}
	if (y1 > y2) {
		inv(y1);
		inv(y2);
		for (auto &x : pts) inv(x.second);
	}
	vector<pair<int, int> > tmp;
	for (int i = 0; i < n; i++) {
		if (in(x1, x2, pts[i].first) && in(y1, y2, pts[i].second)) {
			tmp.push_back(pts[i]);
		}
	}
	pts = tmp;
	vector<int> xx, yy;
	for (auto &x : pts) {
		xx.push_back(x.first);
		yy.push_back(x.second);
	}
	sort(xx.begin(), xx.end());
	sort(yy.begin(), yy.end());
	int cnt = 0;
	for (auto &p : pts) {
		if (in(x1, x2, p.first) && in(y1, y2, p.second)) {
			int x = lower_bound(xx.begin(), xx.end(), p.first) - xx.begin() + 1;
			int y = lower_bound(yy.begin(), yy.end(), p.second) - yy.begin() + 1;
			pos[x] = y;
			cnt++;
		}
	}
	ST t(n + 3);
	int ress = 0;
	for (int i = 1; i <= n; i++) {
		if (pos[i] != 0) {
			int cur = t.gm(1, 1, n, 1, pos[i]) + 1;
			ress = max(ress, cur);
			t.ch(1, 1, n, pos[i], cur);
		}
	}
	bool bad = false;;
	if ((int)pts.size() == min(abs(x1 - x2), abs(y1 - y2)) + 1) {
		bad = true;
		sort(pts.begin(), pts.end());
		for (int i = 1; i < (int)pts.size(); i++) {
			if (pts[i].second < pts[i - 1].second) bad = false;
		}
	}
	ld res = abs(x1 - x2) + abs(y1 - y2);
	res *= 100LL;
	ld diff = 20.0 - 5.0 * PI;
	res -= diff * ress;
	if (bad) {
		res += diff;
		res -= 20;
		res += 10.0 * PI;
	}
	cout.precision(20);
	cout << fixed << res << endl;
}



Measured memory_bytes: 10224
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


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

  ll ans = INF;
  rep(i, 12) {
    int x = i * 1000;
    if (x >= n) chmin(ans, x-n);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<map>
#include<cstdio>
#define F first
#define S second
#define INF 1<<30
using namespace std;
typedef pair<int,int> P;
int cost[120][120]={0};
int prim(int n);
main(){
  int n,m;
  while(1){
    cin>>n;
    if(n==0)break;
    cin>>m;
    int from,to,mm,nn;
    nn=n;
    for(int i=0;i<120;i++){
      for(int j=0;j<120;j++){
	cost[i][j]=INF;
      }
    }
    for(int i=0;i<m;i++){
      scanf("%d,%d,%d",&from,&to,&mm);
      cost[from][to]=mm;
      cost[to][from]=mm;
    }
    cout<<prim(n)/100-(n-1)<<endl;
  }
}
int prim(int n){
  int min_cost[120];
  bool used[120];
  //すでにいけるかどうかを表す
  for(int i=0;i<n;i++){
    min_cost[i]=INF;
    used[i]=false;
  }
  min_cost[0]=0;
  int ans=0;
  while(1){
    int v=-1;
    for(int i=0;i<n;i++){
      if(used[i]==false/*まだ行くことができない*/&&(v==-1/*まだ他のルートを見つけていない*/||min_cost[i]<min_cost[v]/**/)){
	v=i;
      }
    }
    if(v==-1)break;//もうすべてのばしょにいける
    used[v]=true;//この場所にいく道を造った
    ans+=min_cost[v];//辺のコストを加える
    for(int i=0;i<n;i++){
      min_cost[i]=min(min_cost[i],cost[v][i]);
    }
  }
  return ans;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector <vector <int>> a(N , vector<int>(2));
  for(int i = 0;i<N;i++){
    cin>>a[i][1]>>a[i][0];
  }
  sort(a.begin(),a.end());
  int p = 0,q = 0;
  bool t = 0;
  for(int i = 0;i<N;i++){
    q += a[i][1];
    if(a[i][0]<q){
      t = 1;
      break;
    }
  }
  if(t == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 11136
use num::One;
use proconio::input;
use std::{
    fmt::{self, Display},
    iter::Sum,
    ops::{Add, Mul, Sub},
};

fn main() {
    input! {
        n: usize,
        k: usize,
    }

    let mut counts = vec![Zp::unchecked(0); k + 1];

    for x in (1..=k).rev() {
        counts[x] = num::pow(Zp::unchecked(k / x), n)
            - (2..)
                .take_while(|m| m * x <= k)
                .map(|m| counts[m * x])
                .sum::<Zp>();
    }

    let ans = counts
        .into_iter()
        .enumerate()
        .map(|(m, c)| Zp::new(m) * c)
        .sum::<Zp>();
    println!("{}", ans);
}

const P: usize = 1_000_000_007;

#[derive(Debug, Clone, Copy)]
struct Zp {
    repr: usize,
}

impl Zp {
    fn new(val: usize) -> Self {
        Self { repr: val % P }
    }

    fn unchecked(repr: usize) -> Self {
        Self { repr }
    }
}

impl Display for Zp {
    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
        Display::fmt(&self.repr, fmt)
    }
}

impl Add for Zp {
    type Output = Self;

    fn add(self, rhs: Self) -> Self {
        Self::new(self.repr + rhs.repr)
    }
}

impl Sub for Zp {
    type Output = Self;

    fn sub(self, rhs: Self) -> Self {
        Self::new(P + self.repr - rhs.repr)
    }
}

impl Mul for Zp {
    type Output = Self;

    fn mul(self, rhs: Self) -> Self {
        Self::new(self.repr * rhs.repr)
    }
}

impl Sum for Zp {
    fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
        iter.fold(Self::unchecked(0), Add::add)
    }
}

impl One for Zp {
    fn one() -> Self {
        Zp::unchecked(1)
    }
}


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

#define pb push_back
#define mp make_pair
#define ld long double
#define ll long long int
#define f(i,g,n) for(int i=g;i<=n;i++)
#define rf(i,g,n) for(int i=n;i>=g;i--)

const int N=1e3+1;

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


	int n;
	cin>>n;
	set<int> S;
	for(int i=1;i<=9;i++)
		for(int j=1;j<=9;j++)
			S.insert(i*j);
	if(S.find(n) == S.end())
		cout<<"No\n";
	else
		cout<<"Yes\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main()
{
    int n, k; string s; cin >> n >> s >> k;
    rep(i,n) {
        if (s[i] == s[k-1])
            cout << s[i];
        else
            cout << "*";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3612
// B - Common Raccoon vs Monster
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
int H,N;

int in(){int x;cin>>x;return x;}

int main(){
	cin>>H>>N;
	rp(i,0,N) H -= in();
	puts(H<=0? "Yes":"No");
}

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

int main()
{
  int a, b, k;
  cin >> a >> b >> k;
  int n = min(a, b);
  vector<int> v;
  for (int i = 1; i <= n; i++)
  {
    if (a % i == 0 && b % i == 0)
      v.push_back(i);
  }
  cout << v[v.size() - k] << endl;
  return 0;
}

Measured memory_bytes: 3580
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node
{
	int key;
	Node *next,*prev;
};

Node* nil;

Node* listSearch(int key)
{
	Node *cur = nil->next;
	while(cur!=nil&&cur->key!=key)
	{
		cur=cur->next;
	}
	return cur;
}

void init()
{
	nil = (Node*)malloc(sizeof(Node));
	nil->next=nil;
	nil->prev=nil;
}

void printList()
{
	Node *cur=nil->next;
	int isf=0;
	while(1)
	{
		if(cur==nil) break;
		if(isf++>0) printf(" ");
		printf("%d",cur->key);
		cur = cur->next;
	}
	printf("\n");
}

void deleteNode(Node *t)
{
	if(t==nil) return;
	t->prev->next=t->next;
	t->next->prev=t->prev;
	free(t);
}

void deleteFirst()
{
	deleteNode(nil->next);
}

void deleteLast()
{
	deleteNode(nil->prev);
}

void deleteKey(int key)
{
	deleteNode(listSearch(key));
}

void insert(int key)
{
	Node* x=(Node*)malloc(sizeof(Node));
	x->key=key;
	x->next=nil->next;
	nil->next->prev=x;
	nil->next=x;
	x->prev=nil;
}

int main()
{
	int key,n,i;
	char com[20];
	scanf("%d",&n);
	init();
	for(i=0;i<n;i++)
	{
		scanf("%s%d",com,&key);
		if(com[0]=='i')
		{
			insert(key);
		}
		else if(com[0]=='d')
		{
			if(strlen(com)>6)
			{
				if(com[6]=='F')
				{
					deleteFirst();
				}
				else if(com[6]=='L')
				{
					deleteLast();
				}
			}
			else
			{
				deleteKey(key);
			}
		}
	}
	printList();
} 

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

typedef long long ll;

ll N, T;
ll H[100010];
ll s = 0;

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

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

    cout << T / H[0] + 1 << endl;
    s += H[0];

    for(int i = 1; i < N; i++)
    {
        if(s >= T)
        {
            cout << 1 << endl;
            s += H[i];
        }
        else if(H[i - 1] >= H[i])
        {
            cout << (T - s + H[i - 1] - H[i]) / H[i - 1] + 1 << endl;
            s += H[i];
            H[i] = H[i - 1];
        }
        else
        {
            cout << (T - s) / H[i] + 1 << endl;
            s += H[i];
        }

    }
}



Measured memory_bytes: 3868
H, W = map(int, input().split())
state = [[1 if a == '#' else 0 for a in list(input()+'.')] for _ in range(H)]
state.extend([[0]*(W+1)])


ans = 'Yes'
for h in range(H):
    for w in range(W):
        if state[h][w] == 0:
            continue
        nexts = [[h+1, w], [h-1, w], [h, w+1], [h, w-1]]
        ok = False
        for n in nexts:
            if state[n[0]][n[1]] == 1:
                ok = True
        if not ok:
            ans = 'No'
            break
    if ans == 'No':
        break

print(ans)


Measured memory_bytes: 3064
fun main(args : Array<String>) {
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }
    val ss = Array(h) { readLine()!!.toMutableList() }

    val dp = Array(h) { IntArray(w) { 0 } }

    for (i in 0 until h) {
        inner@for (j in 0 until w) {
            if (i == 0 && j == 0) {
                if (ss[i][j] == '#') {
                    dp[i][j] = 1
                } else {
                    dp[i][j] = 0
                }
                continue@inner
            }

            if (i == 0) {
                if (ss[i][j] == '#' && ss[i][j-1] == '.') {
                    dp[i][j] = dp[i][j-1] + 1
                } else {
                    dp[i][j] = dp[i][j-1]
                }
                continue@inner
            }

            if (j == 0) {
                if (ss[i][j] == '#' && ss[i-1][j] == '.') {
                    dp[i][j] = dp[i-1][j] + 1
                } else {
                    dp[i][j] = dp[i-1][j]
                }
                continue@inner
            }

            if (ss[i][j] == '#') {
                val up = if (ss[i-1][j] == '.') dp[i-1][j] + 1 else dp[i-1][j]
                val left = if (ss[i][j-1] == '.') dp[i][j-1] + 1 else dp[i][j-1]
                dp[i][j] = Math.min(up, left)
            } else {
                val up = dp[i-1][j]
                val left = dp[i][j-1]
                dp[i][j] = Math.min(up, left)
            }
        }
    }

    println(dp[h-1][w-1])
}

Measured memory_bytes: 37808
def main():
    N = input()
    X = list(map(int,input().split()))
#    print(sum(X),len(X))
    # 全員が0の場合   全員が同じ場合 AGVは変わらない
    # 全員が100の場合 AVGは変わらない
    # 四捨五入の場合
    AVG = int(sum(X)/len(X))    # intにすることによる誤差
    AVG1 = int(sum(X)/len(X)) + 1    # intにすることによる誤差
#    print()
    total = 0
    total1 = 0
    for i in X:
        total += (AVG - i)**2

    for i in X:
        total1 += (AVG1 - i)**2

    if total >= total1:
        print(total1)
    else:
        print(total)

main()

Measured memory_bytes: 3060
import scala.io.StdIn._
object Main extends App {
  val n = readInt
  val cities = (1 to n).map{i => readLine.split(" ").map(_.toInt)}
  def distance(i: Array[Int], j: Array[Int]): Double = 
    Math.sqrt((i(0) - j(0)) * (i(0) - j(0)) + (i(1) - j(1)) * (i(1) - j(1)))
  val distances = (for {
    i <- 0 until n - 1
    j <- i until n
  } yield distance(cities(i), cities(j))).sum
  println(2 * distances / n)
}

Measured memory_bytes: 25404
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/













int N; string S[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> S[i];

	map<string, ll> cnt;
	rep(i, 0, N) {
		sort(all(S[i]));
		cnt[S[i]]++;
	}

	ll ans = 0;
	fore(p, cnt) ans += p.second * (p.second - 1) / 2;

	cout << ans << endl;
}









Measured memory_bytes: 16640
x = gets.split.map(&:to_i)
a = x[0].times.map{gets.chomp.split("").map{|c|c==?.}}

y = []*2

2.times{|i|
  y[i] = [false]*x[i]
  x[i].times{|j|
    y[i][j] = true if a[j].all?
  }
  a = a.transpose
}

x[0].times{|i|
  next if y[0][i]
  x[1].times{|j|
    next if y[1][j]
    print a[i][j] ? ?. : ?#
  }
  puts
}

Measured memory_bytes: 2044
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

s = input()
x, y = MAP()

x_list = []
y_list = []
for i, s_ in enumerate(s.split('T')):
	if i == 0:
		x -= len(s_)
	elif i % 2 == 0:
		x_list.append(len(s_))
	else:
		y_list.append(len(s_))

def check(d, x):
  se =set([0])
  for dx in d:
    se={a+b for a,b in product(se,[-dx,dx])}  # 直積としてDPを計算
  return (x in se)

print('Yes' if check(x_list, x) and check(y_list, y) else 'No')


Measured memory_bytes: 4444
#include <cstdio>

int H, W, N;
int a[10010];
int c[110][110];

void solve()
{
	int i, j;
	int row=0, col=0;
	int dire=0;
	for(i=0; i<N; i++){
		for(j=0; j<a[i]; j++){
			c[row][col] = i+1;
			if(dire==0){
				col ++;
				if(col == W){
					col = W-1;
					row ++;
					dire = 1;
				}
			}
			else{
				col --;
				if(col==-1){
					col = 0;
					row ++;
					dire = 0;
				}
			}
		}
	}
	for(i=0; i<H; i++){
		printf("%d", c[i][0]);
		for(j=1; j<W; j++)
			printf(" %d", c[i][j]);
		printf("\n");
	}
}

int main()
{
	int i;
	scanf("%d%d", &H, &W);
	scanf("%d", &N);
	for(i=0; i<N; i++)
		scanf("%d", &a[i]);
	solve();
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

const int MOD = (int)1e9 + 7;

/*
行列の積(mod)
行列Aと行列Bの積を返す
O(n^3)
*/
vector<vector<int> > mulMatMod(const vector<vector<int> > &A, const vector<vector<int> > &B) {
    auto n = A.size(), m = A[0].size(), p = B[0].size();
    vector<vector<int> > res(n, vector<int>(p));
    for (int i = 0; i < n; ++i)for (int j = 0; j < p; ++j) for (int k = 0; k < m; ++k)
        res[i][j] = (int)((res[i][j] + (long long)A[i][k] * B[k][j]) % MOD);
    return res;
}

/*
行列Aの累乗(mod)を返す
O(n^3 * log(k))
*/
vector<vector<int> > powMatMod(vector<vector<int> > A, long long k) {
    auto n = A.size();
    vector<vector<int> > res(n, vector<int>(n));
    for (int i = 0; i < n; ++i)res[i][i] = 1;
    while (k) {
        if (k % 2)res = mulMatMod(res, A);
        k /= 2;
        A = mulMatMod(A, A);
    }
    return res;
}

void solve() {
    int N;
    cin >> N;
    ll K;
    cin >> K;
    vector<vi> A(N, vi(N));
    rep(i, N)rep(j, N)cin >> A[i][j];

    auto B = powMatMod(A, K);
    int ans = 0;
    rep(i, N)rep(j, N)(ans += B[i][j]) %= MOD;
    cout << ans << endl;
}

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

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


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

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

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

        if x == y:
            return

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

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

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

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

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

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

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

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

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





def main():
	n,m=MI()

	L=[[] for _ in range(m+1)]
	for i in range(1,n+1):
		KL=LI()
		for l in KL[1:]:
			L[l].append(i)
	#print(L)

	UF=UnionFind(n)

	for l in L:
		if len(l)>=2:
			for i,j in zip(l[:-1],l[1:]):
				UF.union(i-1,j-1)
	print("YES" if UF.group_count()==1 else "NO")
























if __name__ == "__main__":
	main()


Measured memory_bytes: 86420
fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    val p = mutableListOf<Int>()
    (1..N).forEach {
        val num = readLine()!!.toInt()
        p.add(num)
    }
    p.sort()
    p[N - 1] /=2

    println(p.sum())
}

Measured memory_bytes: 31864
//read by human
// 1 min = 60 sec
// 1 hour = 60 min = 3600 sec

 

#include <iostream>

 

using namespace std;

 

int main()
{
   int i, h, m, s;     
   cin >> i;
   h = i / 3600;
   m = i/ 60 % 60;
   s = i % 60;
   cout << h << ":" << m << ":" << s << endl;
   
   return 0;
}


Measured memory_bytes: 3080
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions
struct UnionFind {
    par: Vec<usize>,
    rank: Vec<usize>,
}

impl UnionFind {
    fn new(n:usize) -> UnionFind {
        UnionFind {
            par: (0..n+1).collect(),
            rank: vec![0; n+1],
        }
    }
    fn find(&mut self, x:usize) -> usize {
        if self.par[x] == x {
            return x;
        }else{
            let parx = self.par[x];
            self.par[x] = self.find(parx);
            return self.par[x];
        }
    }
    fn unite(&mut self, x:usize, y:usize) {
        let x = self.find(x);
        let y = self.find(y);
        if self.rank[x] < self.rank[y] {
            self.par[x] = y;
        }else{
            self.par[y] = x;
            if self.rank[x] == self.rank[y] {
                self.rank[x] += 1;
            }
        }
    }
    fn check(&mut self, x:usize, y:usize) -> bool {
        return self.find(x) == self.find(y);
    }
}

// Main
fn main(){
    input!{
        N: usize,
        K: usize,
        L: usize,
        PQ: [(usize,usize); K],
        RS: [(usize,usize); L],
    }
    // 道路
    let mut A = UnionFind::new(N);
    for i in 0..K{
        let (x,y) = PQ[i];
        A.unite(x,y);
    }
    // 鉄道
    let mut B = UnionFind::new(N);
    for i in 0..L{
        let (x,y) = RS[i];
        B.unite(x,y);
    }
    // (道路グループ,鉄道のグループ) の組を集計
    let mut map = HashMap::new();
    for i in 1..N+1{
        let ab = (A.find(i), B.find(i));
        *map.entry(ab).or_insert(0) += 1;
    }
    // 出力
    for i in 1..N+1{
        let ab = &(A.par[i],B.par[i]);
        print!("{} ", map.get(ab).unwrap());
    }
}

Measured memory_bytes: 28972
#include <bits/stdc++.h>
using namespace std;
    
#define int long long

signed main() {
    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b));
    
#ifdef LOCAL
    cout << endl;
    system("pause");
#endif
    return 0;
}

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

using namespace std;
typedef long long ll;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

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

int main(){
	ll N,K; cin>>N>>K;
    ll ans=0;
    rep(i,N){
        ll x; cin>>x;
        if(x>=K) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const double eps = 1e-8;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
	string s;
	cin >> s;
	ll black = 0;
	ll answer = 0;
	for (int i = 0;i < s.size();i++) {
		if (s[i] == 'B')
			black++;
		else
			answer += black;
	}
	cout << answer << endl;
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    
    vector<int> A(n);
    for (int i=0; i<n; i++){
        cin >> A[i];
    }
    
    for (int i=0; i<n; i++){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
    
    for (int i=1; i<n; i++){
        int key = A[i];
        int j = i-1;
        while(j>=0 && A[j] > key){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = key;
        
        for (int k=0 ;k<n; k++){
            if (k) cout << ' ';
            cout << A[k];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3092
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        cs: chars,
    }
    let A = vec!['A','A','A'];
    let B = vec!['B','B','B'];

    if cs==A || cs==B{
        println!("No");
    } else {
        println!("Yes");
    }

    //println!("{}",cs[0]);
}

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

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	//int keta;
	//for(int i=1; i<5; i++){
	//	keta = i;
	//	if(pow(10,i) > n){break;}
	//}
	int ans, ss, x, y; 
	ans = 0;

	for(int m=0; m<n+1; m++){
		ss = 0;
		x = m;
	while(true){
		y = x%10;
		x = x/10;
		ss += y;
		if(x==0){
			if(a <= ss && ss <= b){ans += m;}
			break;}
	}
	}
	cout << ans << endl;
	return 0;
}



	



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl
typedef pair<int,int> Pp;
int Roundup(int a,int b){
    return (a+b-1)/b;
}


signed main(){
    int D,G;
    int p[10],c[10];
    cin >> D >> G;G/=100;
    REP(i,D){
        cin >> p[i] >> c[i];c[i]/=100;
    }
    
    int Ans=INF;
    for(int j=0;j<(1<<D);j++){
        int num=0,sum=0;
        REP(i,D){
            if((j>>i)%2==1){
                sum+=p[i]*(i+1);
                num+=p[i];
                sum+=c[i];
            }
        }
        //cout << j << " " << sum <<" " << num << endl;
        if(sum>=G){
            Ans=min(Ans,num);
            continue;
        }
        RREP(i,D){
            if((j>>i)%2==0){
                if(sum+p[i]*(i+1)<G){
                    sum+=p[i]*(i+1);
                    num+=p[i];
                }else{
                    num+=Roundup(G-sum,i+1);
                    Ans=min(Ans,num);//cout << num << endl;
                } 
            }
        }
    }
    cout << Ans << endl;
    return 0;
}   


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

def gcd(i,j):
  if i>j:
    i,j=j,i
  if j%i==0:
    return i
  return gcd(j-i,i)

n=int(input())
l=[int(i) for i in input().split()]
l.sort()
g=gcd(l[0],l[1])
for i in range(2,len(l)):
  g=gcd(g,l[i])
print(g)

Measured memory_bytes: 69400