akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <unordered_map>

using namespace std;

long long choose(long long n, long long r)
{
	if (n < r) {
		return 0;
	}
	long long ans = 1;

	for (int i = 0; i < r; ++i) {
		ans *= n - i;
	}
	for (int i = 0; i < r; ++i) {
		ans /= (i + 1);
	}
	return ans;
}

int main()
{
	int N;
	cin >> N;
	vector<long long> A(N);
	for (auto &x : A) {
		cin >> x;
	}

	vector<long long> S(N);
	partial_sum(A.begin(), A.end(), S.begin());

	unordered_map<long long, int> P;
	for (int i = 0; i < N; ++i) {
		++P[S[i]];
	}

	long long ans = P[0];
	for (const auto &e : P) {
		ans += choose(e.second, 2);
	}
	cout << ans << endl;
}


Measured memory_bytes: 11592
N,K = map(int, input().split())
ans = 0


#if (N < K):
 #   ans = N
if(N % K == 0):
    ans = 0
else:
    if (N < K):
        ans = N
    N = N % K
    if(N <= abs(N-K)):
        ans = N
    else:
        ans = abs(N-K)

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
class Eratosthenes{
  public:
    int n, sqlim;
    vector<bool> prime;
    Eratosthenes(int N):n(N+1){
        sqlim=(int)ceil(sqrt(n));
        prime=vector<bool>(n,1); prime[0]=prime[1]=0;
        for(int i=2;i<=sqlim;i++) if(prime[i]) for(int j=i*i;j<=n;j+=i) prime[j]=0;}
    vector<int> primeArray(){vi ret; for(int i=2;i<=55555;i++) if(prime[i]) ret.push_back(i); return ret;}
};


int main(){
	int n;cin>>n;
	Eratosthenes e(55555);
	vi v=e.primeArray(),ans;
	for(auto i:v){
		if(i%5==1)ans.push_back(i);
		if(ans.size()==n)break;
	}
	puti(ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // cin, cout の高速化
#define MOD 1000000007
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i <= (n); i++)

int main()
{
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    int max_x, min_y;
    max_x = x;
    min_y = y;

    REP(i, n)
    {
        cin >> x;
        if (max_x < x)
        {
            max_x = x;
        }
    }
    REP(i, m)
    {
        cin >> y;
        if (min_y > y)
        {
            min_y = y;
        }
    }
    if (max_x < min_y)
    {
        cout << "No War" << endl;
    }
    else
    {
        cout << "War" << endl;
    }
}

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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define pp pop_back()
#define ll long long
#define ld long double
#define ok puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

inline ll min(ll a, ll b) {
    return (a > b) ? b : a;
}

inline ll max(ll a, ll b) {
    return (a > b) ? a : b;
}

const int N = 1e5 + 7;
const int inf = 1e9 + 7;
const ll linf = 1e18 + 9;
const int mod = inf;

ll f[N];

ll binpow (ll a, ll n) {
    if (n == 0) return 1;
    if (n == 1) return a;
    if (n & 1) {
        return (a * 1LL * binpow(a, n - 1)) % inf;
    } else {
        ll t = binpow (a, n / 2);
        return (t * 1LL * t) % inf;
    }
}

ll Cnk (ll n, ll k) {
    if (k > n) return 0;
    return f[n] * (binpow(f[k] * f[n - k] % inf, inf - 2) % inf) % inf;
}

ll a[N];
ll freq[N];

int main() {
    f[0] = 1;
    for (ll i = 1; i <= N; i++) {
        f[i] = i * f[i - 1] % inf;
    }
    ll n; scanf ("%I64d", &n);
    ll d;
    for (ll i = 1; i <= n + 1; i++) {
        scanf ("%I64d", a + i);
        if (freq[a[i]]) {
            d = i - freq[a[i]];
        }
        freq[a[i]] = i;
    }
    printf ("%I64d\n", n);
    for (ll i = 2; i <= n; i++) {
        printf ("%I64d\n", (Cnk(n + 1, i) - Cnk(n - d, i - 1) + inf) % inf);
    }
    printf ("1");
}


Measured memory_bytes: 8960
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")
    };
}

pub struct Sieve {
    primes: Vec<usize>,
    tbl: Vec<usize>,
}
impl Sieve {
    pub fn new(n: usize) -> Sieve {
        let sz: usize = (n + 1) as usize;
        let mut primes = Vec::new();
        let mut tbl = vec![0; sz];
        tbl[0] = 0;
        tbl[1] = 0;
        for i in 2..sz {
            if tbl[i] != 0 {
                continue;
            }
            primes.push(i as usize);
            tbl[i] = i as usize;
            let mut j = i * i;
            while j < sz {
                if tbl[j] == 0 {
                    tbl[j] = i as usize;
                }
                j += i;
            }
        }
        Sieve { primes: primes, tbl: tbl }
    }
    pub fn primes(&self) -> &Vec<usize> {
        &self.primes
    }
    pub fn is_prime(&self, x: usize) -> bool {
        x > 1 && self.tbl[x as usize] == x
    }
    pub fn factorization(&self, x: usize) -> Vec<(usize, usize)> {
        let mut mx = x;
        let mut fl = Vec::new();
        while mx > 1 {
            let fx = self.tbl[mx as usize];
            fl.push(fx);
            mx /= fx;
        }
        if fl.is_empty() {
            return Vec::new();
        }
        let mut res = vec![(fl[0], 0)];
        for p in &fl {
            let l = res.len() - 1;
            let last = res[l];
            if last.0 == *p {
                res[l].1 += 1;
            } else {
                res.push((*p, 1));
            }
        }
        res
    }
}

const MOD: u64 = 1_000_000_007;

fn main() {
    input! {
        n: usize
    }
    let s = Sieve::new(n);
    let mut tbl = vec![0;n+1];
    for i in 1..n+1 {
        let f = s.factorization(i);
        for x in f {
            tbl[x.0] += x.1;
        }
    }
    let mut res: u64 = 1;
    for v in tbl {
        res *= (v+1) as u64;
        res %= MOD;
    }
    println!("{}", res);
}


Measured memory_bytes: 4352
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
for i in range(h):
    ans = []
    for j in range(w):
        bomb = 0
        if s[i][j] == ".":
            for k in [0, -1, 1]:
                for n in [0, -1, 1]:
                    if i + k < h and j + n < w:
                        if i + k < 0 or j + n < 0:
                            continue
                        if s[i + k][j + n] == "#":
                            bomb += 1
            ans.append(str(bomb))
        else:
            ans.append("#")
    print("".join(ans))

Measured memory_bytes: 3064
#include <stdio.h>
int main ()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if(a > b)
	{
		printf("a > b\n");
	}
	else if(a < b)
	{
		printf("a < b\n");
	}
	else
	{
		printf("a == b\n");
	}
	return 0;
} 


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

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

  unsigned long long N[1000];
  for (unsigned long long i = 0; i < 1000; i++) {
    N[i] = i*i*i*i*i;
  }

  int A=0, B=0;
  for (int i = 0; i < 1000; i++) {
    for (int j = 0; j < 1000; j++) {
      if (N[i] - N[j] == X) {
        A = i;
        B = j;
      } else if (N[i] + N[j] == X) {
        A = i;
        B = -j;
      }
    }
  }

  cout << A << " " << B << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int ab, bc;
  cin >> ab >> bc;
  cout << (ab * bc) / 2;
}

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


int main() {

    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i,m) cin >> b[i];
    int ans = 0;
    rep(i,n) {
        int res = c;
        rep(j,m) {
            int a; cin >> a;
            res += a * b[j];
        }
        if (res > 0) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 *		author:  zvm
 *		created: 27.09.2020 16:42:29
**/

#include <bits/stdc++.h>

using namespace std ;

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

	string s ;
	cin >> s ;
	cout << count(s.begin(),s.end(),'1') << endl ;
}


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

#define MOD 1000000007

int n, a[21][21], dp[1<<21];

void add(int &a, int b) {
    a = (a + b) % MOD;
}

int solve(int subset) {
    if (subset == (1 << n) - 1)
        return 1;
    if (dp[subset] != -1)
        return dp[subset];

    int i = __builtin_popcount(subset);
    dp[subset] = 0;
    for (int j=0; j<n; j++)
        if (a[i][j] && !((subset >> j) & 1))
            add(dp[subset], solve(subset | 1 << j));

    return dp[subset];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    memset(dp, -1, sizeof(dp));
    cout << solve(0) << "\n";

    return 0;
}


Measured memory_bytes: 8448
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
c = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    bag = []
    for k in range(m):
        bag.append(abs(a[i][0] - c[k][0]) + abs(a[i][1] - c[k][1]))
    ind = bag.index(min(bag))
    print(ind + 1)


Measured memory_bytes: 3060
import java.util.Scanner;

class Main{
	public static void main(String arg[]) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		sc.nextLine();
		String[] str = new String[H];
		String[][] S = new String[H][W];
		
		for(int i = 0; i < H; i++ ) {
			str[i]= sc.nextLine(); 
		}
		sc.close();
		
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				String s[] = str[i].split("");
				S[i][j] = s[j];
			}
		}
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(S[i][j].equals("#")) {
					System.out.print("#");
				}else {
					System.out.print(mineCount(i,j,S));
				}
			}
			System.out.println();
		}
	}
	public static int mineCount(int h, int w, String[][] S) {
		int count = 0;
		for(int i = h - 1; i <= h + 1; i++) {
			if( i < 0 || i >= S.length) {
				continue;
			}
			for(int j = w - 1; j <= w + 1; j++) {
				if( j < 0 || j >= S[0].length ) {
					continue;
				}
				if(S[i][j].equals("#")) {
					count++;
				}
			}
		}
		return count;
	}
}

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

using namespace std;

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

	vector<int> a(N);
	int c = 0;
	for(int i = 0; i < N; i++) {
		cin >> a[i];
		c ^= a[i];
	}

	for(int i = 0; i < N; i++) {
		if(i != 0) {
			cout << " ";
		}
		cout << (a[i] ^ c);
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 4032
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
int c[4][4];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    for(int i = 1; i <= 3; i++) {
        for(int j = 1; j <= 3; j++) {
            cin >> c[i][j];
        }
    }
    bool can = false;
    for(int a1 = 0; a1 <= 100 and not can; a1++) {
        for(int a2 = 0; a2 <= 100 and not can; a2++) {
            for(int a3 = 0; a3 <= 100 and not can; a3++) {
                int b1 = c[1][1] - a1;
                int b2 = c[1][2] - a1;
                int b3 = c[1][3] - a1;
                can |= a2 + b1 == c[2][1] and a2 + b2 == c[2][2] and a2 + b3 == c[2][3]
                    and a3 + b1 == c[3][1] and a3 + b2 == c[3][2] and a3 + b3 == c[3][3];
            }
        }
    }
    cout << (can ? "Yes" : "No") << endl;
    return 0;
}


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

int main()
{   char a ,b ,c  ;
    string s1,s2,s3  ;
    cin >> s1 >> s2 >> s3;
    a=s1[0] - 32 ;
    b=s2[0] - 32 ;
    c=s3[0] - 32 ;
    cout << a << b << c ;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
#define il inline
typedef long long ll;

using namespace std;

inline int readINT(){
	int ans=0,c;
	while(!isdigit(c=getchar()));
	do ans=ans*10+c-'0';
	while(isdigit(c=getchar()));
	return ans;
}

int n,sum,ans=0;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n;
	for(register int i=1;i<=n;i++){
		sum=0;
		int dd=i;
	     while(dd>0){
	     	dd=dd/10;
	     	sum++;
	     }
	     if(sum%2==1){
	     	ans++;
	     }
	}
	printf("%d",ans);
	return 0;
}

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    int n;
    cin >> n;
    vector<int> array(n);
    vector<int> p(n);
    vector<int> q(n);
    rep(i, n)
    {
        cin >> p[i];
    }
    rep(i, n)
    {
        cin >> q[i];
    }
    rep(i, n + 1)
    {
        array[i] = i + 1;
    }
    int a = 0;
    int b = 0;
    int count = 1;
    do
    {
        if (array == p)
            a = count;
        if (array == q)
            b = count;
        count++;
    } while (next_permutation(array.begin(), array.end()));
    c(abs(a - b));

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

ll N , M ;
ll S , T;
map<ll, vector<ll> > G;
map<ll, bool> used;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N >> M ;
    
    rep(i, M){
        ll u , v;
        cin >> u >> v;
        u--; v--;
        rep(i, 3){
            // G[u + i * N].pb(N * ((i + 1)%3) + v);
            G[u].pb(N + v);
            G[N + u].pb(N + N + v);
            G[N + N + u].pb(v);
        }
    }
    cin >> S >> T ;
    S--; T--;
    
    used[S] = true;
    
    queue<ll> ret;
    ret.push(S);
    
    ll ans = 0;
    
    while(ret.size() != 0){
        ans ++;
        ll siz = ret.size();
        rep(idx, siz){
            ll front = ret.front();
            ret.pop();
            rep(i, G[front].size()){
                ll idx = G[front][i];
                if(used[idx]) continue;
                ret.push(idx);
                used[idx] = true;
            }
        }
        if(used[T]) break;
    }
    
    if(used[T]) cout << ans/3 << endl;
    else cout << -1 << endl;
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 56576
/* god is with you dont worry */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define input() ios_base::sync_with_stdio(false);cin.tie(0);
const ll mod=1e9+7;
/*ll power(ll x,ll y){
	ll res=1;
	while(y){
		if(y&1){
			res=res*x;
		}
		x=x*x;
		y=y/2;
	}
	return res;
}*/
void solve(){
    ll x;
    cin>>x;
    ll f=100,ans=0;
    while(f<x){
    	f=f+(f/100);
    	ans++;
    }
    cout<<ans;
}
int main(){
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3652
from collections import Counter
if __name__ == '__main__':
    N = int(input())
    V = list(map(int, input().split()))
    V_low = []
    V_up = []
    for i, v in enumerate(V):
        if i%2 == 0:
            V_low.append(v)
        else:
            V_up.append(v)
    

    count_low = Counter(V_low).most_common()
    count_up = Counter(V_up).most_common()
    
    low_most = count_low[0][0]
    up_most = count_up[0][0]
    
    if low_most != up_most:
        print(len(V_low) + len(V_up) - count_low[0][1] - count_up[0][1])
    else:
        if count_low[0][1] > count_up[0][1]:
            if(len(count_up) == 1):
                print(len(V_low) + len(V_up) - count_low[0][1])
            else:
                print(len(V_low) + len(V_up) - count_low[0][1] - count_up[1][1])
        elif count_low[0][1] <  count_up[0][1]:
            if(len(count_low) == 1):
                print(len(V_low) + len(V_up) - count_up[0][1])
            else:
                print(len(V_low) + len(V_up) - count_up[0][1] - count_low[1][1])
        else:
            if len(count_up) != 1 and len(count_low) != 1:
                if count_low[1][1] <= count_up[1][1]:
                    print(len(V_low) + len(V_up) - count_low[0][1] - count_up[1][1])
                else:
                    print(len(V_low) + len(V_up) - count_up[0][1] - count_low[1][1])
            else:
                if len(count_low) == 1 and len(count_up) == 1:
                    print(len(V_low) + len(V_up) - count_low[0][1])
                elif len(count_low) == 1:
                    print(len(V_low) + len(V_up) - count_low[0][1] - count_up[1][1])
                else:
                    print(len(V_low) + len(V_up) - count_up[0][1] - count_low[1][1])

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i=0; i<N; i++){
        cin >> a.at(i);
    }

    sort(a.begin(), a.end(), greater<int>());
    int diff = 0;
    for(int i=0; i<N; i++){
        diff += a.at(i) * (i & 1 ? -1: 1);
    }

    cout << diff << endl;
}

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

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define REP2(i,n) for(int i=0;i<(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP4(i,m,n,s) for(int i=m;(s>0 and i<(int)(n)) or (s<0 and i>(int)(n));i+=s)
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REPIT(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define PIS(x) printf("%d ",x)
#define PN() putchar('\n')
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define MT make_tuple

using PII = pair<int, int>;
using TI3 = tuple<int, int, int>;
using LL = long long;
using ULL =  unsigned long long;
using MAT = array<array<LL, 2>, 2>;

void RI() {}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d", &head);
    RI(tail...);
}
void RLL() {}
template<typename... T>
void RLL( LL& head, T&... tail ) {
    scanf("%lld", &head);
    RLL(tail...);
}
void print() {putchar('\n');}
template<typename T, typename... U>
void print(T head, U... tail) {
    cout << head << " ";
    print(tail...);
}

const int MOD = 1000000007;
#define MAX_N 100005
int a[3 * MAX_N];

int main()
{
    int n;
    RI(n);
    REP(i, 3 * n) {
        RI(a[i]);
    }
    sort(a, a + 3 * n, greater<int>());
    LL ans = 0;
    REP(i, 1, 2*n, 2) {
        ans += a[i];
    }
    printf("%lld\n", ans);
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int N = s.size();

  vector<int> h(N+1, 20000);
  for(int i = 0; i < N; ++i) {
    if(s[i] == '/') h[i+1] = h[i] + 1;
    else if(s[i] == '\\') h[i+1] = h[i] - 1;
    else h[i+1] = h[i];
  }

  vector<vector<int> > f(40002);
  for(int i = 0; i < h.size(); ++i) f[h[i]].push_back(i);

  vector<int> used(N+1, 0);
  vector<int> v(N+1, 0);
  for(int y = (int)f.size()-1; y >= 0; --y) {
    for(int i = 0; i+1 < f[y].size(); ++i) {
      int x = f[y][i];
      int nx = f[y][i+1];
      if(!used[x] && s[x] == '\\') {
        for(int j = x, k = 0; j < nx; ++j) {
          used[j] = true;
          v[x] += h[x] - h[j];
        }
      }
    }
  }

  int sum = 0;
  vector<int> ans;
  for(int i = 0; i < v.size(); ++i) {
    if(v[i]) {
      sum += v[i];
      ans.push_back(v[i]);
    }
  }
  cout << sum << endl;
  cout << ans.size();
  for(int i = 0; i < ans.size(); ++i) cout << " " << ans[i];
  cout << endl;

  return 0;
}

Measured memory_bytes: 2988
//064B

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int mi,ma,N;

void takeMinMax(int a[]){
mi=1000;
ma=0;
for(int i=0;i<=N-1;i++){
mi = min(mi,a[i]);
ma=max(ma,a[i]);
}
}

int main(){
int a[102];
cin>>N;
for(int i=0;i<=N-1;i++){
cin>>a[i];
}

takeMinMax(a);

cout << ma-mi << endl;

return 0;
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
const ll inf=(1e18);
const ll mod=1000000007;
bool dp[100000];
int main(){
int n;
cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++)cin>>a[i];
dp[0]=true;
for(int i=0;i<n;i++){
    for(int j=100000;j>=0;j--){
        if(j<a[i])continue;
        if(dp[j-a[i]])dp[j]=true;
    }
}
int q;
cin>>q;
vector<int> b(q);
for(int i=0;i<q;i++)cin>>b[i];
for(int i=0;i<q;i++){
    if(dp[b[i]])cout<<"yes"<<endl;
    else cout<<"no"<<endl;
}

}





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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> p(m);
    vector<string> s(m);
    rep(i,m){
        int p_i; cin >> p_i; p_i--;
        p[i] = p_i;
        string st; cin >> st;
        s[i] = st;
    }

    vector<bool> cor(n,false);
    vector<int> pen(n,0);
    rep(i,m){
        int pi = p[i];
        string si = s[i];
        if(cor[pi]) continue;
        else if(si == "AC") cor[pi] = true;
        else pen[pi]++;
    }
    int corr = 0;
    int pena = 0;
    rep(i,n){
        if(cor[i]){
            corr++;
            pena += pen[i];
        }
    }
    cout << corr << " " << pena << endl;

    /*for(int i : p) cout << i << " ";
    cout << endl;
    for(string i : s) cout << i << " ";
    cout << endl;
    for(int i : cor) cout << i << " ";
    cout << endl;
    for(int i : pen) cout << i << " ";
    cout << endl;*/
}


Measured memory_bytes: 6528
H, N = map(int, input().split())
A = [0]*N
B = [0]*N

for i in range(N):
    A[i], B[i] = map(int, input().split())
"""
# i番目までの魔法を使い, モンスターの体力をj以上減らすのに必要な魔力の最小値(個数制限なしナップザック)
dp = [[float("inf")]*(H+1) for _ in range(N+1)]
dp[0][0] = 0

for i in range(1, N+1):
    for j in range(H+1):
        if j < A[i-1]:
            dp[i][j] = min(dp[i-1][j], B[i-1])
        else:
            dp[i][j] = min(dp[i-1][j], dp[i][j-A[i-1]]+B[i-1])

print(dp[N][H])
"""
# メモリ削減(ただし, 計算時間は増えてしまう)
# 配るDPで考える
# モンスターの体力をj減らすのに必要な魔力の最小値
dp = [float("inf")]*(H+10**4)
dp[0] = 0
for i in range(N):
    for j in range(H):
        dp[j+A[i]] = min(dp[j+A[i]], dp[j]+B[i])

ans = float("inf")
for j in range(H, H+10**4):
    ans = min(ans, dp[j])

print(ans)


Measured memory_bytes: 49756
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:usize,
    b:usize,
    }
    let mut z=0;
    for i in 0..=b {
        if i/10>1&&i%10>1&&(i/10)*(i%10)<=a {z+=1;}
    }
    println!("{}",z)
}

Measured memory_bytes: 2124
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
    if     (ch=='A')return 1;
    else if(ch=='C')return 2;
    else if(ch=='G')return 3;
    else if(ch=='T')return 4;
    else return 0;
}

long long getKey(char str[]){
    long long sum=0,p=1,i;
    for(i=0; i<strlen(str);i++){
        sum+=p*(getChar(str[i]));
        p*=5;
    }
    return sum;
}

int h1(int x){
    return x%M;
}
int h2(int x){
    return 1+(x%(M-1));
}

int find(char str[]){
    long long x,i,h;
    x=getKey(str);
    for(i=0;;i++){
        h=(h1(x)+i*h2(x))%M;
        if(strcmp(H[h],str)==0)return 1;
        else if(strlen(H[h])==0)return 0;
    }
    return 0;
}

int insert(char str[]){
    long long x,i,h;
    x=getKey(str);
    for(i=0;;i++){
        h=(h1(x)+i*h2(x))%M;
        if(strcmp(H[h],str)==0)return 1;
        else if(strlen(H[h])==0){
            strcpy(H[h],str);
            return 0;
        }
    }
    return 0;
}

int main(){
    int i,n,h;
    char str[L],com[9];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s %s",com,str);

        if(com[0]=='i'){
            insert(str);
        } else {
            if(find(str))printf("yes\n");
            else printf("no\n");
        }
    }
    return 0;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

long long int C[51][51]; // C[n][k] -> nCk
void combTable(int N) {
  for(int i = 0; i <= N; ++i) {
    for(int j = 0; j <= i; ++j) {
      if(j == 0 || j == i) C[i][j] = 1LL;
      else C[i][j] = (C[i-1][j-1] + C[i-1][j]);
    }
  }
}


vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    combTable(50);

    int N,A,B;
    cin >> N >> A >> B;

    vector<long double> v(N);
    REP(i,N) cin >> v[i];

    sort(all(v),greater<>());

    long double ans = 0;
    REP(i,A) ans += v[i]/(long double)A;

    printf("%.6Lf\n",ans);

    int num1 = 0;
    REP(i,N) if(v[i]==v[A-1]) num1++;

    int num2 = 0;
    REP(i,A) if(v[i]!=v[A-1]) num2++;

    ll ans_num = 0;
    if(num1+num2==A){
        ans_num = 1;
    } else if(num2 != 0) {
        ans_num += C[num1][A-num2];
    } else {
        rep(i,A,B+1) {
            ans_num += C[num1][i];
        }
    }

    pl(ans_num)

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;
//#define local
const int mod=1e9+7;
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    int n,i,cnt=0,ans=1,a[100010],f[100010]= {0};
    cin>>n;
    for(i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
        f[a[i]]++;
    }
    for(i=1; i<n; i++)
    {
        if(f[i]==2) cnt++;
        else if(f[i]==0) continue;
        else break;
    }
    if(i<n) cout<<'0'<<endl;
    else
    {
        for(i=0; i<cnt; i++)
        {
            ans*=2;
            ans%=mod;
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

ll max2val(ll a, ll b) {
    if (a > b) {
        return a;
    }
    else {
        return b;
    }
}

int main() {
 ll N,K;
 cin >>N>>K;
 vector<ll>G(N);
 rep(i,N)cin>>G[i];
 sort(G.begin(),G.end());
 int sum=0;
 rep(i,K){
     sum+=G[i];
 }
  cout<<sum<<endl;
 }



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


int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(n*a,b);
  return 0;
}




Measured memory_bytes: 3548
#include <iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int fac=1;
	if(a==b&&a==c) fac=0;
	if(a!=b&&b!=c&&a!=c) fac=0;
	cout<<(fac?"Yes":"No")<<endl;
	return 0;
} 

Measured memory_bytes: 256
# 0-1 Knapsack Problem
N, W = [int(x) for x in input().split()]
items = []
for i in range(N):
    items.append(tuple(int(x) for x in input().split()))

DP = [0] * (W+1)
for i in range(N):
    v, w = items[i]
    for j in range(W, w-1, -1):
        DP[j] = max(DP[j], v + DP[j-w])

print(DP[-1])

Measured memory_bytes: 5920
n=int(input())
ans=0
aend=0
bstart=0
aendbstart=0
for i in range(n):
  s=input()
  ans+=s.count("AB")
  if s[0]=="B" and s[-1]=="A":
    aendbstart+=1
  elif s[0]=="B":
    bstart+=1
  elif s[-1]=="A":
    aend+=1
anow=False
if aend>0:
  aend-=1
  anow=True
elif aendbstart>0:
  aendbstart-=1
  anow=True
if anow:
  ans+=aendbstart
if anow and bstart>0:
  bstart-=1
  ans+=1
  anow=False
if aend>0 and bstart>0:
  ans+=min(aend,bstart)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	vector<ll> h(n);
	for(int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	
	vector<ll> dp(n + 10, 1LL << 60);
	dp[0] = 0; 
	
	/*
	dp[1] = abs(h[0] - h[1]);
	for(int i = 2; i < n; ++i) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	*/
	/*
	for(int i = 1; i < n; ++i) {
		dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if( i > 1 ) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	*/
	for(int i = 0; i < n; ++i) {
		if( i + 1 < n ) dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
		if( i + 2 < n ) dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
	}
	
	cout << dp[n - 1] << endl;
	
	return 0;
}


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

typedef long long ll;

using namespace std;

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

    string ans = "No";

    for (int i = 1; i < 10; i++) {
       for (int j = 1; j < 10; j++) {
           if (N == i * j) ans = "Yes";
       }
    }
    cout << ans << endl;
}

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

#define MAX 100010
#define NIL -1
using namespace std;

struct Node { int p, l, r; }; //親,左の子,右の兄弟

Node T[MAX];
int D[MAX];

void print(int u) {
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
}

void depth(int u) { //深さ
	int de = 0;
	while (T[u].p != NIL) {
		u = T[u].p;
		de++;
	}
	D[u] = de;
	cout << "depth = " << D[u] << ", ";
}

void checktype(int u) {//種類
	if (T[u].p == NIL) {
		cout << "root, ";
	}
	else if (T[u].l == NIL) {
		cout << "leaf, ";
	}
	else {
		cout << "internal node, ";
	}
}

void printchild(int u) {//節点の子
	int c = T[u].l;
	int a = 0;

	cout << "[";
	while (c != NIL) {
		if (a == 0) {
			cout << c;
		}
		else if (a != 0) {
			cout << ", " << c ;
		}
		a++;
		c = T[c].r;
	}
	cout << "]" << endl;
}

/*int searchd(int u,int p) {
	D[u] = p;
	if (T[u].r != NIL) {
		searchd(T[u].r, p);
	}if (T[u].l != NIL) {
		searchd(T[u].l, p + 1);
	}
}*/

int main() {
	int n, d, v, c, l, r;

	cin >> n;//節点の個数
	for (int i = 0; i < n; i++) {
		T[i].p = T[i].l = T[i].r = NIL;
	}

	for (int j = 0; j < n; j++) {
		cin >> v >> d; //節点番号，子の数

		for (int k = 0; k < d; k++) {
			cin >> c; //子供の節点番号
			
			if (k == 0) {
				T[v].l = c;//vのもっとも左の子
				l = c;
			}
			else {
				T[l].r = c; //左の子の右の兄弟
				l = c;
			}
			
			T[c].p = v;//cの親はv
		}
	}
/*for (int i = 0; i < n; i++) {
		if (T[i].p == NIL) {
			r = i;
		}
	}

	searchd(r, 0);*/

	for (int b = 0; b < n; b++) {
		print(b);
		depth(b);
		checktype(b);
		printchild(b);
	}
	return 0;
}



Measured memory_bytes: 4292
inf = float('inf')

L, R = map(int, input().split())

if R > L + 3000:
    R = L + 3000
t = [i % 2019 for i in range(L, R + 1)]
t.sort()
if (3 in t and 673 in t) or (0 in t):
    print(0)
else:
    n = len(t)
    ans = inf
    for i in range(n - 1):
        for j in range(i + 1, n):
            ans = min(ans, t[i] * t[j] % 2019)
    print(ans)
    # print(t)


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

int main() {
  int n;
  cin >>n;
  vector<int> v(n);
  rep(i,n){
    cin >> v.at(i);
  }
  
  vector<int> v2(1);
  int sum = 1, num = -1,j=0,i=0;
  bool ok = false;
  while (i <n){
    if (v.at(j) == 2){
      ok = true;
      break;
    }
    else {
      v2.push_back(v.at(j));
      j=v.at(j)-1;
      i++;
    }
  }
  if (ok){
    cout << v2.size() << endl;
  }
  else {
    cout << num << endl;
  }
}

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

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define RREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define RFOR(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[ ";
    for (auto a : v) os << a << " ";
    os << "]";
    return os;
}

int main() {
    vector<int> x(5);
    REP(i, 5) cin >> x[i];

    REP(i, 5) {
        if (x[i] == 0) cout << i + 1 << endl;
    }
    return 0;
}

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

int main()
{
	int H = 0, W = 0, count = 0, a[10000] = { 0 };
	while (1){
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		a[count] = H, a[++count] = W, count++;
	}
	int i = 0;
	while (i < count){
		for (int j = 0; j < a[i]; j++){
			for (int k = 0; k < a[i + 1]; k++){
				if ((j + k) % 2 == 0) cout << "#";
				else                  cout << ".";
			}
			cout << endl;
		}
		i += 2;
		cout << endl;
	}
	return 0;
}

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

using namespace std;

#define ll long long

int main()
{
    ll h, n, a;
    cin >> h >> n;
    ll sum = 0;
    while(n--)
    {
        cin >> a;
        sum += a;
    }

    if(sum < h) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
typedef  long long     ll ;
typedef  unsigned long long ull;
const double EPS= (1e-9);
using namespace std;
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void SP(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
map<string ,int> mb;
string st;
int main()
{
    SP();
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>st;
        sort(all(st));
        mb[st]++;
    }
    ll ans=0;
    for(auto it=mb.begin();it!=mb.end();it++)
    {
        ll cnt= (*it).second;
        ans+= (cnt*(cnt-1))/2;
    }
    cout<<ans<<endl;

}



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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using mii = std::map<int, int>;
using mll = std::map<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = 2*(int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dc[4] = {1, -1, 0,  0};
const int dr[4] = {0,  0, 1, -1};
//const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
//const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

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

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

int main(void)
{
    int n,h,w;
    cin >> n >> h >> w;

    cout << (n-h+1)*(n-w+1) << endl;
    return 0;
}

/*atcoder*/


Measured memory_bytes: 3556
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
#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[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    int n;
    cin >> n;
    vector<int> a(n);
    for(auto &x:a)cin >> x;

    bool gray=false,brown=false,green=false,sky=false,blue=false,yellow=false,orange=false,red=false;
    int ansmin=0,ansmax=0;
    for(int i=0;i<n;i++){
        switch(a[i]/400){
            case 0:if(!gray){ansmin++;ansmax++;gray=true;}break;
            case 1:if(!brown){ansmin++;ansmax++;brown=true;}break;
            case 2:if(!green){ansmin++;ansmax++;green=true;}break;
            case 3:if(!sky){ansmin++;ansmax++;sky=true;}break;
            case 4:if(!blue){ansmin++;ansmax++;blue=true;}break;
            case 5:if(!yellow){ansmin++;ansmax++;yellow=true;}break;
            case 6:if(!orange){ansmin++;ansmax++;orange=true;}break;
            case 7:if(!red){ansmin++;ansmax++;red=true;}break;
            default:ansmax++;break;
        }
    }

    if(ansmin==0)ansmin++;

    cout << ansmin << " " << ansmax << endl;

    return 0;
}


Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		
		long ans = f(b, x) - f(a - 1, x);
		
		System.out.println(ans);
		
		sc.close();
	}
	
	static long f(long n, long x) {
		return n >= 0 ? n / x + 1 : 0;
	}
	
}




Measured memory_bytes: 27064
#include <iostream>
#include <string>
#include <utility>
using namespace std;

#define QUE_SIZE 1000000
typedef struct {
    string name;
    int time;
} QUE;
QUE que[QUE_SIZE];

int main() {
    int i,n,q,elapsedt=0,head=0,tail;
    cin>>n>>q;
    tail=n;
    for(i=0;i<n;i++) cin>>que[i].name>>que[i].time;
    while(head!=tail){
        if(que[head].time <= q || (QUE_SIZE+tail-head)%QUE_SIZE == 1) {
            elapsedt += que[head].time;
            cout<<que[head].name<<" "<<elapsedt<<endl;
            head = (head+1)%QUE_SIZE;
        } else {
            elapsedt += q;
            que[tail].name = que[head].name;
            que[tail].time = que[head].time - q;
            head = (head+1)%QUE_SIZE;
            tail = (tail+1)%QUE_SIZE;
        }
    }
    return 0;
}


Measured memory_bytes: 21096
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int h = int.Parse(str[0]);
            int w = int.Parse(str[1]);
            string[] str1 = Console.ReadLine().Split(' ');

            int h1 = int.Parse(str1[0]);
            int w1 = int.Parse(str1[1]);
            Console.WriteLine((h - h1) * (w - w1));
        }
    }
}


Measured memory_bytes: 11220
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
console.log(input.map(function(x) {
  const arr = x.split(' ').map(Number);
  return arr[0] == 0 ? '' : function(h, w) {
    const oddLine = function(i, w) {
      return i < w ? (i % 2 == 0 ? '.' : '#').concat(arguments.callee(i + 1, w)) : '\n';
    }(0, w);
    const evenLine = function(i, w) {
      return i < w ? (i % 2 == 0 ? '#' : '.').concat(arguments.callee(i + 1, w)) : '\n';
    }(0, w);
    const board = function(i, h) {
      return i < h ? (i % 2 == 0 ? evenLine : oddLine).concat(arguments.callee(i + 1, h)) : '\n';
    }(0, h);
    return board;
  }(arr[0], arr[1]);
}).join('').trim().concat('\n'));

Measured memory_bytes: 16608
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int M = 1000000007;
#define pb push_back
#define fs first
#define sc second
#define forn(i,k,n) for(int i = k; i < n; ++i)
#define nfor(i,n,k) for(int i = n; i >= k; --i)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define vvpii vector<vector<pait<int,int>>>
#define all(arr) arr.begin(), arr.end()
#define endl '\n'
#define dbgarr(V,n) forn(i,0,n) cout << V[i] << " "; cout << endl;
#define dbgarrrev(V,n) nfor(i,n,0) cout << V[i] << " "; cout << endl;
#define dbgmaze(V) for(auto x: V) {for(auto y : x) cout << y <<  " ";cout << endl;}
#define dbg2d(V,n,m) forn(i,0,n) {forn(j,0,m) cout << V[i][j] <<  " ";cout << endl;}
#define N 100005
#define inf 1000000000
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n, c; cin >> n >> c;
	ll W[n] , V[n];
	forn(i,0,n) cin >> W[i] >> V[i];
	ll dp[n + 1][c + 1] = {};
	forn(i,1,n + 1){
		forn(w,1,c + 1){
			if(W[i - 1] <= w)
				dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - W[i - 1]] + V[i - 1]);
			else dp[i][w] = dp[i - 1][w];
		}
	}
	cout << dp[n][c] << endl;
    return 0;
}

Measured memory_bytes: 82524
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
 



int N, K, A[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> A[i];
    map<int, int> cnt;
    rep(i, 0, N) cnt[A[i]]++;
    vector<int> v;
    fore(p, cnt) v.push_back(p.second);
    sort(v.begin(), v.end());

    int n = v.size();

    if (n <= K) {
        printf("0\n");
    }
    else {
        int ans = 0;
        rep(i, 0, n - K) ans += v[i];
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 11640