akhauriyash/Code-Regression huggingface dataset:
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int a, b;
  int s = 0, t = 0, n = 0;
  char gomi;
  while (cin >> a >> gomi >> b) {
    s += a * b;
    t += b;
    n++;
  }
  cout << s << '\n'
       << (int) (1.0 * t / n + 0.5) << endl;
}

Measured memory_bytes: 3068
N,K=map(int,input().split())
S=input()
change=[0]
for i in range(len(S)-1):
  if S[i]!=S[i+1]:
    change.append(i+1)
change.append(N)
r=len(change)
X=[]
for i in range(r-1):
  if S[change[i]]=='0':
    a=min(i+2*K,r-1)
    X.append(change[a]-change[i])
  else:
    a=min(i+2*K+1,r-1)
    X.append(change[a]-change[i])
print(max(X))

Measured memory_bytes: 16888
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        string s, t;
        cin >> s >> t;

        int ans = 0;
        for(int i = 0; i < s.size(); i++)
            ans += s[i] != t[i];
        cout << ans << '\n';
    }
    
    return 0;
}



Measured memory_bytes: 3884
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, W; cin >> N >> W; vl ws(N+1,0), vs(N+1,0);
    REP(i, N) cin >> ws[i+1] >> vs[i+1];
    vvl dp(N+1, vl(W+1, 0));
    FOR(i, 1, N+1){
        FOR(w, 1, W+1){
            dp[i][w] = max(dp[i][w], dp[i-1][w]);
            if(w >= ws[i]) dp[i][w] = max(dp[i][w], dp[i-1][w-ws[i]] + vs[i]);
        }
    }
    cout << dp[N][W] << endstr;
    return 0;
}


Measured memory_bytes: 80256
#ABC122B - ATCoder
s = str(input())
size = len(s)
ans = 0
for i in range (0,size):
    for j in range (i,size+1):
        hantei = s[i:j]
        countA = hantei.count('A')
        countC = hantei.count('C')
        countG = hantei.count('G')
        countT = hantei.count('T')
        if (len(hantei) == countA + countC + countG + countT):
            if(ans < len(hantei)):
                ans = len(hantei)
print(ans)

        

Measured memory_bytes: 3060
function main(arg) {
	arg = arg.split("\n")[0]
	arg = Number(arg.split("/").join(""))

	if (arg <= 20190430) {
		console.log("Heisei")
	} else {
		console.log("TBD")
	}
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21956
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define pi pair<int, int>
#define ppi pair<pair<int, int>, int>
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
#define INF (ll)1e18
#define s(v) v.size()
#define e(v) v.empty()

using namespace std;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);}
// bool sortbysec(const pll &a, const pll &b){return (a.second < b.second);} 
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}

ll ctoi(char x){
    return (ll)(x-'0');
}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        ll n, p;
        cin>>n>>p;
        string str;
        cin>>str;
        if(p==2 || p==5){
            ll ans = 0;
            fod(i, n-1, 0){
                if(ctoi(str[i])%p == 0)   ans+=(i+1);
            }
            cout<<ans;
        }else{
            vl freq(p), post(n);
            freq[0] = 1;
            ll tmp = 0, pten = 1;
            fod(i, n-1, 0){
                post[i] = ctoi(str[i])*pten;
                post[i] %= p;
                pten *= 10;
                pten %= p;
            }
            ll sum = 0;
            fod(i, n-1, 0){
                sum += post[i];
                sum %= p;
                freq[sum]++;
            }
            ll ans = 0;
            rep(i, p){
                // cout<<freq[i]<<" ";
                ans += freq[i]*(freq[i]-1)/2; 
            }
            cout<<ans;
        }
    }
}

Measured memory_bytes: 2196
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using pi = std::pair<int, int>;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    int n, m; cin >> n >> m;
    vector<pi> p(n);
    REP(i, n) {
        int a, b; cin >> a >> b;
        p[i] = make_pair(a, b);
    }

    sort(p.begin(), p.end(), [](pi x, pi y) {
        return x.first < y.first;
    });

    auto compare = [](pi x, pi y) {
        return x.second < y.second;
    };
    priority_queue<pi, vector<pi>, decltype(compare)> pq(compare);

    ll ans = 0LL;
    vector<bool> used(m+1, false);
    for(int i=m-1, j=0; i>=0; i--) {
        while(j < n && p[j].first <= m-i) {
            pq.push(p[j]);
            j++;
        }

        if(!pq.empty()) {
            ans += pq.top().second;
            pq.pop();
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	vector <int> v;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		v.push_back(a);
	}
	vector <int> dp(n,1e9);
	dp[0]=0;
	for(int i=1;i<n;i++){
		for(int j=1;j<=k;j++){
			if(i-j>=0){
				dp[i]=min(abs(v[i]-v[i-j])+dp[i-j],dp[i]);	
			}
		}
	
	}
	cout<<dp[n-1]<<endl;
	
} 

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

int main(int argc, char const *argv[]) {
  int n;
  double tmp = 0;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());

  for (int i = 0; i < n; i++) {
    if (i == 0)
      tmp = v[i];
    else
      tmp = (tmp + v[i]) / 2;
  }
  cout << setprecision(15) << tmp << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	l := 0
	r := len(a) - 1
	for l <= r {
		m := (l + r) / 2
		if a[m] >= x {
			r = m - 1
		} else {
			l = m + 1
		}
	}
	return l
}

func calc(a, s []int, x int) (int, int) {
	tot := 0
	num := 0
	n := len(a)
	for i := 0; i < n; i++ {
		j := lowerBound(a, x-a[i])
		num += n - j
		tot += s[n] - s[j]
		tot += a[i] * (n - j)
	}
	return tot, num
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M := getInt(), getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}
	sort.Ints(a)
	b := make([]int, N+1)
	for i := 0; i < N; i++ {
		b[i+1] = b[i] + a[i]
	}

	l := 0
	r := 200005
	for l+1 < r {
		c := (l + r) >> 1
		_, num := calc(a, b, c)
		if num >= M {
			l = c
		} else {
			r = c
		}
	}
	ans, num := calc(a, b, l)
	ans -= (num - M) * l
	out(ans)
}


Measured memory_bytes: 3072
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define MOD 998244353

ll inv[1000010];
ll coe[1000010];
ll a[1000010];
int main(){
	inv[1]=1;
	rep(i,2,1000005)inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
	rep(i,1,1000005){
		coe[i]=(coe[i]+inv[i])%MOD;
		repp(j,2*i,1000005,i)coe[j]=(coe[j]-coe[i]+MOD)%MOD;
	}

	int n;
	scanf("%d",&n);
	rep(i,0,n){
		int t;
		scanf("%d",&t);
		a[t]++;
	}
	ll ans=0;
	rep(d,1,1000001){
		ll sum=0;
		repp(i,d,1000001,d)sum=(sum+i*a[i])%MOD;
		ans=(ans+sum*sum%MOD*coe[d])%MOD;
	}
	rep(i,1,1000001)ans=((ans-i*a[i])%MOD+MOD)%MOD;
	printf("%lld",ans*inv[2]%MOD);
}


Measured memory_bytes: 23552
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    string s;
    cin >> s;
    
    int n = s.size();
    
    using ll = long long;
    
    const ll mod = 1000000000 + 7;
    
    vector<ll> three_pow(n + 1);
    
    three_pow[0] = 1;
    for (int i = 1; i <= n; i++) {
        three_pow[i] = three_pow[i - 1] * 3 % mod;
    }
    
    vector<ll> a(n), c(n);
    vector<ll> lq(n), rq(n);
    
    a[0] = s[0] == 'A';
    lq[0] = s[0] == '?';
    
    for (int i = 1; i < n; i++) {
        a[i] = a[i - 1] + (s[i] == 'A');
        lq[i] = lq[i - 1] + (s[i] == '?');
    }
    
    c[n - 1] = s[n - 1] == 'C';
    rq[n - 1] = s[n - 1] == '?';
    
    for (int i = n - 2; i >= 0; i--) {
        c[i] = c[i + 1] + (s[i] == 'C');
        rq[i] = rq[i + 1] + (s[i] == '?');
    }
    
    ll ans = 0;
    
    for (int i = 1; i < n - 1; i++) {
        if (s[i] == 'B' || s[i] == '?') {
            ans = (ans + a[i - 1] * c[i + 1] % mod * three_pow[lq[i - 1] + rq[i + 1]] % mod) % mod;
            
            if (lq[i - 1] != 0) {
                ans = (ans + lq[i - 1] * c[i + 1] % mod * three_pow[lq[i - 1] - 1 + rq[i + 1]] % mod) % mod;
            }
            
            if (rq[i + 1] != 0) {
                ans = (ans + a[i - 1] * rq[i + 1] % mod * three_pow[lq[i - 1] + rq[i + 1] - 1] % mod) % mod;
            }
            
            if (lq[i - 1] != 0 && rq[i + 1] != 0) {
                ans = (ans + lq[i - 1] * rq[i + 1] % mod * three_pow[lq[i - 1] - 1 + rq[i + 1] - 1] % mod) % mod;
            }
        }
    }
    
    cout << ans << endl;
}
  


Measured memory_bytes: 4416
N = int(input())

result = "No"
if (N >=700 and N<800):
	result = "Yes"

if (N%100 >= 70 and N%100 < 80):
	result = "Yes"

if (N%10 >= 7 and N%10 < 8):
	result = "Yes"

print(result)

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

bool rotation(int n) {
    int a;
    int b;
    int c;
    int d;
    a = n % 10;
    n /= 10;
    b = n % 10;
    n /= 100;
    c = n % 10;
    n /= 10;
    d = n % 10;
    if(a == d && b == c)
        return true;
    else
        return false;
}

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    int ans = 0, a, b;
    cin >> a >> b;
    for(int i = a; i <= b; i++)
        if(rotation(i)){
            ans++;
        }

    cout << ans << endl;
}

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

static const int N_MAX = 100;

int bubbleSort(int a[], int n) {
    int flag = 1, cnt = 0;
    while (flag) {
        flag = 0;

        for (int i = n - 1; i > 0; i--)
        {
            if (a[i] < a[i-1]) {
                swap(a[i], a[i - 1]);
                flag = 1;
                cnt++;
            }
        }
    }
    return cnt;
}

void trace(int a[], int n) {
    for (int i = 0; i < n-1; i++) {
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
}

int main() {
    int n, a[N_MAX];

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

    int cnt = bubbleSort(a, n);
    trace(a, n);
    cout << cnt << endl;
}


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

int main() { 
  int N;
  cin >> N;
  int t[110000], x[110000], y[110000];
  t[0] = x[0] = y[0] = 0;
  for (int i = 0; i < N; ++i) cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
  
  bool frag = true;
  
  for (int i = 0; i < N; ++i) {
    int dist = fabs(x[i] - x[i + 1]) + fabs(y[i] - y[i + 1]);
    int T = t[i + 1] - t[i];
    if (T < dist) frag = false;
    if (T % 2 != dist % 2) frag = false;
  }
  if (frag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <set>
#include <queue>
#include <utility>
#include <bits/stdc++.h>
typedef long long ll;
typedef std::pair<int,int> ii;
using namespace std;

int main() {
    int a, b, m; cin >> a >> b >> m;
    vector<int>a1(a);
    vector<int>b1(b);
    for(int i = 0; i < a; i++){
        cin >> a1[i];
    }
    for(int i = 0; i < b; i++){
        cin >> b1[i];
    }
    vector<int>v1 = a1;
    vector<int>v2 = b1;
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    
    priority_queue<int, vector<int>, greater<int>>pq;
    int ans = v1[0]+v2[0];
    pq.push(ans);
    
    while(m--){
        int x, y, d;
        cin >> x >> y >> d;
        int val = (a1[x-1] + b1[y-1]) - d;
        if(val < ans){
            pq.push(val);
        }
    }
    cout << pq.top() << endl;
	return 0;
}



Measured memory_bytes: 2428
/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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")
    };
}

use std::cmp;

fn main() {
    input!(n: usize, a: usize, b: usize);
    if a + b > n + 1 {
        println!("-1");
        return;
    }
    let mut ans = vec![];
    for i in 0..((n + b - 1) / b) {
        for j in 0..b {
            let tmp = (i + 1) * b - j;
            if tmp > n {
                continue;
            }
            ans.push(tmp);
        }
    }
    ans.resize(n, 0);
    let mut cur_a = (n + b - 1) / b;
    if cur_a > a {
        println!("-1");
        return;
    }
    for i in (0..((n + b - 1) / b)).rev() {
        let end = cmp::min(n, cmp::min((i + 1) * b, i * b + a - cur_a + 1));
        ans[(i * b)..end].sort();
        cur_a += (end - (i * b)) - 1;
    }
    assert_eq!(a, cur_a);
    for i in 0..n {
        if i > 0 {
            print!(" ");
        }
        print!("{}", ans[i]);
    }
    println!();
}


Measured memory_bytes: 11128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
	int x[100], i = 0;
	char s[100];

	while( scanf("%s", s) != EOF){
		if(s[0] == '+'){
			x[i-2] += x[i-1];
			i--;
		}else if(s[0] == '-'){
			x[i-2] -= x[i-1];
			i--;

		}else if(s[0] == '*'){
			x[i-2] *= x[i-1];
			i--;
		}else{
			x[i++] = atoi(s);
		}
	}

	printf("%d\n", x[0]);
	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n, x;
    cin >> n >> x;
    vector<int32> m(n);
    REP(i,n){
        cin >> m[i];
        x -= m[i];
    }
    vector<int32> dp(x+1, 0);
    REP(i,n){
        REP(j,x+1-m[i]){
            dp[j+m[i]] = max(dp[j+m[i]], dp[j] + 1);
        }
    }
    int32 ans = 0;
    REP(i,x+1)ans = max(ans, dp[i]);
    ans += n;
    ANS(ans);
    return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3

def main():
    S = input()
    T = input()

    flag1 = False
    if S.islower() and T.islower():
        flag1 = True

    flag2 = False
    if 1 <= len(S) <= 10:
        flag2 = True

    flag3 = False
    if len(T) - len(S) == 1:
        flag3 = True

    flag4 = False
    if T.startswith(S):
        flag4 = True

    if flag1 == flag2 == flag3 == flag4 == True:
        print('Yes')
    else:
        print('No')


main()

Measured memory_bytes: 9060
#include <bits/stdc++.h>
#define rep(n) for (int i=0;i<n;i++)
#define ll long long 
using namespace std;

int main ()
{

int n,sum=0,k;
cin>>n>>k;vector<ll> arr(n);
for(int i=0;i<n;i++)
cin>>arr[i];
sort(arr.begin(),arr.end());
for (int i=0;i<k;i++)
	sum+=arr[i];
cout<<sum;
}



Measured memory_bytes: 3620
#include <stdio.h>

#define swap(type, x, y) do { type t = x; x = y; y = t; } while (0)

int selectionSort(int *A, int n)
{
	int c, i, j, min;

	c = 0;
	for (i = 0; i < n - 1; i++)
	{
		min = i;
		for (j = i; j < n; j++)
		{
			if (A[j] < A[min])
			{
				min = j;
			}
		}
		if (i != min)
		{
			swap(int, A[i], A[min]);
			c++;
		}
	}
	
	return c;
}
int main()
{
	int c, i, n;
	int A[100];

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", &A[i]);

	c = selectionSort(A, n);

	for (i = 0; i < n; i++) {
		printf("%d", A[i]);
		if (i < n - 1) printf(" ");
	}
	printf("\n");

	printf("%d\n", c);

	return 0;
}

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

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);

	string s;
	cin >> s;

	ll ans = 0;
	int cnt = 0;
	int b_cnt = 0;
	bool check = false;
	char c = s.at(0);
	int s_len = (int)s.length();

	for (int i = 0; i < s_len; ++i) {
		char ch = s.at(i);
		if (c == ch) {
			cnt++;
			ans += cnt;
		} else {
			if (c == '<') {
				check = true;
			} else {
				if (check) {
					ans -= min(b_cnt, cnt);
					check = false;
				}
			}
			c = ch;
			b_cnt = cnt;
			cnt = 1;
			ans += cnt;
		}
	}

	// 最後のチェック
	if (check) {
		ans -= min(b_cnt, cnt);
		check = false;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main() {
  vi a(5);
  rep(i,5)cin>>a.at(i);
  rep(i,5){
      if(a.at(i)==0)cout<<1+i<<endl;
  }
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

struct state{
  int i,j,dir,p,q;
};
bool operator<(const state& a,const state& b){
  return a.p+a.q<b.p+b.q;
};

int n,m,a;
int dist[111][111][5][11][11];
string s[111];
int dx[]={1,0,-1,0};
int dy[]={0,-1,0,1};

bool valid(int i,int j){
  return i>=0&&i<n&&j>=0&&j<m;
}

int main(){
	cin.sync_with_stdio(false);
  cin>>n>>m>>a;
  rep(i,n)cin>>s[i];
  rep(i,111)rep(j,111)rep(k,5)rep(p,11)rep(q,11)dist[i][j][k][p][q]=INF;
  priority_queue<state> que;
  rep(i,n)rep(j,m){
    if(s[i][j]=='S'){
      if(valid(i+1,j)&&s[i+1][j]!='#')que.push((state){(int)(i+1),(int)j,3,a,a});
    }
  }
  int res=INF;
  while(que.size()){
    state ns=que.top(); que.pop();
    int i=ns.i,j=ns.j,dir=ns.dir,p=ns.p,q=ns.q;
    if(s[i][j]=='S'&&(dir==1||dir==3))continue;
    if(dist[i][j][dir][p][q]!=INF)continue;
    dist[i][j][dir][p][q]=p+q;
    if(s[i][j]=='G'){
      res=2*a-p-q;
      break;
    }
    int ndir;
    if(s[i][j]!='S'){
      if(p>0){
        if(dir==3||dir==0) ndir=3-dir;
        else ndir=3-dir;
        int ni=i+dy[ndir],nj=j+dx[ndir];
        if(valid(ni,nj)&&s[ni][nj]!='#'){
          que.push((state){ni,nj,ndir,p-1,q});
        }
      }
      if(q>0){
        if(dir==0||dir==1) ndir=1-dir;
        else ndir=5-dir;
        int ni=i+dy[ndir],nj=j+dx[ndir];
        if(valid(ni,nj)&&s[ni][nj]!='#'){
          que.push((state){ni,nj,ndir,p,q-1});
        }
      }
    }
    int ni=i+dy[dir],nj=j+dx[dir];
    if(valid(ni,nj)&&s[ni][nj]!='#'){
      que.push((state){ni,nj,dir,p,q});
    }
  }
  if(res==INF)cout<<-1<<endl;
  else cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 32696
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <map>
#include <functional>
#include <cmath>
#include <cstdio>
using namespace std;

#define PI 4*atan(1);

int main(){
  int n[3], max = 0;
  int cnt[3] = {0}, ans = 0;
  bool t = true;
  while(cin >> n[0] >> n[1] >> n[2]){
    if(t == true){
      if(n[0] < n[1] + n[2] && n[1] < n[0] + n[2] && n[2] < n[0] + n[1]){
        sort(n, n + 3);
        int sum = n[0] * n[0] + n[1] * n[1] - n[2] * n[2];
        if(sum > 0){
          cnt[1]++;
          ans++;
        }else if(sum == 0){
          cnt[0]++;
          ans++;
        }else{
          cnt[2]++;
          ans++;
        }
      }else{
        t = false;
      }
    }else{
    }
  }
  cout << ans << " ";
  for(int i = 0; i < 2; i++){
    cout << cnt[i] << " ";
  }
  cout << cnt[2] << endl;
}

Measured memory_bytes: 1184
#include<cstdio>
#include<cstring>
#include<iostream>
#define N 2010
#define LL long long
#define inf 0x7fffffff/2
using namespace std;

int len, f[N][N], fl, fr;
LL k, g[N][N];
char s[N], data[N << 1];
int min(int a, int b){return (a < b)? a : b;}

void DP(int l, int r)
{
	if (l >= r){f[l][r] = 0; g[l][r] = 1; return;}
	if (f[l][r] != -1) return;
	if (s[l] == s[r])
	{
		DP(l + 1, r - 1);
		f[l][r] = f[l + 1][r - 1];
		g[l][r] = g[l + 1][r - 1];
		return;
	}
	f[l][r] = inf; g[l][r] = 0;
	DP(l + 1, r); f[l][r] = min(f[l][r], f[l + 1][r] + 1);
	DP(l, r - 1); f[l][r] = min(f[l][r], f[l][r - 1] + 1);
	if (f[l][r] == f[l + 1][r] + 1) g[l][r] += g[l + 1][r];
	if (f[l][r] == f[l][r - 1] + 1) g[l][r] += g[l][r - 1];
	if (g[l][r] > k) g[l][r] = k + 1;
}

void Find(int l, int r, LL k)
{
	if (l > r) return;
	if (l == r) {data[fl] = s[l]; return;}
	if (s[l] == s[r])
	{
		data[fl++] = s[l];
		data[fr--] = s[r];
		Find(l + 1, r - 1, k);
		return;
	}
	if (f[l][r] == f[l + 1][r] + 1 && f[l][r] != f[l][r - 1] + 1)
	{
		data[fl++] = data[fr--] = s[l];
		Find(l + 1, r, k);
		return;
	}
	else if (f[l][r] == f[l][r - 1] + 1 && f[l][r] != f[l + 1][r] + 1)
	{
		data[fl++] = data[fr--] = s[r];
		Find(l, r - 1, k);
		return;
	}
	if (s[l] < s[r])
	{
		if (k <= g[l + 1][r])
		{
			data[fl++] = data[fr--] = s[l];
			Find(l + 1, r, k);
			return;
		}
		else
		{
			data[fl++] = data[fr--] = s[r];
			Find(l, r - 1, k - g[l + 1][r]);
			return;
		}
	}
	else
	{
		if (k <= g[l][r - 1])
		{
			data[fl++] = data[fr--] = s[r];
			Find(l, r - 1, k);
			return;
		}
		else 
		{
			data[fl++] = data[fr--] = s[l];
			Find(l + 1, r, k - g[l][r - 1]);
			return;
		}
	}
}

int main()
{
	scanf("%s", s); cin >> k;
	len = strlen(s);
	memset(f, -1, sizeof f);
	DP(0, len - 1);
	if (k > g[0][len - 1])
	{
		printf("NONE\n");
		return 0;
	}
	fl = 0; fr = f[0][len - 1] + len - 1;
	Find(0, len - 1, k);
	for (int i = 0; i < f[0][len - 1] + len; i++) printf("%c", data[i]);printf("\n");
	return 0;
} 

Measured memory_bytes: 48404
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19
constexpr static double EPS = 1e-10;

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

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        string s = to_string(i);
        if ((s.length() % 2) == 1) {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split(' '))
R, S, P = map(int, input().split(' '))
T = input()

flags = [0] * len(T)

point_map = {'r': P, 's': R, 'p': S}

point_sum = 0

for i, t in enumerate(T):
    if i < K:
        point_sum += point_map[t]
        continue
    if t == T[i-K] and not flags[i-K]:
        flags[i] = 1
        continue
    point_sum += point_map[t]

print(point_sum)


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

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	ll n, k; cin >> n >> k;
	ll M = 1000000007;
	vector<vector<ll>> dp(2005, vector<ll>(2005, 0));
	dp[0][0] = 1;
	rep(i, 0, 2002)rep(j, 0, 2002)
	{
		dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % M;
		dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % M;
	}
	rep(i, 1, k)
	{
		ll ans;
		if (n - k + 1 - i < 0)ans = 0;
		else ans = dp[n - k + 1 - i][i] * dp[k - i][i - 1] % M;
		cout << ans << endl;
	}
}

Measured memory_bytes: 31744
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll,ll> P;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define EFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i, n) FOR(i,0,n)
#define INF 1e9
const int MOD = 998244353;

/*  DP 区間数え上げ O(KN)
//  与えられる区間が重複していないので，それぞれの区間の累積和が
//    i番目の移動方法回数となる．
*/
int main(void){
    ll n,k;
    cin >> n >> k;
    vector<ll> ans(n+10,0);
    vector<P> s(k);
    vector<ll> sum(n+10,0);
    REP(i,k){
        cin >> s[i].first >> s[i].second;
    }
    ans[0] = 1, sum[1] = 1; // 0-indexed

    FOR(i,1,n){
       for(auto it : s){
            ll l = max((ll)0, i - it.second);
            ll r = max((ll)0, i - it.first + 1);
            ans[i] += sum[r] - sum[l]; 
            ans[i] += MOD;
            ans[i] %= MOD;
       }
       sum[i+1] = ans[i] + sum[i];
       sum[i+1] += MOD;
       sum[i+1] %= MOD;
    }
    cout << ans[n-1] << endl;

    return 0;
}

Measured memory_bytes: 6436
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int M = stdIn.nextInt();
		int[] H = new int[N];
		int[] A = new int[M];
		int[] B = new int[M];
		
		int[] good = new int[N];
		
		for(int i = 0; i < N; i ++) {
			H[i] = stdIn.nextInt();
			good[i] = 1;
		}
		for(int i = 0; i < M; i ++) {
			A[i] = stdIn.nextInt();
			B[i] = stdIn.nextInt();
		}
		
		for(int i = 0; i < M; i ++) {
			int a = A[i] - 1;
			int b = B[i] - 1;
			if(H[a] < H[b]) {
				good[a] = 0;
			}
			if(H[b] < H[a]) {
				good[b] = 0;
			}
			if(H[a] == H[b]) {
				good[a] = 0;
				good[b] = 0;
			}
		}
		
		int ans = 0;
		for(int i = 0; i < good.length; i ++) {
			if(0 < good[i]) {
				ans ++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 61380
#include<bits/stdc++.h>
const int mo=1e9+7,N=3e3+5;
int n,m,i,j,ans,f[N][N];
inline void add(int&x,const int&y){x+=y-mo;x+=x>>31&mo;}
inline int calc(int n){
	if(n<1)return 0;
	memset(f,0,sizeof f);
	for(i=0;i<=n;++i)f[0][i]=1;
	for(i=0;i<m;++i)for(j=0;j<=n;++j){
		if(j)add(f[i+1][j],f[i][j]),add(f[i+1][j-1],f[i][j]);
		if(j<n)add(f[i+1][j],f[i][j]),add(f[i+1][j+1],f[i][j]);
	}
	ans=0;for(i=0;i<=n;++i)add(ans,f[m][i]);return ans;
}
int main(){
	scanf("%d%d",&n,&m);
	printf("%d\n",(calc(n)+mo-calc(n-1))%mo);
	return 0;
}

Measured memory_bytes: 35584
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

r, g, b, n = map(int, read().split())
cnt = 0
for i in range(n // r + 1):
    for j in range(n // g + 1):
        check = n - (r * i + g * j)
        if check >= 0:
            if check % b == 0:
                cnt += 1
        else:
            break
print(cnt)


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

int main(){
    int A, B, C, K;
    int sum = 0;
    vector<int> S;
    cin >> A >> B >> C >> K;
    
    if(K > A + B){
        sum = A - (K - A - B);
    }
    else if(K > A) sum = A;
    else sum = K;

    cout << sum << endl;
}

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

int main(){
  int K,T;
  cin >> K >> T;
  vector<int> a(T);
  for(int i=0;i<T;i++)  cin >> a.at(i);

  sort(a.begin(),a.end());
  int sum=0;
  for(int i=0;i<T-1;i++)  sum+=a.at(i);
  cout << max(0,a.at(T-1)-sum-1) << endl;

  return 0;
}

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return move(x); }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto A=in();
	auto B=in<double>();
	ll C = (B+0.001)*100ll;
	ll D = A*C;
	D /= 100ll;
	out(D);
	return 0;
}


Measured memory_bytes: 3748
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
 
int main(){
	int n;
	int count=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=1;i<n;i++){
		int temp=a[i];
		for(int j=i-1;j>=0;j--){
			if(temp<a[j]){
				a[j+1]=a[j];
				a[j]=temp;
			}
			else 
				break;
		}
	}
	// for(int k=0;k<n;k++)
	// 	cout<<a[k]<<" ";
	for(int i=0;i<n-2;i++){
		for (int j=i+1;j<n-1;j++){
			// if(i==j)
			// 	continue;
				for(int k=j+1;k<n;k++){
				if(a[i]+a[j]>a[k]){
					if(a[i]+a[k]>a[j]){
						if(a[j]+a[k]>a[i]){
							count++;
						}
						else 
							break;
					}
					else 
						break;
				}
				else
					break;
			}	
		}	
	}
	cout<<count<<endl;
	return 0;  
}

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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define vi vector<int>

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)

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

const int MAX_N = 100005;

void Main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  int ans = 1000000000;
  sort(h.begin(), h.end());
  rep(i, n-k+1) ans = min(ans, h[i+k-1] - h[i]);
  cout << ans << endl;
}

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


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

int main()
{
	int A,B,X;
	cin >> A >> B >> X;
	if (A <= X && X <= A+B)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
s = min(a)
b = max(a)
si = a.index(s)
bi = a.index(b)
op = []
if s + b >= 0:
    for i in range(n):
        if a[i] < 0:
            op.append((bi+1, i+1))
    for i in range(n-1):
        op.append((i+1, i+2))
else:
    for i in range(n):
        if a[i] > 0:
            op.append((si+1, i+1))
    for i in reversed(range(n-1)):
        op.append((i+2, i+1))
print(len(op))
for x, y in op:
    print(x, y)

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL w, h, u[2], ans;
vector<pair<LL, int>> v;

int main() {
	cin >> w >> h;
	inc(i, w) { int p; cin >> p; v.EB(p, 0); }
	inc(i, h) { int p; cin >> p; v.EB(p, 1); }
	
	sort(ALL(v));
	
	inc(i, v.size()) {
		if(v[i].SE == 0) {
			ans += v[i].FI * (h + 1 - u[1]);
			u[0]++;
		} else {
			ans += v[i].FI * (w + 1 - u[0]);
			u[1]++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 6512
N=int(input())

def dfs(s):
    if s=="":
        t=0
    else:
        t=s   
    if int(t)>N:
        return 0
    if all(s.count(c)>0 for c in "753"):
        ret=1
    else:
        ret=0
        
    for c in "753":
        ret+=dfs(c+s)
    return ret

print(dfs(""))

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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 MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    vector<ll> b = a;
    sort(ALL(b));

    auto f = b.begin();
    int ans = 0;
    REP(i, n) {
        auto itr = lower_bound(ALL(b), a[i]);
        if (i % 2 == 0) {
            if ((int)distance(f, itr) % 2 != 0) {
                ans++;
            }
        } else {
            if ((int)distance(f, itr) % 2 != 1) {
                ans++;
            }
        }
    }
    cout << ans / 2 << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <utility>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

int main(void) {
    string s;
    cin >> s;
    Int length = (Int)s.length();
    Int result = length;
    Int count = 0;
    for (Int i = 0; i < length; ++i) {
        if (s[i] == '0') {
            count++;
        } else {
            count--;
        }
    }
    if (count < 0) {
        count *= (-1);
    }
    result -= count;
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define int long long
#define pi acos(-1)
const int INF = 1e18L + 5;
#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++)
using namespace std;

signed main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);

    double a, b, x;
    cin >> a >> b >> x;
    double ans;
    // 素直に場合分けをします
    if (a * a * b >= 2 * x) {
        ans = atan(a*b*b/2.0000000000/x); 
    }
    else {
        ans = atan(2.0000000000*(a*a*b-x)/a/a/a);
        
    }
    ans *= 180.0000000000/pi;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))
b=[0]*9
while a:
  kazu=a.pop(0)
  if 1<=kazu < 400:
    b[0]=1
  elif kazu < 800:
    b[1]=1
  elif kazu < 1200:
    b[2]=1
  elif kazu < 1600:
    b[3]=1
  elif kazu < 2000:
    b[4]=1
  elif kazu < 2400:
    b[5]=1
  elif kazu < 2800:
    b[6]=1
  elif kazu < 3200:
    b[7]=1
  elif kazu >=3200:
    b[8]+=1
coma=b[8]
comi=0
for i in b[:8]:
  if i > 0:
    comi+=1
if coma > 0 and comi ==0:
  comi =1
if comi+coma >= n:
  maxgo=n
else:
  maxgo=comi+coma
print(comi,maxgo)

Measured memory_bytes: 9144
#include <stdio.h>

int main(){

	int n, i, j;
	int b, f, r, v;
	int floor[10][3*4];

	for( i=0; i<(3*4); i++ ){
		for( j=0; j<10; j++ ){
			floor[j][i] = 0;
		}
	} 
	
	scanf( "%d", &n );


	for( i=0; i<n; i++ ){
		scanf( "%d %d %d %d", &b, &f, &r, &v );
		floor[r-1][(3*(b-1))+f-1] += v;
	}



	for( i=0; i<(3*4); i++ ){
		for( j=0; j<10; j++ ){
			printf(" %d", floor[j][i] );
		}

		printf( "\n" );
		
		if( i%3 == 2 && i != 11) 
			printf( "####################\n" );
	}



	return 0;

}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a ,b ,c,d,e,k;
  cin >> a >> b >> c >>d >>e >>k;
  if( e - a <=k){
    cout << "Yay!" ;
  }
  else{
    cout << ":(";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int n,t,a;cin >> n >> t >> a;
    double diff = 1e9;
    double ans;

    for(int i = 0; i < n; i++){
        double h; cin >> h;
        double tmp = abs(a - (t - h*0.006));
        if(diff >= tmp){
            diff = tmp;
            ans = i;
        }
    }
    cout << ans + 1<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T,class U> istream& operator >> (istream &is, pair<T,U> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct { template <typename T> operator T() { T x; cin >> x; return x; } } IN;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int W=IN,H=IN;
    vector<pii> r(H+W);
    REP(i,W) {
        int p=IN;
        r[i]={p,0};
    }
    REP(i,H) {
        int q=IN;
        r[W+i]={q,1};
    }
    sort(ALL(r));
    int a=W+1,b=H+1;
    int ans=0;
    REP(i,W+H) {
        if(r[i].second) {
            ans+=a*r[i].first;
            b--;
        } else {
            ans+=b*r[i].first;
            a--;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3456
#include<stdio.h>
int main()
{
    int a,b,c;
    // スペース区切りの整数の入力
    scanf("%d %d %d",&a,&b,&c);
    // 出力
	if(a==b&&b==c){
  	printf("Yes\n");
    }else{  
    printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>


using namespace std;
/*
 入力1までの日数　−　入力2までの日数
*/

int day_per_month[13] ={0,31, 28, 31, 30, 31, 30 ,31, 31, 30, 31, 30, 31};
int day_per_month_leap_year[13] ={0,31, 29, 31, 30, 31, 30 ,31, 31, 30, 31, 30, 31};

int main(){

    int y1, m1, d1, y2, m2, d2;
    while(cin>>y1>>m1>>d1>>y2>>m2>>d2){
        if(y1<0||m1<0||d1<0||y2<0||m2<0||d2<0){
            break;
        }
        
        long long int ans1=0, ans2=0;
        
        /*--------------------------*/
        for(int i=1; i<y1; i++){
            bool flag=false;
            if(i%4==0){
                flag = true;
                if(i%100==0){
                    flag = false;
                    if(i%400==0){
                        flag = true;
                    }
                }
            }
            
            if(flag){
                ans1+=366;
            }else{
                ans1+=365;
            }
        }
        
        bool flag=false;
        if(y1%4==0){
            flag = true;
            if(y1%100==0){
                flag = false;
                if(y1%400==0){
                    flag = true;
                }
            }
        }
        
        for(int i=1; i<m1; i++){
            if(flag){
                ans1+=day_per_month_leap_year[i];
            }else{
                ans1+=day_per_month[i];
            }
        }
        
        ans1+=d1;
        
        /*--------------------------------*/
        for(int i=1; i<y2; i++){
            bool flag=false;
            if(i%4==0){
                flag = true;
                if(i%100==0){
                    flag = false;
                    if(i%400==0){
                        flag = true;
                    }
                }
            }
            
            if(flag){
                ans2+=366;
            }else{
                ans2+=365;
            }
        }
        
        flag= false;
        if(y2%4==0){
            flag = true;
            if(y2%100==0){
                flag = false;
                if(y2%400==0){
                    flag = true;
                }
            }
        }
        
        for(int i=1; i<m2; i++){
            if(flag){
                ans2+=day_per_month_leap_year[i];
            }else{
                ans2+=day_per_month[i];
            }
        }
        
        ans2+=d2;
        
        /*--------------------------*/
        
        cout<<ans2-ans1<<endl;
        
    }
}

Measured memory_bytes: 1156