akhauriyash/Code-Regression huggingface dataset:
import sys

def solve():
    input = sys.stdin.readline
    A, B, C, X, Y = map(int, input().split())
    if X > Y:
        X, Y = Y, X
        A, B = B, A
    C *= 2
    AB = A * X + B * Y
    allC = C * Y
    CB = C * X + B * (Y - X)
    print(min([AB, allC, CB]))
    
    
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
import java.util.*;
import java.lang.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        char ch[] = line.toCharArray();
        for(int i = ch.length - 1; i >= 0; i--){
            System.out.print(ch[i]);
        }
        System.out.println();
    }
}


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

typedef long long ll;

#ifndef YUKININO
#define cerr if (false) cerr
#endif
#define debug(x) cerr << "[" << #x": " << x << "]" << endl
template <class T, class U> ostream& operator<< (ostream& out, const pair<T, U> &x) { return out << x.first << " " << x.second; }
template <class T> ostream& operator<< (ostream& out, const vector<T> &vec) { for (auto i = vec.begin(); i != vec.end(); i++) { if (i != vec.begin()) out << " "; out << *i; } return out; }

void solve();
int main() {
#ifdef YUKININO
  freopen("Testing.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  int T = 1;
  // cin >> T;
  while (T--) solve();
  debug((clock() * 1.0 / CLOCKS_PER_SEC));
}
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------

const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;

void solve() {
  string s;
  while (cin >> s) {
    stack<char> S;
    int n = s.size(), ans = 0;
    for (int i = 0; i < n; i++) {
      if (S.empty() || S.top() == s[i]) {
        S.push(s[i]);
      } else {
        ans += 2;
        S.pop();
      }
    }
    cout << ans << "\n";
  }
}

Measured memory_bytes: 512
#include <stdio.h>

int main()
{

        int H, W;

        while(1) {
                scanf("%d %d", &H, &W);

                if (H == 0 && W == 0) {
                        break;
                }

                for (int i = 0; i < H; i++) {
                        for (int j = 0; j < W; j++) {
                                if ((j + i) % 2 == 0) {
                                        printf("#");
                                } else {
                                        printf(".");
                                }
                        }
                        printf("\n");
                }
                printf("\n");

        }
        return 0;
}


Measured memory_bytes: 2604
main :: IO ()
main = do
    line <- getLine
    case (words line) of
      ["0", "0"] -> return ()
      [h, w] -> do
          printFrame (read h :: Int) (read w :: Int)
          main

printFrame :: Int -> Int -> IO ()
printFrame h w = do
    putStrLn $ replicate w '#'
    mapM_ putStrLn $ replicate (h-2) ("#" ++ (replicate (w-2) '.') ++ "#")
    putStrLn $ replicate w '#'
    putStrLn ""

Measured memory_bytes: 3940
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;
  int sum[10000] = {};
  for (int i = 0; i < n; ++i)
  {
    for (int j = i + 1; j < n; ++j)
    {
      int t = abs(j - i);
      t = min({t, abs(i - x) + 1 + abs(j - y), abs(j - x) + 1 + abs(i - y)});
      sum[t]++;
    }
  }
  for (int i = 1; i < n; ++i)
  {
    cout << sum[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = 'abcdefghijklmnopqrstuvwxyz'
# a = 'zabcdefghijklmnopqrstuvwxy'
ans = ''
# n-=1
while n > 0:
    # print(n,ans)
    i = (n-1)%26
    n = (n-1)//26
    ans = a[i] + ans
    # print(n,i,a[i],ans)
# ans = a[n] + ans
# print(n,n,a[n],ans)
print(ans)


Measured memory_bytes: 9100
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n) - 1; i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}

template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); 
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    forn(i, 0, n) cin >> a[i];
    forn(i, 0, n) cin >> b[i];
    forn(i, 0, n) cin >> c[i];
    sort(all(a));
    sort(all(b));
    sort(all(c));
    vector<ll> ba(n), aa(n);
    forn(i, 0, n) {
        auto it = lower_bound(all(a), b[i]);
        ba[i] = int(it - a.begin());
    }
    trace(ba);
    forn(i, 1, n) ba[i] += ba[i - 1];
    forn(i, 0, n) {
        auto it = lower_bound(all(b), c[i]);
        int x = int(it - b.begin());
        aa[i] = x == 0 ? 0 : ba[x - 1];
    }
    ll ans = 0;
    forn(i, 0, n) ans += aa[i];
    cout << ans << '\n';
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    double n, m, d; cin >> n >> m >> d;
    if(d == 0){
        cout << (m-1)/n << endl;
    }else{
        cout << 2*(n-d)/(n*n)*(m-1) << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>

#define MAXN 100000

using namespace std;

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

    int n, k;
    int c[MAXN], h[MAXN];

    cin >> n >> k;
    for(int i=0 ; i<n ; i++) cin >> h[i];
    c[0] = 0;
    for(int i=1 ; i<n ; i++)
    {
        c[i] = c[i-1] + abs(h[i] - h[i-1]);
        for(int j=2 ; j<=k && j<=i ; j++)
        {
            c[i] = min(c[i], c[i-j] + abs(h[i] - h[i-j]));
        }
    }
    cout << c[n-1];

    return 0;
}

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

/*****All definitions*******/
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int>
#define vs vector<string>
#define mp make_pair
/***************************/

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (true)
	{
		c = c - b;
		if (c <= 0)
		{
			cout << "Yes";
			break;
		}
		a = a - d;
		if (a <= 0)
		{
			cout << "No";
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3648
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        N: usize,
        A: [i64; N],
    }

    if N == 1 {
        println!("1");
        return;
    }

    let mut ans = 1;
    let mut is_growing = None;
    let mut prev = A[0];

    for i in 1..N {
        let v = A[i];
        match is_growing {
            None => {
                if prev > v {
                    is_growing = Some(false);
                    prev = v;
                } else if prev < v {
                    is_growing = Some(true);
                    prev = v;
                }
            }
            Some(true) => {
                if prev > v {
                    ans += 1;
                    prev = v;
                    is_growing = None;
                } else {
                    prev = v;
                }
            }
            Some(false) => {
                if prev < v {
                    ans += 1;
                    prev = v;
                    is_growing = None;
                } else {
                    prev = v;
                }
            }
        }
    }

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


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
long double EPS=1E-8;
////////////////////////////////////////

int main(){
    ll n,m;cin>>n>>m;
    ll x[m];rep(i,0,m-1)cin>>x[i];
    sort(x,x+m);
    ll y[m-1];rep(i,0,m-2)y[i]=x[i+1]-x[i];
    sort(y,y+m-1);
    ll ans=0;
    rep(i,1,m-n)ans+=y[i-1];
    cout<<ans<<endl;
    
    
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

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

    vvl v(n, vl(3));
    rep(i, n) {
        rep(j, 3) {
            cin >> v[i][j];
        }
    }

    vvl dp(n+1, vl(3));  // dp[i][j] : i日目にjを行ったときの幸福度の総和の最大値
    rep(i, n) {
        rep(j, 3) {
            rep(k, 3) {
                if(j != k) {
                    chmax(dp[i+1][k], dp[i][j] + v[i][k]);
                }
            }
        }
    }
    
    ll ans = 0;
    rep(j, 3) {
        chmax(ans, dp[n][j]);
    }

    out(ans);
    re0;
}

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

vector<int> z_algorithm(char *s, int n) {
  vector<int> a(n);
  a[0] = n;
  int i, j;
  i = 1; j = 0;
  while (i < n) {
    while (i+j < n && s[j] == s[i+j]) ++j;
    a[i] = j;
    if (j == 0) { ++i; continue;}
    int k = 1;
    while (i+k < n && k+a[k] < j) {
      a[i+k] = a[k];
      ++k;
    }
    i += k; j -= k;
  }
  return a;
}

int cal_max(char *s, int n) {
  int maxlen = 0;
  for (int i = 0; i < n; ++i) {
   	vector<int> a = z_algorithm(s+i, n-i);
    for (int j = 0; j < n-i; ++j) {
      if (a[j] <= j) maxlen = max(maxlen, a[j]);
    }
  }
  return maxlen;
}

int main() {
  int n;
  cin >> n;
  char s[n];
  rep(i, n) cin >> s[i];
  cout << cal_max(s, n) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
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 signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
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, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vi a(n, 0), b(n, 0);
    REP(i, n) {
        if (i != 0) a[i] += a[i-1];
        a[i] += (s[i] == 'W');
    }
    REPR(i, n-1) {
        if (i != n-1) b[i] += b[i+1];
        b[i] += (s[i] == 'E');
    }
    int ans = min(b[0], a[n-1]);
    REPF(i, 1, n - 1) {
        chmin(ans, a[i-1]+b[i+1]);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 5396
#include <bits/stdc++.h> // Tomasz Nowak
using namespace std;     // XIII LO Szczecin
using LL = long long;    // Poland
#define FOR(i, l, r) for(int i = (l); i <= (r); ++i)
#define REP(i, n) FOR(i, 0, (n) - 1)
template<class T> int size(T &&x) {
	return int(x.size());
}
template<class A, class B> ostream& operator<<(ostream &out, const pair<A, B> &p) {
	return out << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
	out << '{';
	for(auto it = x.begin(); it != x.end(); ++it)
		out << *it << (it == prev(x.end()) ? "" : ", ");
	return out << '}';
}
void dump() {}
template<class T, class... Args> void dump(T &&x, Args... args) {
	cerr << x << ";  ";
	dump(args...);
}
#ifdef DEBUG
  struct Nl{~Nl(){cerr << '\n';}};
# define debug(x...) cerr << (strcmp(#x, "") ? #x ":  " : ""), dump(x), Nl(), cerr << ""
#else
# define debug(...) 0 && cerr
#endif
mt19937_64 rng(0);
int rd(int l, int r) {
	return uniform_int_distribution<int>(l, r)(rng);
}
// end of templates

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

	int n;
	cin >> n;

	vector<vector<int>> answer(n, vector<int>(n, -1));

	function<void (vector<int>&, int)> solve = [&](vector<int> &vertices, int id) {
		if(size(vertices) == 1)
			return;
		vector<int> lhalf, rhalf;
		for(int v : vertices)
			if(size(lhalf) == size(rhalf))
				lhalf.emplace_back(v);
			else
				rhalf.emplace_back(v);

		solve(lhalf, id + 1);
		solve(rhalf, id + 1);

		for(int v : lhalf)
			for(int u : rhalf)
				answer[min(v, u)][max(v, u)] = id;
	};

	vector<int> perm(n);
	iota(perm.begin(), perm.end(), 0);
	solve(perm, 1);

	REP(v, n) {
		FOR(u, v + 1, n - 1)
			cout << answer[v][u] << ' ';
		cout << '\n';
	}
}


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

//Common
using namespace std;using f64 = double;using i64=long long;using u64=unsigned long long;
template<typename T> using Arr=vector<T>;template<typename T> using Func=function<T>;template<typename T> using Str=basic_string<T>;
#define hfor(v, s, e) for(int v=(s);(s)<=v&&v<(e);++v)//half-opened range
#define hfori(v, s, e) for(int v=(e)-1;(s)<=v&&v<(e);--v)//inversion
#define hforo(v, s, e) int v=(s);for(;(s)<=v&&v<(e);++v)//out declaration
#define hforoi(v, s, e) int v=(e)-1; for(;(s)<=v&&v<(e);--v)
#define cfor(v, s, e) hfor(v,(s),(e)+1)//closed range
#define cfori(v, s, e) hfori(v,(s),(e)+1)
#define cforo(v, s, e) hforo(v,(s),(e)+1)
#define cforoi(v, s, e) hforoi(v,(s),(e)+1)
#define rep(v,x) hfor(v,0,(x))
#define repi(v,x) hfori(v,0,(x))
#define repo(v,x) hforo(v,0,(x))
#define all(x) (x).begin(),(x).end()
#define pushb push_back
#define pushf push_front
#define popb pop_back
#define popf pop_front
#define empl emplace
#define emplb emplace_back
#define emplf emplace_front
#define fi first
#define se second
#define cxp constexpr
#define PQMIN(...) std::priority_queue<__VA_ARGS__,Arr<__VA_ARGS__>,greater<__VA_ARGS__>>
template<class... A>
auto ARR(auto n, A&&...a){
	if constexpr(sizeof...(a)==0) return n;
	else return vector(n,ARR(a...));
}

//Math
template<typename T> cxp T inf() { return numeric_limits<T>::max() / 2; }
template<typename T> inline T sq(T x){return x*x;}
cxp int lgc(int x){return 64-__builtin_clzll(x-1);}
cxp int lgf(int x){return 63-__builtin_clzll(x);}
int rd(int lb, int ub){static mt19937 rng(time(0)^i64(new int)); return uniform_int_distribution<int>(lb, ub-1)(rng);}
int rd(int ub=inf<int>()){return rd(0,ub);}
const f64 pi=acosl(-1), eps=1e-10;

//IO
template<typename T>ostream& operator<<(ostream& s, const Arr<T>& a) {for(auto i:a) cout<<i<<' '; return s;}
auto cinint(){i64 x;cin>>x;return x;}
auto cinchr(){char x;cin>>x;return x;}
auto cinints(int n){Arr<i64> a(n);for(auto&i:a)cin>>i;return a;}
#ifndef DEBUG
	//#pragma GCC optimize ("Ofast") //somtimes it become more slower
	auto __PRE_RUN__=(ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),(cout<<fixed<<setprecision(11)), 0);
#endif

//Misc
int sz(const auto& x){return x.size();}
auto split(auto s, auto p){
	Arr<decltype(s)> ret;
	auto it1=s.begin();
	for(auto it2=it1; (it2 = find(it1,s.end(),p)) != s.end(); it1=it2+1)
		ret.pushb({it1, it2});
	ret.pushb({it1,s.end()});
	return ret;
}
template<typename T> T rev(const T& a){return {a.rbegin(),a.rend()};}
Arr<int> range(int n){ Arr<int> ret(n); rep(i,n)ret[i]=i; return ret; }
struct defer{ defer(auto f):f(f){} ~defer(){f();} function<void()> f; };
#define defer(x) auto _##__COUNTER__ = defer([&](){x;});
#define lam(expr, ...) [&](__VA_ARGS__){return expr;}
#define reduce accumulate

#define endl '\n'//not interactive?
#define int i64//MLE?
using pint = pair<int,int>;
using tint = tuple<int,int,int>;

signed main(){
	int l,r,d; cin>>l>>r>>d;
	int ans=0;
	cfor(i,l,r)
		if(i%d==0)
			ans++;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

int N,M;
cin>>N>>M;
char A[N][N];
char B[M][M];
rep(i,N){
    rep(k,N){
        cin>>A[i][k];
    }
}

rep(i,M){
    rep(k,M){
        cin>>B[i][k];
    }
}

int y=0;
rep(i,N-M+1){
    rep(k,N-M+1){
        bool yes=true;
            rep(y,M){
                rep(x,M){

                    if(A[i+y][k+x]!=B[y][x]){
                    yes=false;
                    break;
                    }        
                }
            }
        if(yes){
            cout<<"Yes"<<endl;
            return 0;
        }

    }
}
cout<<"No"<<endl;
 return 0;
}
/*
3 2
#.#
.#.
#.#
#.
.#

Yes


4 1
....
....
....
....
#

No

*/


Measured memory_bytes: 256
fn b() {
    input! {
        n: usize,
        a: [u32; n]
    }

    let c = a.iter().step_by(2)
        .filter(|s| *s % 2 != 0).count();
    println!("{}", c);
}

use proconio::{input, marker::Chars};

fn main() {
    b();
}

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

r, g, b, n = map(int, input().split())

count = 0

for i in range(n//r+1):
    for j in range((n-i*r)//g+1):
        if (n - i*r - j*g) % b == 0:
            count += 1

# やってはいけないやつ
# for i in range(0, n+1):
#     for j in range(0, n+1):
#         for k in range(0, n+1):
#             if r*i + g*j + b*k == n:
#                 count += 1

print(count)


Measured memory_bytes: 2940
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,no-stack-protector,fast-math")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 4 * N + 5;

int head[N], nxt[M], to[M], typ[M], ne, n;

void init(){
    ne = 0;
    memset(head, -1, n * sizeof head[0]);
}

void addEdge(int f, int t, int ty){
    to[ne] = t;
    typ[ne] = ty;
    nxt[ne] = head[f];
    head[f] = ne++;
}

void addBiEdge(int a, int b, int ty){
    addEdge(a, b, ty);
    addEdge(b, a, ty);
}

struct state{
    int dis;
    set<int> typs;
};

state node[N];

bool inQ[N];

int dij(){
    priority_queue<pair<int, int> , vector<pair<int, int>>, greater<pair<int, int>>> pq;
    pq.emplace(0, 0);

    for(int i = 0 ; i < n ; ++i)
        node[i].dis = (int)1e9;

    node[0].dis = 0;
    inQ[0] = true;

    int cst, v;

    while(pq.size()){
        auto top = pq.top();
        pq.pop();

        int u = top.second;
        int d = top.first;
        inQ[u] = false;


        if(node[u].dis < d)continue;

        for(int e = head[u] ; ~e ; e = nxt[e]){
            v = to[e];
            cst = (node[u].typs.find(typ[e]) == node[u].typs.end());

            if(node[u].dis + cst < node[v].dis){
                inQ[v] = true;
                node[v] = {node[u].dis + cst, {typ[e]}};
                pq.emplace(node[v].dis, v);
            }

            else if(node[u].dis + cst == node[v].dis){
                if(node[v].typs.find(typ[e]) != node[v].typs.end())continue;
                node[v].typs.emplace(typ[e]);
                if(!inQ[v])
                    pq.emplace(node[v].dis, v), inQ[v] = true;
            }
        }

    }

    if(node[n - 1].dis > n)
        node[n - 1].dis = -1;
    return node[n - 1].dis;
}

int main(){
    IO;
    int m;
    scanf("%d %d", &n, &m);
    init();
    while(m--){
        int u, v, ty;
        scanf("%d %d %d", &u, &v, &ty);
        addBiEdge(--u, --v, ty);
    }
    printf("%d\n", dij());
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;


int a[1010];
int b[1010];
int vote[1010];

int main(void){
	int n,m;
	cin >> n >> m;
	rep(i,n) cin >> a[i];
	rep(i,m) cin >> b[i];


	rep(i,m)rep(j,n) if(a[j]<=b[i]) vote[j]++,j=n;

	int cmax=0,ans=-1;
	rep(i,n) if(vote[i]>cmax) cmax=vote[i],ans=i+1;
	cout << ans << endl;
}

Measured memory_bytes: 1172
N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
sum_A1 = [0]
sum_A2 = [0]
for i in range(N):
    sum_A1.append(sum_A1[i]+A1[i])
    sum_A2.append(sum_A2[i]+A2[i])
max = 0
for i in range(1,N+1):
  sum = sum_A1[i] + sum_A2[N] - sum_A2[i-1]
  if sum > max:
    max = sum
print(max)

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

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

  bool d = false;
  std::vector<int> a(n, 10);
  for (int i = 0; i < m; ++i) {
    int s, c;
    std::cin >> s >> c;
    if (a.at(s - 1) != 10 && a.at(s - 1) != c) {
      d = true;
    }
    a.at(s - 1) = c;
  }

  if (d) {
    std::cout << -1 << std::endl;
    return 0;
  }

  if (n == 1 && a.at(0) == 0) {
    std::cout << 0 << std::endl;
    return 0;
  }

  if (a.at(0) == 0) {
    std::cout << -1 << std::endl;
    return 0;
  }

  for (int i = 0; i < n; ++i) {
    if (a.at(i) == 10) {
      if (n != 1 && i == 0) {
        std::cout << 1;
      } else {
        std::cout << 0;
      }
    } else {
      std::cout << a.at(i);
    }
  }
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 256
s = gets.chomp
s1 = s[0..1].to_i
s2 = s[2..3].to_i

if s1.between?(1,12) && s2.between?(1,12)
    print "AMBIGUOUS"
elsif s2.between?(1,12)
    print "YYMM"
elsif s1.between?(1,12)
    print "MMYY"
else
    print "NA"
end

Measured memory_bytes: 1788
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
	static BufferedReader br;

	public static void main(String[] args) {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			String S = br.readLine();
			long length = S.length();
			long sum = 0;
			for (int i = 0; i < length; i++) {
				long left = (long) Math.ceil(Math.pow(2, i - 1));
				for (int j = i + 1; j < length + 1; j++) {
					String s = S.substring(i, j);
					long n = (long) Long.valueOf(s);
					long right = (long) Math.ceil(Math.pow(2, length - j - 1));
					sum += left * n * right;
				}
			}
			System.out.println(sum);
		} catch (Exception e) {
			System.err.println("Error : " + e.getMessage());
		}
	}
}


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

using namespace std;

typedef long long ll;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vp vector<pair<int, int>>
#define graph vector< vector<int> >
#define vs vector<string>

int x;
int main() {

  //ios::sync_with_stdio(false);
  //cin.tie(0);
  int n;
  int d;
  sf(n);sf(d);
  float e;
  vector<vector<float> > a(n);
  in(i,n)
  {
      in(j,d)
      {
          sf(e);
          a[i].push_back(e);
      }
  }
  int count=0;
  for(int i=0;i<n;i++)
  {
      for(int j=i+1;j<n;j++)
      {
          float sum=0;
          for(int k=0;k<d;k++)
          {
              sum+=((a[i][k]-a[j][k])*(a[i][k]-a[j][k]));
          }
          sum=sqrt(sum);
          //pf(sum);
          if(sum==floor(sum))
            count++;
      }
  }
  pf(count);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+87, M=1e9+7;
int c[N],la[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> c[i];
    n = unique(c,c+n) - c;
    int*a=c-1,dp=1;
    for (int i = 1; i <= n; ++i) {
        (la[a[i]] += dp) %= M;
        dp = la[a[i]];
    }
    cout << dp << endl;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var num = int.Parse(Console.ReadLine());
        var str = Console.ReadLine();

        var dict = new Dictionary<int, char>();
        var i = 1;

        var rList = new List<int>();
        var gList = new List<int>();
        var bList = new List<int>();

        long ans = 0;

        foreach (var c in str)
        {
            dict.Add(i, c);

            if(c == 'R')
            {
                rList.Add(i);
            }
            if (c == 'G')
            {
                gList.Add(i);
            }
            if (c == 'B')
            {
                bList.Add(i);
            }
            i++;
        }

        foreach(var r in rList)
        {
            foreach(var g in gList)
            {
                var exCount = 0;
                if (r - g > 0)
                {
                    //rの方が大きい
                    if (dict.ContainsKey(r + (r - g)) && dict[r + (r - g)] == 'B')
                    {
                        exCount += 1;
                    }

                    if ((r - g) % 2 == 0 && dict[r - ((r - g) / 2)] == 'B')
                    {
                        exCount += 1;
                    }

                    if (dict.ContainsKey(g - (r - g)) && dict[g - (r - g)] == 'B')
                    {
                        exCount += 1;
                    }
                }
                else
                {
                    if (dict.ContainsKey(g + (g - r)) && dict[g + (g - r)] == 'B')
                    {
                        exCount += 1;
                    }

                    if ((g - r) % 2 == 0 && dict[g - ((g - r) / 2)] == 'B')
                    {
                        exCount += 1;
                    }

                    if (dict.ContainsKey(r - (g - r)) && dict[r - (g - r)] == 'B')
                    {
                        exCount += 1;
                    }
                }

                ans = ans + bList.Count - exCount;
            }
        }

        Console.WriteLine(ans);
        Console.ReadKey();

    }
}


Measured memory_bytes: 18004
import math
import time

MOD = 10 ** 9 + 7

n, a, b = list(map(int, input().split(' ')))

start = time.time()
all_combi = pow(2, n, MOD) - 1


def calc_combi(m):
    x = 1
    for i in range(m):
        x = (x * (n - i)) % MOD
    return x * pow(math.factorial(m), MOD - 2, MOD) % MOD


print((all_combi - (calc_combi(a) + calc_combi(b))) % MOD)


Measured memory_bytes: 5428
//test https://blog.csdn.net/rising_shit/article/details/80739593
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 2005
#define _x1 x1
#define _x2 x2
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int n,m;
ll v;
int fa[maxn],id[maxn],x[maxn],y[maxn];
ll w[maxn];
int getfa(int now)
{
	return fa[now]==now ? now : fa[now]=getfa(fa[now]);
}
int cmp(int i,int j)
{
	return w[i]<w[j];
}
ll kruskal(int now)
{
	for(int i=1;i<=n;i++) fa[i]=i;
	ll ans=0;
	if(now)
		fa[x[now]]=y[now],ans+=w[now];
	for(int i=1;i<=m;i++)
	{
		int pos=id[i];
		int x1=getfa(x[pos]),y1=getfa(y[pos]);
		if(x1!=y1)
		{
			ans+=w[pos];
			fa[x1]=y1;
		}
	}
	return ans;
}
ll quickpow(ll p,ll k)
{
	ll ans=1;
	while(k)
	{
		if(k&1)
			ans=(ans*p)%mod;
		p=(p*p)%mod;
		k>>=1;
	}
	return ans;
}
int main()
{
	scanf("%d%d%lld",&n,&m,&v);
	for(int i=1;i<=m;i++)
		scanf("%d%d%lld",&x[i],&y[i],&w[i]),id[i]=i;
	sort(id+1,id+1+m,cmp);
 
	ll temp=kruskal(0);
 
	if(temp>v)
	return printf("0\n"),0;
 
	if(temp==v)
	{
		int cnt1=0,cnt2=0;
		for(int i=1;i<=m;i++)
		{
			if(kruskal(i)==temp)
				cnt1++;
			else
				cnt2++;
		}
		ll res1=(quickpow(2,cnt1)-2+mod)%mod;
		ll res2=quickpow(2,cnt2)%mod;
		return printf("%lld\n",res1*res2%mod),0;
	}
	else
	{
		int cnt1=0,cnt2=0;
		for(int i=1;i<=m;i++)
		{
			ll res1=kruskal(i);
			if(res1==v)
				cnt1++;
			else if(res1>v)
				cnt2++;
		}
		ll res1=2ll*((quickpow(2,cnt1)-1+mod)%mod)%mod;
		ll res2=quickpow(2,cnt2);
		printf("%lld\n",res1*res2%mod);
	}
}


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

int main() {
    ll c,t; double c1,c2,x,y; cin>>x>>y; 
    c=(4*x-y)/2; t=(y-2*x)/2; c1=(4*x-y)/2; c2=(y-2*x)/2; 
    if (c1<0||c2<0) {cout<<"No";return 0;}
    if (c1==c&&t==c2) {cout<<"Yes";} else {cout<<"No";}
    return 0;
}

Measured memory_bytes: 3684
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int A, P;
		A = scan.nextInt();
		P = scan.nextInt();

		int kakera;

		//リンゴをかけらにする
		kakera = A * 3 + P;

		int applePie = kakera / 2;

		System.out.println(applePie);
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 21844
def main():
    import itertools
    a,b,c,d = map(int,input().split())
    ans = -1 * float('inf')
    if a*c>ans:
        ans = a*c
    if a*d>ans:
        ans = a*d
    if b*c > ans:
        ans = b*c
    if b*d>ans:
        ans = b*d
    print(ans)

if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, MA, MB; scanf("%d %d %d", &N, &MA, &MB);
  vector<int> A(N), B(N), C(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d %d %d", &A[i], &B[i], &C[i]);
  }
  vector<vector<vector<int>>> dp(N + 5, vector<vector<int>>(405, vector<int>(405, INF)));
  dp[0][0][0] = 0;
  for (int i = 0; i < N; ++i) {
    for (int a = 0; a <= 400; ++a) {
      for (int b = 0; b <= 400; ++b) {
       // dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a][b]);
        dp[i + 1][a][b] = dp[i][a][b];
        if (a - A[i] >= 0 and b - B[i] >= 0) {
          dp[i + 1][a][b] = min(dp[i][a][b], dp[i][a - A[i]][b - B[i]] + C[i]);
        }
      }
    }
  }

  int ans = INF;
  for (int a = 1; a <= 400; ++a) {
    for (int b = 1; b <= 400; ++b) {
      if (dp[N][a][b] == INF) { continue; }
      if (a * MB == b * MA) {
        ans = min(ans, dp[N][a][b]);
      }
    }
  }
  if (ans == INF) { ans = -1; }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 30336
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  //a
  int a, b, t;
  cin >> a >> b >> t;
  int ans = 0;
  for (int i = a; i <= t; i++) {
    if (i % a == 0) ans += b;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    if ((a < b) && (b < c)) {
        cout << "Yes" << endl;
    }
    
    else {
        cout << "No" << endl;
    }
}


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

#define pb push_back
#define all(a) begin(a), end(a)
#define deb(x) cout << #x << " = " << x << endl
template <typename T> vector<T> readVector(int n) { vector<T> res(n); for (int i = 0 ; i < n ; i++) cin >> res[i]; return res; }

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }

    int ans;

    /// binary search
    int lf = 0;
    int rg = 1e9;

    while(rg - lf > 1) {
        int mid = (rg + lf)/2;
        int cnt = 0;
        for(int i=0; i<n; i++) {
            if(a[i] > mid) {
                cnt += (a[i]-1)/mid;
            }
        }
        if(cnt <= k) {
            rg = mid;
        } else {
            lf = mid;
        }
    }

    cout << rg << endl;

    return 0;
}


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

int main(){
    long long n, x;
    cin >> n >> x;
    vector<long long> a(n);

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

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

    long long count = 0;
    for(long long i = 0; i < n; i++){
        if(i == n-1){
            if(x == a[i]){
                count++;
            }
            continue;
        }

        if(a[i] <= x){
            x -= a[i];
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)

#define MAX 1001
int n, x;
long long a[MAX];
long long ans;

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  scanf("%d", &n);
  loop(n) {
    scanf("%d", &x);
    a[x]++;
  }
  rep(i, 0, MAX) rep(j, i + 1, MAX) rep(k, j + 1, MAX) {
    if (k < i + j && i < j + k && j < k + i && a[i] && a[j] && a[k]) {
      ans += a[i] * a[j] * a[k];
    }
  }
  rep(i, 0, MAX) rep(j, 0, MAX) {
    if (i == j) continue;
    if (j < i + i && 1 <= a[i] && a[j]) {
      ans += a[i] * (a[i] - 1) * a[j] / 2;
    }
  }
  rep(i, 0, MAX) {
    if (3 <= a[i]) {
      ans += a[i] * (a[i] - 1) * (a[i] - 2) / 6;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <cstdint>
#include <iostream>
#include <set>

int main()
{
	int n, m;
	std::multiset<double> s;
	
	std::cin >> n >> m;
	
	for (int i = 0; i < n; ++i)
	{
		double x;
		std::cin >> x;
		s.insert(x);
	}
	
	for (int i = 0; i < m; ++i)
	{
		double x = *s.rbegin() / 2;
		s.erase(std::prev(s.end()));
		s.insert(x);
	}
	
	int64_t c = 0;
	
	for (double x : s)
	{
		c += static_cast<int64_t>(x);
	}
	
	std::cout << c << std::endl;
	
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n,k; cin >> n >> k;
    int ans = 0;
    rep(i,n){
        int x; cin >> x;
        ans += 2* min(x,k-x);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

l=input()
# print(l)
dp1=[0]*(len(l)+1)
dp2=[0]*(len(l)+1)
dp1[0]=1
for i in range(len(l)):
    if l[i]=="1":
        dp1[i+1]+=dp1[i]*2
        dp2[i+1]+=dp1[i]
        dp2[i+1]+=dp2[i]*3
    else:
        dp1[i+1]+=dp1[i]
        dp2[i+1]+=dp2[i]*3
    dp1[i+1]%=mod
    dp2[i+1]%=mod
# print(dp1)
# print(dp2)
print((dp1[-1]+dp2[-1])%mod)

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

signed main(){

  int q; cin >> q;
  while(q-- > 0){
    string x,y; cin >> x >> y;
    int dp[x.size()+1][y.size()+1];
    fill(dp[0],dp[x.size()+1],0);
    for(int i = 0; i < x.size(); i++){
      for(int j = 0; j < y.size(); j++){
        if(x[i] == y[j]) dp[i+1][j+1] = dp[i][j] + 1;
        else dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
      }
    }
    cout << dp[x.size()][y.size()] << endl;
  }

  return 0;
}



Measured memory_bytes: 7096
n,m,q=map(int,input().split())
data=[[0 for i in range(n+1)] for j in range(n+1)]
for _ in range(m):
    l,r=map(int,input().split())
    data[l][r]+=1

for i in range(n+1):
    for j in range(1,n+1):
        data[i][j]+=data[i][j-1]
for i in range(n+1):
    for j in range(1,n+1):
        data[j][i]+=data[j-1][i]

for _ in range(q):
    x,y=map(int,input().split())
    print(data[y][y]-data[x-1][y]-data[y][x-1]+data[x-1][x-1])


Measured memory_bytes: 57944
/* This Template is property of Pranav Khiste aka desmond_kaneki*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi(x,n) for(ll i=x;i<n;i++)
#define fj(x,n) for(ll j=x;j<n;j++)
#define fit(a,b) for(auto it=a;it!=b;it++)
#define vll vector<ll>
#define pb push_back
#define qll queue<ll>
#define p push
#define mp make_pair
#define fst first
#define snd second
#define pll pair<ll,ll>
#define vpll vector<pll>
#define debug(x) cout<<#x<<' '<<x<<endl;
#define endl '\n'
#define SUP LLONG_MAX
#define INF -1000000000000
#define MAX_N 100005
#define test() ll var;  cin>>var; while(var--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fileio freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);  // use cin cout only!!
main()
{
    ll n;
    cin>>n;
    ll ans=1000*(n/500);
    n=n%500;
    ans+=5*(n/5);
    cout<<ans;
}


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

int main()
{
	string S1,S2;
	cin >> S1 >> S2;
	if (S1[0] == S2[2] && S1[1] == S2[1] && S1[2] == S2[0]) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
    int n;cin >> n;
    vector<bool> dp(1010,0);
    dp[4]=true;dp[7]=true;
    for (int i = 0; i < n; i++) {
        if(dp[i]){
            dp[i+4]=true;
            dp[i+7]=true;
        }
    }
    if(dp[n]) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
o[256],z[256];main(N,S,A,C,s,a,c,r,i){for(;scanf("%d",&N),N;printf("%d %d %d\n",S,A,C)){
	double H=9,h,n=N;
	for(i=0;i<N;i++)scanf("%d",z+i);
	for(s=0;s<16;s++)for(a=0;a<16;a++)for(c=0;c<16;c++){
		for(r=s,i=0;i<N;)o[(z[i++]+(r=(a*r+c)%256))%256]++;
		for(h=i=0;i<256;i++)if(o[i])h-=o[i]/n*log(o[i]/n),o[i]=0;
		if(h+1e-9<H)H=h,S=s,A=a,C=c;
	}
}exit(0);}

Measured memory_bytes: 636
n = gets.to_i

def sum a, n
    return (n * (2 * a + (n - 1) * a)) / 2
end

sum_n = sum(1, n)
sum_3 = sum(3, (n / 3))
sum_5 = sum(5, (n / 5))
sum_15 = sum(15, (n / 15))

puts sum_n - (sum_3 + sum_5 - sum_15)

Measured memory_bytes: 14280
#include <iostream>
#include <math.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	long long int A, B, C;
	cin >> A >> B >> C;
	cout << B + min(A+B + 1, C);
}


Measured memory_bytes: 256
N = int(input())
S = list(input())

T = [0 for _ in range(N+1)]
a = 0
for i, s in enumerate(S):
    if s == '#':
        a += 1
    T[i+1] = a

ans = N
for l in range(N+1):
    a = T[l] + (N-l)-(T[-1]-T[l])
    ans = min(ans, a)


print(ans)

Measured memory_bytes: 12740
"use strict";
const Main = (input) =>{
   let xs = input.trim().split('');
   let xs1 = input.trim().split(' ');
   //console.log(xs.length);
   let result = "";
   for (let i = 0 ; i < xs.length; i++) {
   let pos = xs.length - i - 1;
   result += xs1[0].charAt(pos);
   }
   let count = 0;
   for(let j =0; j< xs.length; j++){
       if(result[j]==xs[j]){
          count++
       }else{
          count += 0
       }
   }
   console.log((xs.length-count)/2);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
from math import ceil
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

A = (10-a%10)%10
B = (10-b%10)%10
C = (10-c%10)%10
D = (10-d%10)%10
E = (10-e%10)%10

gap =10 -  max(A,B,C,D,E)

ans = ceil(a/10)*10+ceil(b/10)*10+ceil(c/10)*10+ceil(d/10)*10+ceil(e/10)*10+gap-10
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int A,B,z;
	if(0<=A&&A<=23){
		if(0<=B&&B<=23)
		{
			scanf("%d%d",&A,&B);
			z=A+B;
			int f=z%24;
			printf("%d",f);
		}
		else
		{
			printf("Error");
		}	
	}
	else
	{
		printf("Error");
	}
	return 0;
}

Measured memory_bytes: 256