akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

template <long long mod>
struct modular {
    long long value;
    modular(long long x = 0) {
        value = x % mod;
        if (value < 0) value += mod;
    }
    modular& operator+=(modular other) {
        if ((value += other.value) >= mod) value -= mod;
        return *this;
    }
    modular& operator-=(modular other) {
        if ((value -= other.value) < 0) value += mod;
        return *this;
    }
    modular& operator*=(modular other) {
        value = value * other.value % mod;
        return *this;
    }
    modular& operator/=(modular other) {
        long long a = 0, b = 1, c = other.value, m = mod;
        while (c != 0) {
            long long t = m / c;
            m -= t * c;
            swap(c, m);
            a -= t * b;
            swap(a, b);
        }
        a %= mod;
        if (a < 0) a += mod;
        value = value * a % mod;
        return *this;
    }
    modular operator-() {
        return modular(-value);
    }
    modular operator+(modular rhs) {
        return modular(*this) += rhs;
    }
    modular operator-(modular rhs) {
        return modular(*this) -= rhs;
    }
    modular operator*(modular rhs) {
        return modular(*this) *= rhs;
    }
    modular operator/(modular rhs) {
        return modular(*this) /= rhs;
    }
    bool operator==(modular rhs) {
        return value == rhs.value;
    }
    bool operator!=(modular rhs) {
        return value != rhs.value;
    }
    bool operator<(modular rhs) {
        return value < rhs.value;
    }
};
template <long long mod>
string to_string(modular<mod> x) {
    return to_string(x.value);
}
template <long long mod>
ostream& operator<<(ostream& stream, modular<mod> x) {
    x.value %= mod;
    if (x.value < 0) x.value += mod;
    return stream << x.value;
}
template <long long mod>
istream& operator>>(istream& stream, modular<mod>& x) {
    stream >> x.value;
    x.value %= mod;
    if (x.value < 0) x.value += mod;
    return stream;
};
const long long mod = (long long)1e9 + 7;
using mint = modular<mod>;

inline mint pw(mint a, long long n) {
    mint res = 1;
    while (n > 0) {
        if (n & 1) {
            res *= a;
        }
        a *= a;
        n >>= 1;
    }
    return res;
}
vector<mint> fact, finv;
inline void cinit(int n) {
    fact.resize(n, 1);
    finv.resize(n, 1);
    for (int i = 2; i < n; i++) {
        fact[i] = fact[i - 1] * i;
    }
    finv[n - 1] /= fact[n - 1];
    for (int i = n - 2; i >= 2; i--) {
        finv[i] = finv[i + 1] * (i + 1);
    }
}
inline mint C(int n, int k) {
    if (n < k || k < 0 || n < 0) return 0;
    return fact[n] * finv[k] * finv[n - k];
}
inline mint H(int n, int k) {
    return C(n + k - 1, k);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    mint ans = 0;
    for (ll i = k; i <= n + 1; i++) {
        ll mn = i * (i - 1) / 2;
        ll mx = i * (n * 2 - i + 1) / 2;
        mx -= mn - 1;
        ans += mx;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3612
import java.util.*;

class Main {
    private static Scanner sc;


    public static void main(String[] args) {
        sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray(); 
        char[] lib = new char[26];
        for (int i = 0; i < 26; i++) {
            lib[i]=(char)(97+i);
        }
        for (int j= 0; j < lib.length; j++) {
            for (int k = 0; k < S.length; k++) {
                if(lib[j]==S[k]){
                    break;
                }
                if(k==S.length-1) {
                    System.out.println(lib[j]);
                    System.exit(0);
                }                   
            }
        }
        System.out.println("None");
    }
}





Measured memory_bytes: 25928
use std::io::stdin;
use std::str::FromStr;
use std::cmp::max;

fn read_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}

fn main() {
    // DP $B;H$&LdBj$C$]$$(B
    let in_vec: Vec<i64> = read_line();
    let n = in_vec[0];
    let a: Vec<i64> = read_line();

    // $B2?2s(B +2 $B$G$-$k$+(B
    let plus_2_num = 2 + (n % 2);

    let mut dp: Vec<Vec<Option<i64>>> = vec![vec![None;plus_2_num as usize];(n/2) as usize];

    for i in 0..n/2 {
        let i = i as usize;
        for j in 0..plus_2_num {
            let j = j as usize;
            if i == 0 {
                dp[i][j] = Some(a[2*i+j]);
            } else {
                let better_num;
                if j > 0 {
                    better_num = Some(max(dp[i-1][j].unwrap(), dp[i-1][j-1].unwrap()));
                } else {
                    better_num = dp[i-1][j];
                }
                dp[i][j] = Some(better_num.unwrap() + a[2*i+j]);
            }
        }
    }

    let mut res = dp[(n/2-1) as usize][0].unwrap();
    for i in 1..plus_2_num {
        res = max(res, dp[(n/2-1) as usize][i as usize].unwrap());
    }

    println!("{}", res);
}


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

int n;
vector<int> ans;
vector<vector<pair<int,int>>> graph;

void bfs(int v,int c){
  queue<pair<int,int>> que;
  que.push(make_pair(v,c));
  while(!que.empty()){
    v=que.front().first;
    c=que.front().second;
    que.pop();
    ans[v]=c;
    for(auto e:graph[v]){
      if(ans[e.first]!=-1) continue;
      if(e.second%2==0) que.emplace(e.first,c);
      else que.emplace(e.first,1-c);
    }
  }
}

int main(){
  cin >> n;
  ans.assign(n+1,-1);
  graph.assign(n+1,vector<pair<int,int>>());

  for (int i = 0; i < n-1; i++)
  {
    int u,v,w;
    cin >> u >> v >> w;
    graph[u].push_back(make_pair(v,w));
    graph[v].push_back(make_pair(u,w));
  }
  bfs(1,0);

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

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

#define I_AM_SPEED ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using ll = long long;
#define double long double

int32_t main() {
	I_AM_SPEED
	int n;

	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<>());
	ll ans = 0;
	queue<int> q;
	q.push(a[0]);
	int c = 0;
	for(int i = 1 ; i < n ; i++){
		ans += q.front();
		q.pop();
		q.push(a[i]);
		q.push(a[i]);

	}
	cout << ans << endl;
}

Measured memory_bytes: 5548
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 1e9;
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
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; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
int main(){
  int n, k; cin >> n >> k;
  vector<int> h(n); rep(i,n) cin >> h[i];
  sort(all(h));
  int ans=INF;
  rep(i,n-k+1) chmin(ans,h[i+k-1]-h[i]);
  cout << ans;  
        
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    int N, K;
    cin >> N >> K;
    vector<long double> p(N);
    rep(i, N) cin >> p[i];

    vector<long double> e(N+1);
    rep(i , N) e[i + 1] = (1 + p[i]) / 2;
    for(int i = 1; i < N + 1; i++) e[i] += e[i - 1];

    long double ans = 0;
    for(int k = K; k <= N; k++){
        ans = max(ans, e[k] - e[k - K]);
    }

    cout << setprecision(8) << ans << endl;
}

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

#define All(a)          (a).begin(), (a).end()
#define Sort(x)         sort(All(x))
#define ll              long long int 
#define ull             unsigned ll
#define ld              long double
#define vll             vector<ll>
const ll MOD = (ll) 1e9 + 7;
inline long long int LD(long long int n) { return (n % 10);}
inline long long TT(long long int n){int digits = (int)log10(n);}
#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define Unique(v)       Sort(v); (v).resize(unique(All(v)) - (v).begin())
inline ll Gcd(ll a, ll b) {ll r; while(b){ r = a % b; a = b; b = r;} return a;}
inline ll Lcm(ll a, ll b) {return a / Gcd(a, b) * b;}
inline ll Pow(ll n, ll k) {ll r = 1; for(; k; k >>= 1, n = n * n % MOD){if(k & 1) r = r * n % MOD;} return r;}
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))


signed main() {
	IOS;
	vector<int> v,v1;

	ll n,m1,m2,d1,d2;
	cin>>m1>>d1;
	cin>>m2>>d2;
	if(m1!=12 and m2>m1)cout<<1;
	else if(m1==12 and m2 ==1) cout<<1;
	else cout<<0;
  
  	
    return 0;
}

Measured memory_bytes: 256
N = int(input())
C = input()
rcount = C.count("R")

ans = 0
w = 0
r = 0
for i in range(rcount):
    if C[i] == "W":
        if r > 0:
            r -= 1
            ans += 1
        else:
            w += 1
    j = N - i - 1
    if C[j] == "R":
        if w > 0:
            w -= 1
            ans += 1
        else:
            r += 1
ans += w
print(ans)

Measured memory_bytes: 9320
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using Graph = vector< vector<int> >;
int A[1000000];
int main(){
	ll N; cin >> N;
	for (int i = 2; i <= sqrt(N); i++)
	{
		while(N%i == 0){
			A[i]++;
			N/=i;
		}
	}
	ll ans = 0;
	for (int i = 0; i < 1000000; i++)
	{
		if(A[i]!=0){
			int j = 1;
			A[i] -= j;
			ans++;
			while(A[i] > j){
				j++;
				A[i]-=j;
				ans++;
			}
		}
	}
	if(N!=1) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 3684
/*
   ~~~~~~~~~~~~~~~~~~~
   \  |\/| | |\ | |  /
   /  |  | | |/ |_|  \
   ~~~~~~~~~~~~~~~~~~~
*/
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<iterator>
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
int main()
{
	ll a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
const int sz = 1<<23;
const long mod = 998244353l;
long modpow(long x, long y, long m){
    long res = 1l, tmp = x;
    while(y){
        if(y&1) res = res * tmp % m;
        tmp = tmp * tmp % m;
        y >>= 1;
    }
    return res;
}
void dft(long f[], int n){
    if(n == 1)return;
    long f0[n/2], f1[n/2];
    for(int i=0; i<n/2; i++){
        f0[i] = f[2*i + 0];
        f1[i] = f[2*i + 1];
    }
    dft(f0, n/2);
    dft(f1, n/2);
    long zeta = modpow(15311432, sz / n, mod), pow_zeta = 1l;
    for(int i=0; i<n; i++){
        f[i] = (f0[i % (n/2)] + pow_zeta * f1[i % (n/2)]) % mod;
        pow_zeta = (pow_zeta * zeta) % mod;
    }
    return;
}
void idft(long f[], int n){
    if(n == 1)return;
    long f0[n/2], f1[n/2];
    for(int i=0; i<n/2; i++){
        f0[i] = f[2*i + 0];
        f1[i] = f[2*i + 1];
    }
    idft(f0, n/2);
    idft(f1, n/2);
    long zeta = modpow(469870224, sz / n, mod), pow_zeta = 1l;
    for(int i=0; i<n; i++){
        f[i] = (f0[i % (n/2)] + pow_zeta * f1[i % (n/2)]) % mod;
        pow_zeta = (pow_zeta * zeta) % mod;
    }
    return;
}
#define t 1<<20
long a[t], b[t];
int N, M;
int main(){
	scanf("%d%d", &N, &M);
	for(int i=0; i<N; i++)scanf("%ld", &a[i]);
	for(int i=0; i<M; i++)scanf("%ld", &b[i]);
	dft(a, t); dft(b, t);
	for(int i=0; i<t; i++)a[i] = (a[i]*b[i]) % mod;
	idft(a, t);
	for(int i=0; i<N+M-1; i++){
		if(i)putchar(32);
		printf("%ld", a[i] * 998243401 % mod);
	}putchar(10);
	return 0;
}

Measured memory_bytes: 43552
#include <bits/stdc++.h>
#define int long long 
#define uint unsigned long long 
#define double long double 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sz(a) (int)(a).size()
#define hell 1000000007
#define vi vector<int> 
#define vb vector<bool> 
#define vpi vector<pair<int,int>> 
#define x first 
#define y second 
#define endl '\n'

using namespace std;


void solve(){
	int a , b;
	cin >> a >> b;
	if( a <= 9 and b <= 9 ){
		cout << a*b << endl;
	}else {
		cout << -1 << endl;
	}
}

int32_t main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(10);

	int t = 1;
	//cin >> t ;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
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; }
const long long INF = 1LL << 60;
const int inf = 1001001001;
 
int main(){

    ll max=101010;
    vector<ll> is_prime(max,1);
    is_prime[0]=0;
    is_prime[1]=0;
    for(ll i=2; i<max; i++){
        if(!is_prime[i]) continue;
        for(ll j=i*2; j<max; j+=i) is_prime[j]=0;
    }

    vector<ll> a(max,0);
    for(ll i=0; i<max; i++){
        if(i%2==0) continue;
        if(is_prime[i] && is_prime[(i+1)/2]) a[i]=1;
    }

    vector<ll> dp(max+1,0);
    for(ll i=0; i<max; i++) dp[i+1]=dp[i]+a[i];

    ll Q;
    cin >> Q;
    rep(q,Q){
        int l,r;
        cin >> l >> r;
        cout << dp[r+1]-dp[l] << endl;
    }



 
}

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

using namespace std;

int main(){
  int N;
  int K;
  cin >> N >> K;
  
  int ans = 0;
  for(int i = 0; i < N ; i++){
    int a;
    cin >> a;
    ans += min(a, abs(K-a));
  
  }
  cout << ans*2;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
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;
}
///////////////////////////////////////////////////////////////

struct RandomNumberGenerator {
  mt19937 mt;

  RandomNumberGenerator() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}

  int operator()(int a, int b) { // [a, b)
    uniform_int_distribution< int > dist(a, b - 1);
    return dist(mt);
  }

  int operator()(int b) { // [0, b)
    return (*this)(0, b);
  }
};

RandomNumberGenerator RNG;
const unsigned long long base = RNG(10,1<<30);

struct RollingHash {
    typedef unsigned long long ull;

    const ull MASK30 = (1ull << 30) - 1;
    const ull MASK31 = (1ull << 31) - 1;
    const ull mod = (1ull << 61) - 1;
    const ull POSITIVIZER = mod * 3;

    vector<ull> hash,power;

    RollingHash(const string &s) {
        int sz = s.size();
        hash.assign(sz + 1,0);
        power.assign(sz + 1,1);
        for (int i = 0; i < sz; i++) {
            power[i+1] = CalcMod(Mul(power[i],base));
            hash[i+1] = CalcMod(Mul(hash[i],base) + s[i]);
        }
    }

    ull get(int l, int r) {
        ull res;
        res = CalcMod(hash[r] + POSITIVIZER - Mul(hash[l],power[r-l]));
        return res;
    }


    ull Mul (ull a, ull b) {
        ull au = a >> 31;
        ull ad = a & MASK31;
        ull bu = b >> 31;
        ull bd = b & MASK31;
        ull mid = ad * bu + au * bd;
        ull midu = mid >> 30;
        ull midd = mid & MASK30;
        return (au * bu * 2 + midu + (midd << 31) + ad * bd);
    }

    ull CalcMod(ull val) {
        val = (val & mod) + (val >> 61);
        if (val > mod) val -= mod;
        return val;
    }
};

int N;
string S;
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> N >> S;
 
    RollingHash RH(S);
    int left = 0;
    int right = N;
    while (right - left > 1) {
        int mid = (left+right)/2;
        set<unsigned long long> dic;
        bool ok = false;
        for (int i = 0; i <= N-2*mid; i++) {
            dic.emplace(RH.get(i,i+mid));
            if (dic.count(RH.get(i+mid,i+2*mid))) ok = true;
        }
        if (ok) left = mid;
        else right = mid;
    }
 
    cout << left << endl;
}

Measured memory_bytes: 640
import sys

# inputを高速化する。
input = sys.stdin.readline

# 入力
vacation = int(input())
lst_happiness = [list(map(int, input().split())) for i in range(vacation)]

# DPテーブル
# 最大化問題なので0で初期化
dp = [[0 for i in range(3)] for j in range(vacation+1)]

def chmax(a, b):
    if a > b:
        return a
    else:
        return b

# dp[i-1][0] から dp[i][1] への遷移
# dp[i-1 ][0] から dp[i][2] への遷移
# dp[i-1][1] から dp[i][0] への遷移
# dp[i-1][1] から dp[i][2] への遷移
# dp[i-1][2] から dp[i][0] への遷移
# dp[i-1][2] から dp[i][1] への遷移
# 各 j (= 0, 1, 2) と各 k (= 0, 1, 2) に対して、j ≠ k ならば
# chmin(dp[i][k], dp[i-1][j] + lst_happiness[i-1][k])
for i in range(1, vacation+1):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i][k] = chmax(dp[i][k], dp[i-1][j] + lst_happiness[i-1][k])


ans = 0
for i in range(3):
    ans = chmax(ans, dp[vacation][i])

print(ans)

Measured memory_bytes: 47344
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

int main()
{
    int row,col,i,j;

    while(cin>>row>>col)
    {
        if(row==0 || col==0)
            return 0;
        for(i=1; i<=row; i++)
        {
            for(j=1; j<=col; j++)
            {
                if((i+j)%2==0)
                    cout<< "#";
                else
                    cout<< ".";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    vector<int> l(n);
    for (int i = 0; i < n; i++)
        cin >> l[i];
    int cnt = 0;
    sort(l.begin(), l.end());
    for(int i = n - 1; 0 < i; i--){
        for(int j = i - 1; 0 <= j; j--){
            auto itr = lower_bound(l.begin(),l.end(), l[i] + l[j]);
            ll ng = distance(itr, l.end());
            cnt += (n - 1 - i) - ng;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <fstream>

using namespace std;


struct Magic{
	string name;
	int mp;
	bool isAll;
	int dmg;
};

int n;
int hps[101];
int m;
Magic magics[101];
const int INF=1000000000;

// SÌÉ é_[Wð^¦éÌÉKvÈÅ¬ÌMP(¶ÝµÈ¯êÎ-1)
int dp[2][200001];
// PÌÉ é_[Wð^¦éÌÉKvÈÅ¬MP(¿å¤ÇÌ_[WÅÈ­Äàæ¢
int dp2[2][200001];

int main(){
	while(cin>>n&&n){
		vector<Magic> allMagics;
		vector<Magic> singleMagics;
		vector<Magic> crit;
		for(int i=0;i<n;i++)cin>>hps[i];
		cin>>m;
		for(int i=0;i<m;i++){
			cin>>magics[i].name>>magics[i].mp;
			string tgt;
			cin>>tgt;
			if(tgt=="All")magics[i].isAll=true;
			else magics[i].isAll=false;
			cin>>magics[i].dmg;
			if(magics[i].dmg==0)continue;
			else if(magics[i].isAll){
				// 100000ÈãÌêAêKE
				if(magics[i].dmg>=100000)crit.push_back(magics[i]);
				else allMagics.push_back(magics[i]);
			}
			else singleMagics.push_back(magics[i]);
		}
		int minMP=INF;
		// êKE
		for(int i=0;i<(int)crit.size();i++)minMP=min(minMP,crit[i].mp);
		for(int i=0;i<2;i++)for(int j=0;j<=200000;j++)dp[i][j]=dp2[i][j]=INF;
		dp[(allMagics.size())%2][0]=0;
		dp2[(singleMagics.size())%2][0]=0;
		for(int i=allMagics.size()-1;i>=0;i--){
			for(int j=0;j<=200000;j++){
				int dmg=j;
				int pos=i;
				int res=INF;
				int cur=(i+1)%2;
				int nxt=i%2;
				res=min(res,dp[cur][dmg]);
				// ¿å¤Ç0ÉÈéKvª é
				if(dmg-allMagics[pos].dmg>=0)
					res=min(res,dp[nxt][dmg-allMagics[pos].dmg]+allMagics[pos].mp);
				dp[nxt][dmg]=res;
			}
		}
		for(int i=singleMagics.size()-1;i>=0;i--){
			for(int j=0;j<=200000;j++){
				int dmg=j;
				int pos=i;
				int res=INF;
				int cur=(i+1)%2;
				int nxt=i%2;
				res=min(res,dp2[cur][dmg]);
				if(dmg-singleMagics[pos].dmg>=0)
					res=min(res,dp2[nxt][dmg-singleMagics[pos].dmg]+singleMagics[pos].mp);
				// KvÈÌÍ¡ñÌªÌÝ
				else res=min(res,singleMagics[pos].mp);
				dp2[nxt][dmg]=res;
			}
		}
		// SÌÉ^¦é_[WÊðvZ
		for(int i=0;i<=200000;i++){
			if(dp[0][i]==INF)continue;
			int cnt=0;
			bool no=false;
			for(int j=0;j<n;j++){
				int a=hps[j]-i;
				if(a>0){
					if(dp2[0][a]==INF){
						no=true;
						break;
					}
					cnt+=dp2[0][a];
				}
			}
			if(no)continue;
			minMP=min(minMP,cnt+dp[0][i]);
		}
		cout<<minMP<<endl;
	}
	return 0;
}

Measured memory_bytes: 4060
n = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
c = list(map(int, input().split(' ')))
ans = 0
for i in range(len(a)):
    ans += b[a[i]-1]
    if (i > 0) and (a[i] == a[i-1]+1):
        ans += c[a[i-1]-1]
print(ans)


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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: usize,
        s: chars,
    }
    let mut s = s;
    s.dedup();
    println!("{}", s.len());
}


Measured memory_bytes: 4352
#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <array>
#include <string>
#include <tuple>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>

/* ----- Type Alias ----- */
using lint = long long int;
using ldouble = long double;
template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T>
T ndvec(T v) { return v; }

template <class T, class... Ts>
auto ndvec(size_t l, Ts... ts) {
    return std::vector<decltype(ndvec<T>(ts...))>(l, ndvec<T>(ts...));
}

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Edges = std::vector<Edge<Cost>>;
template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;

#endif

/* ----- Misc ----- */
void fastio() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

struct Fout {
    int precision;
    explicit Fout(int precision) : precision(precision) {}
};

std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}

/* ----- Constants ----- */
// constexpr int INF = std::numeric_limits<int>::max() / 3;
// constexpr int MOD = 1000000007;
// const Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

int main() {
    int a, b;
    std::cin >> a >> b;
    std::cout << (a < 10 && b < 10 ? a * b : -1) << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int x = s.length();
  int flag =1;
  for(int i=0; i<x; i++){
    if(t[i] != s[i]){
      flag =0;
      break;
    }
  }
  if(flag == 1){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3628
S = input()
N = len(S)

def get_sequence(arr):
    if len(arr) == 0:
        return [], []
    elements = []
    nums = []
    n = 1
    prev = arr[0]
    for c in arr[1:]:
        if c == prev:
            n += 1
        else:
            elements.append(prev)
            nums.append(n)
            prev = c
            n = 1
    elements.append(prev)
    nums.append(n)
    return elements, nums

ans = [0]*N
nums = get_sequence(S)[1]
Nu = len(nums)//2
boundary = 0
for i in range(Nu):
    lenR = nums[2*i]
    lenL = nums[2*i+1]
    ans[boundary+lenR-1] = (lenR+1)//2 + lenL//2
    ans[boundary+lenR] = lenR//2 + (lenL+1)//2
    boundary += lenR + lenL

print(' '.join(map(str,ans)))

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

typedef long long ll;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;

#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define MOD 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  char a,b;
  cin >> a >> b;
  string s, t;
  for (int i = 0; i < b - '0'; ++i) {
    s += a;
  }

  for (int j = 0; j < a - '0'; ++j) {
    t += b;
  }

  if (s > t) {
    cout << t << endl;
  } else {
    cout << s << endl;
  }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define EPS 1e-6
#define MOD (ll)1e15
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;
typedef pair<int, int> pr;
typedef pair<int, pair<int, int>> tup;

inline void sol()
{
	int n;
	cin >> n;
	bool is = 1;
	fore(i, 0, n)
	{
		int a;
		cin >> a;
		if (a % 2 == 0 && a % 3 != 0 && a % 5 != 0)
			is = 0;
	}

	cout << (is ? "APPROVED" : "DENIED");
}

inline void solve()
{
	int q = 1;
	//cin >> q;
	while (q--)
	{
		sol();
		cout << '\n';
	}
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
}

Measured memory_bytes: 256
s = input()
K = int(input())
strs = [[] for _ in range(26)]
cnts = [0]*26

for ind,i in enumerate(s):
    if(sum(cnts[:ord(i)-97])>=5):
        continue
    for j in range(1,K+1):
        st = s[ind:ind+j]
        if(not st in strs[ord(i)-97]):
            strs[ord(i)-97].append(st)
            cnts[ord(i)-97]+=1


cnt = 0
num = 0
while(cnt<K):
    cnt += len(strs[num])
    num += 1
num -= 1
cnt -= len(strs[num])
strs[num].sort()
print(strs[num][K-cnt-1])


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

int main(){
    int a,b;
    char op;

    while (1) {
        cin >> a >> op >> b;
        if(op=='?') break;
        if (op == '+') {
            cout << a + b << endl;
        }
        else if (op == '*') {
            cout << a * b << endl;
        }
        else if (op == '-') {
            cout << a - b << endl;
        }
        else  {
        cout << a / b << endl;
        }
        
    }
    return 0;
}


Measured memory_bytes: 3080
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
#define MAX_N 55
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
ll dp[MAX_N][MAX_N][MAX_N*MAX_N]={};
signed main(){
  init_io();
  ll n,a,ans=0;
  cin >> n >> a;
  vector<ll> x(n);
  for(int i=0;i<n;i++){
    cin >> x[i];
  }
  for(int i=0;i<n;i++){
    dp[i+1][1][x[i]]++;
    for(int j=1;j<MAX_N;j++){
      for(int k=0;k<MAX_N*MAX_N;k++){
        dp[i+1][j][k] += dp[i][j][k];
        if(k>=x[i]){
          dp[i+1][j][k] += dp[i][j-1][k-x[i]];
        }
      }
    }
  }
  for(int j=1;j<MAX_N;j++){
    for(int k=1;k<MAX_N*MAX_N;k++){
      if(j*a==k){
        ans+=dp[n][j][k];
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 66560
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define fi first 
#define se second
#define forn(i, n)for(int i=0;i<int__(n);i++) 
#define sz(a)int__(a.size())
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a){return out << "(" << a.first << ", " << a.second << ")";}
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int Mod(int x){const int mm=1e9 + 7;x%=mm;if(x<0)x+=mm;return x;}
int Pow(int x,int n){if(n<0)return 0;if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
#define all(x) x.begin(),x.end()
#define Return(x) {cout << x << endl; return 0;}


int__ main() {
    int n,k; cin >> n >> k;
    int mx = n/k;

    cout << min( abs(mx*k - n), abs((mx+1)*k - n));
}

Measured memory_bytes: 256
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){function t(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=[],n=!0,o=!1,u=void 0;try{for(var i,l=e[Symbol.iterator]();!(n=(i=l.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(e){o=!0,u=e}finally{try{n||null==l.return||l.return()}finally{if(o)throw u}}return t}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}e.exports=function(e){var r=t(e.split("\n")[0].split(" ").map(function(e){return Number(e)}),4),n=r[0],o=r[1],u=r[2],i=r[3],l=n*o/2,f=0;u==n/2&&i==o/2&&(f=1),console.log(`${l} ${f}`)}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 7628
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int N;
  while(cin >> N){
    vector<int> A(N); cin >> A;

    vector<int> odd, even;
    REP(i,N){
      if(i%2==1) even.push_back(A[i]);
      else odd.push_back(A[i]);
    }

    sort(ALL(even));
    sort(ALL(odd));

    sort(ALL(A));
    for(auto &x : even) x = lower_bound(ALL(A),x) - A.begin() + 1;
    for(auto &x : odd) x = lower_bound(ALL(A),x) - A.begin() + 1;

    dump(even);
    dump(odd);

    int ans = 0;

    for(auto & x : even) if(x%2==1) ++ans;

    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1276
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0043
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line)) return;

                List<int> res = new List<int>();
                for (int i = 1 ; i < 10 ; i++) if (IsCompleteHand(line + i)) res.Add(i);
                Console.WriteLine(res.Count > 0 ? WAr(res) : "0");
            }

        }

        private static bool IsCompleteHand(string line)
        {
            int[] numsCnt = new int[9];
            for (int i = 0 ; i < line.Length ; i++) numsCnt[int.Parse(line[i].ToString()) - 1]++;

            if (numsCnt.Max() > 4) return false; //牌が4枚を超えるとNG

            int sum = numsCnt.Select((x, i) => (i + 1) * x).Sum(); //牌の合計値
            int remOfSum = sum % 3;

            //remOfsum:0 ⇒ 雀頭候補：3,6,9⇒i:2,5,8
            //remOfsum:1 ⇒ 雀頭候補：2,5,8⇒i:1,4,7
            //remOfsum:2 ⇒ 雀頭候補：1,4,7⇒i:0,3,6

            for (int i = (2 - remOfSum) ; i < 9 ; i += 3)
            {
                if (numsCnt[i] < 2) continue;
                int[] numsCntClone = (int[])numsCnt.Clone();
                numsCntClone[i] -= 2;
                if (CanCreate4Set(numsCntClone)) return true;
            }

            return false;
        }

        private static bool CanCreate4Set(int[] numsCnt)
        {
            for (int i = 0 ; i < 7 ; i++)
            {
                int r = numsCnt[i] % 3;
                if (numsCnt[i + 1] >= r && numsCnt[i + 2] >= r)
                {
                    numsCnt[i] -= r; numsCnt[i + 1] -= r; numsCnt[i + 2] -= r;
                }
                else return false;
            }

            if (numsCnt.All(x => x == 0 || x == 3)) return true;
            else return false;
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 16360
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
    	Scanner sc=new Scanner(System.in);
    	long a=sc.nextLong(),b=sc.nextLong(),x=sc.nextLong(),C =0;
    	C =b/x-a/x;
    		if(a%x==0){
    			C++;
    }
    	System.out.println(C);
    	sc.close();
    }
    }

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

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

    vector<int> D;

    int num = n;
    while (num != 0) {
        D.push_back(num % 10);
        num /= 10;
    }

    if (D[0] == D[1] && D[1] == D[2]) {
        cout << "Yes" << endl;
    }
    else if (D[1] == D[2] && D[2] == D[3]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#define max(a,b) (a>b?a:b)
int a[101];
int main()
{
	int k,t;
	scanf("%d %d",&k,&t);
	int sum=0,maxn=0;
	for(int i=1;i<=t;i++){
		scanf("%d",&a[i]);
		maxn=max(maxn,a[i]);
		sum+=a[i];
	}
	sum-=maxn;
	if(sum>=maxn){
		printf("0\n");
	}else{
		printf("%d\n",maxn-sum-1);
	}
	return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rept(i,k,n) for(ll i = (k); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;
typedef tuple<int,int,int> Tii;

int ctoi(const char c){
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}


int main(){
    ll a;
    string b;
    cin>>a>>b;
    ll c=0;
    c+=ctoi(b[0])*100+ctoi(b[2])*10+ctoi(b[3]);
    cout<<a*c/100<<endl;
    return 0;
}


Measured memory_bytes: 3612
from fractions import gcd
N=int(input())
A=list(map(int,input().split()))
left,right=[0],[0]
[(left.append(gcd(left[i],A[i])),right.append(gcd(right[i],A[N-i-1]))) for i in range(N-1)]
right.reverse()
print(max([gcd(a,b) for a,b in zip(left,right)]))

Measured memory_bytes: 19280
fn main(){
    let r: u32 = read();
    let ans = if r < 1200 {"ABC"} else if r < 2800 {"ARC"} else {"AGC"};
    println!("{}", ans);
}

use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long Y = sc.nextLong();
		long cnt = 1;
		
		while(true) {
			X *= 2;
			if(X > Y) {
				break;
			} else {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 25300
#include <bits/stdc++.h>
#define foi(i,k,n) for (int i = (int)k; i < (int)n; ++i)

using namespace std;

constexpr int MOD = 7+1e9;
constexpr int MAXN = 5+3e6;

int add(int a, int b) {
  int ans = a + b;
  if (ans >= MOD) ans -= MOD;
  return ans;
}

int mul(int a, int b) {
  return (int)((1LL*a*b) % MOD);
}

int fpow(int b, int e) {
  int ans = 1;
  for (; e; e >>= 1) {
    if (e&1) ans = mul(ans, b);
    b = mul(b, b);
  }
  return ans;
}

int f[MAXN];
int choose(int n, int k) {
  assert(k <= n);
  return mul(f[n], fpow(mul(f[k], f[n-k]), MOD-2));
}

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  f[0] = 1;
  for (int i = 1; i < MAXN; ++i) {
    f[i] = mul(f[i-1], i);
  }
  int n,k,ans = 0; cin >> k;
  string s; cin >> s;
  n = s.size() + k;
  k = s.size();
  for (int j = 0; j <= n-k; ++j) {
    ans = add(ans, mul(choose(n, j+k), fpow(25, n-k-j)));
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 15904
r1,c1,r2,c2=map(int,input().split())
a=r2-r1+1
b=c2-c1+1
m=max(a,b)
n=min(a,b)
mod=10**9+7
def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a
def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod
def f(x,y):
  return comb(x+y+2,y+1,mod)-1
 
print((f(r2,c2)-f(r2,c1-1)-f(r1-1,c2)+f(r1-1,c1-1))%mod)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a - 1) * (b - 1) << endl;
}

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

const int N=1e6+1;
const int mod=1e9+7;

int a,b,m;
int ca[N],cb[N];

int main(){
    cin>>a>>b>>m;
    int mna=INT_MAX,mnb=INT_MAX;
    for(int i=0;i<a;i++) cin>>ca[i],mna=min(mna,ca[i]);
    for(int i=0;i<b;i++) cin>>cb[i],mnb=min(mnb,cb[i]);
    int mn=mna+mnb;
    for(int i=0;i<m;i++){
        int x,y,dis;
        cin>>x>>y>>dis;
        mn=min(mn,ca[x-1]+cb[y-1]-dis);
    }
    mn=max(mn,0);
    cout<<mn;
    return 0;
}

Measured memory_bytes: 4736
N = gets.to_i
ab_list = N.times.map do
  gets.split(' ').map(&:to_i)
end.sort_by { |(a, b)| -(a + b) }

t_sum = 0
a_sum = 0
(0...N).each do |i|
  if i % 2 == 0
    t_sum += ab_list[i][0]
  else
    a_sum += ab_list[i][1]
  end
end

res = t_sum - a_sum
puts res


Measured memory_bytes: 12664
#include <stdio.h>

int main(void)
{
  int a,b,ans;
  scanf("%d%d",&a,&b);
  if(a+b>=a-b&&a+b>=a*b){
    ans=a+b;
  }
  else if (a-b>=a+b&&a-b>=a*b){
    ans=a-b;
  }
  else ans=a*b;
  
  printf("%d\n",ans);
  
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

const int DIV = 1e9 + 7;
typedef long long ll;
int n, a, b;

int modPow(long long a1, long long n1, int mod) {
    if (n1 == 1) return a1 % mod;
    if (n1 % 2 == 1) return (a1 * modPow(a1, n1 - 1, mod)) % mod;
    long long t = modPow(a1, n1 / 2, mod);
    return (t * t) % mod;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> a >> b;

    ll x = 1;
    ll y = 1;
    for (int i = 0; i < a; ++i) {
        x = (x * (n - i)) % DIV;
        y = (y * (i + 1)) % DIV;
    }

    ll ans = modPow(2, n, DIV) - 1;
    ans = (ans - (x * modPow(y, DIV - 2, DIV))) % DIV;

    y = x = 1;
    for (int i = 0; i < b; ++i) {
        x = (x * (n - i)) % DIV;
        y = (y * (i + 1)) % DIV;
    }

    ans -= (x % DIV * modPow(y, DIV - 2, DIV)) % DIV;
    if (ans < 0) {
        ans = (ans + 2 * DIV) % DIV;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
#define pb=push_back
int INF=1e9+7;

int main() {
  int D;
  cin >> D;
  vi c(26);
  rep(i,26) cin >> c[i];
  vvi s(D,vi(26));
  rep(i,D) {
    rep(j,26) cin >> s[i][j];
  }
  vi t(D);
  rep(i,D) {
    cin >> t[i];
    t[i]--;
  }
  
  vvi last(D+1,vi(26));
  int ans=0;
  rep2(d,1,D+1) {
    ans+=s[d-1][t[d-1]];
    rep(i,26) last[d][i]=last[d-1][i];
    last[d][t[d-1]]=d;
    int down=0;
    rep(i,26) down+=c[i]*(d-last[d][i]);
    ans-=down;
    cout << ans << endl;
  }
}

Measured memory_bytes: 3696
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

#mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


def main():
	h,a=map(int,input().split())
	print((h-1)//a+1)
	
	

if __name__ == "__main__":
	main()


Measured memory_bytes: 2940
#include <iostream>
#include <string>

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;

	int gap = 0;
	char prev = S[0];
	for(int i = 1; i < S.size(); i++) {
		if(S[i] != prev) gap++;
		prev = S[i];
	}
	cout << N - 1 - max(0, gap - 2 * K) << endl;
}


Measured memory_bytes: 512
/*
   AUTHOR :- Gaurang_Kothiya
   
   Quote:-" Great things never come from comfort zones."                                                                                                                
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set; 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long  
#define ld long double
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(ll i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007


ll ncr(ll a,ll b)
{
	if(a==b)return 1;
	if(b>a)return 0;
	if(b==0)return 1;
	
	return ncr(a-1,b-1)+ncr(a-1,b);
}


void solver()
{
	ll a,b;
	cin>>a>>b;
	cout<< ncr(a,2)+ncr(b,2);	
}


signed main() 
{
	speed	
		
	ll q=1;	
	//cin>>q;	
	
	while(q--)	
	solver();	
	
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

 
 

Measured memory_bytes: 256