akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
typedef long long LL;
int cs(LL n)
{
int s=0;
while(n>0){s+=n%10;n/=10;}
return s;
}
int main()
{
LL n,temp,cnt=1;
cin>>n;
int ans=cs(n);
temp=n;
while(temp>=10){temp/=10,cnt*=10;}
ans=max(ans,cs(n/cnt*cnt - 1));
printf("%d\n",ans);
return 0;
}

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

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

    int num = 0;

    for (int i = 1; i <= n; i += 2) {
        int count = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) count++;
        }
        if (count == 8) num++;
    }

    cout << num << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())

cnt_dict = defaultdict(int)
for a in map(int, input().split()):
    cnt_dict[a] += 1

n_unique = len(cnt_dict.keys())

if (N - n_unique) % 2 == 0:
    print(n_unique)
else:
    print(n_unique - 1)

Measured memory_bytes: 22636
#include <bits/stdc++.h>
using namespace std;
int n, x, y, ans = 1;
const int MOD = 1000000007;
const int N = 200010;
int ok[N];
vector <int> bi[N], ls;
int fac[N], inv[N], sum;
int powi(int a, int b)
{
    int c = 1;
    for (; b; b >>= 1, a = 1ll * a * a % MOD)
        if (b & 1) c = 1ll * c * a % MOD;
    return c;
}
int main()
{
    cin >> n >> x >> y;
    fac[0] = 1;
    for (int i = 1; i <= n; ++ i) fac[i] = 1ll * fac[i - 1] * i % MOD;
    inv[n] = powi(fac[n], MOD - 2);
    for (int i = n - 1; ~i; -- i) inv[i] = 1ll * inv[i + 1] * (i + 1) % MOD;

    for (int i = 1; i <= n; ++ i)
    {
        int c, w;
        cin >> c >> w;
        bi[c].push_back(w);
    }
    for (int i = 1; i <= n; ++ i)
    {
        sort(bi[i].begin(), bi[i].end());
    }

    int fs = 0, sc = 0;
    for (int i = 1; i <= n; ++ i) if (bi[i].size())
    {
        if (!fs || bi[fs][0] > bi[i][0]) sc = fs, fs = i;
        else if (!sc || bi[sc][0] > bi[i][0]) sc = i;
    }
    if (!sc) {puts("1"); return 0;}
    ok[fs] = 1;
    for (int i = 1; i <= n; ++ i) if (bi[i].size())
        if (bi[fs][0] + bi[i][0] <= y) ok[i] = 1;

    for (int i = 1; i <= n; ++ i) if (bi[i].size() && ok[i])
    {
        int cnt = 1;
        for (int j = 1; j < bi[i].size(); ++ j)
            if (bi[i][0] + bi[i][j] <= x || bi[fs == i? sc: fs][0] + bi[i][j] <= y)
                cnt ++;
        ls.push_back(cnt); sum += cnt;
    }
    ans = fac[sum];
    for (int i = 0; i < ls.size(); ++ i) ans = 1ll * ans * inv[ls[i]] % MOD;
    cout << ans;
}


Measured memory_bytes: 12288
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n)cin >> a[i];
	for(int i = 0;i < n ;i++){
		a[i] -= (i+1);
	}
	// trace(a);
	sort(a.begin(),a.end());
	int x;
	if(n%2 == 1)x = a[n/2];
	else x = (a[n/2-1]+ a[n/2])/2;
	int ans = 0;
	for(int i = 0;i < n ;i++){
		ans += abs(a[i] - x);
	}
	cout << ans << endl;
	return 0;
}

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

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; }

using ll = long long;

ll pow(ll a, ll n, ll m) {
	ll ret = 1LL;
	for (; n > 0LL; n >>= 1LL, a = a * a % m) {
		if (n % 2LL == 1LL) {
			ret = ret * a % m;
		}
	}
	return ret;
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll s, t=1LL;
  ll mod = 1000000007LL;
  for(ll i = 0LL; i < b;i++){
    t = t * (n-i) % mod;
    t *= pow(i+1LL,mod-2LL,mod);
    t %= mod;
    if(i == a-1LL) s=t;
  }
  ll ans = 0LL;
  ans = (pow(2LL,n,mod)-1LL-t-s) % mod;
  if(ans < 0LL) ans += mod;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int H, W;
    char c = '#';

    cin >> H >> W;
    while ((H != 0) || (W != 0))
    {
        for (int i=0; i<H; i++)
        {
            for (int j=0; j<W; j++)
            {
                if (j == 0)
                {
                    if (i % 2 == 0)
                        c = '#';
                    else 
                        c = '.';
                }
                else
                {
                    if (c == '#')
                        c = '.';
                    else
                        c = '#';
                }
                cout << c;
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W;
    }
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for(int i = (s); i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
typedef long long ll;
const int INF = 1001001001;
const int mod = 1000000007;

void dfs(int x, int y) {}

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> v(N);
    rep(i, N) { cin >> v[i]; }
    sort(v.begin(), v.end());
    rep(i, N) { cout << v[i]; }
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

struct flowGraph{
	struct edge{ int to, cap, rev, id; };
	
	int n, *level, *iter;
	vector<vector<edge> > G;
	
	flowGraph(int sz) : n(sz){
		G.resize(n);
		iter = new int[n]; level = new int[n];
	}
	~flowGraph(){
		delete iter; delete level;
	}
	
	void add(int s, int t, int cap, int id){
		G[s].pb((edge){t, cap, G[t].size(), 0});
		G[t].pb((edge){s, 0, G[s].size() - 1, id});
	}
	void bfs(int s){
		rep(i, n) level[i] = -1;
		queue<int> q;
		level[s] = 0;
		q.push(s);
		while(!q.empty()){	
			int v = q.front();
			q.pop();
			rep(i, G[v].size()){
				edge &e = G[v][i];
				if(e.cap > 0 && level[e.to] < 0){
					level[e.to] = level[v] + 1;
					q.push(e.to);
				}
			}
		}
	}
	int dfs(int v, int t, int f){
		if(v == t) return f;
		for(int &i = iter[v]; i < (int)G[v].size(); i++){
			edge &e = G[v][i];
			if(e.cap > 0 && level[v] < level[e.to]){
				int d = dfs(e.to, t, min(f, e.cap));
				if(d > 0){
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
	int max_flow(int s, int t){
		int flow = 0;
		while(1){
			bfs(s);
			if(level[t] < 0) return flow;
			rep(i, n) iter[i] = 0;
			int f;
			while((f = dfs(s, t, inf)) > 0) flow += f;
		}
	}
};

int main(){
	int n, m, s, t;
	cin >> n >> m;
	flowGraph g(n);
	rep(i, m){
		int a, b;
		cin >> a >> b;
		a--; b--;
		g.add(a, b, 1, i + 1);
		g.add(b, a, 1, -i -1);
	}
	cin >> s >> t;
	cout << g.max_flow(s - 1, t - 1) << endl;
	vi res;
	rep(i, n) each(j, g.G[i]) if(j->id < 0 && j->cap > 0) res.pb(-j->id);
	cout << res.size() << endl;
	rep(i, res.size()) cout << res[i] << endl;
	return 0;
}

Measured memory_bytes: 1344
#include <iostream>
#include <algorithm>
#define REP(i,n) for(int i=0;i<n;i++)
#define REP3D(i,s,g) for(int i=s;i>=g;i--)
using namespace std;

int main() {
    int N, W;
    cin >> N >> W;
    int dp[W+1], v[N], w[N];
    REP(i,W+1)
        dp[i] = 0;
    REP(i,N){
        cin >> v[i] >> w[i];
    }
    REP(i,N){
        REP3D(j,W,0){
            if (j-w[i] >= 0)
                dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
        }
    }
    cout << dp[W] << '\n';

}

Measured memory_bytes: 1200
#pragma GCC optimize "O2"
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <queue>
// for iota, accumulate, partial_sum
// #include <numeric>
// #include <iomanip>
// #include <fstream>
// #include <deque>
// #include <cmath>
// #include <unordered_map>
// #include <utility>
// #include <unordered_set>
// #include <ctime>
// #include <stack>
// #include <bitset>
// #include <random>
// #include <cstring>
// #include <cassert>
// #include <complex>
using namespace std;
typedef long long int lu;
typedef long long int ll;
typedef long double ld;
#define v vector<ll>
#define vu vector<lu>
#define vvu vector<vector<lu>>
#define vld vector<ld>
#define vs vector<string>
#define pll pair<ll, ll>
#define vpll vector<pair<ll, ll>>
#define puu pair<lu, lu>
#define vpuu vector<pair<lu, lu>>
const lu MOD = 1000000007;
const ld PI = 2 * acos(0.0);
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))

#define all(x) x.begin(), x.end()

v ga(ll n)
{
    v a;
    for (ll i = 0; i < n; i++)
    {
        ll p;
        // scanf("%lld", &p);
        cin >> p;
        a.push_back(p);
    }
    return move(a);
}

vu gau(lu n)
{
    vu a;
    for (lu i = 0; i < n; i++)
    {
        lu p;
        // scanf("%lu", &p);
        cin >> p;
        a.push_back(p);
    }
    return move(a);
}
vs gas(lu n)
{
    vs a;
    for (lu i = 0; i < n; i++)
    {
        string p;
        // scanf("%lu", &p);
        cin >> p;
        a.push_back(p);
    }
    return move(a);
}

template <typename T, typename A>
void pa(vector<T, A> const &a)
{
    for (T p : a)
    {
        // printf("%lu ", a[i]);
        cout << p << " ";
    }
    cout << "\n";
}

void yes()
{
    cout << "YES\n";
}

void no()
{
    cout << "NO\n";
}

void yesno(int f)
{
    if (f)
        yes();
    else
        no();
}

void solve()
{
    lu n, k;
    cin >> n >> k;
    vu a = gau(n);
    vu dp(n + 1, (ll)(1e15));
    dp[0] = 0;

    for (lu i = 0; i < n; i++)
    {
        ll lim = min(i + k, n);
        for (lu j = i + 1; j <= lim; j++)
        {
            amin(dp[j], dp[i] + abs(a[j] - a[i]));
        }
    }
    cout << dp[n - 1];
}

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

    solve();
    return 0;
}

Measured memory_bytes: 1908
#include <stdio.h>
int max(int a,int b){
  if(a<b)return b;
  else return a;
}
int dp[101][10001];
int main(){
  int N,W;
  int v[101],w[101];
  int i,j;
  scanf("%d %d",&N,&W);
  for(i=0;i<N;i++)scanf("%d %d",&v[i],&w[i]);

  for(i=0;i<N;i++){
    for(j=0;j<=W;j++){
      if(w[i]>j)dp[i+1][j]=dp[i][j];
      else dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
    }
  }
 
  printf("%d\n",dp[N][W]);
  return 0;
}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    string ans = "";
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '0')
            ans += "0";
        else if (s[i] == '1')
            ans += "1";
        else {
            if (ans.empty() == false)
                ans.erase(ans.begin() + ans.size() - 1);
        }
    }
    cout << ans << endl;
    return 0;
}


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


const int N = 2e5 + 7, mod = 1e9 + 7;

int POW(int a, int b, int mod) {
	a %= mod; int r = 1;
	for(int i = b; i > 0; i >>= 1) {
		if(i & 1) r = (r * a) % mod;
		a = (a * a) % mod;
	}
	return r;
}

int f[N];


int nCr(int n, int r) {
	if(n < r) return 0;
	return f[n] * POW(f[n - r] * f[r], mod - 2, mod) % mod;
}

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

	f[0] = 1;
	for(int i = 1; i < N; i++) {
		f[i] = (f[i - 1] * i) % mod;
	}

	int n, m, a, b; cin >> n >> m >> a >> b;

	int ans = 0;

	for(int i = b; i <= m - 1; i++) {
		ans += nCr(i + n - a - 1, i) * nCr(m - 1 - i + (n - 1) - (n - a), m - 1 - i) % mod;
		ans %= mod;
	}

	cout << ans << endl;

} 

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

int main()
{
  uint64_t n, m;
  cin >> n >> m;
  vector<pair<uint64_t, uint64_t>> drink(n);
  for (int i = 0; i < n; i++) {
    cin >> drink[i].first >> drink[i].second;
  }
  sort(begin(drink), end(drink));
  uint64_t ans = 0;
  for (int i = 0; i < n; i++) {
    if (m == 0) break;
    auto price = drink[i].first;
    auto stock = drink[i].second;
    auto buy = min(m, stock);
    ans += buy * price;
    m -= buy;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a,b,k,x=0,n;
	cin>>a>>b>>k;
	if(a>b)n=a;
	else n=b;
	for(int i=n;i>0;i--){
		if(a%i==0&&b%i==0){
			x++;
			}
		if(x==k){
			cout<<i<<endl;
			return 0;
			}
		}
}



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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

lli dp[301][301]; // k 個分用意しなくても上書きしてけば良いので、dp[i][j]のみ用意
#define INF (LLONG_MAX / 3);

bool used[9];
lli r[9];
lli N, M, R;

lli rec(lli cur, lli used_count) {
    if (used_count == R) {
        return 0;
    }

    // r[i] が未使用ならそれを使う
    lli ans = LLONG_MAX;
    REPE(i, 1, R) {
        lli target = r[i];
        if (target == cur || used[target])
            continue;

        used[cur] = true;
        ans = min(ans, rec(target, used_count+1) +dp[cur][target]);
        //cout1(target);
        //cout1(used_count);
        //cout1(ans);
        used[cur] = false;
    }
    return ans;
}

int main() {
    cin3(N, M, R);
    REPE(i, 1, R) {
        cin >> r[i];
    }
    REP(i, 0, M) {
        lli from, to, cost;
        cin >> from >> to >> cost;
        dp[from][to] = dp[to][from] = cost;
    }

    // 初期化
    REPE(i, 1, N) {
        REPE(j, 1, N) {
            if (dp[i][j])
                continue;
            if (i == j)
                continue;
            dp[i][j] = INF;
        }
    }

    REPE(k, 1, N) {
        REPE(i, 1, N) {
            REPE(j, 1, N) {
                dp[j][i] = dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]);
            }
        }
    }
    lli ans = LLONG_MAX;
    REPE(i, 1, R) {
        used[r[i]] = true;
        ans = min(ans, rec(r[i], 1));
        used[r[i]] = false;
    }
    cout << ans << endl;
    // dump
    //cout << endl;
    //REPE(i, 1, N) {
    //    REPE(j, 1, N) {
    //        cout << i << "-" << j << ": " << dp[i][j] << endl;
    //    }
    //    cout << endl;
    //}

    // Rの順番を全て舐める

}





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

void solve() {
    int N; cin >> N;
    vector<vector<P>> V(N);
    rep(i, N) {
        int a; cin >> a;
        while(a--) {
            int x;
            bool y;
            cin >> x >> y;
            --x;
            V[i].emplace_back(x, y);
        }
    }
    int ans = 0;
    for(int mask = 0; mask < (1 << N); ++mask) {
        bool ok = true;
        rep(i, N) {
            if(mask & (1 << i)) {
                for(auto &a : V[i]) {
                    int m = a.first;
                    bool t = a.second;
                    bool s = mask & (1 << m);
                    if(s ^ t) {
                        ok = false;
                    }
                }
            }
        }
        if(ok) {
            int cnt = 0;
            rep(i, N) {
                if(mask & (1 << i)) cnt++;
            }
            ans = max(ans, cnt);
        }
    }
    cout << ans << '\n';
}

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


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

int main(){
  int t_HP,t_At,a_HP,a_At;
  cin >> t_HP >> t_At >> a_HP >> a_At;
  bool b = true;
  while(t_HP>0 && a_HP >0){
    if(b) a_HP -= t_At;
    else t_HP -= a_At;
    b = !b;
  }

  if(t_HP<1) cout <<"No" <<endl;
  else cout <<"Yes" << endl;

}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
typedef long long ll;
typedef long double ld;


long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
    ll X, Y;
    cin >> X >> Y;


    ll n = (2 * Y - X) / 3;
    ll m = (X - (2 * Y - X) / 3) / 2;

    if(n < 0 || m < 0 || (X + Y) % 3 != 0){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    for(int i = n + m; i > m; i--){
        ans = (ans * i) % 1000000007;
        ans = ans * modinv(n + m + 1 - i, 1000000007) % 1000000007;
    }
    ans = ans % 1000000007;
    cout << ans << endl;

}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

int main(void){
    int N,K;
    cin>>N>>K;
    vector<long long> h(N);
    for(int i=0;i<N;i++){
        cin>>h[i];
    }
    sort(h.begin(),h.end());
    long long ans=INT64_MAX;
    for(int i=0;i<N-K+1;i++){
        if(ans>h[i+K-1]-h[i]){ans=h[i+K-1]-h[i];}
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vp vector<pair<int, int>>
#define vll vector<long long>
#define inf 1000000100
#define infll 1LL << 50

int main()
{
    ll k;
    cin >> k;
    int n = 50;
    vll ans(n);
    for(int i = 0; i < n; ++i)
    {
        ans[i] = i+(k/n);
    }
    k %= n;
    for(int i = 0; i < k; ++i)
    {
        ans[i] += n;
        for(int j = 0; j < n; ++j)
        {
            if(j == i)
            {
                continue;
            }
            ans[j]--;
        }
    }

    cout << n << endl;

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

}


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


struct SegTree{
    static const int N=1<<18;
    int *dat;

    SegTree(){
        dat=new int[N*2-1];
        for(int i=0;i<N*2-1;i++)dat[i]=INT_MAX;
    }

    void update(int k,int x){
        k+=N-1;
        dat[k]=min(dat[k],x);
        while(k){
            k=(k-1)/2;
            dat[k]=min(dat[k],x);
        }
    }

    int getMin(int a,int b,int k=0,int l=0,int r=N){
        if(r<=a||b<=l)return INT_MAX;
        if(a<=l&&r<=b)return dat[k];
        int m=(l+r)/2;
        int vl=getMin(a,b,k*2+1,l,m);
        int vr=getMin(a,b,k*2+2,m,r);
        return min(vl,vr);
    }
};
typedef pair<int,int>P;
typedef pair<int,P>PP;
#define fi first
#define se second
typedef long long ll;

int N,D;
PP Stars[200000];
SegTree minx,miny,maxx,maxy;

int main(){
    scanf("%d%d",&N,&D);
    for(int i=0;i<N;i++){
        int x,y,b;
        scanf("%d%d%d",&x,&y,&b);
        Stars[i]=PP(b,P(x,y));
    }

    sort(Stars,Stars+N);

    for(int i=0;i<N;i++){
        minx.update(i,Stars[i].se.fi);
        miny.update(i,Stars[i].se.se);
        maxx.update(i,-Stars[i].se.fi);
        maxy.update(i,-Stars[i].se.se);
    }

    ll ans=0;

    for(int i=0;i<N;i++){
        int j=upper_bound(Stars,Stars+N,PP(Stars[i].fi+D,P(INT_MAX,INT_MAX)))-Stars;
        ll w=-maxx.getMin(i,j)-minx.getMin(i,j);
        ll h=-maxy.getMin(i,j)-miny.getMin(i,j);
        ans=max(ans,h*w);
    }

    cout<<ans<<endl;

    return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli func(lli x,lli a,lli b){
    return abs(x-a)+b;
}

int main(){
    // cout << fixed << setprecision(5);

    lli n;
    cin>>n;


    /*
    REP(i,-20,20){
        lli ans = 0;
        REP(j,0,a.size()){
            ans += func(i,a[j],0);
        }

        cout<<"i="<<i<<" ans="<<ans<<endl;
    }
    */

    //偶数なら真ん中2つの片方, 奇数なら真ん中が答え

    priority_queue<lli> small;
    priority_queue<lli,vector<lli>,greater<lli>> large;

    small.push(-INF);
    large.push(INF);

    lli b = 0;
    lli cnt=0;
    lli smallSum = 0;
    lli largeSum = 0;

    REP(i,0,n){
        lli num;
        cin>>num;
        lli sum = 0;
        if(num==1){
            lli aa,bb;
            cin>>aa>>bb;
            b += bb;
            cnt++;

            if(aa>=small.top()){
                large.push(aa);
                largeSum+=aa;
            }
            else {
                small.push(aa);
                smallSum += aa;
            }

            if(large.size()>small.size()){
                lli num = large.top();
                small.push(num);
                smallSum += num;
                large.pop();
                largeSum -=num;
            }
            if(small.size()-large.size()>=2){
                lli num = small.top();
                large.push(num);
                largeSum += num;
                small.pop();
                smallSum-=num;
            }
        }
        else{
            lli smallAns = abs((smallSum - (lli)small.top()*(lli)(small.size()-1)));
            lli largeAns = abs((largeSum - (lli)small.top()*(lli)(large.size()-1)));
            cout<<small.top()<<" "<<smallAns+largeAns+b<<endl;
        }
    }

    return 0;
}


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

namespace atcoder_B120問題
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = Convert.ToInt32(input[0]);
            int B = Convert.ToInt32(input[1]);
            int K = Convert.ToInt32(input[2]);
            int C = Math.Min(A, B);
            int D = Math.Max(A, B);
            int count = 0;
            for (int i = C; i > 0; --i)
            {
                if (C % i == 0 && D % i == 0)
                {
                    //K番目に大きい数と比較するため、1番目、2番目・・・とcountを加算
                    count++;
                    if (K == count)
                    {
                        Console.WriteLine(i);
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,y,z;
    while(1<2){
        cin >>x >>y;
        if(x == 0 && y==0){
            break;
        }
        if(x>y){
            z = x;
            x = y;
            y = z;
        }
        cout << x <<" "<< y << endl;
    }
}


Measured memory_bytes: 2996
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int counter(int a) {
	if (a == 0) return 0;
	return counter(a >> 1) + (a & 1);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> A(n + 1);
	vector<vector<int>> x(n + 1, vector<int>(n + 1)), y(n + 1, vector<int>(n + 1));
	for (int i = 1; i <= n; ++i) {
		cin >> A[i];
		for (int j = 1; j <= A[i]; ++j) {
			cin >> x[i][j] >> y[i][j];
		}
	}

	int ans = 0;
	for (int bit = 1; bit < (1 << n); ++bit) {
		bool elf = true;
		for (int i = 1; i <= n; ++i) {
			if (!(bit & (1 << (i - 1)))) continue;
			for (int j = 1; j <= A[i]; ++j) {
				if (((bit >> (x[i][j] - 1)) & 1) ^ y[i][j]) elf = false;
			}
		}
		if (elf) ans = max(ans, counter(bit));
	}

	dunk(ans);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
int main(){
    int M,T,P,R;
    while(1){
        cin>>M>>T>>P>>R;
        if(M==0 && T==0 && P==0 && R==0) break;
        int m,t,p,j;
        bool judge[51][11]={};
        int pena[51][11]={};
        int time[51]={};
        int rep[51]={};
        pair<int,int> ans[51];
        for(int i=0;i<R;i++){
            cin>>m>>t>>p>>j;
            if(j==0){
                judge[t][p]=true;
                time[t]+=m;
                rep[t]++;
            }
            else pena[t][p]++;
        }
        
        for(int i=1;i<=T;i++) ans[i].S=i,ans[i].F=rep[i];
        
        for(int i=1;i<=T;i++)
            for(int j=1;j<=P;j++) if(judge[i][j]) time[i]+=pena[i][j]*20;
        
        sort(ans+1,ans+1+T);
        reverse(ans+1,ans+1+T);
        
        bool flag=true;
        while(flag){
            flag=false;
            for(int i=1;i<T;i++){
                if(ans[i].F==ans[i+1].F && time[ans[i].S] > time[ans[i+1].S]){
                    swap(ans[i],ans[i+1]);
                    flag=true;
                }
            }
        }
        
        for(int i=1;i<T;i++){
            cout<<ans[i].S;
            if(ans[i].F==ans[i+1].F && time[ans[i].S]==time[ans[i+1].S]) cout<<"=";
            else cout<<",";
        }
        cout<<ans[T].S<<endl;
    }
    return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	bool b=true;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		if(a[i]%2==0){
			if(a[i]%3!=0&&a[i]%5!=0){
				b=false;
			}
		}
	}
	if(b){
		cout<<"APPROVED"<<endl;
	}else{
		cout<<"DENIED"<<endl;
	}
	
}

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


def solve(a, b):
    score = a*b
    l, r = 0, int(1e18)
    while r-l > 1:
        k = (l+r) // 2
        if k**2 < score:
            l = k
        else:
            r = k

    ans1 = l*2 - 1
    if a <= l:
        ans1 -= 1
    if b <= l and a != b:
        ans1 -= 1
    
    ans2 = 0
    if l*r < a*b:
        ans2 = l*2
        if a <= l:
            ans2 -= 1
        if b <= l and a+b != l+r:
            ans2 -= 1

    ans = max(ans1, ans2)
    return ans

  
def main():
    q = int(input())
    for i in range(q):
        a, b = map(int, input().split())
        ans = solve(a, b)
        print(ans)


if __name__ == "__main__":
    main()



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

int main(void){
    int n;
    cin >> n;
    map<string,int> data; 
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        if(data.count(s)) data[s]++;
        else data[s] = 1;
    }

    priority_queue<pair<int,string>> pq;
    priority_queue<string,vector<string>,greater<string>> pq2;
    for(auto p: data){
        pq.push(make_pair(p.second,p.first));
    }



    int maxnum = pq.top().first;
    while(!pq.empty()){
        pair<int,string> p = pq.top(); pq.pop();
        if(p.first==maxnum) pq2.push(p.second);
        else break;
    }

    while(!pq2.empty()){
        cout << pq2.top() << endl;
        pq2.pop();
    }

    return 0;

}

Measured memory_bytes: 32496
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

ll n, m, ans;

int main()
{
    cin >> n >> m;
    vector<ll> x(m), l;
    for (int i = 0; i < m; i++)
    {
        cin >> x[i];
    }
    if (m == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    sort(x.begin(), x.end());
    ans = abs(x[0] - x[m - 1]);
    for (int i = 0; i + 1 < m; i++)
    {
        l.push_back(abs(x[i] - x[i + 1]));
    }
    sort(l.begin(), l.end());
    reverse(l.begin(), l.end());
    for (int i = 0; i + 1 < min(n, m); i++)
    {
        ans -= l[i];
    }
    cout << max(ans, 0LL) << endl;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
    using namespace std;
    int main(){
        string s1,s2;
        cin>>s1>>s2;
        vector<vector<int>>dp(s1.size()+1,vector<int>(s2.size()+1));
        for(int i=0;i<dp.size();i++)
        {
            dp[i][0]=0;
        }
        for(int i=0;i<dp[0].size();i++)
        {
            dp[0][i]=0;
        }
        for(int i=1;i<dp.size();i++)
        {
            for(int j=1;j<dp[i].size();j++)
            {
                if(s1[i-1]==s2[j-1]){
                    dp[i][j]=dp[i-1][j-1]+1;
                }
                else{
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                }
            }
        }
        stack<char>st;
        int indexx=s1.size(),indexy=s2.size();
        while(indexx!=0&&indexy!=0){
            if(dp[indexx-1][indexy]==dp[indexx][indexy]){
                indexx--;
            }
            else
            if(dp[indexx][indexy-1]==dp[indexx][indexy]){
                indexy--;
            }
            else{
                st.push(s1[indexx-1]);
                indexx--;
                indexy--;
            }
        }
        while(!st.empty()){
            cout<<st.top();
            st.pop();
        }
    }

Measured memory_bytes: 38556
using System;

namespace abc124_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            int sum = 0;
            if(a >= b)
            {
                sum += a;
                a -= 1;
            }
            else
            {
                sum += b;
                b -= 1;
            }

            if (a >= b)
            {
                sum += a;
                a -= 1;
            }
            else
            {
                sum += b;
                b -= 1;
            }
            Console.WriteLine(sum);
            Console.Read();
        }
    }
}

Measured memory_bytes: 11092
import itertools

l = list(input())

for i in itertools.product('+-', repeat=3):
    s = l[0] + i[0] + l[1] + i[1] + l[2] + i[2] + l[3]
    m = eval(s)
    if m == 7:
        print(s + '=7')
        break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll n,k,a,b,sum;

int main(){

  cin >> n >> k;

  rep(i,k,n+2){
    ll u = (ll)i;
    a = u*(2*n+1-u)/2;
    b = u*(u-1)/2;
    ll t = (a-b+1)%MOD;
    sum += t;
    sum %= MOD;
    //cout << i << " " << t << endl;
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main(void)
{
	string n[100];
	int a[100], b[100];

	for (int i = 0; i < 9; i++)
	{
		cin >> n[i] >> a[i] >> b[i];
	}

	for (int i = 0; i < 9; i++)
	{
		cout << n[i] << " " << a[i] + b[i] << " " << (a[i] * 200) + (b[i] * 300) << endl;;
	}
}




Measured memory_bytes: 3072
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<queue>

using namespace std;

typedef pair<int,int> pii;
#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
//short v[100000000];
int d(int n){
	int r=0;
	do{
		n/=10;
		r++;
	}while(n>0);
	return r;
}
int main(){
	int n,m,s;
	vector<int> v;
	vector<int>::iterator it;
	scanf("%d",&n);
	rep(i,n){
		scanf("%d",&m);
		it = upper_bound(v.begin(),v.end(),m);
		v.insert(it,m);
		if(v.size()>4)v.pop_back();
	};
	vector<int> a;
	s=v.size();
	rep(i,s)rep(j,s)if(i!=j)a.push_back(pow(10,d(v[j]))*v[i]+v[j]);
	sort(a.begin(),a.end());
	printf("%d\n",a[2]);
	return 0;
}

Measured memory_bytes: 1252
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n,k,h[100000],ans=1000000000;
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    sort(h,h+n);
    for(int i=0;i+k-1<n;i++){
        ans=min(ans,h[i+k-1]-h[i]);
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;

  unordered_map<char, string> um;

  for(char c = 'a'; c <= 'z'; c++) {
    um[c] = c;
  }

  for(int i = s.length() - 1; i >= 0; i--) {
    pair<char, int> charAndStrLen = make_pair('a', um['a'].length());

    for(char c = 'a'; c <= 'z'; c++) {
      if(um[c].length() < charAndStrLen.second) {
        charAndStrLen = make_pair(c, um[c].length());
      }

    }
    um[s[i]] = s[i] + um[charAndStrLen.first];
  }

  size_t minLength = um['a'].length();

  for(char c = 'a'; c <= 'z'; c++) {
    minLength = min(minLength, um[c].length());
  }

  vector<string> strings;

  for(char c = 'a'; c <= 'z'; c++) {
    if(um[c].length() == minLength) {
      strings.push_back(um[c]);
    }
  }
  sort(strings.begin(), strings.end());

  cout << strings[0] << endl;

}


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

int main()
{
	int n, x, i;
	int d[100] = {0};

	//n?????°????????????
	cin >> n;

	for (i = 1; i <= n; i++)
	{
		cin >> x; //x?????°??????????´?
		d[i] = x;
	}
	for (i = n; 1 <= i; i--)
	{
		if(i != 1) cout << d[i] << " ";
		if(i == 1) cout << d[i] << "\n";
	}

	return 0;
}

Measured memory_bytes: 3052
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main(void)
{
    int A,B,C,D;
    cin >> A >> B >> C >> D;

    if(A * B >= C * D)
        cout << A * B << endl;
    else if(C * D > A * B)
        cout << C * D << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define ull unsigned long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define pi acosl(-1)
#define sqr(x) ((x)*(x))
#define mod (1000*1000*1000+7)
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
template <typename T>
string NumberToString(T pNumber)
{
     ostringstream oOStrStream;
     oOStrStream << pNumber;
     return oOStrStream.str();
}
ll modPow(ll x,ll n,ll m)
{
    if(n==0)
    return 1%m;
    ll u = modPow(x,n/2,m);
    u=u*u%m;
    if(n%2==1)
    u=u*x%m;
    return u;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
ll seive[1000000];
void seiveForm()
{
    ll i,j;
    seive[0]=seive[1]=1;
    f(i,2,100000)
    {
        if(seive[i]==0)
            for(j=i*i;j<1000000;j+=i)
                seive[j]=1;
    }
}
bool isPerfectSquare(ll num)
{
    double n = sqrt(num);
    return n==(ll)n?true:false;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i,siz;
    bool f=true;
    string s;
    cin>>s;
    map<char,int> mp;
    rep(i,s.size())
    mp[s[i]]++;
    rep(i,s.size())
    {
        if(mp[s[i]]%2==0)
            continue;
        else
        {
            f=false;
            break;
        }
    }
    if(f)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include "string.h"
#define UNVISITED 0
#define VISITED 1
#define N 100010
using namespace std;
int flag[N];
vector<vector<pair<int, int>>> g(N);
void DFS(int u){
	if(flag[u] == VISITED)return;
	flag[u] = VISITED;
	for(int i=0;i<(int)g[u].size();i++){
		int nx = g[u][i].first;
		DFS(nx);
	}
}

int main(){
	memset(flag,UNVISITED,sizeof(flag));
	// for(int )
	int n;int m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y,z;
		cin>>x>>y>>z;
		x -= 1;
		y -= 1;
		g[x].emplace_back(y,-1);
		g[y].emplace_back(x,-1);
	}
	int ct = 0;
	for(int i=0;i<n;i++){
		if(flag[i] == UNVISITED){
			ct++;
			DFS(i);
		}
	}
	cout<<ct<<'\n';
	return 0;
}

Measured memory_bytes: 9216
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int N = 2*(int)1e5 + 3;

int n, dp[N][2];
string s;

int main() {
  init_ios();
  cin >> s;
  n = s.size();
  dp[0][0] = 1;
  for (int i = 1; i < n; ++i) {
    if (dp[i-1][1])
      dp[i][0] = 1+dp[i-1][1];
    if (s[i-1] != s[i])
      dp[i][0] = max(dp[i][0], 1+dp[i-1][0]);
    if (i == 1 || dp[i-2][0])
      dp[i][1] = 1+(i == 1 ? 0 : dp[i-2][0]);
    if (i > 2 && s.substr(i-1, 2) != s.substr(i-3, 2))
      dp[i][1] = max(dp[i][1], 1+dp[i-2][1]);
  }
  cout<<max(dp[n-1][0], dp[n-1][1])<<"\n";
}

Measured memory_bytes: 2196
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
  size_t n; cin >> n;
  vector<unsigned long long> a(n+1uLL);
  vector<unsigned long long> b(n+1uLL);
  for(size_t i=0;i<=n;++i) {
    cin >> a[i];
  }
  for(size_t i=0;i<=n;++i) {
    cin >> b[i];
  }
  unsigned long long c=0uLL, x=0uLL;
  x = min(a[n], b[n]);
  c += x;
  a[n] -= x;
  b[n] -= x;
  for(size_t i=n;i>0;) {
    --i;
    x = min(a[i+1], b[i]);
    c += x; a[i+1] -= x; b[i] -= x;
    x = min(a[i], b[i]);
    c += x; a[i] -= x; b[i] -= x;
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using pint=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define el '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define ceil_div(a,b) ((a+(b-1))/b)
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
#define $in(v,n) ;rep(II,0,n)cin>>v[II]
inline void IN(void){return;}
template<typename F,typename... R>inline void IN(F& f, R&... r){cin>>f;IN(r...);}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}


int main(){
    string s; IN(s);
    if(s=="Sunny") puts("Cloudy");
    else if(s =="Cloudy") puts("Rainy");
    else puts("Sunny");
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

struct SegmentTree{
	vector<int> data;
	int sz;
	const int M0 = numeric_limits<int>::max();
	
	SegmentTree(int n){
		sz = 1;
		while(sz < n)	sz <<= 1;
		data.assign(sz << 1, M0);
	}

	void update(int i, int x){
		int k = sz + i;
		data[k] = x;
		while(k > 1){
			k >>= 1;
			data[k] = min(data[k << 1], data[k << 1 | 1]);
		}
	}

	int find(int a, int b, int k = 1, int l = 0, int r = -1){
		if(r == -1)	r = sz;
		if(b <= l || r <= a)	return M0;
		else if(a <= l && r <= b)	return data[k];
		else{
			return min(find(a, b, k << 1, l, (l + r) >> 1),
						find(a, b, k << 1 | 1, (l + r) >> 1, r));
		}
	}

	int operator[](const int& k) const{
		return data[sz + k];
	}
};

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

	int n, q;
	cin >> n >> q;
	SegmentTree seg(n);
	for(int i = 0; i < q; ++i){
		int com, x, y;
		cin >> com >> x >> y;
		if(!com)	seg.update(x, y);
		else	cout << seg.find(x, y + 1) << '\n';
	}
}


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

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

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H,K;
	string s;
	while(cin>>s) {
		string ans='a'<=s[0]&&s[0]<='z' ? "a":"A";
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3120
t = int(input())
ans = []

for tt in range(t):
    n = int(input())

    redk = {}
    bluek = {}
    asum = 0
    for i in range(n):
        k,l,r = list(map(int,input().split()))
        asum += min(l,r)
        if l >= r:
            if k in redk:
                redk[k].append(l-r)
            else:
                redk[k] = [l-r]
        else:
            if k in bluek:
                bluek[k].append(r-l)
            else:
                bluek[k] = [r-l]
    reds = []
    for i in range(1,n+1):
        if i in redk:
            reds += redk[i]
        while len(reds) > i:
            reds.remove(min(reds))
    blues = []
    for i in range(n,0,-1):
        if i in bluek:
            blues += bluek[i]
        while len(blues) >= n + 1 - i:
            blues.remove(min(blues))
    ans.append(asum + sum(reds) + sum(blues))

for i in range(len(ans)):
    print(ans[i])

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

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int x = tx - sx;
    int y = ty - sy;
    rep(i, x){
	printf("R");
    }
    rep(i, y){
	printf("U");
    }
    rep(i, x){
	printf("L");
    }
    rep(i, y+1){
	printf("D");
    }
    rep(i, x+1){
	printf("R");
    }
    rep(i, y+1){
	printf("U");
    }
    printf("L");
    printf("U");
    rep(i, x+1){
	printf("L");
    }
    rep(i, y+1){
	printf("D");
    }
    printf("R\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
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(){
    int a,b,c ; cin>>a>>b>>c ;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
}

Measured memory_bytes: 3512