akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll minn=1ll<<60;
ll n,s;
ll f(ll b,ll n)
{
	if(n<b)
		return n;
	else
		return f(b,n/b)+(n%b);
}
int main()
{
	scanf("%lld %lld",&n,&s);
	if(s==n)
	{
		printf("%lld\n",n+1);
		return 0;
	}
	else if(s>n)
	{
		printf("-1\n");
		return 0;
	}
	ll temp=sqrt(n);
	for(ll i=2;i<=temp+1;i++)
	{
		if(f(i,n)==s)
		{
			minn=i;
			break;
		}
	}
	ll cz=n-s;
	for(ll i=1;i<=sqrt(cz);i++)
	{
		if(cz%i==0)
		{
			ll t=cz/i+1;
			if(f(t,n)==s)
				minn=min(minn,t);
		}
	}
	if(minn!=(1ll)*1<<60)
		printf("%lld\n",minn);
	else
		printf("-1\n");
	return 0;
}

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

using namespace std;

#define rep(i,n,m) for(int i=n;i<(int)(m);i++)


int main() {
	int n, m;
	cin >> n >> m;
	
	vector<long long int>numx(n);
	vector<long long int>numy(n);
	vector<long long int>checkx(m);
	vector<long long int>checky(m);

	rep(i, 0, n) {
		cin >> numx[i];
		cin >> numy[i];
	}
	rep(i, 0, m) {
		cin >> checkx[i];
		cin >> checky[i];
	}


	long long int pre,aft;
	vector<long long int>number(n,-1);

	rep(i, 0, n) {
		pre = 0;
		aft = 0;
		rep(j, 0, m) {
			aft = abs(numx[i]-checkx[j]) + abs(numy[i]-checky[j]);

			if (number[i] == -1) {
				pre = aft;
				number[i] = j;
			}
			else {
				if (aft < pre) {
					number[i] = j;
					pre = aft;
				}
			}
		}
	}



	rep(i, 0, n) {
		cout << number[i]+1 << endl;
	}



	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;

int gcd(int a, int b) {

  if (b == 0) return a;
  return gcd(b, a % b);

}  


int main() {

  // ---------------------
  // Input
  
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int K;
  cin >> K;

  ll sum = 0;
  
  for (int a = 1; a <= K; a++) {
    for (int b = 1; b <= K; b++) {
      for (int c = 1; c <= K; c++) {
	sum += gcd( gcd(a,b), c);
      }
    }
  }

  cout << sum << endl;

  return 0;
  
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int a;
  cin >>a;
  
  cout <<a*a*a <<endl;
  
}


Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
 
int main()
{
    int N;

    int i=0;
    int j=0;
//    int k=0;
    scanf("%d", &N);
    printf("%d\n",(N/3));


return 0;
}


Measured memory_bytes: 128
def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    BITS = 30
    sum_bit = [0] * BITS
    a_bits = []

    for a in a_list:
        bits = [a>> j & 1 for j in range(BITS)]
        for i, bit in enumerate(bits):
            sum_bit[i] += bit
        a_bits.append(bits)

    for a_bit in a_bits:
        # rb -> sum_bitのビット, ab -> a_bitのビット
        res = 0
        cur = 1
        for i in range(BITS):
            res += cur if (a_bit[i] + sum_bit[i])%2 == 1 else 0
            cur *= 2
        print(res, end=" ")

if __name__ == "__main__":
    main()



Measured memory_bytes: 172808
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

vector<bool> seen;
vector<int> x;
void dfs(const Graph &g, int v, int w) { 
  seen[v] = true;
  x[v] = w;
  for(auto next : g[v]) {
    if(seen[next] == true){
      continue;
    }
    dfs(g, next, w + x[next]);
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  Graph g(n);
  seen.resize(n);
  x.resize(n);
  for(int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  x.assign(n, 0);
  for(int i = 0; i < q; i++) {
    int p;
    cin >> p;
    p--;
    int tmp;
    cin >> tmp;
    x[p] += tmp;
  }
  seen.assign(n, false);
  dfs(g, 0, x[0]);

  for(int i = 0; i < n; i++){
    cout << x[i] << ' ';
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 23552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> vii;
typedef vector<ll> vi;
const ll mod = 1e9+7;
int n;

vii operator*(const vii &a, const vii &b) {
    vii ret(n, vi(n, 0));
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            for(int k = 0; k < n; ++k)
                ret[i][j] = (ret[i][j] + a[i][k] * b[k][j] % mod) % mod;
    return ret;
}

vii binpow(vii a, ll k){
    vii ret(n, vi(n, 0));
    for(int i = 0; i < n; ++i)
        ret[i][i] = 1;
    while(k) {
        if(k&1)
            ret = ret * a;
        a = a * a;
        k >>= 1;
    }
    return ret;
}

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll k;
    cin >> n >> k;
    vii a(n, vi(n, 0));
    for(int i = 0; i < n; ++i) for(int j = 0; j < n; ++j)
        cin >> a[i][j];
    vii res = binpow(a, k);
    ll ans = 0;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            ans = (ans + res[i][j]) % mod;
    cout << (ans + mod) % mod;
    return 0;
}


Measured memory_bytes: 384
import std.stdio, std.string, std.conv;
import std.math;

void main() {
    auto input = getStdin!(string[]);
    auto num = input[1].split(" ").to!(long[]).sort;
    long sum = 0;
    foreach (n; num) sum += n;
    writefln("%d %d %d", num[0], num[num.length - 1], sum);
}

T getStdin(T)() {
    string[] cmd;
    string line;
    while ((line = chomp(stdin.readln())) != "") cmd ~= line;
    return to!(T)(cmd);
}

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

#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << endl;

using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
#define scl1(a)             scanf("%lld", &a)
#define scl2(a, b)          scanf("%lld %lld", &a, &b)

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
const int mod = 1e9+7;
const db pi = acos(-1);
const long long infl = LLONG_MAX;
const int inf = 0x3f3f3f3f;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase   
ll a[100000+4],dp[100000+4];

ll fun(ll i,ll n){
	if(i==n)return 0;
	if(dp[i]!=-1)	return dp[i];
	ll q1=100000, q2=100000;
	if(i+1<n)q1=abs(a[i]-a[i+1])+fun(i+1,n);
	if(i+2<n)q2=abs(a[i]-a[i+2])+fun(i+2,n);
	if(i+1==n)q1=q2=0;
	// if(q1!=0 && q2!=0)
		dp[i]=min(q1,q2);
	// else if(q1!=0)
	// 	dp[i]=q1;
	// else if(q2!=0)
	// 	dp[i]=q2;
	
	return dp[i];
}

int32_t main(){

ios_base::sync_with_stdio(false);
cin.tie(NULL);

ll t,i,x,j,y,z,k,n;
memset(dp,-1,sizeof(dp));
cin>>n;
rep(i,0,n,1)cin>>a[i];
cout<<fun(0,n);
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>


template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;


int bfs(int start, vector<int>& d, vector<vector<int>>& g) {
	d[start] = 0;
	int last = -1;
	queue<int> q;
	q.push(start);
	while (!q.empty()) {
		int cur = q.front();
		q.pop();
		last = cur;
		for (int next : g[cur]) {
			if (d[next] != -1) continue;
			d[next] = d[cur] + 1;
			q.push(next);
		}
	}
	return last;
}
int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n, m, s, t; cin >> n >> m >> s >> t; s--; t--;
	vector<int> cs(n), ct(n);
	vector<vector<int>> g(n);
	for (int i = 0; i < m; i++) {
		int u, v; cin >> u >> v;
		u--; v--;
		g[u].emplace_back(v);
		g[v].emplace_back(u);
	}
	vector<int> ds(n, -1);
	vector<int> dt(n, -1);
	bfs(s, ds, g);
	bfs(t, dt, g);
	ll res = 0;
	int len = ds[t];
	for (int i = 0; i < n; i++) {
		if (dt[i] != -1) {
			ct[dt[i]]++;
		}
		if (ds[i] != -1) {
			cs[ds[i]]++;
		}
	}
	for (int i = 0; i < n; i++) {
		int r = len - i - 2;
		if (r < 0) continue;
		res += 1LL * cs[i] * ct[r];
	}
	cout << res << endl;
}


Measured memory_bytes: 10944
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007

int dp[1002][1002];
char mat[1002][1002];

int solve(int n, int m)
{
	dp[0][0] = 1;


	for (int j = 1; j < m; j++)
	{
		if (mat[0][j] == '#')
			break;
		dp[0][j] = 1;
	}
	for (int j = 1; j < m; j++)
	{
		if (mat[j][0] == '#')
			break;
		dp[j][0] = 1;
	}

	for (int i = 1; i < n; i++)
	{
		for (int j = 1; j < m; j++)
		{

			if (mat[i][j] == '.')
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
		}
	}
	return dp[n - 1][m - 1];
}

int main()
{
	int H, W;

	cin >> H >> W;

	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++)
			cin >> mat[i][j];

	memset(dp, 0, sizeof(dp));

	cout << solve(H, W) % mod;
}

Measured memory_bytes: 8496
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右下左上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, 1, 0, -1, -1, 1, 1, -1 };

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

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; ++i) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t szi, szj;
        inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(szi); for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i]; return a; }
        template <typename T> operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i) for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j]; return a;
        }
    };
    inp inp1;
}

int main() {

    int n = inp1;
    vector<int> t(n), a(n);
    rep(i, n) cin >> t[i] >> a[i];

    ll left = t[0];
    ll right = a[0];

    Rep(i, 1, n) {
        ll rate = 1LL;
        if (left % t[i] == 0) rate = left / t[i];
        else rate = left / t[i] + 1LL;
        if (right % a[i] == 0) chmax(rate, right / a[i]);
        else chmax(rate, right / a[i] + 1LL);

        left = t[i] * rate;
        right = a[i] * rate;
    }

    Cout(left + right);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
    int N, M;
    cin >> N >> M;
    string Ai[N], Bi[M];

    for (int i = 0; i < N; i++) {
        cin >> Ai[i];
    }
    for (int i = 0; i < M; i++) {
        cin >> Bi[i];
    }   
    
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < N; j++) {
            if (M > 1 && N > 1 && Ai[j].find(Bi[i]) >= 0 && Ai[j].find(Bi[i]) <= N-1) {
                if (M > 1 && N > 1 && Ai[j+1].find(Bi[i+1],j) >= 0 && Ai[j+1].find(Ai[i+1],j) <= N-1) {
                    cout << "Yes" << endl;
                    return 0;
                } else {
                    break;
                }
            } else if (M == 1 && N == 1 && Ai[j].find(Bi[i]) >= 0 && Ai[j].find(Bi[i]) <= N-1) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

template <ll Mod>
struct ModInt {
  ll n;
  ModInt(const ll x = 0) : n(x) { while (n < 0) n += Mod; n %= Mod; }
  ModInt operator+(const ModInt r) const { return ModInt(*this) += r; }
  ModInt operator-(const ModInt r) const { return ModInt(*this) -= r; }
  ModInt operator*(const ModInt r) const { return ModInt(*this) *= r; }
  ModInt operator/(const ModInt r) const { return ModInt(*this) /= r; }
  ModInt &operator+=(const ModInt r) { n += r.n; if (n >= Mod) n -= Mod; return *this; }
  ModInt &operator-=(const ModInt r) { if (n < r.n) n += Mod; n -= r.n; return *this; }
  ModInt &operator*=(const ModInt r) { n = n * r.n % Mod; return *this; }
  ModInt &operator/=(const ModInt r) { return *this *= r.inv(); }
  ModInt pow(ll x) const { ModInt<Mod> ret(1), tmp(*this); while (x) { if (x&1) ret *= tmp; tmp *= tmp; x >>= 1; } return ret; }
  ModInt inv() const { return pow(Mod-2); }
  friend ostream& operator<<(ostream& os, const ModInt& obj) { return os << obj.n; }
  friend istream& operator>>(istream& is, ModInt& obj) { ll t; is >> t; obj = ModInt(t); return is; }
};
constexpr ll mod = 1000000007;
using mint = ModInt<mod>;
mint operator"" _mi(unsigned long long n) { return mint(n); }

// T modint
template<class T>
struct Combination {
  vector<T> fact, inv_fact;
  Combination(ll n) : fact(n+1), inv_fact(n+1) {
    fact[0] = T(1);
    for (ll i = 1; i <= n; i++) fact[i] = fact[i-1] * static_cast<T>(i);
    inv_fact[n] = fact[n].inv();
    for (ll i = n; i > 0; i--) inv_fact[i-1] = inv_fact[i] * static_cast<T>(i);
  }

  T P(ll n, ll k) const {
    if (n < k or k < 0) return T(0);
    return fact[n] * inv_fact[n-k];
  }

  T C(ll n, ll k) const {
    if (n < k or k < 0) return T(0);
    return fact[n] * inv_fact[n-k] * inv_fact[k];
  }

  T H(ll n, ll k) const {
    if (n < 0 or k < 0) return T(0);
    if (n == 0 and k == 0) return T(1);
    return C(n+k-1, n-1);
  }
};

mint com(ll n, ll k) {
  mint ans(1);
  mint s(n);
  mint t(1);
  rep(i, k) {
    ans *= s;
    ans /= t;
    s -= 1_mi;
    t += 1_mi;
  }
  return ans;
}

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

  ll n, a, b;
  cin >> n >> a >> b;

  mint ans = (2_mi).pow(n);
  ans -= com(n, a);
  ans -= com(n ,b);
  ans -= 1_mi;

  cout << ans << endl;
}


Measured memory_bytes: 256
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
cost0 = 0
costN = 0
for a_i in a:
  if a_i < x:
    cost0 += 1
  elif a_i > x:
    costN += 1
print(min(cost0, costN))

Measured memory_bytes: 9172
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    
    if (N%1000 == 0)
    {
        cout << "0" << endl;
    }
    else
    {
        cout << 1000 - N%1000 << endl;
    }
}


Measured memory_bytes: 3528
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    ld X[N], Y[N];
    F0R(i, N) cin >> X[i] >> Y[i];

    ld dist[N][N];
    F0R(i, N) {
        F0R(j, N) {
            dist[i][j] = powl((X[i]-X[j])*(X[i]-X[j])+(Y[i]-Y[j])*(Y[i]-Y[j]), (ld) 0.5);
        }
    }

    ld ans = 0;
    vi perm; F0R(i, N) perm.pb(i);
    ld count = 0;
    F0R(i, N) {
        F0R(j, N) {
        }
    }
    do {
        ld cur = 0;
        F0R(i, N-1) {

            cur += dist[perm[i]][perm[i+1]];
        }
        count++;
        ans += cur;
    } while (next_permutation(all(perm)));
    cout << setprecision(20) << ans/count << endl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 512
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem (I) in C++
// MAIN IDEA   : max sum of S(X) + S(S(X)) => 100 so brute force
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 2e5 + 5, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	ll n;
	cin >> n;
	ll z = (n / 11);
	if (z)
		n %= (z * 11);
	z *= 2;
	if (n > 6)
		z += 2;
	else if (n)
		z++;
	cout << z << "\n";
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars
    }
    let acgt = vec!['A','C','G','T'];
    let mut mxcnt = 0;
    let mut cnt = 0;
    for c in s {
        if acgt.contains(&c) {
            cnt += 1;
        } else {
            cnt = 0;
        }
        mxcnt = std::cmp::max(mxcnt, cnt);
    }
    println!("{}", mxcnt);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
int a[6],k;
using namespace std;
int main(){
  for(int i=0;i<5;i++)cin>>a[i];
  cin>>k;
  sort(a,a+5);
  if(a[4]-a[0]>k)cout<<":("<<endl;
  else cout<<"Yay!"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){

    ll N, D, X;
    cin >> N >> D >> X;

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

    ll eat = 0;
    for(int day = 1; day <= D; day++){
        for(int i = 0; i < N; i++){
            if( (day-1) % v[i] == 0 ) eat++;
        }
    }

    cout << X + eat << endl;

}

Measured memory_bytes: 256
/*
  Contest 078
  A - HEX
  Rakesh Kumar --> 13/09/2020
 */

#include <bits/stdc++.h>

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

    char x, y;
    std::cin >> x >> y;
    if (x < y)
        std::cout << "<" << std::endl;
    else if (x > y)
        std::cout << ">" << std::endl;
    else
        std::cout << "=" << std::endl;

    return 0;
}


Measured memory_bytes: 3648
#include<iostream>

int main()
{
  int k,a,b,f=0;
  std::cin>>k>>a>>b;
  for(int i=0;i<=b-a;i++)
  {
   if((a+i)%k==0)
   {
     f=1;
     break;
   }
      
  }
  if(f==1)
     std::cout<<"OK"<<std::endl;
  else
     std::cout<<"NG"<<std::endl;
  
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n; cin >> n;
    vec<pair<pair<string, int>, int>> ps(n);
    rep(i,n) {
        cin >> ps[i].first.first >> ps[i].first.second;
        ps[i].second = i;
        ps[i].first.second *= (-1);
    }
    sort(all(ps));
    for(auto p : ps) {
        cout << p.second + 1  << '\n';
    }

    // printf("ExcutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 384
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #n = int(stdin.readline()[:-1])   
    r = stdin.readline()[:-1]
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #n = int(r)
    #a = r.split()
    a,b,c = r.split()
    #a = list(map(int, r.split()))
    #a,b,c,d = map(int, r.split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    #res = 0

    print("A"+b[0].upper()+"C")

if __name__ == '__main__':
    main()


Measured memory_bytes: 38412
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int max(int a,int b)
{
	return a>b? a:b;
}
int min(int a,int b)
{
	return a<b ? a:b;
}
int main()
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	int zhan=min(b,d)-max(a,c);
	if(zhan<0)
		printf("0\n");
	else
		printf("%d\n",zhan);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define prime 1000000007
#define INF 2147483647
int dx8[8]={-1,0,1,1,1,0,-1,-1};
int dy8[8]={1,1,1,0,-1,-1,-1,0};
int dx4[4]={-1,0,1,0};
int dy4[4]={0,-1,0,1};
signed main(void){
    while(true){
        int n,x;cin>>n>>x;
        if(n==0&&x==0)return 0;
        int ans=0;
        for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++){
            int k=x-i-j;
            if(k>j&&k<=n)ans++;
        }
        cout<<ans<<endl;
    }
}
        



Measured memory_bytes: 3088
#include <iostream>
   
inline unsigned insertion_sort(unsigned a[], unsigned n, unsigned gap){
  unsigned count = 0;
  for(unsigned i = gap; i < n; i++){
    unsigned v = a[i];
    int j = i - gap;
    while(j >= 0 && a[j] > v){
      a[j+gap] = a[j];
      j -= gap;
      count++;
    }
    a[j+gap] = v;
  }
  return count;
}
   
inline void shell_sort(unsigned a[], unsigned n){
  const unsigned gaps[] = {1,8,23,77,281,1073,4193,16577,65921,262913,1050113};
  // generated from pow(4,i)+3*pow(2,i-1)+1 (prefixed with 1)
   
  unsigned gap_num = 0, count = 0;
  while(gaps[gap_num+1] < n) gap_num++;
   
  for(int i = gap_num; i >= 0; i--) count += insertion_sort(a,n,gaps[i]);
   
  std::cout << (gap_num+1) << '\n';
   
  for(int i = gap_num; i; i--) std::cout << gaps[i] << ' ';
  std::cout << gaps[0] << '\n';
   
  std::cout << count << '\n';
}
   
int main(){
  std::ios::sync_with_stdio(false);
  unsigned n;
  unsigned a[1000000];
  std::cin >> n;
  for(unsigned i = 0; i < n; i++) std::cin >> a[i];
  shell_sort(a,n);
  for(unsigned i = 0; i < n; i++) std::cout << a[i] << '\n';
}

Measured memory_bytes: 7004
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  std::string s; std::cin >> s;
  int da[4], db[4];
  da[0] = db[0] = da[3] = -1;
  da[1] = db[1] = db[3] = 1;
  int a0 = 0, a1 = 1, b0 = 0, b1 = -1;
  int c0 = a0-b0, c1 = a0-b1, c2 = a1-b0, c3 = a1-b1;
  for(auto c: s) {
    a0 += da[c&3]; if(a0 < 0) a0 = 1;
    a1 += da[c&3]; if(a1 < 0) a1 = 1;
    b0 += db[c&3]; if(b0 > 0) b0 = -1;
    b1 += db[c&3]; if(b1 > 0) b1 = -1;
    c0 = std::max(c0, a0-b0);
    c1 = std::max(c1, a0-b1);
    c2 = std::max(c2, a1-b0);
    c3 = std::max(c3, a1-b1);
  }
  fin(std::min(std::min(c0, c1), std::min(c2, c3)));
  return 0;
}


Measured memory_bytes: 4744
import java.io.*;
import java.util.*;
public class Main
{
  public static void main(String args[])throws IOException
  {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer(br.readLine());
    int n = Integer.parseInt(st.nextToken());
   String arr[] = new String[n];
   for(int i=0;i<n;i++)
   {
   		
   		arr[i]=br.readLine();
   }
   Arrays.sort(arr);
   int c=0;
   HashMap <String, Integer> map= new HashMap<>();
   for(int i=0;i<n;i++)
   {
   		if(!map.containsKey(arr[i])){
   			c++;
   			map.put(arr[i],1); 
   		}
   }
   System.out.println(c);
}
}

Measured memory_bytes: 66384
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
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;
}

//a^n mod を計算する関数
long long modpow(long long a,long long n,long long mod) {
    long long res = 1;
    while(n > 0) {
        if(n % 2 == 1) {
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//a^(-1) mod すなわちaの逆元を返す関数
long long modinv(long long a,long long mod) {
    return modpow(a,mod-2,mod);
}

//最大公約数をを返す関数
long long gcd (long long a,long long b) {
    if(a % b == 0) {
        return b;
    }else {
        return (gcd(b,a%b));
    }
}

const long long INF = 1LL << 60;
const long long P = 1000000007;

//nCkを求める関数
long long conbi (long long n,long long k) {
    long long res = 1;
    long long inv;
    for(long long i = n-k+1; i <= n; i++) {
        res *= i;
        res %= P;
    }
    for(long long i = 1; i <= k; i++) {
        inv = modinv(i,P);
        res *= inv;
        res %= P;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    int d[n];
    int sum = 0;
    for(int i = 0; i < n; i++) {
        cin >> d[i];
    }
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            sum += d[i]*d[j];
        }
    }
    cout << sum;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"
#include <set>
#include <iomanip>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N;
int C[10][3] =
{{0,1,2},
 {0,1,3},
 {0,1,4},
 {0,2,3},
 {0,2,4},
 {0,3,4},
 {1,2,3},
 {1,2,4},
 {1,3,4},
 {2,3,4},
};

double A[5];


int main()
{

	cin >> N;



	REP(i,N){
		string a;
		cin >> a;
		switch(a[0]){
		case 'M':
			A[0]++;
			break;
		case 'A':
			A[1]++;
			break;
		case 'R':
			A[2]++;
			break;
		case 'C':
			A[3]++;
			break;
		case 'H':
			A[4]++;
			break;

		}

	}
	double ans = 0.0;
	REP(i,10){
		double ans0 = 1.0;
		REP(j,3){
			ans0 *=(double)A[C[i][j]];
		}
		ans += ans0;
	}
    cout <<fixed << setprecision(0) << ans;
}







Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
int a, b;
cin >> a >> b;
if( a>b ){
cout << "a > b" <<endl;
}else if( a==b ){
cout << "a == b" << endl;
}else if ( a<b ){
cout << "a < b" << endl;
}
return 0;
}

Measured memory_bytes: 1156
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;


int main(void)
{
	int n, m;

	while(scanf("%d%d", &n, &m)==2)
	{
		vi ac(n+1);
		vi wa(n+1);
		int ans_ac=0, ans_wa=0;

		for(int i=0;i<m;i++)
		{
			int p;
			char s[2+2];
			scanf("%d%2s", &p, s);

			if(ac[p]) continue;
			if(strcmp(s, "AC")==0)
			{
				ac[p]=1;
				ans_ac++;
				ans_wa+=wa[p];
			}
			else
			{
				wa[p]++;
			}
		}
		printf("%d %d\n", ans_ac, ans_wa);
	}
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using vii = vector<ii>;

int main() {
    int n, t;
    cin >> n >> t;
    vii vs;
    for (int i = 0; i < n; i++) {
        int l, r;
        cin >> l >> r;
        vs.push_back(ii(l, 1));
        vs.push_back(ii(r, 0));
    }
    sort(vs.begin(), vs.end());
    int cnt = 0;
    int ans = 0;
    for (auto v: vs) {
        if (v.second == 0) {
            cnt--;
        } else {
            cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4884
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#define forn(i, n) for(int i = 1; i <= int(n); i++) 
using namespace std;
typedef long long ll;
inline int read() {
    char ch = getchar(); int x = 0, f = 1;
    while(ch < '0' || ch > '9') {
        if(ch == '-') f = -1;
        ch = getchar();
    } while('0' <= ch && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    } return x * f;
}
inline void out(int x)
{
    if(x<0){
    	putchar('-');
		x=-x;
	}
    if(x>9) out(x/10);
    putchar(x%10+'0');
}
int f[210][210][210];
int find(int a,int b,int c)
{
	int maxn=0;
	for(int i=a;i>=1;i--)
	{
		if(a%i==0&&b%i==0&&c%i==0) {maxn=i;break;};
	}
	f[a][b][c]=maxn;
	return maxn;
}
int main()
{
	long long sum=0;
	memset(f,0,sizeof(f));
	int k=read();
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=k;j++)
		{
			for(int l=1;l<=k;l++)
			{
				int g[3]={i,j,l},ans;
				sort(g,g+3);
				if(f[g[0]][g[1]][g[2]]) ans=f[g[0]][g[1]][g[2]];
				else ans=find(g[0],g[1],g[2]);
				sum+=ans;
			}
		}
	}
	printf("%lld",sum);
	return 0;
 } 

Measured memory_bytes: 39936
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
	
ll mod = 1e9 + 7;
 
int main(){
	ll n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    string s; cin >> s;
    a--;b--;c--;d--;
    for(ll i = a + 1; i < c; ++i){
        if(s[i] == '#' && s[i + 1] == '#'){
            cout << "No";
            return 0;
        }
    }
    for(ll i = b + 1; i < d; ++i){
        if(s[i] == '#' && s[i + 1] == '#'){
            cout << "No";
            return 0;
        }
    }
    if(d > c){
        cout << "Yes";
    }else{
        for(ll i = b; i <= d; ++i){
            if(s[i] == '.' && s[i - 1] == '.' && s[i + 1] == '.'){
                cout << "Yes";
                return 0;
            }
        }
        cout <<"No";
    }
    return 0;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
int main()
{
    int N,L;
    cin >> N >> L;
    int ans = 0;
    int min = abs(L+1);
    int sub = L+1;
    int t = 0;
    for(int i=1; i<=N; i++){
        t = L+i-1;
        if(abs(t) < min){
            min = abs(t);
            sub = t;
        }
        ans += t;
    }
    cout << (ans - sub) << endl;
}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <iomanip>
int main()
{
	//下20桁まで出す処理。たまに精度求められるため記述。
	std::cout << std::fixed << std::setprecision(20);
	double a;
	std::cin >> a;
	auto A = a * a * M_PI;
	auto C = 2 * a * M_PI;
	std::cout << A << " " << C << std::endl;
	return 0;
}


Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <algorithm>
int main(){
    using namespace std;
    int a;
    vector<int> v;
    int i;
    for(i=0;i<3;i++){
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    cout<<v[0]<<" "<<v[1]<<" "<<v[2];
    cout << endl;
    return 0;
}

Measured memory_bytes: 3124
package main

import (
	"bufio"
	"container/heap"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	iv, _ := strconv.Atoi(readStr())
	return iv
}

func readStr() string {
	sc.Scan()
	return sc.Text()
}

type poll struct {
	s string
	c int
}
type prQue []*poll

func (p prQue) Len() int            { return len(p) }
func (p prQue) Less(i, j int) bool  { return p[i].c > p[j].c }
func (p prQue) Swap(i, j int)       { p[i], p[j] = p[j], p[i] }
func (p *prQue) Push(x interface{}) { *p = append(*p, x.(*poll)) }
func (p *prQue) Pop() interface{} {
	old := *p
	n := len(old)
	x := old[n-1]
	*p = old[0 : n-1]
	return x
}
func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := readInt()
	m := make(map[string]int)
	for i := 0; i < n; i++ {
		s := readStr()
		m[s]++
	}

	pq := make(prQue, 0, len(m))
	for s, c := range m {
		heap.Push(&pq, &poll{s, c})
	}

	ans := make([]string, 0, len(m))
	pm := heap.Pop(&pq).(*poll)
	ans = append(ans, pm.s)
	for len(pq) > 0 {
		p := heap.Pop(&pq).(*poll)
		if p.c == pm.c {
			ans = append(ans, p.s)
		} else {
			break
		}
	}
	sort.Strings(ans)

	var wr = bufio.NewWriter(os.Stdout)
	for _, s := range ans {
		wr.WriteString(s + "\n")
	}
	wr.Flush()
}


Measured memory_bytes: 25856
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;



int main(){
  int N; cin >> N; 
  vector<vector<int>> to(N); vector<vector<int>> cost(N);
  for(int i = 1; i < N; i++){
    int a,b,w; cin >> a >> b >> w; a--; b--;
    to[a].push_back(b); cost[a].push_back(w);
    to[b].push_back(a); cost[b].push_back(w);}
   
  int cnt = 0; vector<int> ans(N,-1);
  
  queue<int> Q; Q.push(0); ans[0] = 0;
  
  while(!Q.empty()){
    int p = Q.front();
    Q.pop();
    for(int i = 0; i < to[p].size(); i++){
      int u = to[p][i];
      if( ans[u] != -1){ continue;}
      ans[u] = ( ans[p] + cost[p][i] ) % 2;
      Q.push(u);}}
  
 for(int i = 0; i < N; i++){
   cout <<  ans[i] << endl;}
  return 0;}

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

int S(int n) {
	int sum = 0;
	int keta = 0;

	while (n) {
		keta = n % 10;
		sum += keta;
		n = n / 10;
	}
	return sum;
}

int main() {
	int N;
	int ans = 0;
	cin >> N;
	ans = S(N);
	if (N % ans == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}



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

using namespace std;

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    int result = 0;
    int count = 0;
    for(int i = 0; result <= x; ++i) {
        result = y*i + z*(i+1);
        count = i;
    }
    cout << count - 1 << endl;
    return 0;
}


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

t=input()
t=t.split()

m=int(input())
px=[]
su=[]
for i in range(m):
    px.append(input().split())
    o=t[int(px[-1][0])-1]
    t[int(px[-1][0])-1]=int(px[-1][1])
    temp=0
    for i in t:
        temp=temp+int(i)
    su.append(temp)
    t[int(px[-1][0])-1]=o
    
for i in su:
    print(i)
        


Measured memory_bytes: 3064
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var n int
    fmt.Scan(&n)
    ans := 1
    for i:=n; i>0; i--{
        for j:=2; j*j<=i; j++{
            for k:=2; k<=10; k++{
                num := 1
                for l:=0; l<k; l++{
                    if num*j<=n{
                        num*=j
                    } else {
                        break
                    }
                }
                ans = max32(ans,num)
            }
        }
    }
    fmt.Println(ans)
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  for(ll i=1; i<=3500; i++) {
    for(ll j=1; j<=3500; j++) {
      ll a=4*i*j-n*j-n*i,b=n*i*j;
      if(a>0&&b%a==0) {
        cout << i << " " << j << " " << b/a << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
const int mod = 998244353;
int T, A, B;
int main() {
    cin >> A >> B;
    cout << (ll)A*B - A - B + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  int n;
  cin >> n;
  set<int> s;
  REP(i,n) {
    int d;
    cin >> d;
    s.insert(d);
  }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 3584
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d, g;
    cin >> d >> g;
    g /= 100;
    vector<P> a;
    rep(i,d){
        int p, c;
        cin >> p >> c;
        c /= 100;
        a.emplace_back(p, c);
    }
    vector<int> v(d);
    rep(i,d) v[i] = i;
    int ans = 1000;
    do{
        int cnt = 0, score = 0;
        bool ok = false;
        rep(i,d){
            if((v[i]+1)*a[v[i]].first + score < g){
                cnt += a[v[i]].first;
                score += (v[i]+1)*a[v[i]].first + a[v[i]].second;
                if(score >= g){
                    ok = true;
                    break;
                }
            }
            else{
                rep(j,a[v[i]].first){
                    cnt++;
                    score += (v[i] + 1);
                    if(score >= g){
                        ok = true;
                        break;
                    }
                }
            }
            if(ok) break;
        }
        chmin(ans, cnt);
    }while(next_permutation(v.begin(), v.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256