akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=1;
  cin >> n;
  
  ll cnt=0;
  vi a(n),b(n);
  REP(i,n){
	  cin>>a[i];
	  if (a[i]<n){
	  b[a[i]]+=1;
	  cnt++;
	  }
  }

  if (a[0]!=0){
	cout<<0<<endl;
	return 0;
  }
  if (b[0]!=1){
	cout<<0<<endl;
	return 0;
  }
  if (n==1){
	cout<<1<<endl;
	return 0;
  }
  if (cnt!=n){
	  cout<<0<<endl;
	  return 0;
  }



ll w=n;
  for(ll i=1;i<n;i++){
	  if (b[i]==0){
		  w=i;
		  break;
	  }
	  REP(j,b[i]){
		ans=(ans*b[i-1])%998244353LL;
	  }
  }
  
  for(ll i=w;i<n;i++){
	  if (b[i]!=0)ans=0;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     int n;
     cin>>n;
     int x[n],y[n],h[n];
     for(int i=0;i<n;i++)
        cin>>x[i]>>y[i]>>h[i];
     for(int i=0;i<=100;i++)
     {
          for(int j=0;j<=100;j++)
          {
               int H=0;
               bool okay=false;
               vector<int>v;
               int temp;
               for(int k=0;k<n;k++)
               {
                   temp=abs(i-x[k])+abs(j-y[k]);
                   if(h[k]==0)
                   {
                       if(temp==0)
                       {
                          okay=true;
                          break;
                       }
                       v.push_back(temp);
                       if(H==0)
                        continue;
                       if(H>temp)
                       {
                          okay=true;
                          break;
                       }
                   }
                   else
                   {
                       if(H==0)
                       {
                           H=h[k]+temp;
                           continue;
                       }
                       if(H!=h[k]+temp)
                       {
                           okay=true;
                           break;
                       }
                   }
               }
               if(!okay)
               {
                   for(int f=0;f<v.size();f++)
                   {
                       if(H>v[f])
                       {
                           okay=true;
                           break;
                       }
                   }
                   if(okay)
                    continue;
                  else
                  {
                     cout<<i<<" "<<j<<" "<<H;
                     return 0;
                  }
               }
          }
     }
 }

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;

#define MAXN 524288
#define MAXC 1048576
#define NO_VALUE -1

#define LEFT(x) ( 2*(x) )
#define RIGHT(x) ( 2*(x)+1 )

int A, B, C, M;

int r() {
    A = 36969 * (A & M) + (A >> 16);
    B = 18000 * (B & M) + (B >> 16);
    return (C & ((A << 16) + B)) % 1000000;
}

int x[MAXN], y[MAXN], z[MAXN], ox[MAXN], val[MAXN], used[MAXC], stack[MAXN], ymap[MAXC], Y;

bool cmp_x(const int &a, const int &b) {
    if (x[a] != x[b]) return x[a] < x[b];
    else if (y[a] != y[b]) return y[a] < y[b];
    else return z[a] < z[b];
}

map<int, int> bit[MAXC];

int answer(int idx, int th) {
    map<int, int>::iterator it = bit[idx].lower_bound(th);
    if (it != bit[idx].begin()) return (--it)->second;
    else return NO_VALUE;
}

int query(int idx, int th) {
    int res = NO_VALUE;
    while (idx > 0) {
        res = max(res, answer(idx, th));
        idx &= idx-1;
    }
    return res;
}

void update(int idx, int th, int v) {
    map<int,int>::iterator it1, it2;
    while (idx < Y) {
        it1 = it2 = bit[idx].upper_bound(th);
        while (it2 != bit[idx].end() && it2->second <= v) it2++;
        bit[idx].erase(it1, it2);
    
        it1 = bit[idx].upper_bound(th);
        if (it1 == bit[idx].begin() || (--it1)->second < v) bit[idx][th] = v;
        idx += idx&(-idx);
    }
}

int main() {
    int m, n, i, j, N, t = 1, STACK;

    while (scanf("%d %d %d %d", &m, &n, &A, &B) && (m || n || A || B)) {
        C = ~(1<<31); M = (1<<16)-1;
        for (i=0; i<m; i++) scanf("%d %d %d", &x[i], &y[i], &z[i]);
        for (i=m; i<m+n; i++) { x[i] = r(); y[i] = r(); z[i] = r(); }
        N = m+n;

        Y = 0;
        for (i=0; i<N; i++) {
            ox[i] = i;
            if (used[y[i]] < t) { used[y[i]] = t; stack[Y++] = y[i]; }
        }
        sort(ox, ox+N, cmp_x);
        sort(stack, stack+Y);
        for (i=0; i<Y; i++) ymap[stack[i]] = i+1;
        for (i=0; i<N; i++) y[i] = ymap[y[i]];
        t++; Y++;

        for (i=0; i<Y; i++) bit[i].clear();

        i = 0;
        do {
            for (j=i; j<N && x[ox[j]]==x[ox[i]]; j++) val[ox[j]] = max(1, query(y[ox[j]]-1, z[ox[j]])+1);
            for (; i<j; i++) update(y[ox[i]], z[ox[i]], val[ox[i]]);
        } while (i < N);
        printf("%d\n", query(Y-1, MAXC));
    }

    return 0;
}

Measured memory_bytes: 111920
#include <stdio.h>
 
int main(void)
{
    int i,a,min,max;
    int b[10000];
    long long sum;
     
    sum = 0;
    min = 1000000;
    max = -1000000;
 
    scanf("%d",&a);
 
    for(i=0;i<a;i++)
    {
        scanf("%d", &b[i]);
 
        if(b[i] < min)
        {
            min = b[i];
        }
        if(b[i] > max)
        {
            max = b[i];
        }
 
        sum = sum + b[i];
    }
 
    printf("%d %d %lld\n",min,max,sum);
 
    return 0;
}

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

int main() {
	int n,m;
	cin >> n >> m;
	int a[n][m];
	int b[m];
	int i, j;
	int sum = 0;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	for (j = 0; j < m; j++) {
		cin >> b[j];
	}
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			sum += (a[i][j] * b[j]);
		}
		cout << sum << endl;
		sum = 0;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    lint ei[26];
  int main(){
    lint n;
    string s;
    cin>>n>>s;
    rep(i,n){
        ei[s[i]-'a']++;
    }
    lint ans=0;
    rep(i,n){
        lint g=s[i]-'a';
        lint mul=1;
        rep(j,26){
            if(j==g)continue;
            mul*=(ei[j]+1);
            mul%=MOD;
        }
        ei[g]--;
        ans+=mul;
        ans%=MOD;
    }
    cout<<ans<<endl;
  }
  
     


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    if (S == "SAT") {
        cout << 1 << endl;
    }
    else if (S == "SUN") {
        cout << 7 << endl;
    }
    else if (S == "MON") {
        cout << 6 << endl;
    }
    else if (S == "TUE") {
        cout << 5 << endl;
    }
    else if (S == "WED") {
        cout << 4 << endl;
    }
    else if (S == "THU") {
        cout << 3 << endl;
    }
    else if (S == "FRI") {
        cout << 2 << endl;
    }
}

Measured memory_bytes: 256
use std::cmp;

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
       a: usize,
       b: usize
    }
    for _ in 0..cmp::max(a, b) {
        print!("{}", cmp::min(a, b))
    }
    println!()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long int 
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define pqmin priority_queue<ll,vector<ll>,greater<ll>>
#define pqmax priority_queue<ll>
using namespace std;
ll power(ll a,ll n){
	if(n==0)
	  return 1;
	if((n%2)==0)
	  return (power((a*a),n/2));
	else
	  return (a*(power((a*a),n/2)));    
}
int main()
{
  IOS;
   
     
        
    ll n;
    cin>>n;
    cout<<n/2+n%2<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.text.*;
import java.util.*;

public class Main {

    static InputReader sc = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        solver s = new solver();
        int t = 1;
        while (t > 0) {
            s.solve();
            t--;
        }
        out.close();
    }

    static class InputReader {

        public BufferedReader br;
        public StringTokenizer token;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream), 32768);
            token = null;
        }

        public String sn() {
            while (token == null || !token.hasMoreTokens()) {
                try {
                    token = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return token.nextToken();
        }

        public int ni() {
            return Integer.parseInt(sn());
        }

        public String snl() throws IOException {
            return br.readLine();
        }

        public long nlo() {
            return Long.parseLong(sn());
        }

        public double nd() {
            return Double.parseDouble(sn());
        }

        public int[] na(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = sc.ni();
            return a;
        }

        public long[] nal(int n) {
            long a[] = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = sc.nlo();
            return a;
        }
    }

    static int inf = 5000013;

    static class solver {
        DecimalFormat df = new DecimalFormat("0.00000000");
        long max = 1000000000000l, min = -10000000000000l;
        long mod = (long) 1e9 + 7;

        long pro(long a, long b) {
            return (a % mod * b % mod) % mod;
        }

        long add(long a, long b) {
            return (a + b) % mod;
        }

        long ncr3(long n) {
            return (n * (n - 1) * (n - 2)) / 6l;
        }

        long ncr2(long n) {
            return n * (n - 1) / 2l;
        }

        long modPow(long x, long y) {
            long res = 1l;
            x = x % mod;
            while (y > 0) {
                if (y % 2 != 0)
                    res = pro(res, x);
                x = pro(x, x);
                y = y >> 1;
            }
            return res;
        }

        int MAXN = 200005;

        void solve() {
            int a, b, c;
            a = sc.ni();
            b = sc.ni();
            c = sc.ni();
            int t = a;
            a = b;
            b = t;
            t = a;
            a = c;
            c = t;
            out.println(a+" "+b+" "+c);
        }
    }
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define lim 100005
#define INF 1e13
int main()
 {
  
  ll n,k;
  cin>>n>>k;
  set<ll>st;
  map<ll,ll>m;
  ll x;
  while(n--)
  {
    cin>>x;
    m[x]++;
  }
  ll ans=0;
  ans=max(ans,(ll)m.size()-k);
  ll fans=0;
  map<ll,ll>::iterator it;
 vector<ll>v;
 for(it=m.begin();it!=m.end();it++)
 v.push_back(it->second);
 sort(v.begin(),v.end());
 for(int i=0;i<ans;i++)
 fans+=v[i];
  cout<<fans<<endl;

}


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

int main() {
  double Ans = 0;  // 回答：
  int R; cin >> R;  // 半径

  cout << Ans << setprecision(7);	// 計算前に桁数指定
  Ans = R * 2 * 3.141592653589;

  cout << Ans << endl;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll n;
	cin >> n;

	vector<ll> ans;
	ll v = n;
	for (ll i = 2; i * i <= n; i++) {
		while (v % i == 0) {
			ans.push_back(i);
			v /= i;
		}
	}
	if (v != 1L) {
		ans.push_back(v);
	}

	cout << n << ":";
	for (auto vv : ans) {
		cout << " " << vv;
	}
	cout << endl;
	return 0;
}



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

// MY TOOLS
#define let long long int
#define async ios_base::sync_with_stdio(false);cin.tie(NULL);

//


int dp[10001][101][2] ;
int mod = 1e9 + 7 ;
void self_add( int &a, int b ){
	a += b ;
	if( a >= mod ) a -= mod ;
}
int SIZE ;
int generate_top_down( string num, int idx, int sum, int D, int bound ){
	if( idx == SIZE ) return ( sum % D == 0 ) ;
	int &check = dp[idx][sum][bound] ;
	if( check != -1 ) return check ;
	int N = ( num[idx]-'0' ) ;
	int up_to = ( bound == 1 ) ? N : 9 ;
	int payload = 0, new_bound ;
	for( int digit = 0 ; digit <= up_to ; digit++ ){
		new_bound = ( digit == N ) ? bound : 0 ;
		self_add( payload, generate_top_down( num, idx+1, (sum+digit)%D, D, new_bound ) ) ; 
	}
	return check = payload ; 
}



// main
// write your code here
int main(){
	async ;
	memset( dp, -1, sizeof(dp) ) ;
	string K ; int D ;
	cin >> K >> D ;
	SIZE = K.size() ;
	int ans = generate_top_down( K, 0, 0, D, 1 ) - 1 ;
	if( ans == -1 ) {
		cout << mod - 1 ;
	}
	else{
		cout << ans ;
	}
    return 0 ;
}


Measured memory_bytes: 110804
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

count = 0
for i in range(n):
    if b[i] > a[i]:
        b[i] -= a[i]
        count += a[i]
    else:
        count += b[i]
        b[i] = 0
    if a[i+1] > b[i]:
        count += b[i]
        a[i+1] -= b[i]
    else:
        count += a[i+1]
        a[i+1] = 0

print(count)

Measured memory_bytes: 82148
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)
    A = [next(it) for i in range(N)]

    if N == 1:
        print(1)
        return

    ax = max(A)+1
    dp = [0]*ax
    for ai in A:
        da = dp[ai]
        if da > 1:
            continue
        dp[ai] += 1
        if da == 0:
            for aj in range(2*ai, ax, ai):
                dp[aj] = 2
    ans = 0
    for ai in A:
        if dp[ai] == 1:
            ans += 1
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 39836
import sys

def shuffle( cards ):
    h = int( sys.stdin.readline() )
    cards = cards[ h : ] + cards[ 0 : h ]
    return cards

while True:
    cards = sys.stdin.readline().rstrip()
    if '-' == cards:
        break
    m = int( sys.stdin.readline())
    for i in range( m ):
        cards = shuffle( cards )
    print( cards )
    

Measured memory_bytes: 7692
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(stdR.readLine());
        String[] s = stdR.readLine().split(" ");
        int[] a = new int[N];
        for(int i = 0 ; i < N ; i++) {
            a[i] = Integer.parseInt(s[i]);
        }
        Arrays.sort(a);
        int alice = 0;
        int bob = 0;
        int count = 0;
        for(int i = N - 1 ; i >= 0 ; i--) {
            if(count % 2 == 0) {
                alice += a[i];
            }else {
                bob += a[i];
            }
            count++;
        }
        System.out.println(alice - bob);
    }
}

Measured memory_bytes: 22612
import java.util.*;

public class Main {
	int p;
	
	class C implements Comparable<C>{
		int id,ans,time;
		int [] wrong;
		public C(int id, int ans, int time) {
			this.id = id;this.ans = ans;this.time = time;
			wrong = new int[p+1];
		}

		public int compareTo(C o) {
			if(ans < o.ans) return 1;
			if(ans > o.ans) return -1;
			if(time < o.ans) return -1;
			if(time > o.time) return 1;
			if(id < o.id) return -1;
			if(id > o.id) return 1;
			return 0;
		}
		
		
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int t = sc.nextInt();
			p = sc.nextInt();
			int r = sc.nextInt();
			if(t == 0 && p == 0 && r == 0){
				break;
			}
			C [] data = new C[t+1];
			for(int i=0; i <= t; i++){
				if(i == 0){
					data[i] = new C(-1,-1,0);
				}
				else{
					data[i] = new C(i,0,0);
				}
			}
			for(int i=0; i < r; i++){
				int tt = sc.nextInt();
				int pp = sc.nextInt();
				int time = sc.nextInt();
				String msg = sc.next();
				if(msg.equals("WRONG")){
					data[tt].wrong[pp]++;
				}
				else{
					data[tt].time += time + data[tt].wrong[pp] * 1200;
					data[tt].ans++;
				}
			}
			Arrays.sort(data);
			for(int i=0; i < t; i++){
				System.out.println(data[i].id + " " + data[i].ans + " " + data[i].time);
			}
		}
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
typedef long long LL;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 2e5 + 5;

string s;
int k;

vector <int> V;
int len;
LL dp[1005][2][5];

LL go( int idx , int smaller , int cnt ) {
        if (cnt > k) return 0;
        if( idx >= len ) return cnt == k;
        if( dp[idx][smaller][cnt] != -1 ) return dp[idx][smaller][cnt];
        LL ret = 0;
        if( smaller ) {
                for( int i = 0; i <= 9; i++ ) {
                        ret += go( idx + 1 , 1 , cnt + (i != 0) );
                }
        }
        else {
                for( int i = 0; i < V[idx]; i++ ) {
                        ret += go( idx + 1 , 1 , cnt + (i != 0) );
                }
                ret += go( idx + 1 , 0 , cnt + (V[idx] != 0) );
        }
        return dp[idx][smaller][cnt]= ret;
}
LL solve( ) {
        V.clear();
        for (int i = 0; i < len; i++) V.push_back(s[i] - '0');
        memset( dp , -1 , sizeof( dp ) );
        return go( 0 , 0 , 0 );
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    //freopen("input.txt", "r", stdin);
  #endif // LOCAL
  cin >> s >> k;
  len = s.size();
  cout << solve() << endl;
  return 0;
}



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

int main() {
  int M,D;
  cin >>M>>D;
  int k,p;
  k=0;
  for(int i=1;i<=M;i++){
    for(int j=1;j<=D;j++){
      p=(j-(j%10))/10;
      if(p>=2&&(j%10)>=2&&i==(p*(j%10))){
        k++;
      }
    }
  }
  cout <<k<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define MAX_N 60
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
pii students[MAX_N];
pii checkP[MAX_N];
ll getlog(ll a){
    ll k = 0;
    while (a){
        k++;
        a/=10;
    }
    return k;
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n,m;
    cin >> n;
    ll best = 1e9;
    for (ll i  = 1;i * i <= n;i++){
        if (n % i) continue;
        ll c = max(getlog(i),getlog(n / i));
        if (c < best) best = c;
    }
    cout << best << endl;
    return 0;
}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    int a[n];
    f1(i,0,n)
    cin>>a[i];

    int arr[n+1];
    memset(arr, 0, sizeof(arr));

    f1(i,0,n)
    {
        arr[a[i]]++;
    }
    // f1(i,1,n)
    // cout<<arr[i]<<

    int ans = 0;
    f1(i,1,n+1)
    {
        ans+=((arr[i]*(arr[i]-1))/2);
    }
    f1(i,0,n)
    {
        temp = ((arr[a[i]]*(arr[a[i]]-1))/2);
        arr[a[i]]--;
        int sum = ans;
        sum -= temp;
        sum += ((arr[a[i]]*(arr[a[i]]-1))/2);
        cout<<sum<<endl;
        arr[a[i]]++;
    }

    return 0;
}

Measured memory_bytes: 5760
N, M, Q = map(int, input().split())
a = [0]*Q
b = [0]*Q
c = [0]*Q
d = [0]*Q
for i in range(Q):
    a[i], b[i], c[i], d[i] = map(int, input().split())

import itertools
import numpy as np    
    
ans = 0  
  
for A in itertools.combinations_with_replacement(range(1,M+1),N):
  score = 0
  for i in range(Q):
    if A[b[i]-1] - A[a[i]-1] == c[i]:
      score += d[i]
  ans = max(score,ans)
    
print(ans)

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

#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define l(i,a,b) for(int i=a;i<b;i++)
#define L(i,a,b) for(int i=a;i<=b;i++)
#define r(i,a,b) for(int i=a;i>=b;i--)
#define R(i,a,b) for(int i=a;i>b;i--)
#define scanl(a) scanf("%lld",&a)
#define scani(a) scanf("%d",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanil(a,b) scanf("%d %lld",&a,&b)
#define pr(a) cout<<a<<" "<<endl;
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" a "<<b<<" b "<<c<<"\n"
#define input(a,n) l(i,0,n) cin>>a[i];

long long int m = 998244353;

//long long int mod = 1000000000;
//ll mod=998244353;
long long  int modularExponentiation(long long int x,long long int n)
{   x = abs(x);
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return  modularExponentiation((x*x),n/2)%m;
    else                             //n is odd
        return (x*(modularExponentiation((x*x)%m,(n-1)/2)))%m;
}

long long int GCD(long long int a,long long  int b)
{
    if (a == 0)
        return b;
    return GCD(b % a, a);
}

/*
int n=10;
struct node1 {
    long long int sum,prefix,suffix;
    sum=prefix=suffix=0;
};
struct node1 tree[2*n+2];

void join(int node){
    int l=2*node,r=l+1;
    tree[node].sum = tree[l].sum+tree[r].sum;
    tree[node].prefix = max(tree[l].prefix,tree[l].sum+tree[r].prefix);
    tree[node].suffix = max(tree[r].suffix,tree[l].suffix+tree[r].sum);
}

void build(int node , int l ,int r){
    if(l==r){
        tree[node].sum = a[l];
        tree[node].prefix = max(0,a[l]);
        tree[node].suffix = max(0,a[l]);
    } else {
        int mid = (l+r)/2;
        auto first,second;
        build(2*node,l,mid);
        build(2*node+1,mid+1,r);
        join(node,2*node,2*node+1);
    }
}

void update(int node,int l,int r,int p){
    if(l>r){
        return ;
    } else if(l==p && r==p){
        tree[node].sum=a[p];
        tree[node].prefix=max(0,a[p]);
        tree[node].suffix = max(0,a[p]);
    } else {
        int mid = (l+r)/2;
        update(2*node,l,mid,p);
        update(2*node+1,mid+1,r,p);
        join(node);
    }
}

node1 query(int node,int l,int r, int start,int last){
    if(start<=l && last>=r){
        return tree[node];
    } else if(l>r){
        return null;
    }
    int mid = (l+r)/2;
    auto first,second;
    first= query(2*node,l,mid,start,last);
    second = query(2*node+1,mid+1,r,start,last);
    join
}
*/



int main(){
    int n,k;
    cin>>n;
    int a[n+1],b[n+1],c[n+1];
    a[0]=0;
    l(i,1,n+1)  cin>>a[i]>>b[i]>>c[i];
    long long int dp[n+1][3]={0};

    a[0]=a[1];
    dp[1][0]=a[1],dp[1][1]=b[1],dp[1][2]=c[1];
    l(i,2,n+1){
        dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
        //pr3(dp[i][0],dp[i][1],dp[i][2]);
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
}




Measured memory_bytes: 7108
N, L = map(int, input().split())

t = list(map(lambda i: L + i, range(N)))

targ = sum(t)
m = 10000000000000
res = 0
for c in t:
    now = targ - c
    if m > abs(targ - now):
        m = abs(targ - now)
        res = now

print(res)


Measured memory_bytes: 3060
#include<iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)

int main() {
    ll n;
    cin >> n;
    ll ac = 0;
    ll wa = 0;
    ll re = 0;
    ll tle = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s == "AC") {
            ac++;
        } else if (s == "WA") {
            wa++;
        } else if (s == "RE") {
            re++;
        } else if (s == "TLE") {
            tle++;
        }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}


Measured memory_bytes: 3624
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

A,B,C = I()
if A <= C <= B:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 77368
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#define neko 300010
#define chkmin(a,b) ((a)<(b)?(a):(b))
#define chkmax(a,b) ((a)>(b)?(a):(b))
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~i))
#define rf(i,a,b) for(register int i=(a);i>=(b);i=~(-i))
using namespace std;
int n,ans;
int main()
{
	int x,y,z,maxi,scnd,thrd;
	scanf("%d%d%d",&x,&y,&z);
	maxi=chkmax(chkmax(x,y),z);
	if(x==maxi)scnd=chkmax(y,z),thrd=chkmin(y,z);
	if(y==maxi)scnd=chkmax(x,z),thrd=chkmin(x,z);
	if(z==maxi)scnd=chkmax(x,y),thrd=chkmin(x,y);
	ans=(maxi-scnd)+(maxi-(thrd+maxi-scnd))/2;
	if((maxi-(thrd+maxi-scnd))&1)ans+=2;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
     int N,t,a;
     cin >> N >> t >>a;
     int tmp = 0;
     int A = 999999;
     int ans = 0;
     for(int i = 0; i < N; i++){
          int h; cin >> h;
          tmp = t*1000 - h*6;
          A = min(A,abs(tmp - a*1000));
          if(A == abs(tmp - a*1000)) ans = i;
     }
     cout << ans+1 << endl;
}

Measured memory_bytes: 256
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)

int min(int a,int b){return (a!=0 && a<b)? a:b;}
int main (){
	int NN,MM,tempa,tempb,ans=1;
	cin >> NN >> MM;
	int tt[100005]={0};
	// 一番狭い区間のデータだけとっておきたいので、終端をメモる配置に適当にでかい値を予め入れておく
	rep(i,MM){
		cin >> tempa >> tempb;
		tt[min(tempa,tempb)] = min(tt[min(tempa,tempb)],(-1)*min(-1*tempb,-1*tempa));
	}
	vector <pair <int ,int > > ttt;
	rep(i,NN)if(tt[i]!=0)ttt.push_back(make_pair(i,tt[i]));
	int ff = ttt[0].first;
	int fb = ttt[0].second;
	rep(i,ttt.size()){
		if( fb <= ttt[i].first ){ff = ttt[i].first;fb = ttt[i].second;ans ++;}
		if( fb > ttt[i].second ){fb = ttt[i].second;}
	}
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 1784
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int X = scan.nextInt();
        int T = scan.nextInt();

        int ans;

        if(N%X == 0){
            ans = N/X*T;
        } else {
            ans = (N/X+1)*T;
        }
        os.println(ans);
    }
}

Measured memory_bytes: 27084
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll A;
    bool approve = true;
    rep(i, N){
        cin >> A;
        if(A % 2 == 0){
            if(A % 3 != 0 && A % 5 != 0){
                approve = false;
            }
        }
    }

    if(approve){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }

    return 0;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<deque>
#include<cmath>
#include<set>
#include<cstring>
#include<string.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
//----------------
#define int long long
//----------------
inline int read()
{
    int x = 0, f = 1;char ch = getchar();
    while (ch < '0' || ch > '9'){if (ch == '-')f = -1;ch = getchar();}
    while (ch >= '0' && ch <= '9'){x = (x << 1) + (x << 3) + (ch ^ 48);ch = getchar();}
    return x * f;
}
#define sdf(x) x=read()
#define For(i, a, b) for (int i = (a); i <= (b); i++)
#define FFor(i, a, b) for (int i = (a); i >= (b); i--)
#define me(a, b) memset(a, b, sizeof(a))
#define mid ((l + ((r - l)/2)))
#define random(a, b) ((a) + rand() % ((b) - (a) + 1))
#define bg1(x) cout<<(#x)<<":"<<(x)<<" "<<endl
#define bg2(x,y) cout<<(#x)<<":"<<(x)<<" "<<(#y)<<":"<<(y)<<" "<<endl
#define bg3(x,y,z) cout<<(#x)<<":"<<(x)<<" "<<(#y)<<":"<<(y)<<" "<<(#z)<<":"<<(z)<<" "<<endl
#define bg4(x,y,z,w) cout<<(#x)<<":"<<(x)<<" "<<(#y)<<":"<<(y)<<" "<<(#z)<<":"<<(z)<<" "<<(#w)<<":"<<(w)<<" "<<endl
#define bg5(x,y,z,w,k) cout<<(#x)<<":"<<(x)<<" "<<(#y)<<":"<<(y)<<" "<<(#z)<<":"<<(z)<<" "<<(#w)<<":"<<(w)<<" "<<(#k)<<":"<<(k)<<" "<<endl
#define call(x) cout<<x<<":"
#define lll cout<<"\n------\n"
int die = 0;
#define Die die++;if(die>100000){cout<<"dead!!!";exit(0);}
#define mk make_pair
#define pb push_back
const double eps = 1e-8;
// srand((unsigned)time(NULL));
const int mod = 1e9 + 7;
const int N = 1e6 + 5;

int n,k;

void sol1(){
    double ans=0;
    For(i,1,n){
        int x=0;
        while(i*(1<<x)<k)x++;
        ans+=1.0/(double)(1<<x);
    }
    ans/=n;
    printf("%.9f\n", ans);
}

void rd(){
    sdf(n),sdf(k);
    sol1();
}

signed main()
{

    rd();
}




Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {

    public static void main(String[] args) {
        Scanner num = new Scanner(System.in);
        int[] A = new int[100];
        int sum = 0;

        int N = num.nextInt();
        for(int i = 0; i < N; i++) {
            A[i] = num.nextInt();    
        }

        for(int i = 0; i < N - 1; i++) {
            int min = i;
            for(int j = i + 1; j < N; j++) {
                if(A[j] < A[min]) {
                    min = j;
                }
            }
            if(min != i){
                int tmp = A[min];
                A[min] = A[i];
                A[i] = tmp;
                sum++;
            }
        }

        for(int i = 0; i < N; i++) {
            System.out.print(A[i]);
            if(i != N - 1) {
                System.out.print(" ");
            }
        }
        System.out.println("\n" + sum);
    }
}


Measured memory_bytes: 26260
#include<bits/stdc++.h>
using namespace std;
int main(){

	cout << fixed << setprecision(5);

	int a, b;
	cin>>a>>b;

	cout<< a / b <<" ";
	cout<< a % b <<" ";
	cout<<(double)a / b <<endl;

	return 0;
}



Measured memory_bytes: 3260
//written by NewbieChd
#include <cstdio>
#include <cctype>
#include <algorithm>
using namespace std;

const int BUF = 1000000;
char buf[BUF], *p1, *p2;
inline char getChar() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BUF, stdin), p1 == p2) ? EOF : *p1++; }
inline int read() {
    register int f = 0;
    bool b = 1;
    register char c;
    while (!isdigit(c = getChar()))
        if (c == 45)
            b = 0;
    do
        f = f * 10 + (c ^ 48);
    while (isdigit(c = getChar()));
    return b ? f : ~f + 1;
}

const int N = 100003;
const long long inf = 1e18;
int a[N];
long long f[N][2];

int main() {
    register int n = read(), i;
    for (i = 1; i <= n; ++i)
        a[i] = read();
    f[1][0] = a[1], f[1][1] = -inf;
    for (i = 2; i <= n; ++i)
        f[i][0] = max(f[i - 1][0] + a[i], f[i - 1][1] + a[i]),
        f[i][1] = max(f[i - 1][0] - (a[i - 1] << 1) - a[i], f[i - 1][1] + (a[i - 1] << 1) - a[i]);
    printf("%lld\n", max(f[n][0], f[n][1]));
    return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace std;
int main()
{/*
	 #ifndef ONLINE_JUDGE
	 freopen("input.txt","r",stdin);
	 freopen("output.txt","w",stdout);
	 #endif
	 ios_base::sync_with_stdio(false);
	cin.tie(NULL);*/
	int n;
	cin>>n;
	string s;
	cin>>s;
	int count=0;
	for(int i=0;i+3<=n;i++)
	{
		//string k=s.substr(i,3);
		//watch(k);
		if(s.substr(i,3)=="ABC")
			count++;
	}
	cout<<count;

}
	


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    ll h, n; cin >> h >> n;
    rep(i,n) {
        ll tmp;
        cin >> tmp;
        h -= tmp;
    }

    if (h > 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
using namespace std;
 
int main(){
    int n,m;
    cin>>n>>m;

    int ans[51]={0};

    for(int t=0;t<m;t++){
        int a,b;
        cin>>a>>b;
        ans[a-1]++;
        ans[b-1]++;
    }

    for(int t=0;t<n;t++){
        cout<<ans[t]<<"\n";
    }
  
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
#include<cmath>
#include<cstring>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

struct edge{
    int from,to;
    ll cost;
    edge(int t,ll c):to(t),cost(c){};
    edge(int f,int t,ll c):from(f),to(t),cost(c){};
};

const ll INF = 1LL<<60;

using P = pair<ll,ll>;
using PP = pair<P,ll>;
void dijkstra(int s,int h,vector<ll> &d,vector<ll> &y,vector<ll> &H,vector<vector<edge> > &G) {
    priority_queue<PP, vector<PP>, greater<PP> > que;
    fill(All(d),INF);
    d[s] = 0;
    y[s] = h;
    que.push(PP(P(0,h),s));

    while (!que.empty()) {
        PP pp = que.top();
        que.pop();
        ll cost = pp.first.first;
        ll curH = pp.first.second;
        int v = pp.second;
        if (d[v] < cost) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if(H[v]<e.cost)continue;//飛び移れない
            //上ってからじゃないと渡れないとき
            if(curH-e.cost<0){
                if(e.cost-curH<=H[v]-curH&&d[e.to] > d[v] + (e.cost-curH)+e.cost){
                    //本当に登れるか？&&最短距離を更新できるか？
                    d[e.to]=d[v] + (e.cost-curH)+e.cost;
                    y[e.to]=0;
                    que.push(PP(P(d[e.to],0),e.to));
                }
            }else if(curH-e.cost>H[e.to]){//下ってからじゃないと渡れないとき
                    if(d[e.to] > d[v] + ((curH-e.cost)-H[e.to])+e.cost){
                        d[e.to] = d[v] + ((curH-e.cost)-H[e.to])+e.cost;
                        y[e.to]=H[e.to];
                        que.push(PP(P(d[e.to],H[e.to]),e.to));
                    }
            }else {
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    y[e.to] = curH - e.cost;
                    que.push(PP(P(d[e.to], curH-e.cost),e.to));
                }
            }
        }
    }
}

int main(){
    int N,M,X;
    cin >> N >> M >> X;
    vector<ll> H(N);
    rep(i,N)cin >> H[i];
    vector<vector<edge> > G(N);
    rep(i,M){
        int a,b;
        ll c;
        cin >> a >> b >> c;
        a--;b--;
        G[a].push_back(edge(b,c));
        G[b].push_back(edge(a,c));
    }

    vector<ll> dist(N),Y(N,0);
    dijkstra(0,X,dist,Y,H,G);
    if(dist[N-1]==INF)cout << -1 << endl;
    else cout << dist[N-1]+(H[N-1]-Y[N-1]) << endl;
    return 0;
}


Measured memory_bytes: 24508
#include <bits/stdc++.h>
using namespace std;
 
int main() {
      string c;
      cin >> c;
      if (c=="a"||c=="i"||c=="u"||c=="e"||c=="o"){
            cout << "vowel" << endl;
            }
      else{
            cout << "consonant" << endl;
            }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N, fac[500001];
vi P;
Tree<int> tmp, tmp2;
int ans = 0;

ll po (ll b, ll p) { return !p?1:po(b*b%MOD,p/2)*(p&1?b:1)%MOD; }
ll inv (ll b) { return po(b,MOD-2); }

ll ad(ll a, ll b) { return (a+b)%MOD; }
ll sub(ll a, ll b) { return (a-b+MOD)%MOD; }
ll mul(ll a, ll b) { return a*b%MOD; }
ll divi(ll a, ll b) { return mul(a,inv(b)); }

int aft = 0;
ll sum2 = 0;

void process(int ind) {
    ll res = 0;
    if (P[ind] == 0) {
        res = ad(res,mul(sum2,inv(sz(tmp))));
        res = ad(res,mul(aft,inv(2)));
        aft ++;
    } else {
        res = ad(res,tmp2.order_of_key(P[ind]));
        res = ad(res,mul(mul(aft,tmp.order_of_key(P[ind])),inv(sz(tmp))));
        sum2 = ad(sum2,sz(tmp)-tmp.order_of_key(P[ind]));
        tmp2.insert(P[ind]);
    }
    ans = ad(ans,mul(res,fac[N-1-ind]));
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    fac[0] = 1;
    FOR(i,1,500001) fac[i] = mul(i,fac[i-1]);
    cin >> N; P.resize(N);
    FOR(i,1,N+1) tmp.insert(i);
    F0R(i,N) {
        cin >> P[i];
        if (P[i]) tmp.erase(P[i]);
    }
    F0Rd(i,N) process(i);
    cout << mul(ad(ans,1),fac[sz(tmp)]);
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 27648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int l;
    cin >> l;
    int n = 1;
    while(n < 20 && l >= pow(2, n))
    {
        n++;
    }

    vector<vector<int>> edge;
    int mmax = pow(2, n-1) - 1;
    int diff = l-1;
    for(int i = n-1; i > 0; i--)
    {
        int tmp = diff - pow(2, i-1) + 1;
        if(tmp > mmax)
        {
            edge.push_back({i, n, tmp});
            diff = tmp - 1;
        }
    }

    cout << n << " " << 2 * (n-1) + edge.size() << endl;
    for(int i = 1; i < n; i++)
    {
        cout << i << " " << i+1 << " " << pow(2, i-1) << endl;
        cout << i << " " << i+1 << " " << 0 << endl;
    }
    for(int i = 0; i < edge.size(); i++)
    {
        vector<int> ans = edge[i];
        cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
    }
}


Measured memory_bytes: 256
N = int(input())
MARCH = [0] * 5

for i in range(N):
    s = input()
    if s[0] == "M":
        MARCH[0] += 1
    elif s[0] == "A":
        MARCH[1] += 1
    elif s[0] == "R":
        MARCH[2] += 1
    elif s[0] == "C":
        MARCH[3] += 1
    elif s[0] == "H":
        MARCH[4] += 1

ans = 0

for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+1, 5):
            ans += MARCH[i] * MARCH[j] * MARCH[k]

print(ans)

Measured memory_bytes: 3064
n=int(input())
a=n*3//4+3
for i in range(max(n//4,1),a):
    for j in range(a-3,3501):
        k=4*i*j-n*(i+j)
        if k==0:
            continue
        x,y=divmod(n*i*j,k)
        if y==0 and x>0:
            print(i,j,x)
            exit()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define MAX 100005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);
#define fi(a,b,c) for(int i=a;i<b;i=i+c)
#define fj(a,b,c) for(int j=a;j<b;j+=c)
using namespace std;
 
ll gcd(ll n1,ll n2) {
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent) {
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
ll max(ll a,ll b,ll c) {
	return max(a,max(b,c));
}
int max(int a,int b,int c) {
	return max(a,max(b,c));
}

int main()
{
	int n, W;
	sd(n);sd(W);
	int v[n],w[n];
	fi(0,n,1){
		sd(w[i]);sd(v[i]);
	}
	ll dp[n][W+1][2]={0};
	for(int i=0;i<n;i++) {
		for(int j=0;j<W+1;j++) {
			if(i==0 && w[i]==j){
				dp[i][j][1]=v[i];
				dp[i][j][0]=0;
			}else if(i==0){
				dp[i][j][0]=0;
				dp[i][j][1]=0;
			}else if(j-w[i]>=0) {
				dp[i][j][1]=v[i]+max(dp[i-1][j-w[i]][1], dp[i-1][j-w[i]][0]);
				dp[i][j][0]=max(dp[i-1][j][1], dp[i-1][j][0]);
			}else{
				dp[i][j][0]=max(dp[i-1][j][1], dp[i-1][j][0]);
				dp[i][j][1]=max(dp[i-1][j][1], dp[i-1][j][0]);
			}
			
		}
	}
	ll ans=0;
	for(int i=0;i<=W;i++) {
		ans=max(ans, dp[n-1][i][0], dp[n-1][i][1]);
	}
	cout<<ans;
}

Measured memory_bytes: 159856