akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define FOR(variable,start,end) for(int variable = start; variable < end; ++variable)
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second

using namespace std;
int main(){
    std::ios::sync_with_stdio(false);
    
    int n,k;
    cin >> n >> k;
    int a[n];
    FOR(i,0,n){
        cin >> a[i];
    }
    ll sum=0;
    sort(a,a+n);
    FOR(i,0,k){
        sum+=a[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const long long N = 1e5 + 17;
ll cnt, lnt, mn = N, mx, a[N], n, m,k, x, y, ans, sum;
pair<ll,ll>pr[N];
vector<ll>v,v2,v3;
map<ll,ll>mp;
bool used[N], t1, t2;
vector<string>sv;

int main()
{
    cin >> n >> m;
    for(ll i = 0; i < n; i ++)
    {
        cin >> pr[i].first >> pr[i].second;
    }
    sort(pr, pr + n);
    for(ll i = 0; i < n; i ++)
    {
            if(m > pr[i].second and m > 0 and !used[i])
            {
                ans += pr[i].first * pr[i].second;
                m -= pr[i].second;
                used[i] = true;
            }
            if(m <= pr[i].second and m > 0 and !used[i])
            {
                ans += pr[i].first * m;
                m = 0;
                used[i] = true;
            }
    }
    cout << ans;
}


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

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
namespace adaptor = boost::adaptors;

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

using ll = long long;
using ull = unsigned long long;

bool is_product_overflow(ull a, ull b) {
	ull prod = a * b;
	return (prod / b != a);
}

void Main()
{
	ull N;
	cin >> N;

	ull x = 1e18;

	ull A;
	cin >> A;
	ull s = A;
	bool f = false;
	for (ull i = 0; i < N - 1; ++i) {
		cin >> A;
		if (A == 0) {
			cout << 0;
			return;
		}
		if (is_product_overflow(s, A)) {
			f = true;
		}
		s *= A;
	}
	if (f || s > x) {
		cout << -1;
		return;
	}
	cout << s;
	return;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy" << endl;
        return 0;
    } else if(s == "Cloudy"){
        cout << "Rainy" << endl;
        return 0;
    } else {
        cout << "Sunny" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <ll MOD>
class Combination {
private:
    ll N;
    V<ll> factv, ifactv;

public:
    Combination<MOD>(ll N) : N(N), factv(N + 1, 1), ifactv(N + 1) {
        for(ll i = 1; i <= N; i++) factv[i] = factv[i - 1] * i % MOD;
        ifactv.back() = inv(factv.back());
        for(ll i = N - 1; 0 <= i; i--) ifactv[i] = (i + 1) * ifactv[i + 1] % MOD;
    }

    ll fact(ll n) { return 0 <= n ? factv[n] : 0; }

    ll ifact(ll n) { return ifactv[n]; }

    ll pow(ll a, ll b) { return b ? (b & 1 ? a : 1) * pow(a * a % MOD, b / 2) % MOD : 1; }

    ll inv(ll a) { return pow(a, MOD - 2); }

    ll comb(ll n, ll k) { return factv[n] * ifactv[n - k] % MOD * ifactv[k] % MOD; }
};

const ll mod = 1e9 + 7;
Combination<mod> C(1e6);

int main() {
    ll N;
    cin >> N;
    V<ll> X(N);
    for (ll &e : X) cin >> e;
    ll ans = 0;
    ll fn = C.fact(N - 1);
    ll sum = 0;
    for (ll i = 1; i < N; i++) {
        sum += fn * C.inv(i) % mod;
        sum %= mod;
        ll d = X[i] - X[i - 1];
        (ans += d * sum % mod) %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 18432
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int m,f,r;
		while(true) {
			m=scan.nextInt();
			f=scan.nextInt();
			r=scan.nextInt();
			if(m==-1&&f==-1&&r==-1)break;
			if(m==-1||f==-1)System.out.println("F");
			else if(m+f>=80)System.out.println("A");
			else if(m+f>=65)System.out.println("B");
			else if(m+f>=50||m+f<50&&r>=50)System.out.println("C");
			else if(m+f>=30)System.out.println("D");
			else System.out.println("F");
		}
		scan.close();
	}

}


Measured memory_bytes: 26284
S = input()
 
flag = 1
c_count = 0
ans = 'AC'
if S[0] != 'A':
  ans = 'WA'
for i in range(1,len(S)):
  if (i == 1 or i == len(S)-1) and S[i].islower() == False:
    ans = 'WA'
  elif 2 <= i <= len(S)-2:
      if S[i] == 'C':
        c_count += 1
if c_count != 1:
  ans = 'WA'
print(ans)

Measured memory_bytes: 9048
#include <iostream>
#include <algorithm>
#include <vector>

using i64 = long long;

const i64 MOD = 1000000007;
const int N = 100000 + 7;

int n;
std::vector<int> v[N];

void init() {
	static int k, m, a[N], b[N];
	scanf("%d%d", &k, &m);
	for (int i = 1; i <= k; ++i)
		scanf("%d", a + i);
	for (int i = 1; i <= m; ++i)
		scanf("%d", b + i);
	static int l[N], r[N];
	for (int i = 1, j = 0; i <= k; ++i) {
		while (b[j] < a[i]) ++j;
		if (a[i] > b[1] && a[i] < b[m])
			l[++n] = a[i] - b[j - 1], r[n] = b[j] - a[i];
	}
	static int e[N];
	std::copy(l + 1, l + n + 1, e + 1);
	std::sort(e + 1, e + n + 1);
	k = std::unique(e + 1, e + n + 1) - e - 1;
	for (int i = 1; i <= n; ++i)
		l[i] = std::lower_bound(e + 1, e + k + 1, l[i]) - e;
	std::copy(r + 1, r + n + 1, e + 1);
	std::sort(e + 1, e + n + 1);
	k = std::unique(e + 1, e + n + 1) - e - 1;
	for (int i = 1; i <= n; ++i)
		r[i] = std::lower_bound(e + 1, e + k + 1, r[i]) - e;
	for (int i = 1; i <= n; ++i)
		v[l[i]].push_back(r[i]);
	for (int i = 1; i <= n; ++i)
		std::sort(v[i].begin(), v[i].end());
}

void work() {
	static i64 f[N];
	auto add = [&](int i, int v) {
		for (++i; i <= n + 1; i += i & -i)
			( f[i] += v ) %= MOD;
	};
	auto sum = [&](int i) {
		i64 t = 0;
		for (++i; i; i -= i & -i)
			( t += f[i] ) %= MOD;
		return t;
	};
	add(0, 1);
	for (int i = 1; i <= n; ++i)
		for (int j = v[i].size() - 1; ~j; --j)
			if (!j || v[i][j] != v[i][j - 1])
				add(v[i][j], sum(v[i][j] - 1));
	printf("%lld\n", sum(n));
}

int main() {
//	freopen("code.in", "r", stdin);
//	freopen("code.out", "w", stdout);
	init(), work();
	return 0;
}


Measured memory_bytes: 11588
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int y = sc.nextInt();
		int count10000 = 0;
		int count5000 = 0;
		int count1000 = 0;

		int limitCount10000 = (y / 10000) + 1;
		int limitCount5000 = (y / 5000) + 1;
		int limitCount1000 = (y / 1000) + 1;

		for (int i = 0; i < limitCount1000; i++) {
			if (i > n) {
				break;
			}
			for (int j = 0; j < limitCount5000; j++) {
				if (i + j > n) {
					break;
				}
				for (int k = 0; k < limitCount10000; k++) {
					if (i + j + k > n) {
						break;
					}
					if (i * 1000 + j * 5000 + k * 10000 == y) {
						if (i + j + k == n) {
							System.out.println (k + " " + j + " " + i);
							return;
						}
					}
				}
			}
		}
		System.out.println(-1 + " " + -1 + " " + -1);
	}
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

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

#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n,k;cin>>n>>k;
	cout<<max(n-k+1,(ll)0)<<endl;











	
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
INF = 10**9

n = int(input())
s = input().rstrip()
ans = ""
ordA = ord("A")
for ch in s:
    val = ord(ch) - ordA
    val = (val + n) % 26
    ans += chr(val + ordA)
print(ans)

Measured memory_bytes: 3060
import sys
s = list(input())
n = len(s)
t = list(reversed(s))
if s != t:
    print("No")
    sys.exit()
else:
    u = s[:(n-1)//2]
    v = s[(n+1)//2:]
    w = list(reversed(u))
    x = list(reversed(v))
    if u == w and v == x:
        print("Yes")
    else:
        print("No")

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define X first
#define Y second
#define INF 1000 * 1000 * 1000
#define LL long long
#define LINF INF * (LL)INF
#define PB push_back
#define SZ(a) ((LL)a.size())
#define INVALID 2392139
const LL MAX = 300005;
const LL minim = -1000 * 1000 - 1;
const LL zsuv = MAX;
using namespace std;
using namespace __gnu_pbds;
const int mod = 1000 * 1000 * 1000 + 7;

int main()
{
	string s;
	cin >> s;
	int cntA = 0;
	int cntBC = 0;
	LL ans = 0;
	for(int i = 0; i < SZ(s); i++)
	{
		if(s[i] == 'A')
		{
			cntA++;
			continue;
		}
		if(s[i] == 'B' && i + 1 < SZ(s) && s[i + 1] == 'C')
		{
			ans += cntA;
			i ++;
			continue;
		}
		cntA = cntBC = 0;
	}
	cout << ans;
	
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if((x<=W-r)&&(x>=r)&&(y<=H-r)&&(y>=r)){
		cout << "Yes" << endl;
	}
	else{
	cout<<"No"<<endl;
	}
return 0;
}


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

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;

    int s = a+b+c;
    int m = max(a, max(b,c));
    if((3*m-s)%2==0){
        cout << (3*m-s)/2 << endl;
    }else{
        cout << (3*m+3-s)/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
    int S, h, m;
    scanf("%d", &S);   

    h = S / 3600;
    S = S - h * 3600;
    m = S / 60;
    S = S - m *60;

    printf("%d:%d:%d\n", h, m, S);
    return 0;
}

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

int main() {

  while( true ) {

    long long int n;
    cin >> n;
    if ( n == 0 ) break;
    n = 1000 - n;

    long long int ans = 0;
    if ( n >= 500 ) {
      ans++;
      n -= 500;
    }
    ans += n / 100;
    n %= 100;

    if ( n >= 50 ) {
      ans++;
      n -= 50;
    }
    ans += n / 10;
    n %= 10;

    if ( n >= 5 ) {
      ans++;
      n -= 5;
    }
    ans += n / 1;

    cout << ans << endl;

  }

  return 0;

}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

    if (K == 1) {
        cout << "1\n";
        return 0;
    }
    if (K % 2 == 0 || K % 5 == 0) {
        cout << "-1\n";
        return 0;
    }
    if (K % 7 == 0) K /= 7;
    K *= 9;
    int a = 10;
    for (int i = 0; i <= 10 * K; i++) {
        if ((a - 1 + K) % K == 0) {
            cout << i + 1 << "\n";
            return 0;
        }
        a = (a * 10) % K;
    }
   
    return 0;
}

Measured memory_bytes: 3604
#define __GLIBCXX_DEBUG

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <random>
#include <queue>
#include <bitset>

#define pb push_back
#define int long long
#define dbl long double
#define str string
using namespace std;
const int M = 1e9 + 7;
map<int, pair<int, int>> lol;

int bip(int a, int x) {
    int ans = 1;
    while (x) {
        if (x & 1) {
            ans *= a;
            ans %= M;
        }
        a *= a;
        a %= M;
        x /= 2;
    }
    return ans;
}

pair<int, int> f(int n, int k) {
    if (k == 0) return {0, 0};
    if (lol.find(k) != lol.end()) return lol[k];
    int ans = 0;
    int cnt = 0;
    for (int j = 2; j <= k; j++) {
        pair<int, int> x = f(n, k / j);
        ans += (j * (M + bip(k / j, n) - x.second)) % M;
        ans %= M;
        cnt += bip(k / j, n) - x.second;
        cnt %= M;
    }
    ans += (M + bip(k, n) - cnt);
    ans %= M;
    lol[k] = {ans, cnt};
    return {ans, cnt};
}


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, k;
    cin >> n >> k;
    cout << f(n, k).first;
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int A, B, C, res;
  rd(A);
  rd(B);
  rd(C);
  res =min_L(C, B/A);
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// {
//   int A, B, C, res;
//   rd(A,B,C);
//   res = min(C, B/A);
//   wt(res);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    vector<double> v(N), t(N);
    cin >> t >> v;
    auto calc = [](double v0, double t, double a) {
        return v0 * t + 0.5 * a * t * t;
    };
    double ans = 0, now = 0;
    for (int i = 0; i < N; i++) {
        for(double j = 0; j < t[i]; j += 0.5) {
            bool check = true, temp = true;
            double next = t[i] - j - 0.5;
            for (int k = i + 1; k < N; k++) {
                next += t[k];
                if(now + 0.5 - next > v[k + 1]) check = false;
                if(now - v[k + 1] > next) temp = false;
            }
            if(now + 0.5 <= v[i] && check && (now + 0.5 - (t[i] - j - 0.5)) <= v[i + 1]) {
                ans += calc(now, 0.5, 1);
                now += 0.5;
            } else if(now - v[i + 1] <= t[i] - j - 0.5 && temp) {
                ans += now * 0.5;
            } else {
                ans += calc(now, 0.5, -1);
                now -= 0.5;
            }
        }
    }
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int ans = 0;

		while (true) {

			int n = sc.nextInt();
			int x = sc.nextInt();
			ans = 0;

			if (n == 0 && x == 0) {
				break;
			}

			for (int i = 1; i <= n; i++) {
				for (int j = i + 1; j <= n; j++) {
					for (int k = j + 1; k <= n; k++) {
						if (i + j + k == x) {
							ans++;
						}
					}
				}
			}
			System.out.println(ans);

		}

	}

}

Measured memory_bytes: 26488
import collections
def I(): return int(input())
def LI(): return list(map(int,input().split()))
##################################################
N = I()
A = LI()
count = collections.Counter(A)
sum = 0
for x in count.values():
    sum += x*(x-1)//2
for x in A:
    temp = count[x]
    minus = temp*(temp-1)//2
    plus = (temp-1)*(temp-2)//2
    print(sum-minus+plus)

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

[N, L] = [int(i) for i in input().split()]

tastes = []
for n in range(N):
    tastes.append(L + n)

minimum = tastes[0]
for t in tastes:
    if abs(t) < abs(minimum):
        minimum = t

tastes.remove(minimum)
pie_taste = sum(tastes)

print(pie_taste)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

string s;
int k;

int main(){
  cin>> s >>k;
  int cnt=0;
  int n=s.size();
  for(int i=0;i<n;i++){
    cnt+=(s[i]=='a'?0:(26-(s[i]-'a')));
  }
  bool p=false;
  if(cnt!=0){
    if(k-cnt>0){
      p=true;
      k-=cnt;
      k%=26;
    }
  }
  else{
    k%=26;
    s[s.size()-1]+=k;
    cout << s << endl;
    return 0;
  }
  if(p){
    for(int i=0;i<n;i++)
      s[i]='a';
  }
  cnt=k;
  for(int i=0;i<n;i++){
      if(cnt-(s[i]=='a'?0:(26-(s[i]-'a')))>=0){
        cnt-=(s[i]=='a'?0:(26-(s[i]-'a')));
        s[i]='a';
      }
      if(cnt==0){
        cout << s << endl;
        return 0;
      }
  }
  s[n-1]+=cnt;
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 512
N = int(input())
S = []
T = []
for _ in range(N):
    s, t = input().split()
    S.append(s)
    T.append(int(t))
X = input()

time = None
for s, t in zip(S, T):
    if s == X:
        time = 0
    elif time is not None:
        time += t
    else:
        continue

print(time)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>

#define INF_LL 9000000000000000000
#define INF 2000000000

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

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

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

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

int ice[92][92];

int dfs(int x, int y){
	int dx[4] = {-1, 0, 0, 1};
	int dy[4] = {0, -1, 1, 0};
	int a = 0;

	REP(i, 4){
		if(ice[x+dx[i]][y+dy[i]] == 1){
			ice[x+dx[i]][y+dy[i]] = 0;
			a = max(a, dfs(x+dx[i], y+dy[i]));
			ice[x+dx[i]][y+dy[i]] = 1;
		}
	}
	if(a == 0) return 1;
	return a + 1;
}

int main(void){
	int n, m;
	while(cin >> m >> n && m && n){
		int res = 0;
		REP(i, 92){
			fill(ice[i], ice[i]+92, 0);
		}
		REP(i, n){
			REP(j, m){
				cin>> ice[i+1][j+1];
			}
		}
		REP(i, n){
			REP(j, m){
				if(ice[i+1][j+1] == 1){
					ice[i+1][j+1] = 0;
					res = max(res, dfs(i+1, j+1));
					ice[i+1][j+1] = 1;
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3044
use proconio::marker::Usize1;
fn main() {
    proconio::input! {
        n: usize,
        cs: [Usize1; n],
        ab: [(Usize1,Usize1); n-1],
    }
    let mut g = vec![vec![];n];
    for (a,b) in ab {
        g[a].push(b);
        g[b].push(a);
    }
    let mut all=0;
    let mut cnt = vec![0;n];
    let mut ans = vec![s(n as i64);n];
    f(0, 0, &cs, &g, &mut all, &mut cnt, &mut ans);
    for c in 0..n {
        ans[c] -= s(n as i64-cnt[c]);
    }
    for c in cs {
        ans[c] += 1;
    }
    for a in ans {
        println!("{}",a);
    }
}
fn f(v: usize, p: usize, cs: &Vec<usize>, g: &Vec<Vec<usize>>, all: &mut i64, cnt: &mut Vec<i64>, ans: &mut Vec<i64>)->i64 {
    let c = cs[v];
    let mut sub = 1;
    let bfr = cnt[c];
    for &u in &g[v] {
        if u==p {continue;}
        let b = *all-cnt[c];
        sub += f(u, v, cs, g, all, cnt, ans);
        ans[c] -= s(*all-cnt[c]-b)
    }
    cnt[c] = bfr+sub;
    *all+=1;
    sub
}
fn s(n: i64)->i64 {
    n*(n-1)/2
}

Measured memory_bytes: 46412
K = int(input())

def snk(n):
   s = 0
   for i in str(n):
       s += int(i)
   return n / s

x = 1
y = 1
for _ in range(K):
    print(x)
    if snk(x + y) > snk(x + y * 10):
        y *= 10
    x += y


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

int main()
{
  int N, M;
  vector<pair<int, int> > v;

  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    v.push_back(make_pair(b, a));
  }

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

  int x = 0, ans = 0;
  for(int i = 0; i < M; i++){
    if(v[i].second >= x){
      x = v[i].first;
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

struct edge { ll to,cost; };
vector<edge> G[100050];
ll d[100050];

void dfs(int s,int p,ll dis){
    d[s] = dis;
    for(auto j : G[s]){
        if(j.to == p) continue;
        dfs(j.to,s,dis+j.cost);
    }
}


int main()
{
    int n;cin >> n;
    
    for(int i = 0; i < n-1; i++){
        ll a,b,c;
        cin >> a >> b >> c;
        a--; b--;
        G[a].push_back((edge){b,c});
        G[b].push_back((edge){a,c});
    }
    int q,k;
    cin >> q >> k;
    k--;
    dfs(k,-1,0);
    for(int i = 0; i < q; i++){
        int x,y;
        cin >> x >> y;
        x--; y--;
        cout << d[x] + d[y] << endl;
    }
}

Measured memory_bytes: 15616
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
#define int long long
int N, A, B;
int h[100010], d[100010];

bool ensure(int p) {
  if(p < 0) return false;
  for(int i = 0; i < N; ++i) {
    d[i] = h[i] - p * B;
  }
  int ret = 0;
  for(int i = 0; i < N; ++i) {
    if(d[i] >= 0) ret += (d[i] + (A-B) - 1) / (A - B);
  }
  if(ret > p) return false;
  return true;
}

signed main() {
  cin >> N >> A >> B;
  for(int i = 0; i < N; ++i) {
    cin >> h[i];
  }
  int l = -1, r = 1e9+7, m;
  while(true) {
    m = (l + r) / 2;
    bool p1 = ensure(m-1), p2 = ensure(m);
    if(!p1 && p2) {
      cout << m << endl;
      break;
    }
    if(p1) {
      r = m;
    } else {
      l = m;
    }
  }
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
void Digvijay()
{
   int n;
   cin>>n;
   int prime[1001]={0};
   prime[0]=1;
   prime[1]=1;
   for(int i=2;i*i<1001;i++)
   {
       if(!prime[i])
       {
           for(int j=i*i;j<=1000;j+=i)
           {
               prime[j]=1;
           }
       }
   }
   vector<int> p_fact(1001,0);
   for(int i=1;i<=n;i++)
   {
       int val=i;
       while(val%2==0)
       {
           p_fact[2]++;
           val/=2;
       }
       for(int j=3;j*j<=val;j+=2)
       {
           while(val%j==0)
           {
               p_fact[j]++;
               val/=j;
           }
       }
       if(val>2)p_fact[val]++;
   }
   int ans =1;
   int mod=1e9+7;
   for(int i=2;i<=n;i++)
   {
       if(prime[i]==0)
       {
           ans*=(p_fact[i]+1);
           ans%=mod;
       }
   }
   cout<<ans<<"\n";
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _=1;
    //cin>>_;
    for(int __=0;__<_;__++)
    {
        Digvijay();
    }
}

Measured memory_bytes: 3624
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
ans = 0

for i in range(N):
	A = list(map(int, input().split()))
	feature = C

	for j in range(M):
		feature += B[j] * A[j]

	if feature > 0:
		ans += 1

print(ans)


Measured memory_bytes: 3060
# require 'pp'

$n = gets.to_i + 1

mods = [0] + gets.split.map(&:to_i)

# p nums

nums = Array.new($n, 0)

def count_right_ones(index, nums)
    mul = 1
    i = index * mul
    res = 0
    # puts "   count: start(#{index})"

    while i < $n
        # puts "   count: nums[#{i}] = #{nums[i]}"
        res += nums[i]
        mul += 1
        i = index * mul
    end
    return res
end

res = []

mods.each_with_index.reverse_each do |mod, i|
    next if i == 0
    # puts "==="
    ones = count_right_ones(i, nums)
    ones_mod = ones % 2
    if ones_mod != mod
        # puts ones
        # p [i, ones_mod, num]
        # p nums
        nums[i] = 1
        # p nums
        res << i
    end
    # puts "---"        
end

puts res.size
puts res.join(' ') if res.size > 0

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		List<Integer> list = new ArrayList<>();

		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		String str = sc.next();
		String[] strArray = str.split("");
		List<Integer> rootLog = new ArrayList<>();

		String stone = "#";
		
		if(stone.equals(strArray[d-1])||stone.equals(strArray[c-1])){
			System.out.println("No");
			return;
		}

		boolean isSuccess =true;
		for(int i=b;i<=d;i++){
			String curPosition = strArray[i-1];
			if(!curPosition.equals(stone)){
				rootLog.add(i);
				// System.out.println("i "+ i);
				continue;
			} 
			//次が岩
			String nextPosition = strArray[i];
			if(!nextPosition.equals(stone)){
				i++;
				rootLog.add(i);
				// System.out.println("i "+ i);
				continue;
			} 
			isSuccess =false;
			break;
		}

		if(isSuccess){
			for(int i=a;i<c-1;i++){
				String curPosition = strArray[i-1];
				if(!curPosition.equals(stone)){
					continue;
				} 
				//次が岩
				String nextPosition = strArray[i];
				if(!nextPosition.equals(stone)){
					i++;
					continue;
				} 
				isSuccess =false;
				break;
			}
		}

		if(d>c){
			System.out.println(isSuccess ? "Yes" : "No");
		} else {
			//またごすことが出来るかだけを最後にチェックする
			boolean isSuccessMatagoshi = false;
			for(int root:rootLog){
				// System.out.println("root "+ root);
				String leftPosition = strArray[root-2];
				String rightPosition = strArray[root];
				// System.out.println("leftPosition "+ leftPosition);
				// System.out.println("rightPosition "+ rightPosition);
				if(!leftPosition.equals(stone) && !rightPosition.equals(stone)){
					isSuccessMatagoshi = true;
				}
			}

			System.out.println(isSuccessMatagoshi ? "Yes" : "No");

		}
		

	}
}


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

int mod = 1000000007;
int64_t large = 9223372036854775807;

int main()
{
    int N;
    string S;
    cin >> N >> S;
    for (int i = 0; i < S.size(); i++)
    {
        int x = (S[i] - 'A' + N) % 26;
        cout << (char)('A' + x);
    }
}

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

int u_b(vector<int> &a, int x){
    int left=-1,right=a.size();
    while(right-left>1){
        int mid=(left+right)/2;
        if(a[mid]>x) right=mid;
        else left=mid;
    }
    return right;
}

int l_b(vector<int> &a, int x){
    int left=-1,right=a.size();
    while(right-left>1){
        int mid=(left+right)/2;
        if(a[mid]>=x) right=mid;
        else left=mid;
    }
    return right;
}

int main(){
    int n; cin>>n;
    vector<int> a(n),b(n),c(n);
    for(int &x: a) cin>>x;
    for(int &x: b) cin>>x;
    for(int &x: c) cin>>x;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());

    long long ans=0;
    for(int i=0;i<n;i++){
        ans+=(long long)l_b(a,b[i])*(n-u_b(c,b[i]));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1408
from collections import defaultdict
n, k = map(int, input().split())
d = defaultdict(int)
for i in range(k):
    x = int(input())
    a = list(map(int, input().split()))
    for j in a:
        d[j]+=1
count = 0
for i in range(1, n+1):
    if not d[i]:
        count+=1
print(count)

Measured memory_bytes: 9464
N = int(input())
A = list(map(int, input().split()))
count = 0
for i in range(1,N):
    if A[i] < A[i-1]:
        count += A[i-1]-A[i]
        A[i] += A[i-1]-A[i]
    #print(A)
        
print(count)

Measured memory_bytes: 32232
#include <cstdio>
#include <vector>
#include <algorithm>

int testcase_ends() {
  int N;
  scanf("%d", &N);

  if (N == 0)
    return 1;

  std::vector<std::vector<int>> t(N, std::vector<int>(N+1));
  for (int i=0; i<N; ++i)
    for (int j=0; j<=N; ++j)
      // is t[i][i] meaningful?
      scanf("%d", &t[i][j]);

  std::vector<int> dp(1<<N, 1e9);
  dp[0] = 0;
  for (int i=0; i<(1<<N); ++i) {
    for (int j=0; j<N; ++j) {
      if (i >> j & 1) continue;

      int cur=t[j][0];
      for (int k=0; k<N; ++k)
        if (i >> k & 1)
          cur = std::min(cur, t[j][k+1]);

      dp[1<<j|i] = std::min(dp[1<<j|i], dp[i] + cur);
    }
  }

  printf("%d\n", dp.back());
  return 0;
}

int main() {
  while (true)
    if (testcase_ends())
      return 0;
}

Measured memory_bytes: 2948
use std::io::*;
use std::str::FromStr;

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let mut po = 0;
    for i in 0..s.len() {
        if s[i] == 'C' && po == 0 {
            po = 1;
        }
        if s[i] == 'F' && po == 1 {
            po = 2;
        }
    }
    println!("{}", if po == 2 { "Yes" } else { "No" });
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np
MOD = 998244353

S = input().rstrip()
N = len(S)

# 現時点までで使える個数
blue = 0
red = 0
# 青の個数、通り数
dp = np.array([1], dtype=np.int64)
for i in range(2*N):
    if i < N:
        blue += int(S[i])
        red = 2 * (i+1) - blue
    prev = dp
    dp = np.zeros(blue+1, dtype=np.int64)
    # 青を追加する場合
    L = min(len(prev), blue)
    dp[1:L+1] += prev[:L]
    # 赤を追加する場合
    dp[:len(prev)] += prev
    # 赤を選べない場合もある。
    min_blue = (i+1) - red
    if min_blue >= 1:
        dp[:min_blue] = 0
    dp %= MOD

answer = dp[-1]
print(answer)

Measured memory_bytes: 14412
#include <cstdio>
#include <vector>
using namespace std;
#define PB push_back

int main() {
	int n; scanf("%d",&n);
	vector<int> deck(2*n), tmp1(n), tmp2(n);
	for (int i=0; i<2*n; i++) deck[i] = i+1;
	int m; scanf("%d",&m);
	for (int c=0; c<m; c++) {
		int k; scanf("%d",&k);
		if (k != 0) {
			vector<int> back, before;
			for (int l=0; l<k; l++) before.PB(deck[l]);
			for (int l=k; l<2*n; l++) back.PB(deck[l]);
			for (int i=0; i<back.size(); i++) deck[i] = back[i];
			for (int i=0; i<before.size(); i++) deck[i+back.size()] = before[i];
		} else {
			vector<int> before, back;
			for (int i=0; i<n; i++) before.PB(deck[i]);
			for (int i=n; i<2*n; i++) back.PB(deck[i]);
			for (int i=0; i<2*n; i+=2) deck[i]=before[i/2];
			for (int i=1; i<2*n; i+=2) deck[i]=back[(int)(i/2)];
		}
	}
	for (int i=0; i<2*n; i++) printf("%d\n",deck[i]);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextLong();
  int Q = nextLong();

  dsu d(N);

  REP(i, Q) {
    int t = nextLong();
    int u = nextLong();
    int v = nextLong();

    if (t == 0) {
      d.merge(u, v);
    } else {
      cout << (d.same(u, v) ? 1 : 0) << '\n';
    }
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

#define MAX 100000
#define EMAX 500000
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY 1 << 30
int v,r;
vector<pair<int,int> > adj[EMAX];

void DIJKSTRAHOU(){
    priority_queue<pair<int,int> > PQ;
    int color[MAX];
    int d[MAX];
    for(int i = 0; i < v; i++){
        color[i] = WHITE;
        d[i] = INFTY;
    }

    d[r] = 0;
    PQ.push(make_pair(0,r));
    color[r] = GRAY;

    while(!PQ.empty()){
        pair<int,int> m = PQ.top(); PQ.pop();
        int x = m.second;
        color[x] = BLACK;

        if(d[x] < m.first*(-1)) continue;

        for(int i = 0; i < adj[x].size(); i++){
            int v = adj[x][i].first;
            if(color[v] == BLACK) continue;
            if(d[x]+adj[x][i].second < d[v]){
                d[v] = d[x]+adj[x][i].second;
                PQ.push(make_pair(d[v]*(-1),v));
                color[v] = GRAY;
            }
        }
    }
        for(int i = 0; i < v; i++){
          if(d[i] < INFTY) printf("%d\n",d[i]);
          else printf("INF\n");
    }
}

int main(void){
    int e,s,t,d;
    scanf("%d %d %d", &v, &e, &r);
    for(int i = 0; i < e; i++){
        scanf("%d %d %d", &s, &t, &d);
        adj[s].push_back(make_pair(t,d));
    }
    DIJKSTRAHOU();

    return 0;
}



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

using namespace std;
const int INF = (int)1e9;

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

  vector< pair<int, int> > keys;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    int s = 0;
    for (int j = 0; j < b; ++j) {
      int c;
      cin >> c;
      c--;
      s |= 1 << c;
    }
    keys.emplace_back(s, a);
  }

  int dp[1 << n];
  fill(dp, dp + (1 << n), INF);

  dp[0] = 0;
  for (int s = 0; s < 1 << n; ++s) {
    for (int i = 0; i < m; ++i) {
      int t = s | keys[i].first;
      int c = dp[s] + keys[i].second;
      dp[t] = min(dp[t], c);
    }
  }

  int ans = dp[(1 << n) - 1];
  cout << (ans == INF? -1: ans) << endl;
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>


int main()
{
	int n, i, A[100000], ord[100000];

	scanf("%d", &n);

	for(i=1; i<=n; i++)
    {
		scanf("%d", &A[i]);
		ord[A[i]]=i;
	}

    for(i=1; i<=n; i++)
    {
		printf("%d ", ord[i]);
	}

return 0;
}


Measured memory_bytes: 1536
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
//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>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

ll ans;
int cnt[N], a[N], n, q;

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}
 
inline void Solve () {
   cin >> n;
   for (int i = 1; i <= n; i ++) cin >> a[i], cnt[a[i]] ++, ans += a[i];
   cin >> q;
   for (int i = 1; i <= q; i ++) {
      int b, c;
      cin >> b >> c;
      ans -= 1ll * cnt[b] * b;
      ans += 1ll * cnt[b] * c;
      cnt[c] += cnt[b];
      cnt[b] = 0;
      cout << ans << endl;
   }
}               
 
signed main () {                                       
   #ifdef QWERTY
      freopen("input", "r", stdin);
   #endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                   

Measured memory_bytes: 4432
n=int(input())
m=str(n)
minus1=10**(len(m)-2)*9
minus=minus1
if len(m)==1:
    print(n)
elif len(m)%2==0:
    for i in range(len(m)//2):
        minus1+=minus//(100**(len(m)//2-i))
    print(minus1)
else:
    for i in range(len(m)//2):
        minus1+=minus//(100**(len(m)//2-i))
    print(minus1//10+n-10**(len(m)-1)+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	cin>>n;
	long long int arr[n];
	long long int sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		sum=sum^arr[i];
	}
	for(int i=0;i<n;i++){
		long long int fake=(sum^arr[i]);
		cout<<fake<<" ";
	}
}

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

int D=365,c[26+1],last[26+1],M;

int main(){
    cin>>D;
    //input
    int s[D+1][26+1];
    for(int i=1;i<=26;i++)cin>>c[i];
    for(int i=1;i<=D;i++)for(int j=1;j<=26;j++)cin>>s[i][j];

    int t[D+1];
    for(int day=1;day<=D;day++){
        //greedy
        int max_type=0,max=-1000000000;
        for(int type=1;type<=26;type++){
            int score=s[day][type];
            for(int i=1;i<=26;i++)score-=c[i]*(day-last[i]);
            if(score>max){max=score;max_type=type;}
        }
        t[day]=max_type;
        last[max_type]=day;
    }
    //output
    for(int i=1;i<=D;i++)cout<<t[i]<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int N;

void dfs(string s) {
    if (s.length() == N) {
        cout << s << "\n";
        return;
    }
    char up = 'a';
    for (char c : s) {
        up = max(up, c);
    }
    for (char c = 'a'; c <= up + 1; c++) {
        dfs(s + c);
    }
    
} 

int main() {
    cin >> N;
    string s = "a";
    dfs(s);
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

int N,M,Q;
ll ans=0;
vector<tuple<int,int,int,int>> cond(50);
int main(){
    cin>>N>>M>>Q;
    for(int i=0;i<Q;i++){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        cond[i]=make_tuple(a,b,c,d);
    }

    foreach_comb(N+M-1, M-1, [](int *indexes) {
        //std::cout << indexes[0] << ',' << indexes[1] << ',' << indexes[2] << std::endl;
        int val=1,idx=0;
        vi A(N);
        vi B(N+M-1,0);
        for(int i=0;i<M-1;i++){
            B[indexes[i]]=-1;
        }
        for(int i=0;i<N+M-1;i++){
            if(B[i]==0){
                A[idx]=val;idx++;
            }else{
                val++;
            }
        }
        // for(int i=0;i<N;i++){
        //     cout<<A[i]<<" ";
        // }
        // cout<<endl;
        ll score=0;
        for(int i=0;i<Q;i++){
            int cond_a=get<0>(cond[i]);
            int cond_b=get<1>(cond[i]);
            int cond_c=get<2>(cond[i]);
            int cond_d=get<3>(cond[i]);
            cond_a--;cond_b--;
            if(A[cond_b]-A[cond_a]==cond_c){
                score+=cond_d;
            }
        }
        ans=max(ans,score);
    });
    
        
            
        // int val=1,idx=0;
        // for(int i=0;i<N+M-1;i++){
        //     if(P[i]<N){
        //         A[idx]=val;idx++;
        //     }else{
        //         val++;
        //     }
        // }
        // for(int i=0;i<N;i++){
        //     cout<<A[i]<<" ";
        // }
        // cout<<endl;
        // ll score=0;
        // for(int i=0;i<Q;i++){
        //     int cond_a=get<0>(cond[i]);
        //     int cond_b=get<1>(cond[i]);
        //     int cond_c=get<2>(cond[i]);
        //     int cond_d=get<3>(cond[i]);
        //     cond_a--;cond_b--;
        //     if(A[cond_b]-A[cond_a]==cond_c){
        //         score+=cond_d;
        //     }
        // }
        // ans=max(ans,score);
    

    cout<<ans<<endl;
}


Measured memory_bytes: 3636
let s = Int(readLine()!)!
let mod = 1000000007

var dp = Array(repeating: 0, count: s+1)
if s >= 3 {
    dp[0] = 1
    for i in 3..<s+1 {
        dp[i] = dp[i-1] + dp[i-3]
        dp[i] %= mod
    }
}
print(dp[s])


Measured memory_bytes: 7812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const int mod = 998244353;

int main(){
    int N; cin >> N;
    vector<int> a(N);
    int sum = 0;
    for(int i=0; i<N; i++){
        cin >> a[i];
        sum += a[i];
    }

    vector<vector<ll>> dp(N, vector<ll>(sum+1, 0));
    vector<vector<ll>> dp2(N, vector<ll>(sum+1, 0));

    // 初期化
    dp[0][a[0]] = 1;
    dp[0][0] = 2;

    // 配るdp：dp[i][A]がdp[i+1][?]に貢献する値を配っていく
    for(int i=0; i<N-1; i++){
        for(int A=0; A<=sum; A++){
            if(dp[i][A] == 0) continue;

            // i+1番目をAに入れないなら、BかCに入れるかの２通りがある
            dp[i+1][A] += 2*dp[i][A];
            dp[i+1][A] %= mod;
            // i+1番目をAに入れるなら、１通り
            dp[i+1][A+a[i+1]] += dp[i][A];
            dp[i+1][A+a[i+1]] %= mod;
        }
    }

    // printf("  |");
    // for(int i=0; i<N; i++) printf("%4d|", i);
    // cout << endl;
    // for(int A=0; A<=sum; A++){
    //     printf("---");
    //     for(int i=0; i<N; i++) printf("-----");
    //     printf("\n");
    //     printf("%2d|", A);
    //     for(int i=0; i<N; i++) printf("%4lld|", dp[i][A]);
    //     cout << endl;
    // }

    ll sub1 = 0;
    for(int A=((sum-1)/2+1); A<=sum; A++){
        sub1 += dp[N-1][A];
        sub1 %= mod;
    }
    sub1 = sub1*3%mod;
    //cout << sub1 << endl;


    // 初期化
    dp2[0][a[0]] = 1;
    dp2[0][0] = 1;

    for(int i=0; i<N-1; i++){
        for(int A=0; A<=sum; A++){
            dp2[i+1][A] += dp2[i][A];
            dp2[i+1][A] %= mod;

            dp2[i+1][A+a[i+1]] += dp2[i][A];
            dp2[i+1][A+a[i+1]] %= mod;
        }
    }

    // printf("  |");
    // for(int i=0; i<N; i++) printf("%4d|", i);
    // cout << endl;
    // for(int A=0; A<=sum; A++){
    //     printf("---");
    //     for(int i=0; i<N; i++) printf("-----");
    //     printf("\n");
    //     printf("%2d|", A);
    //     for(int i=0; i<N; i++) printf("%4lld|", dp2[i][A]);
    //     cout << endl;
    // }

    ll sub2;
    if(sum%2 == 1) sub2 = 0;
    else sub2 = dp2[N-1][sum/2];

    sub2 = 3*sub2%mod;
    //cout << sub2 << endl;

    ll ans = 1LL;
    for(int i=0; i<N; i++) ans = ans*3%mod;
    //cout << ans << endl;

    ans -= sub1;
    if(ans < 0){
        ans += mod;
        ans %= mod;
    }
    ans += sub2;
    ans %= mod;

    cout << ans << endl;
}

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

const int MAXN = 1e5+5;
const int MAXNN = 1e2+5;
#define ll long long
ll dp[MAXNN][MAXN];
int val[MAXNN],weight[MAXNN];

int main()
{
    int n,cap;cin >> n >> cap;
    for(int i=1;i<=n;++i){
        cin >> val[i] >> weight[i];
    }
    for(int i=1;i<=n;++i){
        for(int j=0;j<=cap;++j){
            if(j>=val[i]) dp[i][j] = dp[i-1][j-val[i]] + weight[i];
            dp[i][j] = max(dp[i][j],dp[i-1][j]);
        }
    }
    cout << dp[n][cap];
}


Measured memory_bytes: 79360