akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	string s;
	cin >> s;
	int n = s.size();
	int m = n / 2;
	REP(i, n) {
		if (s[i] != s[n - 1 - i]) {
			put("No");
			return 0;
		}
	}
	REP(i, m) {
		if (s[i] != s[m - 1 - i]) {
			put("No");
			return 0;
		}
	}
	put("Yes");
	return 0;
}

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

const ll MOD = (1e+9) +7;

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n), cnt(n, 0), after(n, 0);
  for(ll i=0;i<n;i++) cin >> a[i];
  for(ll i=0;i<n;i++){
    for(ll j=0;j<n;j++){
      if(a[i] > a[j]){
        cnt[i] ++;
        if(i < j) after[i]++;
      }
    }
  }
  ll ans = 0;
  for(ll i=0;i<n;i++){
    ans = (ans + (k * after[i])%MOD + (((k*(k-1)/2)%MOD) * cnt[i])%MOD) %MOD; 
  }
  cout << ans << endl;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            Console.WriteLine(input[0] - input[1] + 1);
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////


typedef pair <int, int> P;
 
const ll MOD=1000000007;
 
ll power(ll x, ll k, ll p){
    if (k==0) return 1;
    else if (k==1) return x%p;
	ll res = power(x, k / 2, p);
	if (k%2==0) return (res * res)%p;
    else return (res * res % p * x)%p;
}
 
ll dp[2][1010];
 
void solve() {
    ll N, M;
    cin >> N >>M;
    
    if (M==1){
        cout << 1<< endl;
    }
    else {
        int a=0;
        ll b=2;
        while (b<=1000){
            if (M%b==0){
                dp[0][a]=b;
                while (M%b==0){
                    M/=b;
                    dp[1][a]++;
                }
                a++;
            }
            b++;
        }
		if(M != 1) {
			dp[0][a] = M;
			dp[1][a] = 1;
			a++;
		}
        ll ans=1;
        if (a==0){
            cout << N << endl;
        }
        else {
            rep(i, 0, a){
                ll p=1;
                ll q=1;
                for (ll j=N ;j< dp[1][i]+N; j++){
                    p*=j;
                    p%=MOD;
                }
                for(ll j=1; j<dp[1][i]+1; j++){
                    q*=j;
                    q%=MOD;
                }
                ans*=(p*power(q, MOD-2, MOD)) % MOD;
                ans%=MOD;
            }
            cout << ans << endl;
        }
    }
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 384
n, k, *v = map(int, open(0).read().split())

ans = 0
for i in range(n+1):
    for j in range(n+1):
        if i+j>k: continue
        cand = sorted([v[I] for I in range(n) if I<i or n-j<=I])
        cnt = sum(cand)
        ans = max(ans, cnt)
        for l in range(min(k-i-j, len(cand))):
            cnt -= cand[l]
            ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		int ans = 0;
		for(int i=0; i<4; i++) {
			if(S.charAt(i) == '+') {
				++ans;
			} else {
				--ans;
			}
		}
		
		System.out.println(ans);

	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
int input() {
	int r;
	cin >> r;
	//scanf("%lld", &r);
	return r;
}
int h, w;
string s[100]; string dp[100][100];
signed main() {
	while (cin >> h >> w, h + w) {
		string ans = "";
		for1(i, w)cin >> s[i];
		for1(i, h)for1(j, w) {
			char ch = s[j][i - 1];
			if ('0' <= ch && ch <= '9') {
				if (dp[i - 1][j].size() > dp[i][j - 1].size())dp[i][j] = dp[i - 1][j] + ch;
				else if (dp[i - 1][j].size() < dp[i][j - 1].size())dp[i][j] = dp[i][j - 1] + ch;
				else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + ch;
				if (dp[i][j] == "0")dp[i][j] = "";
			}
			else dp[i][j] = "";
			if (ans.size() < dp[i][j].size())ans = dp[i][j];
			else if (ans.size() == dp[i][j].size())ans = max(ans, dp[i][j]);
		}
		cout << ans << endl;
	}
}


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

//Compiler version g++ 6.3.0

int main()
{
    int n,y;cin>>n>>y;
    y/=1000;
    for(int i=0;i<=n;i++){
      for(int j=0;i+j<=n;j++){
        int k = n-i-j;
        //cout<<i<<" "<<j<<" "<<k<<"\n";
        if((i*10+j*5+k)==y){
          cout<<i<<" "<<j<<" "<<k;
          return 0;
        }
      }
    }
    cout<<"-1 -1 -1";
}

Measured memory_bytes: 256
from heapq import heappush, heappop

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append((1, b))
    edges[b].append((1, a))

INF = 10 ** 9
dist = [INF] * n
prev = [-1] * n
def dijkstra(s):
    q = [(0, s)]
    dist[s] = 0
    while q:
        v = heappop(q)[1]
        for cost, to in edges[v]:
            if dist[v] + cost < dist[to]:
                dist[to] = dist[v] + cost
                prev[to] = v
                heappush(q, (dist[to], to))

dijkstra(0)
print("Yes")
for i in range(1, n):
    print(prev[i] + 1)


Measured memory_bytes: 64016
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { rep(i,v.size())os<<v[i]<<(i==v.size()-1?"\n":" "); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint& a) { if ((x += a.x) >= mod) x -= mod; return *this;}
    mint& operator++() { return *this += mint(1); }
    mint& operator-=(const mint& a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; }
    mint& operator--() { return *this -= mint(1); }
    mint& operator*=(const mint& a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint& a) const { mint res(*this); return res+=a; }
    mint operator-(const mint& a) const { mint res(*this); return res-=a; }
    mint operator*(const mint& a) const { mint res(*this); return res*=a; }
    mint pow(ll t) const {
        mint res = mint(1),a(*this);
        while(t > 0) {
            if(t&1) res *= a;
            t >>= 1;
            a *= a;
        }
        return res;
    }
    // for prime mod
    mint inv() const { return pow(mod-2); }
    mint& operator/=(const mint& a) { return *this *= a.inv(); }
    mint operator/(const mint& a) const { mint res(*this); return res/=a; }
};
ostream& operator<<(ostream& os,const mint& m) { return os << m.x; }

class combination {
  vector<mint> fact, ifact;
public:
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(200010);

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    mint ans = 0;
    rep(i,h-a) ans += comb(b+i-1,b-1)*comb(w-b+h-i-2,w-b-1);
    cout << ans << endl;
}


Measured memory_bytes: 3456
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        n:usize,
    }
    let divisors = divisor(n);

    let mut ans = 0;
    for &m in divisors.iter() {
        let x = n / m;
        // m*x = n
        if m > 1 && (m - 1) > x {
            ans += m - 1;
        }
    }
    println!("{}", ans);
}
pub fn divisor(n: usize) -> Vec<usize> {
    let mut res = Vec::new();
    for i in (1..).take_while(|x| x * x <= n) {
        if n % i == 0 {
            res.push(i);
            if i != n / i {
                res.push(n / i);
            }
        }
    }
    res.sort();
    res
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n, x;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  mllll m;
  fi(0, n) {
    cin >> x;
    m[x]++;
  }

  if(m.size() > 3) {
    cout << "No\n";
  } else if(m.size() == 1) {
    if(m[0])
      cout << "Yes\n";
    else
      cout << "No\n";
  } else {
    vllll v;
    for(auto y: m) {
      v.push_back(y);
    }
    if(m.size() == 2) {
      if(v[0].first == 0 && v[0].second * 2 == v[1].second)
        cout << "Yes\n";
      else
        cout << "No\n";
    }
    else {
      if(v[0].second == v[1].second && v[0].second && v[2].second && v[1].second && v[2].second && (v[0].first ^ v[1].first) == v[2].first) 
        cout << "Yes\n";
      else
        cout << "No\n";
    }
  }
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 5120
#include <stdio.h>

int main(void) {

  int A, B;
  do {
    scanf("%d %d", &A, &B);
  } while (A < 0 || A > 100 || B < 2 || B > 1000 || B % 2 != 0);

  if (A >= 13) {
    printf("%d\n", B);
  } else if (A >= 6 && A <= 12) {
    printf("%d\n", B / 2);
  } else {
    printf("%d\n", 0);
  }

  return 0;
}

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

void solve(long long A, long long B, long long C, long long K){
    if(K<=A){
        cout << K <<endl;
        return;
    }
    K-=A;
    if(K<=B){
        cout << A << endl;
        return;
    }
    K-=B;
    cout << A -K << endl;

}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    solve(A, B, C, K);
    return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const int mod = 1000000007;
struct mint{
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const{ return mint(-x);}
  mint& operator+=(const mint a){
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a){
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if(t&1) a *= *this;
    return a;
  }
  
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};
mint f(int n){
  if(n==0) return 1;
  mint x = f(n/2);
  x *= x;
  if(n%2==1) x*=2;
  return x;
}
mint choose(int n, int a){
  mint x = 1, y = 1;
  for(int i=0; i<a; i++){
    x *= n-i;
    y *= i+1;
  }
  return x/y;
}
int main(){
  ll n,a,b; cin >> n >> a >> b;
  mint ans = f(n);
  ans -= 1;
  ans -= choose(n,a);
  ans -= choose(n,b);
  cout << ans.x << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	//ここから

	string s,t,u;
	int k;
	int n = 0,m = 0,l =0;
	cin >> s;
	cin >> k;
	t = s + s;
	u = s + s + s;
	for (int i = 1; i < s.length(); i++) {
		if (s[i - 1] == s[i]) {
			s[i] = '1';
			n++;
		}
	}
	for (int i = 1; i < t.length(); i++) {
		if (t[i - 1] == t[i]) {
			t[i] = '1';
			m++;
		}
	}
	for (int i = 1; i < u.length(); i++) {
		if (u[i - 1] == u[i]) {
			u[i] = '1';
			l++;
		}
	}
	cout << n + (long long)(k / 2) * (m - n) + (long long)((k - 1) / 2) * (l - m);
	//ここまでテンプレ
	return 0;
}


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

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

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;


void solve(){
  string s;
  cin>>s;
  int q;
  cin>>q;
  int x=0;
  while(q--){
    int query;
    cin>>query;
    if(query==1)x^=1;
    else {
      int f;
      char c;
      cin>>f>>c;
      f--;
      f^=x;
      if(f==0)s.insert(s.begin(),c);//高速らしいので
      else s+=string{c};
    }
  }
  if(x==1)reverse(all(s));
  cout<<s;
}

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


Measured memory_bytes: 912
use proconio::input;

fn main() {
    unsafe {
        input!(n: usize, k: usize, ijc: [(usize, usize, char); n]);
        let mut g = vec![vec![0; k + 1]; k + 1];
        let mut b_count = 0;
        let mut w_count = 0;
        for &(i, j, c) in &ijc {
            *g.get_unchecked_mut(i % k + 1).get_unchecked_mut(j % k + 1) +=
                if ((i / k + j / k) % 2 == 1) ^ (c == 'W') {
                    w_count += 1;
                    1
                } else {
                    b_count += 1;
                    -1
                };
        }
        for i in 0..k {
            for j in 0..k {
                *g.get_unchecked_mut(i + 1).get_unchecked_mut(j + 1) +=
                    g.get_unchecked(i + 1).get_unchecked(j)
                        + g.get_unchecked(i).get_unchecked(j + 1)
                        - g.get_unchecked(i).get_unchecked(j);
            }
        }

        let mut min = std::i32::MAX;
        let mut max = std::i32::MIN;
        for i in 0..k {
            for j in 0..k {
                let x = -g.get_unchecked(i).get_unchecked(k) - g.get_unchecked(k).get_unchecked(j)
                    + 2 * g.get_unchecked(i).get_unchecked(j);
                if x < min {
                    min = x;
                }
                if max < x {
                    max = x;
                }
            }
        }
        println!(
            "{}",
            std::cmp::max(
                -(g.get_unchecked(k).get_unchecked(k) + min) + w_count,
                g.get_unchecked(k).get_unchecked(k) + max + b_count
            )
        );
    }
}


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

typedef long long ll;
const int mod = 1000000007;
const int MAX_N = 100005;

ll fact[MAX_N];         // 階乗
ll ifact[MAX_N];        // 階乗の逆元

// x^nを求める繰り返し二乗法(累乗の高速化)
// フェルマーの小定理より、逆元を計算するときに用いる。
ll mod_pow(ll x, int n){
    if(n == 0)      return 1;

    ll res = 1;
    while(n > 0){
        if(n & 1)   res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }

    return res;
}

// 階乗とその逆元テーブルを(0-n)まで埋める
void table(int n){
    fact[0] = 1;    // i^0 = 1;
    for(int i = 1; i <= n; ++i){
        fact[i] = fact[i - 1] * i % mod;
    }

    // フェルマーの小定理を利用して、右端の逆元を求める
    // 階乗の(mod-2)乗
    ifact[n] = mod_pow(fact[n], mod - 2);

    // 逆元の性質を利用して、テーブルを埋める
    for(int i = n; i >= 1; --i){
        ifact[i - 1] = ifact[i] * i % mod;
    }
}

// nCrを求める
ll combination(int n, int r){
    if(n < 0 || r < 0 || n < r)     return 0;

    return fact[n] * ifact[r] % mod * ifact[n - r] % mod;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, id1 = 0, id2 = 0;
    cin >> n;
    vector<int> a(n+1), cnt(n+1, 0);
    for(int i = 0; i < n+1; ++i){
        cin >> a[i];
        ++cnt[a[i]];
        
        if(cnt[a[i]] == 2)      id2 = i;   
    }
    for(int i = 0; i < n+1; ++i){
        if(a[i] == a[id2]){
            id1 = i;
            break;
        }
    }
    
    table(n+2);
    
    // 重複している数字をxとして、xの左にある数字の個数
    // a = [...x.....x...]
    int num1 = id1;
    // xの右側にある数字の個数
    int num2 = n - id2;

    // 重複している数字：x
    for(int i = 1; i <= n+1; ++i){        // 数字をi個取る
        ll res = (combination(n + 1, i) - combination(num1 + num2, i - 1) + mod) % mod;
        
        cout << res << "\n";
    }
}

Measured memory_bytes: 3584
# coding: utf-8
class Point():
    def __init__(self, x, y):
        self.x = x
        self.y = y

init_point = map(float,raw_input().split())
p0 = Point(init_point[0], init_point[1])
p1 = Point(init_point[2], init_point[3])

q = int(raw_input())
for i in range(q):
    xp2,yp2 = map(float,raw_input().split())
    p2 = Point(xp2,yp2)
    p0p2 = Point(p2.x - p0.x, p2.y - p0.y)
    p0p1 = Point(p1.x - p0.x, p1.y - p0.y)
    k = ((p0p2.x * p0p1.x + p0p2.y * p0p1.y)/(p0p1.x ** 2 + p0p1.y ** 2))
    # p2t??¨p0p1????????????T??¨??????
    p0T = Point(k * p0p1.x, k * p0p1.y)
    OT = Point(p0.x + p0T.x, p0.y + p0T.y)
    p2t = Point(2*(OT.x - p2.x), 2*(OT.y - p2.y))
    Ot =  Point(p2t.x + xp2, p2t.y + p2.y)
    print "%.10f %.10f" % (Ot.x, Ot.y)

Measured memory_bytes: 4328
import java.util.Scanner;
public class Main {
	public static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int i, j, k;
		int x = sc.nextInt();
		int y = sc.nextInt();
		if(x >= y) gcd(x, y);
		else gcd(y, x);
	}
	
	public static void gcd(int x, int y){
		int r = 0;
		if(y != 0){
			r = x % y;
			gcd(y, r);
		}
		else System.out.println(x);
	}
}


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

using namespace std;

int n;
int a[110];

int main(void)
{
	scanf("%d", &n);
	
	for(int i = 0 ; i < n ; i++)
	{
		scanf("%d", &a[i]);
		
		if(a[i] % 2 == 0)
		{
			if(a[i] % 3 != 0 && a[i] % 5 != 0)
			{
				printf("DENIED");
				return 0;
			}
		}
	}
	
	printf("APPROVED");
	return 0;
}

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

sixs = [6]
while sixs[-1] * 6 <= n:
    sixs.append(sixs[-1] * 6)

nines = [9]
while nines[-1] * 9 <= n:
    nines.append(nines[-1] * 9)

dp = [float('inf')] * (n + 1)
dp[0] = 0

for i in range(1, n + 1):
    dp[i] = dp[i-1] + 1
    for six in sixs:
        if i - six >= 0:
            dp[i] = min(dp[i], dp[i-six] + 1)

    for nine in nines:
        if i - nine >= 0:
            dp[i] = min(dp[i], dp[i-nine] + 1)

print(dp[-1])


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

typedef long long int ll;
typedef long double ld;

#define Pb push_back
#define Mp make_pair

#define ff first
#define ss second

#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))

#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN

#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define db1(x) cout<<#x<<" : "<<x<<endl;
#define db2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define db3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;

const int mod = 1e9+7;
const ll N = 1e18;

void solve()
{
	ll a;
	ld b;
	cin >> a >> b;
	cout << (ll)(a*1LL*b);
}

signed main()
{
  	IOS;
  	//freopen("input.txt", "rt", stdin);
  	//freopen("output.txt", "wt", stdout);
  	int t=1;
  	//cin >> t;
  	while(t--)
  	{
   	solve();
  	}
  	return 0;
}
/*==============================================================================================================================================================*/


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] - 'A' >= 26 - n) s[i] -= 26;
    s[i] += n;
  }
  
  cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin>>N>>M;
  
  vector<int> road(2*M),count(N);
  
  for(int i=0;i<2*M;i++)
      cin>>road.at(i);
      
  for(int j=0;j<N;j++){
    for(int i=0;i<2*M;i++){
      if(road.at(i)==j+1)
        count.at(j)++;
    }
    
    cout<<count.at(j)<<endl;
  }
  
  }


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define TRI_MAX 101
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
long long combination[TRI_MAX + 1][TRI_MAX + 1];
void makeTriangle() {
    int i, j;
    // initialize the first row
    combination[0][0] = 1; // C(0, 0) = 1
    for(i = 1; i < TRI_MAX; i++) {
        combination[i][0] = 1; // C(i, 0) = 1
        for(j = 1; j <= i; j++) {
            combination[i][j] =combination[i - 1][j - 1] + combination[i - 1][j];
        }
    }
}

 ll C(ll n, ll r) {
    return combination[n][r];
}
#define int ll
signed main(){
    makeTriangle(); // set_combination
    int n,a,b;cin>>n>>a>>b;
    map<int,int>mp;
    vi v(n,0);
    rep(i,n){cin>>v[i];mp[v[i]]++;}
    sort(all(v),greater<int>());
    ld ave=0;
    for(int i=0; i<a;i++)
        ave+=v[i];
    ave/=a;
    int ans=0;
    if(v[0]==v[a-1]){
        for(int i=a; i<=b;i++)
            ans+=C(mp[v[i-1]],i);
    }else{
        int range=0;
        for(int i=0; i<a; i++)
            if(v[i]==v[a-1])break;
            else range++;
        ans=C(mp[v[a-1]],a-range);
       }
    printf("%.7Lf\n",ave);
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int MAXN=200010;
int u,v,n,m,flag,cnt;
int fa[MAXN],head[MAXN];
struct edge{
    int v,next;
}e[MAXN<<1];
void add(int u,int v){
    e[++cnt].v=v;
    e[cnt].next=head[u];
    head[u]=cnt;
}
void bfs(){
    queue<int>q;
    q.push(1);
    while(!q.empty()){
        int u=q.front(); q.pop();
        for(int i=head[u];i;i=e[i].next){
            int v=e[i].v;
            if(fa[v]) continue;
            fa[v]=u; q.push(v);
        }
    }
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;++i){
        scanf("%d%d",&u,&v);
        add(u,v);
        add(v,u);
    }
    bfs();
    for(int i=2;i<=n;++i) if(!fa[i]) {printf("No");flag=1;break;}
    if(!flag){
        printf("Yes\n");
        for(int i=2;i<=n;++i) printf("%d\n",fa[i]);
    }
    return 0;
}

Measured memory_bytes: 7732
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int N, T, A, B;
pair<int, int>p[3000];
ll res, DP[3001];
int main() {
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		cin >> p[i].first >> p[i].second;
	}
	sort(p, p + N);
	for (int i = 0; i < N; i++) {
		A = p[i].first;
		B = p[i].second;
		for (int j = T - 1; j >= 0; j--) {
			DP[min(T, j + A)] = max(DP[min(T, j + A)], DP[j] + B);
		}
	}
	cout << DP[T] << endl;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    sort(h.begin(),h.end());
    reverse(h.begin(),h.end());
    rep(i,min(n,k)){
        h[i] = 0;
    }
    int64_t ans = 0ll;
    rep(i,n){
        ans += h[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))
        
    
def gcd(a, b):
    if a < b:
        return gcd(b, a)
    while b != 0:
        s = a % b
        a = b
        b = s
    return a

F = [A[0]]
for i in range(1, N):
    F.append(gcd(F[-1], A[i]))
#print(F)

A = A[::-1]
B = [A[0]]
for i in range(1, N):
    B.append(gcd(B[-1], A[i]))
#print(B)

MAX = max(B[-2], F[-2])
for i in range(N-2):
    #print(B[-(3+i)], F[i])
    #print(gcd(B[-(3+i)], F[i]))
    MAX = max(MAX, gcd(B[-(3+i)], F[i]))
    
print(MAX)

Measured memory_bytes: 14584
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
ll mod =   1e9 +7  ;
//const ll inf  = 1e9 + 10 ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
void solve(){
    int x ;
    cin >> x ;
    int d = (x-400)/200;
    cout << 8 - d ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1 ;
     //cin >> t ;
    while(t--){
        solve( );
    }
}
//
//aaaaaaaaaaa
//ab
//abbb
//abbb
//d


Measured memory_bytes: 3608
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,avx2,fma,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(0),cin.tie(0), cout.tie(0)
typedef long long ll;


ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

//#######################################

int main(){
  boost;

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

  int dp[n+1]={};
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++){
    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
  }
  cout<<dp[n-1];
 
}



Measured memory_bytes: 4380
n,m=map(int,input().split())
lis=[]
for i in range(n):
    lis.append(list(map(int,input().split())))

lis.sort()
money=0
for i in range(n):
    if lis[i][1]<=m:
        m-=lis[i][1]
        money+=(lis[i][0]*lis[i][1])
    else:
        money+=(m*lis[i][0])
        m=0
    if m==0:
        break

print(money)


Measured memory_bytes: 27884
#include <bits/stdc++.h>
using namespace std;
int dp[200002][2];

int main() 
{
    string s;
    cin >> s;
    int n = s.size();
    string ans="";
    
    if(s[0]=='P') dp[0][0]=0;
    else if(s[0]=='D') dp[0][1]=1;
    else {
        dp[0][0]=0,dp[0][1]=1;
    }
    
    for(int i=1;i<n;i++) {
        if(s[i]=='?') {
            if(s[i-1]=='P') {
                dp[i][0] = dp[i-1][0];
                dp[i][1] = dp[i-1][0] + 2;
            }
            else if(s[i-1]=='D'){
                dp[i][0] = dp[i-1][1];
                dp[i][1] = dp[i-1][1] + 1;
            } else{
                dp[i][0] = max(dp[i-1][0],dp[i-1][1]);
                dp[i][1] = max(dp[i-1][0]+2,dp[i-1][1]+1);       
            }
        }
    }
    
    for(int i=0;i<n;i++){
        if(s[i]=='?') {
            if(dp[i][0]>=dp[i][1]) ans+='P';
            else ans+='D';
        }else ans+=s[i];
    }
    
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5524
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

vector<pair<ll, ll>> directions = {
  {+0, +2},
  {+0, -2},
  {+2, +0},
  {-2, +0},
};

struct Value {
  ll y, x, cost;
};
Value bfs(ll sy, ll sx, vector<vector<ll>> &grid) {

  queue<Value> que;
  que.push({sy, sx, 0});

  while (!que.empty()) {
    Value node = que.front();
    que.pop();

    // --- 終端 ---
    if (node.y == grid.size() - 2 && node.x == grid[0].size() - 2) {
      return node;
    }

    if (grid[node.y][node.x] != 0) continue;
    grid[node.y][node.x] = 8;

    for(auto d: directions) {
      ll ny = node.y + d.first, nx = node.x + d.second;
      if (0 <= ny && ny < grid.size() && 0 <= nx && nx < grid[ny].size()
          && grid[ny][nx] == 0 && grid[node.y + d.first / 2][node.x + d.second / 2] == 0) {
        que.push({ny, nx, node.cost + 1});
      }
    }
  }
  return {-1, -1, -1};
}

bool solve() {
  ll input(w, h);
  if (w == 0 && h == 0) return false;

  vector<vector<ll>> grid(h * 2, vector<ll>(w * 2));
  REP(i, h * 2 - 1) {
    if (i % 2 == 0) {
      REP(j, w - 1) {
        cin >> grid[i][j * 2 + 1];
      }
    } else {
      REP(j, w) {
        cin >> grid[i][j * 2];
      }
    }
  }

  // for(auto v: grid) print(v);
  // print("---");
  cout << bfs(0, 0, grid).cost + 1 << endl;
  // for(auto v: grid) print(v);
  return true;
}

int main() {
  while(solve());
}



Measured memory_bytes: 3192
N=int(input())
A=list(map(int,input().split()))
M=int((max(A)**0.5)//1)
c=0
for i in range(M):
    for j in range(N):
        if A[j]%2==0:
            A[j]=int(A[j]//2)
            c+=1
        elif A[j]%2!=0:
            break
print(c//N)

Measured memory_bytes: 68448
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, a: "List[int]"):
    a.sort(key=lambda x: x[1])
    ret = 1
    cur = a[0][1]
    for t in a:
        if t[0] >= cur:
            ret += 1
            cur = t[1]
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = []
    for i in range(M):
        a.append((int(next(tokens)), int(next(tokens))))
    solve(N, M, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 18228
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
l = A[0]
for i in range(N):
    r = A[i + 1]
    cur = B[i]
    # print(l, r, cur)
    ans += min(l + r, cur)
    l = max(r - max(cur - l, 0), 0)  # めちゃくちゃ整理するとこの形の式になる
print(ans)

Measured memory_bytes: 18624
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
int main(){
    int h,w;
    cin>>h>>w;
    vector<string> s(h);
    rep(i,0,h){
            cin>>s[i];
    }
    vector<int> cnt1(h),cnt2(w);
    rep(i,0,h){
        rep(j,0,w) {
            if (s[i][j]=='#') {
                cnt1[i]++;//i行目は消えない
                cnt2[j]++;//j列目は消えない
            }
        }
    }
    rep(i,0,h){
        if(cnt1[i]!=0){
            rep(j,0,w){
                if(cnt2[j]!=0) cout<<s[i][j];
            }
        }
    cout<<endl;//1行出力→改行
    }
}


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

int main()
{
	int n, ans = 0;
	cin >> n;
	vector<int> a(n); for (auto& e : a) cin >> e;

	int avg = round(accumulate(a.begin(), a.end(), 0) / double(n));
	for (int i = 0; i < n; i++) {
		ans += (avg - a[i])*(avg - a[i]);
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }


int main() {
    vector<int> hon = {2,4,5,7,9}, pon = {0,1,6,8};
    int n;
    cin >> n;
    n %= 10;
    for (int v: hon) {
        if (v == n) {
            cout << "hon" << endl;
            return 0;
        }
    }
    for (int v: pon) {
        if (v == n) {
            cout << "pon" << endl;
            return 0;
        }
    }
    cout << "bon" << endl;
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<string>
using namespace std;

struct Node {
	int prnt = -1, child[2], sbl = -1, dgr = 0, dpth = 0, hght = 0;
};

void dec_down(Node*, int, int);
void dec_up(Node*, int, int);
const char* translate(Node);

int main()
{
	int n, id, l, r;
	Node *nodes;
	scanf("%d", &n);
	nodes = new Node[n + 1];
	nodes++;
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d%d", &id, &l, &r);
		nodes[id].child[0] = l;
		nodes[id].child[1] = r;
		nodes[l].prnt = nodes[r].prnt = id;
		nodes[l].sbl = r;
		nodes[r].sbl = l;
	}

	for (int i = 0; i < n; i++)
	{
		if (nodes[i].child[0] + nodes[i].child[1] == -2)
			dec_up(nodes, nodes[i].prnt, 1);
		else if (nodes[i].prnt == -1)
		{
			dec_down(nodes, i, 0);
		}
	}

	for (int i = 0; i < n; i++)
	{
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n",
			i, nodes[i].prnt, nodes[i].sbl, nodes[i].dgr, nodes[i].dpth, nodes[i].hght, translate(nodes[i]));
	}

	nodes--;
	delete[] nodes;
	return 0;
}

void dec_down(Node* nodes, int num, int d)
{
	nodes[num].dpth = d;
	for (int i = 0; i < 2; i++)
		if (nodes[num].child[i] != -1)
		{
			nodes[num].dgr++;
			dec_down(nodes, nodes[num].child[i], d + 1);
		}
	return;
}

void dec_up(Node* nodes, int num, int h)
{
	if (nodes[num].hght < h && num != -1)
	{
		nodes[num].hght = h;
		dec_up(nodes, nodes[num].prnt, h + 1);
	}
	return;
}

const char* translate(Node node)
{
	if (node.dpth == 0)
		return "root";
	else if (node.hght == 0)
		return "leaf";
	else
		return "internal node";
}


Measured memory_bytes: 2716
N = int(input())
otoshidama = []
for i in range(N):
    x, u = input().split(" ")
    otoshidama.append([float(x),u])

ypb = 380000.0
sum = 0.0

for x,u in otoshidama:
    if u == "JPY":
        sum += x
    else:
        sum += ypb * x

print(sum)

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    vl x(5);
    rep(i,5)cin>>x[i];
    rep(i,5){
        if(x[i] == 0){
            out(i+1);
            return 0;
        }
    }
}


Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	int X = rei();
	int Y = rei();
	long ans = 0;
	if(X == 1){
		ans += 300000;
	}	
	if(X == 2){
		ans += 200000;
	}
	if(X == 3){
		ans += 100000;
	}
	if(Y == 1){
		ans += 300000;
	}	
	if(Y == 2){
		ans += 200000;
	}
	if(Y == 3){
		ans += 100000;
	}
	if(X == 1 && Y == 1){
		ans += 400000;
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair < ll, int > PLI;


#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

#define fname ""

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e3 + 6;

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

	#ifdef krauch
        freopen("input.txt", "r", stdin);
    #else
        //freopen(fname".in", "r", stdin);
        //freopen(fname".out", "w", stdout);
    #endif

    string s;
    cin >> s;
    ll sum = 0;
    ll ans = 0;
    forn(i, 0, sz(s) - 1) {
        ans = max(ans, sum + s[i] - '0' - 1 + (sz(s) - i - 1) * 9);
        sum += s[i] - '0';
    }
    ans = max(ans, sum);

    cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256