akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

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

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// ---------------------
#define INF 922337203685477580
typedef long long ll;

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

  int H[X + 10];
  FOR(i, 1, X + 1) {
    cin >> H[i];
  }

  FOR(i, 1, X + 1) {
    cout << "node " << i << ": key = " << H[i] << ", ";
    int left = 2 * i;
    int right = 2 * i + 1;
    int parent = i / 2;

    if (parent > 0) {
      cout << "parent key = " << H[parent] << ", ";
    }
    if (left <= X) {
      cout << "left key = " << H[left] << ", ";
    }
    if (right <= X) {
      cout << "right key = " << H[right] << ", ";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include<bits/stdc++.h>
 
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
 
const long long INF = 1LL << 60;
 
typedef long long ll;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
int main(){
    int r;
    double pi =  3.14159265;
    cin >> r;
    cout << setprecision(20) <<  double(2 *pi *  r )<< endl;
    return 0;
}

Measured memory_bytes: 3780
#include<cstdio>
#include<cmath>

double x1,y01,x2,y2,x3,y3,xp,yp;

double mennseki (double x_1,double y_1,double x_2,double y_2,double x_3,double y_3)
{
	x_2-=x_1;
	y_2-=y_1;
	x_3-=x_1;
	y_3-=y_1;
	return fabs(x_2*y_3-x_3*y_2)/2;
}

int main()
{

	while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y01,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF)
	{
		if(mennseki(x1,y01,x2,y2,xp,yp)+mennseki(x3,y3,x2,y2,xp,yp)+mennseki(x1,y01,x3,y3,xp,yp)==mennseki(x1,y01,x2,y2,x3,y3))
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
}

Measured memory_bytes: 0
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      hs: [isize; n],
    }
    let mut dp = vec![0; n];

    dp[0] = 0;
    dp[1] = (hs[1]-hs[0]).abs();

    for i in 2..n {
        dp[i] = min(
            dp[i-1] + (hs[i] - hs[i-1]).abs(),
            dp[i-2] + (hs[i] - hs[i-2]).abs(),
        )
    }
    println!("{}", dp[n-1]);
}


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

int main(int argc, const char * argv[]) {
    // insert code here...
    std::string s;
    std::cin >> s;
    int cnt = 0;
    if(s[0] == '1'){
        cnt++;
    }
    if(s[1] == '1'){
        cnt++;
    }
    if(s[2] == '1'){
        cnt++;
    }
    std::cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;
 
//****************************************************                
#define f(var,start,end) for(ll var = start; var <end ; ++var)
#define rf(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define vvll vector<vector<ll>>
#define mtp make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define nl cout<<"\n"
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions
void solve();

int binary(int a[],int l,int r,int find)
{
    if(l>r)
    {
        return -1; 
    }else
    {
        int mid=(l+r)/2;
        if(a[mid]==find)
        {
            return mid+1;
        }else if(a[mid]>find)
        {
            binary(a,l,mid-1,find);
        }else
        {
            binary(a,mid+1,r,find);
        }   
    }   
}

int main()
{
    FAST_IO;
    ll testcases = 1;
    // cin >> testcases; //comment for 1 test case
    while(testcases--)
    {
        solve();
    }
}

void solve()
{
	string s;
	cin>>s;
	if(s[0]>='A' && s[0]<='Z')
	{
		cout<<'A';
		nl;
	}else
	{
		cout<<'a';
		nl;
	}
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; i++){
        cin >> x[i];
    }
    sort(x.begin(), x.end());

    vector<int> y(m - 1);
    for(int i = 0; i < m - 1; i++){
        y[i] = x[i + 1] - x[i];
    }
    sort(y.begin(), y.end());

    int ans = 0;
    for (int i = 0; i < m - n; i++){
        ans += y[i];
    }
    cout << ans << endl;
        
    return 0;
}

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
using ll = long long;
using ld = long double;
using str = string;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<str>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

// Constant variables
const ld PI = (acos(-1));
const ll MOD = 1000000007;

// I/O Asynchronizing
struct __io_async{
    __io_async(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};

int main() {
    str s;
    cin >> s;
    int ans = 0;
    if(s == "SUN") ans = 7;
    else if(s == "MON") ans = 6;
    else if(s == "TUE") ans = 5;
    else if(s == "WED") ans = 4;
    else if(s == "THU") ans = 3;
    else if(s == "FRI") ans = 2;
    else ans = 1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#include <cassert>
#define scan(char_array) scanf("%[^\n]s",&char_array);



int main(){
	ll n;
	IOS
	cin>>n;
	ll a[n];
	ll dp[n][n];
	ll pref[n];
	fo(i,n) cin>>a[i];
	pref[0]=a[0];
	FOR(i,1,n-1){
		pref[i]=pref[i-1]+a[i];
	}
	auto sum=[&](ll l,ll r){
		ll pre;
		if(l>0) pre=pref[r]-pref[l-1];
		else pre=pref[r];
		return pre;


	};
	//dbg("fdfewf");
	for(ll l=n-1;l>=0;l--){
		for(ll r=l;r<=n-1;r++){
			if(l==r) dp[l][r]=0;
			else{
				dp[l][r]=1000000000000000000;
                 ll pre=sum(l,r);
				for(ll j=l;j<r;j++){
		              dp[l][r]=min(dp[l][r],dp[l][j]+dp[j+1][r]+pre);
	            }
	            

			}
		}
	}
	cout<<dp[0][n-1]<<endl;

}



Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
long long dp[100007]={};
long long h[100007]={};
long long c = 1E15;
int main(){
  int N,K;
  cin >> N >> K;
  for(int i=0;i<N;i++) cin >> h[i];
  dp[0]=0;
  for(int i=1;i<N;i++){
    long long minc = c;
    for(int j=1;j<=K;j++){
      if(i-j<0) continue;
      if(dp[i-j]+abs(h[i]-h[i-j])<minc) minc = dp[i-j]+abs(h[i]-h[i-j]);
    }
    dp[i] = minc;
  }
  cout << dp[N-1] << endl;
}


Measured memory_bytes: 1792
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<int, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 30010;
const int MAXK = 16;
const int MAXQ = 200010;

int n, Max, res[MAXN];
vector<II> a[MAXN];

void dfs(int u, int p, int col) {
    int c = 0;
    FOR(i,0,SZ(a[u])-1) {
        int v = a[u][i].FI;
        if (v == p) continue;
        int cs = a[u][i].SE;
        c++;
        if (c == col) c++;
        res[cs] = c;
        Max = max(Max, c);
        dfs(v, u, c);
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n-1) {
        int u, v;
        cin >> u >> v;
        a[u].emplace_back(II(v, i));
        a[v].emplace_back(II(u, i));
    }
    dfs(1,0,0);
    cout << Max << "\n";
    FOR(i,1,n-1) cout << res[i] << "\n";
    return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    ll tot=0,x=0,ans=1e9*n+1;
    rep(i,n)tot+=a[i];
    rep(i,n){
        x+=a[i];
        if(i+1<n)ans=min(ans,abs(tot-2*x));
    }
    cout<<ans<<endl;
    return 0;
}


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


void solve(int N){
    int i = 0;
    while (true) {
        if (i * 1000 >= N) {
            int res = i * 1000 - N;
            cout << res << endl;
            return;
        }
        i++;
    }
}

int main(){
    int N;
    scanf("%d",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3756
N, K = map(int, input().split())
*h, = map(int, input().split())

dp = [0] * N
dp[1] = abs(h[1] - h[0])
for i in range(2, N):
    c = 10**10
    for j in range(i - 1, max(i - K - 1, -1), -1):
        t = abs(h[j] - h[i]) + dp[j]
        if t < c:
            c = t
    dp[i] = c
print(dp[N - 1])


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

typedef long long ll;
typedef long double ld;

#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ll A, B, C, D;

    cin >> A >> B >> C >> D;

    cout << min(A, B) + min(C, D) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        String s = sc.next();

        int r=0,b=0;
        String ans;

        for(int i = 0; i<s.length(); i++) {
            switch (s.charAt(i)) {
                case 'R':
                    r++;
                    break;
                case 'B':
                    b++;
                    break;
            }
        }
        if (r > b) {
            ans = "Yes";
        } else {
            ans = "No";
        }

        System.out.println(ans);

    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	int ans = 100000;
	int n;
	long a[300];
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> a[i];
	for (int i = 1; i <= n; i++) {
		int num = 0;
		while(a[i]%2==0){
			a[i] = a[i] / 2;
			num++;
		}
		ans = min(ans, num);
	}
	cout << ans << endl;
	return 0;
}

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

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

  int N;
  cin >> N;
  vector<int> A(N + 1);
  vector<int> B(N);
  for(int i = 0; i < N + 1; ++i){
    cin >> A.at(i);
  }
  for(int i = 0; i < N; ++i){
    cin >> B.at(i);
  }

  long long ans = 0;
  for(int i = 0; i < N; ++i){
    if(A.at(i) >= B.at(i)){
      ans += B.at(i);
      B.at(i) = 0;
    } else{
      ans += A.at(i);
      B.at(i) -= A.at(i);
    }
    if(A.at(i + 1) >= B.at(i)){
      ans += B.at(i);
      A.at(i + 1) -= B.at(i);
    } else{
      ans += A.at(i + 1);
      A.at(i + 1) = 0;
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
struct data{
	int t,s,d;
	bool operator <(const data& d1)const{
		return t<d1.t;
	}
};

int n,m;
data dat[20001];
bool flag[20001];
int cnt;
int main(void){
	while(1){
		scanf("%d %d",&n,&m);
		if(n+m==0)break;
		memset(flag,false,sizeof(flag));
		flag[1]=true;
		cnt=1;
		for(int i=0;i<m;i++){
			scanf("%d %d %d",&dat[i].t,&dat[i].s,&dat[i].d);
		}
		sort(dat,dat+m);
		for(int i=0;i<m;i++){
			if(flag[dat[i].s] && !flag[dat[i].d]){
				flag[dat[i].d]=true;
				cnt++;
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

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

int main(void) {
	int n, k; cin >> n >> k;
	vector<int> dislike(k);
	for (int i = 0; i < k; i++) cin >> dislike[i];

	for (int x = n; x < 100000; x++) {
		int tmp = x;
		set<int> s;
		while (tmp != 0) {
			s.insert(tmp % 10);
			tmp /= 10;
		}

		bool flag = true;

		for (int i = 0; i < k; i++) {
			if (s.count(dislike[i])) {
				flag = false;
				break;
			}
		}
		if (flag) {
			cout << x << endl;
			break;
		}
	}

	return 0;
}

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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

int memo[201][201][201];

// 最大公約数（a > b）
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

int gcd(int a, int b, int c) {
  if (memo[a][b][c] > 0) return memo[a][b][c];

  int tmp = gcd(a, b);
  return gcd(max(tmp, c), min(tmp, c));
}

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

  ll ans = 0;
  for (int i = 1; i <= K; i++) {
    for (int j = 1; j <= K; j++) {
      for (int k = 1; k <= K; k++) {
        int a[3] = {i, j, k};
        sort(a, a + 3);
        ans += gcd(a[2], a[1], a[0]);
      }
    }
  }

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

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int N, K, R, S, P;
    string T;
    scan(N, K, R, S, P, T);
    vector<vector<ll>> dp(N + 1, vector<ll>(3));
    map<char, int> mp = {{'r', 0}, {'s', 1}, {'p', 2}};
    map<int, int> point{{0, P}, {1, R}, {2, S}};
    rep(i, N) {
        char now = T[i];
        int win  = mp[now];
        rep(j, 3) {
            if (win == j) {
                dp[i][j] = point[j];
            }
        }
        if (0 <= i - K && 0 < dp[i - K][win]) {
            dp[i][win] = 0;
        }
    }
    ll ans = 0;
    rep(i, N) {
        rep(j, 3) { ans += dp[i][j]; }
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 5840
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=LONG_LONG_MAX;
const ll ms=(1e5)+5;





int main()
{
    idfc;
    int n;
    cin>>n;
    int ans = n*(1+(n*(1+n)));
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3556
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

var infty = 1000000000

type DirectedGraphNodeID int

type DirectedGraphNode struct {
	key         DirectedGraphNodeID
	adjacents   []*DirectedGraphNode
	costs       []int
	distance    int
	predecessor *DirectedGraphNode
}

func newDirectedGraph(nNodes int) *DirectedGraph {
	graph := DirectedGraph{}
	graph.nodes = make([]*DirectedGraphNode, nNodes)
	for i := 0; i < nNodes; i++ {
		node := DirectedGraphNode{}
		node.key = DirectedGraphNodeID(i)
		node.distance = infty
		graph.nodes[i] = &node
	}
	return &graph
}

type DirectedGraph struct {
	nodes []*DirectedGraphNode
}

func (g *DirectedGraph) setAdjacency(i, j DirectedGraphNodeID, cost int) {
	g.nodes[i].adjacents = append(g.nodes[i].adjacents, g.nodes[j])
	g.nodes[i].costs = append(g.nodes[i].costs, cost)
}

func (g *DirectedGraph) print() {
	for i := 0; i < len(g.nodes); i++ {
		node := g.nodes[i]
		key := node.key
		strings := []string{strconv.Itoa(int(key)), strconv.Itoa(node.distance)}
		for j := 0; j < len(node.adjacents); j++ {
			nodeJ := fmt.Sprintf("(%v, %v)", node.adjacents[j].key, node.costs[j])
			strings = append(strings, nodeJ)
		}
		fmt.Printf("%v\n", strings)
	}
}

func (g *DirectedGraph) relaxEdge(l, r *DirectedGraphNode, w int) {
	if r.distance > l.distance+w {
		// fmt.Printf("%v -> %v, %v\n", l.key, r.key, l.distance+w)
		r.distance = l.distance + w
		r.predecessor = l
	}
}

func main() {
	scanner.Split(bufio.ScanWords)

	nNodes := nextInt()
	graph := newDirectedGraph(nNodes)

	for i := 0; i < nNodes; i++ {
		iNode := DirectedGraphNodeID(nextInt())
		nAdjacent := nextInt()
		for j := 0; j < nAdjacent; j++ {
			jNode := DirectedGraphNodeID(nextInt())
			cost := nextInt()
			graph.setAdjacency(iNode, jNode, cost)
		}
	}

	graph.nodes[0].distance = 0
	for iNode := 0; iNode < nNodes; iNode++ {
		for iLeft := 0; iLeft < len(graph.nodes); iLeft++ {
			nodeLeft := graph.nodes[iLeft]
			for iRight := 0; iRight < len(nodeLeft.adjacents); iRight++ {
				nodeRight := nodeLeft.adjacents[iRight]
				cost := nodeLeft.costs[iRight]
				graph.relaxEdge(nodeLeft, nodeRight, cost)
			}
		}
	}

	// graph.print()

	for iNode := 0; iNode < len(graph.nodes); iNode++ {
		node := graph.nodes[iNode]
		fmt.Println(node.key, node.distance)
	}
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
//#include "Header.h"

#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define d7 1000000007
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++)
        {if (j == 0 || j == i) C[i][j] = 1;
            else C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);}}
    return C[n][k];
 }

ll gcd(ll a, ll b){if (b == 0)
        return a;return gcd(b, a % b);}

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}

ll kk=1;
void dfsi(vector<bool> &vis, vector<ll> adj1[], ll n, ll start, vector<ll> &pre, vector<ll> &pos){
    vis[start]=true;
    pre[start]=kk;kk++;
    for(ll i: adj1[start]){
        if(!vis[i]){
            vis[i]=true;
            dfsi(vis,adj1,n,i,pre,pos);
        }
    }
    pos[start]=kk;kk++;
}

void bfsi(vector<ll> &dis, vector<ll> adj[], ll s, vector<ll> &parent){
    dis[s]=-1;
    queue<ll> q;
    q.push(s);
    while(!q.empty()){
        ll z=q.front();
        q.pop();
        for(ll v:adj[z]){
            if(dis[v]==0){
            q.push(v);
            dis[v]=-dis[z];
                parent[v]=z;}
        }
    }
}

void make_set(ll v, vector<ll> &parent, vector<ll> &krank) {
    parent[v] = v;
    krank[v] = 0;
}

ll find_set(ll v,vector<ll> &parent, vector<ll> &krank) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v], parent, krank);
}

void union_sets(ll a, ll b,vector<ll> &parent, vector<ll> &krank) {
    a = find_set(a,parent,krank);
    b = find_set(b,parent,krank);
    if (a != b) {
        if (krank[a] < krank[b])
            swap(a, b);
        parent[b] = a;
        if (krank[a] == krank[b])
            krank[a]++;
    }
}

void dijkstra(ll s, vector<ll> &dist, vector<ll> &parent, ll n, vector<pair<ll,ll>> adj[]){
    dist[s]=0;
    vector<bool> u(n,false);
    fori(n){
        ll v=-1;
        forj(n){
            if(!u[j] &&(v==-1||(dist[j]<dist[v]))) v=j;
        }
        if(dist[v]==d7) break;
        u[v]=true;
        for(auto j:adj[v]){
            ll a,b;
            a=j.first;
            b=j.second;
            if(dist[v]+b<dist[a]){
                dist[a]=dist[v]+b;
                parent[a]=v;
            }
        }
    }
}


int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
// code now
   
    ll n,k;
    cin>>n>>k;
    ll sum=0;
    ll a[n];
    fori(n){cin>>a[i];}
    sort(a, a+n);
    if(k>=n){cout<<0;}
    else{
        //ll sum=0;
        fori(n-k){
            sum+=a[i];
        }
        cout<<sum;
    }
    
//code ends
    return 0;
}


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

using namespace std;

#define F first
#define S second

const int INF = (1 << 30);

int main(){
	int n;
	cin >> n;
	vector<int> max_pref_balance(n),balance(n);
	vector<int> pos,neg;
	for(int i = 0; i < n; ++i){
		string s;
		cin >> s;
		int len = static_cast<int>(s.size());
		int op = 0, cl = 0;
		for(int j = 0; j < len; ++j){
			if(s[j]=='(')++op;
			else ++cl;
			max_pref_balance[i] = max(max_pref_balance[i],cl-op);
		}
		if(op>=cl){
			pos.push_back(i);
			balance[i] = op - cl;
		}else{
			neg.push_back(i);
			balance[i] = cl - op;
		}
	}
	sort(pos.begin(),pos.end(),[&](const int & a, const int & b){
		return max_pref_balance[a] < max_pref_balance[b];
	});
	int total_balance = 0;
	for(int i = 0; i < (int)pos.size(); i++){
		int id = pos[i];
		if(max_pref_balance[id] > total_balance){
			cout << "No\n";
			return 0;
		}
		total_balance += balance[id];
	}
	sort(neg.begin(),neg.end(),[&](const int & a, const int & b){
		return max_pref_balance[a] - balance[a] > max_pref_balance[b] - balance[b]; 
	});
	
	for(int i = 0; i < (int)neg.size(); i++){
		int id = neg[i];
		if(max_pref_balance[id] > total_balance){
			cout << "No\n";
			return 0;
		}
		total_balance -= balance[id];
	}
	if(total_balance){
		cout << "No\n";
	}else{
		cout << "Yes\n";
	}
	
	return 0;
}


Measured memory_bytes: 15192
N,K=map(int,input().split())
l=list(map(int,input().split()))
L=[0]
for i in range(N):
    L.append(L[-1]+l[i])
#print(L)
A=[]
for i in range(N):
    for j in range(i+1,N+1):
        A.append(L[j]-L[i])
#print(A)
B=[]
for i in range(len(A)):
    B.append(format(A[i],'040b'))
#print(B)


for i in range(40):
    cnt=0
    for j in B:
        if j[i]=="1":
            cnt+=1
    if cnt>=K:
        S=i
        break

ans=2**(39-S)
C=[]
for j in B:
    if j[S]=="1":
        C.append(j)
        
#print(ans)
#print(C)

for i in range(S+1,40):
    D=[]
    for j in C:
        if j[i]=="1":
            D.append(j)
    if len(D)>=K:
        ans+=2**(39-i)
        C=D
print(ans)


Measured memory_bytes: 75704
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
	string s;
	int n = 0;

	cin >> s;

	int sn = s.size();
	n = s.size();

	if (sn > 1){
		for (int i = 0; i < sn - 1; i++) {
			if (s[i] != s[i + 1])
				if (n > max(i + 1, sn - i - 1))
					n = max(i + 1, sn - i - 1);
		}
	}

	cout << n << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <bitset>

const int inf = 1e9;
const int N = 700;
bool edge[N][N];
int group[N];
int gs[2*N];
std::bitset<N+1> cans;
int n;

bool dfs(int i, int g) {
	if (group[i] != -1) {
		if (group[i] == (g ^ 1)) return false;
		return true;
	}
	group[i] = g;
	++gs[g];
	for (int t = 0; t < n; ++t) {
		if (i == t) continue;
		if (! edge[i][t]) {
			if (!dfs(t, g^1)) return false;
		}
	}
	return true;
}

int main() {
	int m;
	std::cin >> n;
	std::cin >> m;
	for (int i = 0; i < n; ++i) edge[i][i];
	for (int i = 0; i < m; ++i) {
		int a, b;
		std::cin >> a >> b;
		--a; --b;
		edge[a][b] = true;
		edge[b][a] = true;
	}
	for (int i = 0; i < n; ++i) group[i] = -1;

	bool fail = false;
	int gc = 0;
	for (int i = 0; i < n; ++i) {
		if (group[i] == -1) {
			fail |= ! dfs(i, 2 * gc);
			++gc;
		}
	}
	if (fail) {
		std::cout << -1 << '\n';
	} else {
		for (int i = 0; i <= n; ++i) cans[i] = 0;
		cans[0] = 1;

		for (int j = 0; j < gc; ++j) {
			cans = ((cans << gs[2*j]) | (cans << gs[2*j+1]));
		}
		int min_ans = inf;
		for (int i = 0; i <= n; ++i) {
			if (cans[i]) {
				min_ans = std::min(min_ans, std::max(0, i*(i-1)/2) + std::max(0, (n-i) * (n-i-1)/2));
			}
		}
		std::cout << min_ans << '\n';
	}
}


Measured memory_bytes: 768
#!/usr/bin/env python3
S = input()
len_S = len(S)
w_num = 0
operation_num = 0
for Ind in range(len_S-1,-1,-1):
	if S[Ind] == "W":
		w_num += 1
	elif S[Ind] == "B":
		operation_num += w_num

print(operation_num)



Measured memory_bytes: 3500
#include <iostream>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
using namespace std;
typedef pair<string, int> P;
const int INF = 100000000;
string a;
int op[4] = {-1, 1, -4, 4};
map<string, int> dp;

void bfs(){
    queue<P> que;
    que.push(P("01234567", 0));
    dp["01234567"] = 0;
    while(!que.empty()){
        P p = que.front();
        que.pop();
        string s = p.first;
        int cur = p.second;
        for(int i = 0; i < 4; i ++){
            int next = cur + op[i];
            string str = s;
            if(next<0) continue;
            swap(str[cur], str[next]);
            map<string, int>::iterator it = dp.find(str);
            if(0 <= next && next < 8
                && !(cur == 3 && next == 4) && !(cur == 4 && next == 3)
                && it == dp.end()){

                que.push(P(str, next));
                dp[str] = dp[s] + 1;
            }
        }
    }
}

void solve(){
    a.erase(remove(a.begin(), a.end(), ' '), a.end());
    cout<<dp[a]<<endl;
}

int main(int argc, char const *argv[]){
    bfs();
    while(getline(cin, a)){
        solve();
    }
    return 0;
}


Measured memory_bytes: 5220
// B - Easy Linear Programming
#include <bits/stdc++.h>
using namespace std;

int main(){
	int a,b,c,k; cin>>a>>b>>c>>k;
	int ans = min(k, a);
	if(k-a-b > 0) ans -= k-a-b;
	cout<<ans<<"\n";

}


Measured memory_bytes: 3572
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        if(a<=b){
            System.out.println(a);
        }
        else{
            System.out.println(a - 1);
        }
    }
}

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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10e18
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef tuple<int , int , int> tiii;
typedef vector<pii> vpii;
typedef vector<tiii> vtiii;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int lli;

             
inline int input(){
  int n;
  scanf("%d" , &n);
  return n;
}

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

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif
 
  int n; cin >> n;
  bool ok = false;
  forn(i , 0 , n){
    int k; cin >> k;
    if(k % 2 == 1) ok = true;
  }
  cout << (ok == true ? "first" : "second") << endl;

#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F            first
#define S            second
#define pb(x)        push_back(x)
#define mp(a,b)      make_pair(a,b)
#define mt(a,b,c)    make_tuple(a,b,c)
#define sz           size()
#define all(A)       A.begin(), A.end()
#define mem(a, b)    memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)      for(ll i=0;i<(b);i++)
#define f1(i,b)      for(ll i=1;i<=(b);i++)
#define f2(i,a,b)    for(ll i=(a);i<=(b);i++)
#define f3(i,b,a)    for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))

#define mod          10000007
#define PI           acos(-1.0)
#define MAX3(a,b,c)  max(a,max(b,c))

#define whilee(i,t)  while(i!=t)
#define  sl(a)       scanf("%lld",&a)
#define  pl(a)       printf("%lld\n",a)

//x = 1e18 means 10^18
//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end()); //sort(A, +n, greater<int>());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//printf("%I64d\n", a);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//pair <ll,ll> A ;
//tuple <ll, ll, ll> A;
//vector <pair <ll,ll>> A ;
//bitset<32> bset1;
//bool ok = true;
//char ch;
//string S, T, U;
double i=0, j=0, k=0, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;

int main()
{

    while(cin>>a>>b>>c>>d>>e>>f)
    {
        double x = (e*c - b*f)/(a*e - d*b);
        double y = (a*f - d*c)/(a*e - d*b);
        if(x==0) x=0;
        if(y==0) y=0;
        printf("%.3lf %.3lf\n",x, y);
    }

    return 0;
}



Measured memory_bytes: 3272
function main(input) {
  var data = input.split(" ");

  const N = data[0];
  const L = data[1];

  var tasteAll = 0;

  var min = 100000;
  var tasteShort = 0;
  var tempTaste = 0;

  for(i = 1; i <= Number(N); i++){
    tempTaste =  Number(L) + i - 1;
    tasteShort += tempTaste;

    if(min > abs(tempTaste)){
      min = abs(tempTaste);
      var j = i;
    }
  }

  tasteShort -= Number(L) + j - 1;

  console.log(tasteShort);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function abs(val){
  if(val < 0){val = -val;}
  return val;
}


Measured memory_bytes: 7500
N,M = list(map(int, input().split()))
data = [0]*30
for i in range(N):
  ai = list(map(int, input().split()))
  ai.remove(ai[0])
  for item in ai:
    data[item-1] += 1

count = 0
for item in data:
  if item == N:
    count += 1

print(count)

Measured memory_bytes: 3060
#include <iostream>
#include<string>
using namespace std;
int main(void){
    int n;
    string x,y;
    int a = 0, b = 0;
    cin >> n;
    
    for(int i = 0; i < n;i++){
        cin >> x >> y;
        if(x > y){
            a += 3;
        }else if(x < y){ 
            b += 3;
        }else {
            a++; b++;
        }
    }
    
    cout << a << " " << b << endl;
    
    
}


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

#define ll long long 
#define MOD 1000000007

/*
ll sub(ll x, ll y){
	x -= y;
	if(x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;	
}
ll power(ll x, ll y){
	if(y == 0) return 1;
	if(y & 1) return mult(power(x, y - 1), x);
	return power(mult(x, x), y / 2);
}
ll inv(ll x) {
	return power(x, MOD - 2);
}*/

int main() {
	ll N, K; 
	cin >> N >> K;
	ll ans = 0;
	for(ll i = K; i <= N + 1; i++) {
		ans = (ans + (i * (N - i + 1) % MOD) + 1) % MOD;
	}
	cout << ans;
}


Measured memory_bytes: 3632
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
        ($line:expr, $name:ident, $t:tt) => {
            let $name = value!($line, $t);
        };
    }

    macro_rules! values_def {
        ($lines:expr, $n:expr, $name:ident, $t:tt) => {
            let $name = {
                let mut vec = Vec::new();
                for i in 0..$n {
                    let mut next = $lines.next().unwrap().split_whitespace();
                    vec.push(value!(next, $t));
                }
                vec
            };
        };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

use std::cmp::{max, min};

macro_rules! max {
  ($x:expr) => {
    $x
  };
  ($x:expr, $($xs:tt)+) => {
    max($x,max!($($xs)+))
  };
}

macro_rules! min {
  ($x:expr) => {
    $x
  };
  ($x:expr, $($xs:tt)+) => {
    min($x,min!($($xs)+))
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    //0.25,0.5,1,2
    input!(input=>(q:i64 h:i64 s:i64 d:i64)(n:i64));
    let one = min!(q * 4, h * 2, s);
    if n % 2 == 0 {
        min(one * n, d * (n / 2))
    } else {
        min(one * n, d * (n / 2) + one)
    }.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "20 30 70 90\n3" => "150",
    test2: "10000 1000 100 10\n1" => "100",
    test3: "10 100 1000 10000\n1" => "40",
    test4: "12345678 87654321 12345678 87654321\n123456789" => "1524157763907942",
}


Measured memory_bytes: 4352
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val W, H, x, y, r = sc.nextInt()
  println(isInARectangle(judeHorizon(r,x,W),judeVertical(r,y,H)))

  def isInARectangle(h:Boolean, v:Boolean): String = if (h && v) "Yes" else "No"
  def judeHorizon(r: Int, x: Int, W: Int): Boolean = if (x - r < 0 || x + r > W) false else true
  def judeVertical(r: Int, y: Int, H: Int): Boolean = if (y - r < 0 || y + r > H) false else true
}

Measured memory_bytes: 45152
/** Author: Dwai
 *  Omae wa mou shindeiru!
**/

#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define all(a) (a).begin(),(a).end()
#define fr(i,a,b) for (i = a; i <= b; i++)
#define frr(i,a,b) for (i = a; i >= b; i--)
#define rep(i,n) for (i = 0 ; i < n; i++)
#define repr(i,n) for (i = n - 1; i >= 0; i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define flushinput   cin.ignore(numeric_limits<streamsize>::max(),'\n');

void debug_out() { cerr << endl; }

void clock_out(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}

void fileio(){
  freopen("/home/dwai/Desktop/cp/input.txt","r", stdin);
  freopen("/home/dwai/Desktop/cp/output.txt", "w", stdout);
  freopen("/home/dwai/Desktop/cp/debug.txt", "w", stderr);
}

void ofileio(){
  freopen("input.txt","r", stdin);
  freopen("output.txt", "w", stdout); 
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define fio() fileio()
#define ofio() fileio()
#define clock() clock_out()
#else
#define debug(...) 42
#define fio() 42
#define ofio() ofileio()
#define clock() 42
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef map<ll,ll> mll;

int IT_MAX = 1 << 20;
const ll MOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;


ll fast_exp(ll base, ll exp)
{
  if(base==0) return 0;
  ll res=1;
  while(exp>0)
  {
    if(exp&1)
      res=(res*base)%MOD;
    base=(base*base)%MOD;
    exp/=2;
  }
  return res%MOD;
}


void solve()
{
	ll n;cin>>n;
	ll dp[n]={0};
	ll i;
	ll a[n];
	mll m;
	rep(i,n){
		cin>>a[i];
		m[a[i]]++;
	}
	if(a[0]!=0)
	{
		cout<<0;
		return;
	}
	sort(a,a+n);
	for(auto x:m)
	{
		ll val=x.ff;
		ll freq=x.ss;
		if(val==0){
			if(freq>1) {
				cout<<0;
				return;
			}
			dp[0]=freq;
		}
		else dp[val]=(dp[val-1]*fast_exp(m[val-1],freq))%MOD;
	}
	cout<<(dp[a[n-1]]+MOD)%MOD;
}

int main()
{
//	fio();
	fast
	ll t=1;
	//cin>>t;

	while(t--){
		solve();	
	}
	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#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++)

int main() {
  string s;
  cin >>s;
  int k;
  cin>>k;
  bool ex=true;
  rep(i,s.size()-1){
    if(s.at(i)!=s.at(i+1)){
      ex=false;
      break;
    }
  }
  if(ex){
    cout<<s.size()*k/2<<endl;
  }
  else{
  string t=s+s;
  string u=t+s;
  long ans=0;
  if(k==1){
    rep(i,s.size()-1){
      if(s.at(i)==s.at(i+1)){
        ans++;
        s.at(i+1)='.';
      }
    }
  }
  else if(k==2){
    rep(i,t.size()-1){
      if(t.at(i)==t.at(i+1)){
        ans++;
        t.at(i+1)='.';
      }
    }
  }
  else{
    long ch=0;
    rep(i,u.size()-1){
      if(u.at(i)==u.at(i+1)){
        ch++;
        u.at(i+1)='.';
      }
    }
    long co=0;
    rep(i,t.size()-1){
      if(t.at(i)==t.at(i+1)){
        co++;
        t.at(i+1)='.';
      }
    }
    ans=co+(k-2)*(ch-co);
  }
  cout<<ans<<endl; 
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define ld long double
#define fi first 
#define se second 
#define mp make_pair
#define pb push_back
#define ull unsigned long long int
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define mo 1000000007
/*int const nmax = 1000006; 
vector<int> v[nmax]; 
void dfs(int i , int p)
{
	for(int j = 0; j<v[i].size(); j++)
	{
		int node = v[i][j]; 
		if(node!=p)
		{
			dfs(node,i); 
		}
	}
}*/
/////////////////////////////
ll gcd(ll a ,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll poww(ll a,ll n){if(n==0)return 1;ll p=poww(a,n/2);p=(p*p)%mo;if(n%2)p=(a*p)%mo;return p;}
////////////////////////////////////////////////////


void solve()
{
 int n , k ; cin>>n>>k; 
 int a[n]={0}; 
 lp(i,0,k)
 {
 	int d; cin>>d; 
 	lp(j,0,d)
 	{
 		int x;cin>>x; 
 		a[x-1]++; 
	 }
 }
 int ans = 0; 
 lp(i,0,n)
 {
 	if(a[i]==0)
 	ans++; 
 }
 cout<<ans<<endl; 
}
int main()
{ ios; 

ll t =1; 
 while(t--)
	solve(); 
	return 0 ; 
}

Measured memory_bytes: 3664
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int n,a,b;
    cin >> n >> a >> b;

    int ans=0;
    for(int i=1;i<=n;i++){
        string s=to_string(i);
        int sum=0;
        for(int j=0;j<s.size();j++){
            sum+=(s[j]-'0');
        }
        if(sum>=a && sum<=b)ans+=i;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3668
# coding: utf-8
 
 
def main():
    n = int(input())
    amari = n % 2
    sho = n // 2
    if amari == 1:
        sho = sho + 1
    
    print(sho)    
    
 
    return 0
 
 
if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#!/usr/bin/env python3
N, M = [int(str) for str in input().strip().split()]
H = [int(str) for str in input().strip().split()]
AB = [[int(str) - 1 for str in input().strip().split()] for _ in range(M)]


def solve():
    G = [0] * N
    for a, b in AB:
        G[a] = max(G[a], H[b])
        G[b] = max(G[b], H[a])

    ans = 0
    for i in range(N):
        if H[i] > G[i]:
            ans += 1

    print(ans)


solve()


Measured memory_bytes: 30384
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
	int N,d[36],ds[36],temp,minj,ch=0;
	char c[36],cs[36],ctemp;
	
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf(" %c%d",&c[i],&d[i]);
		cs[i]=c[i];
		ds[i]=d[i];
		//printf("%d\n",i);
	}
	/*
	for(int i=0;i<N;i++){
		printf("%c%d\n",c[i],d[i]);
	}*/
	//BubbleSort
	for(int i=0;i<N;i++){
		for(int j=N-1;j>=i+1;j--){
			if(d[j]<d[j-1]){
				temp = d[j];
				d[j] = d[j-1];
				d[j-1] = temp;
				ctemp = c[j];
				c[j] = c[j-1];
				c[j-1] = ctemp;
			}
		}
	}
	printf("%c%d",c[0],d[0]);
	for(int i=1;i<N;i++){
		printf(" %c%d",c[i],d[i]);
	}
	printf("\nStable\n");
	//SelectionSort
	for(int i=0;i<N;i++){
		minj = i;
		for(int j=i;j<N;j++){
			if(ds[j]<ds[minj]){
				minj = j;
			}
		}
		temp = ds[i];
		ds[i] = ds[minj];
		ds[minj] = temp;
		ctemp = cs[i];
		cs[i] = cs[minj];
		cs[minj] = ctemp;
	}
	printf("%c%d",cs[0],ds[0]);
	if(cs[0]!=c[0]||ds[0]!=d[0])
	ch=1;
	for(int i=1;i<N;i++){
		printf(" %c%d",cs[i],ds[i]);
		if(cs[i]!=c[i]||ds[i]!=d[i])
		ch=1;
	}
	if(ch==0)
	printf("\nStable\n");
	else
	printf("\nNot stable\n");
}

Measured memory_bytes: 3204