akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long MOD2 = 998244353;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	for (int i = 0; i <= 9; i++) {
		for (int j = 0; j <= 9; j++) {
			for (int k = 0; k <= 9; k++) {
				bool ok = false;
				bool ok2 = false;
				bool ok3 = false;
				rep(a, n) {
					if (ok2&&s[a] - '0' == k) {
						ok3 = true; break;
					}
					else if (ok&&s[a] - '0' == j) {
						ok2 = true;
					}
					else if (s[a] - '0' == i) {
						ok = true;
					}
				}
				if (ok3) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int search(int key, int n, int a[]){
  int left = 0,right = n;
  while(left < right){
    int mid = (right + left)/2;
    if(key == a[mid]) return 1;
    else if(key > a[mid]){
      left = mid + 1;
    }
    else{
      right = mid;
    }
  }
  return 0;
}

int main(void){
  int n; cin >> n;
  int s[n]; rep(i,n) cin >> s[i];
  int q; cin >> q;
  int t[q]; rep(i,q) cin >> t[i];
  int ans = 0;
  for(int i = 0; i < q; i++){
    if(search(t[i],n,s)) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int n = S.size();
  for(int i = 0; i <= n-1; i++){
    if(S.at(i) != S.at(n-1-i)){
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i = 0; i <= (n-3)/2; i++){
    if(S.at(i) != S.at((n-3)/2-i)){
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i = 0; i <= (n-3)/2; i++){
    if(S.at(i+(n+1)/2) != S.at((n-1)-i)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

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

int main () {
    int a, b;
    cin >> a >> b;
    int g = gcd(a, b);
    long long lcm = 1ll * a * b / g;
    cout << lcm;
}



Measured memory_bytes: 384
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	bool b[3];
	rep(i,3)cin>>b[i];
	if((b[0] && b[1] && !b[2]) || (!b[0] && !b[1] && b[2]))cout<<"Open"<<endl;
	else cout<<"Close"<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
char s[3][200];
int tp[3];
int main()
{
    cin>>s[0]>>s[1]>>s[2];
    int x = 0;
    while(true)
    {
        if(!s[x][tp[x]])
        {
            cout << (char)('A'+x) << endl;
            return 0;
        }
        x = s[x][tp[x]++]-'a';
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N;
	cin >> N;
	for (int i = N; i <= 999; i++) {
		string a = to_string(i);
		if (a[0] == a[1] && a[1] == a[2]) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

signed main(){
	int h, w, n;
	scanf("%lld%lld%lld", &h, &w, &n);
	int ans = 0;
	rep(i,h+1)rep(j,w+1){
		int cnt = 0;
		cnt += w*i;
		cnt -= j*i;
		cnt += j*(h-i);
		if(cnt == n)ans = 1;
	}
	printf("%s\n", ans ? "Yes" : "No");
	return 0;
}






Measured memory_bytes: 256
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;

int main()
{
  string s;
  int count = 0;
  const int value = 700;
  cin >> s;

  for (int i = 0; i < s.size(); i++)
  {
    if (s[i] == 'o')
    {
      count++;
    }
  }
  cout << value + count * 100 << endl;

  return 0;
}


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

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

        int ans = 0;
        for(int i=0; i<n; i++){
                int h;
                cin >> h;
                if(h>=k) ans++;
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 3640
S = list(range(1,14))
H,C,D = S[::],S[::],S[::]
N = int(input())
for n in range(N):
    img,num = input().split(' ')
    num = int(num)
    if img == 'S':
        S.remove(num)
    if img == 'H':
        H.remove(num)
    if img == 'C':
        C.remove(num)
    if img == 'D':
        D.remove(num)
for s in S:
    print(f'S {s}')
for h in H:
    print(f'H {h}')
for c in C:
    print(f'C {c}')
for d in D:
    print(f'D {d}')


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;

int main() {
    int n; cin >> n;
    if (n < 10) {
        cout << "Yes"; return 0;
    }
    for (int i = 2; i <= 9; ++i) {
        if (n % i == 0 && ((int) (n/i)) <= 9) {
            cout << "Yes"; return 0;
        }
    }
    cout << "No";

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		long mod = (long)(1e9+7);
		Scanner input = new Scanner(System.in);
		boolean valid = false;
		int K = input.nextInt();
		int A = input.nextInt();
		int B = input.nextInt();
		for (int i = A; i <= B; i++) {
			if (i%K==0) {
				valid = true;
				break;
			}
		}
		System.out.println(valid?"OK":"NG");
	}
}

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

int main(void) {
  int N, Q; cin >> N >> Q;
  string S; cin >> S;
  vector<int> L(Q);
  vector<int> R(Q);
  vector<int> A(N);
  
  for (int i=0; i<Q; i++) {
    cin >> L[i] >> R[i];
  }
  
  int cnt = 0;
  A[0] = 0;
  for (int i=1; i<N; i++) {
    if (S[i] == 'C' && S[i-1] == 'A') cnt++;
    A[i] = cnt;
  }
  
  for (int i=0; i<Q; i++) {
    cout << A[R[i]-1] - A[L[i]-1] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 4564
//ABC0119A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	string s;
	cin >> s;
	if(s <= "2019/04/30"){
		cout << "Heisei" << endl;
	}else{
		cout << "TBD" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <queue>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 1e3 + 10;
typedef long long int ll;
char g[N][N];
int vis[N][N];
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
int sx, sy, ex, ey, n, m;
struct node
{
    int x, y, step;
    node(int x, int y, int step) : x(x), y(y), step(step) {}
    node() {}
    bool operator<(const node &other) const
    {
        return this->step > other.step;
    }
};

void bfs()
{
    priority_queue<node> q;
    q.push(node(sx, sy, 0));
    while (!q.empty())
    {
        node now = q.top();
        q.pop();
        if (now.x == ex && now.y == ey)
        {
            cout << now.step << endl;
            return;
        }
        if (vis[now.x][now.y])
            continue;
        vis[now.x][now.y] = 1;
        for (int i = 0; i < 4; i++)
        {
            int nx = now.x + dx[i];
            int ny = now.y + dy[i];
            if (nx > n || nx < 1 || ny > m || ny < 1)
                continue;
            if (g[nx][ny] == '#')
                continue;
            q.push(node(nx, ny, now.step));
        }
        for (int nx = now.x - 2; nx <= now.x + 2; nx++)
        {
            if (nx < 1 || nx > n)
                continue;
            for (int ny = now.y - 2; ny <= now.y + 2; ny++)
            {
                if (ny > m || ny < 1)
                    continue;
                if (g[nx][ny] == '#')
                    continue;
                q.push(node(nx, ny, now.step + 1));
            }
        }
    }
    cout << -1 << endl;
}
int main()
{
    scanf("%d%d", &n, &m);
    scanf("%d%d%d%d", &sx, &sy, &ex, &ey);
    for (int i = 1; i <= n; i++)
        scanf("%s", &g[i][1]);
    bfs();
    return 0;
}
/*
3 4
1 0 0 0
0 0 0 0
0 0 0 2
*/

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

int main(void){
	int a[3];
	int n;
	int r;
	while(cin>>a[0]>>a[1]>>a[2],a[0]){
		sort(a,a+3);
		int x=(a[0]*a[0]+a[1]*a[1])/4;
		cin>>n;
		while(n--){
			cin>>r;
			r*=r;
			if(x<r)cout<<"OK"<<endl;
			else cout<<"NA"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3064
use std::io::*;

fn main(){
    let a : i64 = input();
    let b : i64 = input();
    let c : i64 = input();
    let d : i64 = input();
    let g = lcm(c, d);
    let ans = b - a + 1 - ((b / c -  (a - 1) / c)  + (b / d - (a - 1) / d) - (b / g - (a - 1) / g));
    println!("{}", ans);
}

fn gcd(x : i64, y : i64) -> i64{
    if y == 0{
        x
    }else{
        gcd(y, x % y)
    }
}

fn lcm(x : i64, y : i64) -> i64{
    x / gcd(x, y) * y
}

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

Measured memory_bytes: 4352
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let it = stdin.lock().bytes().map(|c| c.unwrap() as char);
    let (fs, ft) = (|c: &char| c.is_whitespace(), |c: &char| !c.is_whitespace());
    let token = it.skip_while(fs).take_while(ft).collect::<String>();
    token.parse().ok().unwrap()
}
#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    f(std::io::BufWriter::new(out.lock()));
}
#[allow(unused_macros)]
macro_rules! debug {
    ($($var:expr),*) => { #[cfg(debug_assertions)] {
        $({ match &$var { v => eprint!("{}={:?} ", stringify!($var), v) } })*
        eprintln!();
    }};
}

fn main() {
    let n: usize = input();
    let a: Vec<i32> = (0..1 << n).map(|_| input()).collect();

    let mut dp = vec![(0, 0); 1 << n];
    for i in 0..1 << n {
        dp[i] = (a[i], 0);
    }

    let max2 = |a: (i32, i32), b: (i32, i32)| {
        let mut v = [a.0, a.1, b.0, b.1];
        v.sort();
        (v[2], v[3])
    };

    for i in 0..n {
        for j in 0..1 << n {
            if (j >> i) & 1 == 0 {
                dp[j | (1 << i)] = max2(dp[j | (1 << i)], dp[j]);
            }
        }
    }
    debug!(dp);

    let mut ans = vec![0; 1 << n];
    for i in 1..1 << n {
        ans[i] = std::cmp::max(ans[i - 1], dp[i].0 + dp[i].1);
    }
    with_stdout_lock(|mut w| {
        for i in 1..1 << n {
            writeln!(w, "{}", ans[i]).unwrap();
        }
    });
}


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

int main()
{
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3548
// A - ∴ (Therefore)
#include <bits/stdc++.h>
using namespace std;

int main(){
	string S; cin>>S;
	int s = S.back()-'0';
	string ans = "hon";
	if(s==0 || s==1 || s==6 || s==8) ans = "pon";
	else if(s == 3) ans = "bon";
	cout<< ans <<endl;
}


Measured memory_bytes: 3624
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

int n;
vector<vector<int>> edge;
vector<int> x;
vector<P> best;

bool dfs(int v){
    vector<P> vp;
    for(int u : edge[v]){
        if(not dfs(u)){
            return false;
        }
        vp.push_back(best[u]);
    }

    vector<vector<int>> dp(SZ(vp) + 1, vector<int>(5001, INF));
    dp[0][0] = 0;
    rep(i, SZ(vp)){
        rep(j, 5000){
            if(j + vp[i].first <= 5000){
                dp[i+1][j+vp[i].first] = min(dp[i+1][j+vp[i].first], dp[i][j] + vp[i].second);
            }
            if(j + vp[i].second <= 5000){
                dp[i+1][j+vp[i].second] = min(dp[i+1][j+vp[i].second], dp[i][j] + vp[i].first);
            }
        }
    }

    int ans = -1;
    for(int i = 0; i <= x[v]; i++){
        if(dp[SZ(vp)][i] < INF){
            ans = dp[SZ(vp)][i];
        }
    }
    best[v] = {x[v], ans};

    return ans != -1 ;
}

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

    cin >> n;
    edge = vector<vector<int>>(n + 1, vector<int>());
    for(int i = 2; i <= n; i++){
        int p;
        cin >> p;
        edge[p].push_back(i);
    }
    x = vector<int>(n + 1);
    rep(i, n) cin >> x[i+1];

    best = vector<P>(n + 1);
    cout << (dfs(1) ? "POSSIBLE" : "IMPOSSIBLE") << endl;

    return 0;
}


Measured memory_bytes: 39424
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long, long> > vllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  int ans = 0, w, h, n, x, y, a;
  cin >> w >> h >> n;
  int arr[w][h];
  fi(0, w)
    fj(0, h)
      arr[i][j] = 1;
  
  fi(0, n) {
    cin >> x >> y >> a;
    switch(a) {
      case 1:
        fi(0, x)
          fj(0, h)
            arr[i][j] = 0;
        break;
      case 2:
        fi(x, w)
          fj(0, h)
            arr[i][j] = 0;
        break;
      case 3:
        fi(0, w)
          fj(0, y)
            arr[i][j] = 0;
        break;
      case 4:
        fi(0, w)
          fj(y, h)
            arr[i][j] = 0;
        break;
    }
  }
  fi(0, w)
    fj(0, h)
      ans += arr[i][j];
  cout << ans << endl;
  return 0;
}



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

int main() {
  long H,W,K;
  cin>>H>>W>>K;
  vector<vector<char>> c(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>c[i][j];
    }
  }


  int ans=0;
  for(int bit=0;bit<(1<<H);bit++){
    for(int bit2=0;bit2<(1<<W);bit2++){
      vector<vector<char>> d(H,vector<char>(W));
      for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
          d[i][j]=c[i][j];
        }
      }
    int sum=0;

    for(int i=0;i<H;i++){
      if(bit&(1<<i)){
        for(int w=0;w<W;w++) d[i][w]='x';
        }
      }

      for(int i=0;i<W;i++){
        if(bit2&(1<<i)){
          for(int h=0;h<H;h++) d[h][i]='x';
          }
        }
        for(int i=0;i<H;i++){
          for(int j=0;j<W;j++){
            if(d[i][j]=='#') sum++;
          }
        }
        if(sum==K) ans++;
    }
  }
  cout<<ans<<endl;

  }


Measured memory_bytes: 3640
# include <iostream>
# include <algorithm>

using namespace std;

int main() {
  int N, K, L[60];
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> L[i];
  
  sort(L, L + N);
  reverse(L, L + N);
  
  int ans = 0;
  for (int i = 0; i < K; i++) ans += L[i];
  cout << ans << endl;
  
  return 0;
}

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


int main() {
    int n;

    cin >> n;
    int a[n], max = 0, max_2 = 0, max_num, max_num_2;


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

    for(int i = 0; i < n; ++i){
        if(i != max_num && a[i] > max_2) {
            max_2 = a[i];
        }
    }

    for(int i = 0; i < n; ++i){
        if(i != max_num)
            cout << max << endl;
        else
            cout << max_2 << endl;
    }


    return 0;

}

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

int main()
{
	int n, t[100], sum{};
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", t + i);
		sum += t[i];
	}
	int m;
	scanf("%d", &m);
	for (int i = 0; i < m; i++)
	{
		int p, x;
		scanf("%d%d", &p, &x);
		p--;
		printf("%d\n", sum - t[p] + x);
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pint pair<int,int>
using namespace std;

double ans[3000][3000];

int main(){
	ios::sync_with_stdio(false);
	int i,j,n;  cin>>n;
	double p[n];
	for(i=0;i<n;i++){
	    cin>>p[i];
	}
	ans[0][1]=p[0];
	ans[0][0]=1-p[0];
	for(i=1;i<n;i++){
	    ans[i][0]=(1-p[i])*ans[i-1][0];
	    for(j=1;j<=n;j++){
	        ans[i][j]=p[i]*ans[i-1][j-1]+(1-p[i])*ans[i-1][j];
	    }
	}
	double total=0;
	for(i=n/2+1;i<=n;i++){
	    total+=ans[n-1][i];
	}
	printf("%.15lf",total);
	return 0;
}

Measured memory_bytes: 70528
#include<bits/stdc++.h>
#define N (5000+10)
#define next Next
#define inf (0x3f3f3f3f)
using namespace std;
const int maxn=50000+10;
int to[maxn<<1],next[maxn<<1],head[N<<1],v[maxn<<1],w[maxn<<1];
int ans=0,e=1,dis[N],vis[N];
int a[50][50][2];
inline void add(int x,int y,int z,int zz){
    to[++e]=y;
    next[e]=head[x];
    head[x]=e;
    w[e]=z;
    v[e]=zz;
}
int n,m,s,t,x,y,z,zz;
inline bool spfa(){
    queue<int> q;
    memset(vis,0,sizeof(vis));
    memset(dis,inf,sizeof(dis));
    dis[vis[s]=s]=0;
    q.push(s);
    while(!q.empty()){
        int k=q.front();
        q.pop();
        for(register int i=head[k];i;i=next[i]){
            if(w[i]&&dis[to[i]]>dis[k]+v[i]){
                dis[to[i]]=dis[k]+v[i];
                if(!vis[to[i]])
                    q.push(vis[to[i]]=to[i]);
            }
        }
        vis[k]=0;
    }
    return dis[t]<inf;
}
inline int dfs(int x,int flow){
    vis[x]=1;
	if(x==t||!flow)
        return vis[x];
    for(register int i=head[x];i;i=next[i])
        if(!vis[to[i]]&&w[i]&&dis[to[i]]==dis[x]+v[i]){
            int ovo=dfs(to[i],min(flow,w[i]));
            if(ovo>0){
                ans+=v[i]*ovo;
                w[i]-=ovo;
                w[i^1]+=ovo;
                return ovo;
            }
        }
    return 0;
}
inline int dinic(){
    int flow=0;
    while(spfa()){
        vis[t]=1;
        while(vis[t]){
            memset(vis,0,sizeof(vis));
            flow+=dfs(s,inf);
        }
    }
    return flow;
}
int ovo[maxn];
int main(){
  //  freopen("1559.in","r",stdin);
  //  freopen("1559.out","w",stdout);
	int nn,mm,xx;
	scanf("%d%d%d",&nn,&mm,&xx);
	for(int i=1;i<=nn;++i)
		scanf("%d",&ovo[i]);
	int anss=0;
	for(int i=1;i<=nn;++i)
		for(int j=1;j<=mm;j+=ovo[i])
			++anss;
	cout<<anss+xx;
	return 0;
    scanf("%d",&n);
	for(int k=0;k<2;++k)
		for(register int i=1;i<=n;++i)
			for(int j=1;j<=n;++j)
				scanf("%d",&a[i][j][k]);
	s=n*2+1;t=s+1;
	for(int i=1;i<=n;++i){
		add(s,i,1,0);
		add(i,s,0,0);
		add(i+n,t,1,0);
		add(t,i+n,0,0);
	}
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j){
			add(i,j+n,1,-a[i][j][0]*a[j][i][1]);
			add(j+n,i,0,a[i][j][0]*a[j][i][1]);
		}
    dinic();
    printf("%d",-ans);
    return 0;
}




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

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template<class T>
inline void read(T&);
template<class T>
inline void write(const T&);

typedef long long ll;
typedef const long long & cll;
typedef const int & ci;
const int iinf = 2147483647;
const ll llinf = 9223372036854775807ll;
const int N = 100005;

std::pair<int, int> a[N];

int main () {
    int n, m;
    read(n), read(m);
    for (int i = 1; i <= n; ++i) {
        read(a[i].first), read(a[i].second);
    }
    std::sort(a + 1, a + n + 1);
    ll ans = 0;
    for (int i = 1; i <= n && m; ++i) {
        int k = std::min(a[i].second, m);
        ans += a[i].first * 1ll * k;
        m -= k;
    }
    write(ans), EL;
    return 0;
}

template<class T>
void read(T &Re) {
    T k = 0;
    char ch = getchar();
    int flag = 1;
    while (!isNum(ch)) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while (isNum(ch)) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    Re = flag * k;
}
template<class T>
void write(const T &Wr) {
    if (Wr < 0) {
        putchar('-');
        write(-Wr);
    } else {
        if (Wr < 10) {
            putchar(Wr + '0');
        } else {
            write(Wr / 10);
            putchar((Wr % 10) + '0');
        }
    }
}


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

const int MAXN = 3e5+5;
const int INF = 1e9+7;
#define ll long long
#define pb push_back
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

ll MOD(ll a){
    return ((a%INF)+INF)%INF;
}

ll inv(ll a){
    return poww(a,INF-2,INF);
}

int h[MAXN],dp[MAXN];

int main()
{
    fast_io;
    //cout << fixed << setprecision(15);

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


Measured memory_bytes: 1152
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	long long n; cin >> n;
	vector<pair<long long, long long>> v(n);
	for (long long i = 0; i <= n - 1; i++) cin >> v[i].ff >> v[i].ss;

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

	long long lo = 0;
	if (n % 2 == 1) lo = v[(n - 1) / 2].ff;
	else lo = (v[(n - 1) / 2].ff + v[(n + 1) / 2].ff) ;

	for (long long i = 0; i <= n - 1; i++) swap(v[i].ff, v[i].ss);

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

	long long hi = 0;
	if (n % 2 == 1) hi = v[(n - 1) / 2].ff;
	else hi = (v[(n - 1) / 2].ff + v[(n + 1) / 2].ff) ;

	cout << hi - lo + 1;


	return 0;
}

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

mt19937 rnd;

template<typename T>
struct TreapArray{
    struct Node{
        T val, sum;
        int pri, cnt;
        Node *lch, *rch;
        Node(T v):val(v), pri(rnd()), cnt(1), sum(v){
            lch = rch = nullptr;
        }
    };

    Node* node;

    TreapArray(Node* n=nullptr){ node = n; }
    TreapArray(T v){ node = new Node(v); }
    void initialize(T v){ node = new Node(v); }

    int count(Node* t){ return !t ? 0 : t->cnt; }
    T   sum  (Node* t){ return !t ? 0 : t->sum; }
    int count(){ return count(node); }
    T   sum  (){ return sum  (node); }

    Node* update(Node* t){
        t->cnt = count(t->lch) + count(t->rch) + 1;
        t->sum =   sum(t->lch) +   sum(t->rch) + t->val;
        return t;
    }

    Node* merge(Node* l, Node* r){
        if(!l || !r) return !l ? r : l;
        if(l->pri > r->pri){
            l->rch = merge(l->rch, r);
            return update(l);
        }else{
            r->lch = merge(l, r->lch);
            return update(r);
        }
    }

    pair<Node*, Node*> split(Node* t, int k){
        if(!t) return make_pair(nullptr, nullptr);
        if(k <= count(t->lch)){
            auto s = split(t->lch, k);
            t->lch = s.second;
            return {s.first, update(t)};
        }else{
            auto s = split(t->rch, k - count(t->lch) - 1);
            t->rch = s.first;
            return {update(t), s.second};
        }
    }
    pair<TreapArray*, TreapArray*> split(int k){
        auto p = split(node, k);
        node = p.first;
        auto t2 = new TreapArray(p.second);
        return make_pair(this, t2);
    }

    void insert(int k, T v){
        auto s = split(node, k);
        auto n = new Node(v);
        node = merge(s.first, n);
        node = merge(node, s.second);
    }

    void erase(int k){
        auto s1 = split(node, k-1);
        auto s2 = split(s1.second, 1);
        node = merge(s1.first, s2.second);
    }

    T kth_element(Node* t, int k){
        if(k == count(t->lch)){
            return t->val;
        }else if(k < count(t->lch)){
            return kth_element(t->lch, k);
        }else{
            return kth_element(t->rch, k - count(t->lch) - 1);
        }
    }
    T kth_element(int k){
        return kth_element(node, k);
    }
};

int grundy1(int A, int K){
    while(true){
        if(A < K) return 0;
        if(A%K == 0) return A/K;
        A -= A/K + 1;
    }
}

int grundy2(int A, int K){
    TreapArray<int> treap(0);
    int pos = 0, sz = 1;
    for(int i=1; i*K<=A; i++){
        pos = (pos+K-1) % i + 1;
        treap.insert(pos, i);
        sz++;
    }
    pos = (pos + A%K) % sz;
    return treap.kth_element(pos);
}

int main(){
    int N, G = 0;
    cin >> N;
    for(int i=0; i<N; i++){
        int A, K;
        cin >> A >> K;
        if(K < 1e5){
            G ^= grundy1(A, K);
        }else{
            G ^= grundy2(A, K);
        }
    }
    cout << (G ? "Takahashi" : "Aoki") << endl;
    return 0;
}

Measured memory_bytes: 42880
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

pub fn bsearch<F>(ok: i64, ng: i64, pred: F) -> Option<i64>
where
    F: Fn(i64) -> bool,
{
    let orig_ok = ok;
    let mut ok = ok;
    let mut ng = ng;
    while (ok - ng).abs() > 1 {
        let mid = (ok + ng) / 2;
        if pred(mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    if ok == orig_ok {
        None
    } else {
        Some(ok)
    }
}

fn solve() {
    input! {
        n: usize,
        mut lv: [usize; n]
    };

    lv.sort();
    let mut res = 0;
    for ai in 0..n - 2 {
        for bi in ai + 1..n - 1 {
            let maxc = lv[ai] + lv[bi] - 1;
            let ci = bsearch(bi as i64, lv.len() as i64, |j| {
                let j = j as usize;
                lv[j] <= maxc
            });
            match ci {
                Some(ci) => {
                    res += ci as usize - bi;
                }
                _ => {}
            }
        }
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2224
N,Q = map(int,input().split())
S = input()

cnt = [0]*(N+1)
for i in range(N):
    if S[i:i+2] == 'AC':
        cnt[i+1] = cnt[i]+1
    else:
        cnt[i+1] = cnt[i]
    
#print(cnt)

for q in range(Q):
    l,r = map(int,input().split())
    print(cnt[r-1]-cnt[l-1])

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

int main() {
  string S1, S2, S3;
  cin >> S1 >> S2 >> S3;
  char A = S1[0];
  char B = S2[0];
  char C = S3[0];
  
  cout << (char)(A+('A'-'a')) << (char)(B+('A'-'a')) << (char)(C+('A'-'a')) << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair

#define int ll

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

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

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

  int a[n], b[n];
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];

  vector<pii> p(n);
  rep(i, n){
    p[i] = mp(a[i]-b[i], i);
  }

  sort(all(p));

  int pos = 0, neg = 0;
  int cntneg = 0;
  for(auto q : p){
    if(q.first < 0){
      neg += q.first;
      cntneg++;
    }
    else if(q.first > 0) pos += q.first;
  }

  if(abs(neg) > pos){
    cout << -1 << endl;
    return 0;
  }

  pos = 0;
  int cntpos = 0;
  for(int i = p.size()-1; i >= 0 and abs(neg) > pos; i--){
    if(p[i].first > 0){
      pos += p[i].first;
      cntpos++;
    }
  }

  cout << cntneg + cntpos << endl;

  return 0;
}


Measured memory_bytes: 3328
n,m = map(int,input().split())

if n == 1 and m == 1:
    print(1)
if n != 1 and m == 1:
    print(n-2)
if n == 1 and m != 1:
    print(m-2)
if n != 1 and m != 1:
    print((n-2)*(m-2))

Measured memory_bytes: 3060
// By Shreehari Bodas

#include <bits/stdc++.h>

using namespace std;

const int MOD=1e9+7;

int search(int b[], int m, int s){
	int start=0,end=m-1;
	bool flag=false;
	while(start<=end){
		int mid=(start+end)/2;
		if(b[mid]==s){
			flag=true;
			return mid;
		}
		else if(b[mid]>s) end=mid-1;
		else if(b[mid]<s) start=mid+1;
	}
	if(flag==false) return m;
}

long long int pow(long long int a, long long int b){
	if(b==0) return 1;
	long long int res=pow(a,b/2);
	if(b%2 ==1) return res*res*a;
	else if(b%2 ==0) return res*res;
}

int main(){

	int n,m; cin>>n>>m;
	int good[n];
	for(int i=0;i<n;i++) good[i]=true;
	
	int h[n];
	for(int i=0;i<n;i++) cin>>h[i];
	
	for(int i=0;i<m;i++){
		int u,v; cin>>u>>v;
		if(h[u-1]>h[v-1]) good[v-1]=false;
		else if(h[v-1]>h[u-1]) good[u-1]=false;
		else if(h[v-1]==h[u-1]){
			good[v-1]=false;
			good[u-1]=false;
		}
	}
	
	int count=0;
	for(int i=0;i<n;i++){
		if(good[i]==true) count++;
	}
	
	cout<<count<<endl;
	
	return 0;
} 

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

typedef long long ll;
#define INF 1e15
#define MAX_Q 200001

long long N, Q;
string s;
vector<char> t(MAX_Q), d(MAX_Q);

bool C1(long long c) {
	ll now = c;
	for (long long i = 0; i < Q; i++) {
		if (s[now] == t[i]) {
			if (d[i] == 'L') now--; else now++;
		}
	}
	return now == 0;
}

bool C2(long long c) {
	ll now = c;
	for (long long i = 0; i < Q; i++) {
		if (s[now] == t[i]) {
			if (d[i] == 'L') now--; else now++;
		}
	}
	return now == N+1;
}

int main(){
	scanf("%lld",&N);
	scanf("%lld",&Q);
	cin >> s;
	s = "0"+s+"1";

	for (int i=0; i<Q; i++) {
		cin >> t[i];
		cin >> d[i];
	}

	long long lb = 1, ub = N+1;
	while (ub - lb > 1) {
		long long mid = (lb + ub) / 2;
		if (C1(mid)) lb = mid;
		else ub = mid;
	}

	ll res = N-lb;

	lb = 1; ub = N+1;
	while (ub - lb > 1) {
		long long mid = (lb + ub) / 2;
		if (!C2(mid)) lb = mid;
		else ub = mid;
	}

	res -= N-lb;

	cout << res << endl;
	return 0;

}


Measured memory_bytes: 1156
#include <climits>
#include <cmath>
#include <cstdlib>
#include <iostream>
using namespace std;

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

inline int dist(int a, int b, int w) {
	return abs(a % w - b % w) + abs(a / w - b / w);
}

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

	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	--a; --b; --c; --d;

	int ans = INT_MAX;
	for(int i = 1; i <= n; ++i)
		chmin(ans, dist(a, b, i) + dist(c, d, i));

	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1196
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;


void facts(int64 n, map<int64,int64>& fact) {
    int64 t = n;
    for (int64 i=2; i*i<=t; i++) {
        while(n%i == 0) {
            fact[i]++;
            n /= i;
        }
    }
    if (n != 1) fact[n]++;
}

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

    map<int64,int64> fact;
    facts(n,fact);

    int64 ans = 0;
    for (auto [a,b] : fact) {

        for (int i=1; i<=b; i++) {
            b-=i;
            ans++;
        }
    }
    cout << ans << endl;
}



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

int n;
vector<string> A;

void f(int digitNum, string s, int lim){
    bool a = false, b = false, c = false;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '3') a = true;
        if(s[i] == '5') b = true;
        if(s[i] == '7') c = true;
    }
    if(a && b && c){
        A.push_back(s);
    }
    if(digitNum == lim){
        return;
    }
    f(digitNum + 1, s + '3', lim);
    f(digitNum + 1, s + '5', lim);
    f(digitNum + 1, s + '7', lim);
    return;
}

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

    cin >> n;

    int lim = to_string(n).length();

    // 七五三数は必ず'7', '5', '3'を含むので三桁以上は確定
    // nの桁数がが二桁以下の場合0
    if(lim < 3){
        cout << 0 << endl;
        return 0;
    }

    // nの桁数と同じ桁数までの七五三数を列挙
    f(0, "", lim);

    // vector Aにはstring型で七五三数が格納されているので数値に直す
    vector<int> B;
    for(auto &x : A){
        B.push_back(stoi(x));
    }

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

    // upper_boundを使用
    // もし配列の最後に欲しいものがあった場合、思わしくない動作をするのではないかと思ったが，
    //　vector<int >A = {i, 2, 3}でupper_boundの第三引数を3とした場合，3が返ってくる（指定した数値より大きい数がでてくるところを指すが範囲外参照的な感じになってもいいらしい）
    int idx = upper_bound(B.begin(), B.end(), n) - B.begin();

    cout << idx << endl;

    return 0;
}

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

constexpr int64_t MOD = (int64_t)1e9 + 7;

int64_t MODpow(int64_t n, int64_t m) {
    int64_t result = 1;
    while (m) {
        if (m % 2 == 1) {
            result *= n;
            result %= MOD;
        }

        m /= 2;
        n *= n;
        n %= MOD;
    }

    return result;
}

class Combination {
public:
    Combination(int64_t max_num, int64_t mod) {
        fact_.resize(max_num + 1, 1);
        inv_fact_.resize(max_num + 1, 1);
        mod_ = mod;
        for (int64_t i = 2; i <= max_num; i++) {
            fact_[i] = i * fact_[i - 1] % mod_;
            inv_fact_[i] = MODpow(fact_[i], mod_ - 2);
            assert(fact_[i] * inv_fact_[i] % mod_ == 1);
        }
    }
    int64_t operator()(int64_t n, int64_t m) const {
        if (m < 0 || m > n) return 0;
        return fact_[n] * inv_fact_[n - m] % mod_ * inv_fact_[m] % mod_;
    }
private:
    vector<int64_t> fact_, inv_fact_;
    int64_t mod_;
};

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> C(N);
    for (int64_t& c : C) {
        cin >> c;
    }

    constexpr int64_t MOD = 1e9 + 7;

    //順番は関係ないのでCを降順にソート
    sort(C.begin(), C.end(), greater<int64_t>());

    //あるS,Tが定まったとき、基本的にコストが小さい順に変換していく

    int64_t ans = 0;
    for (int64_t i = 0; i < N; i++) {
        //i桁目が異なるとする(0,1と1,0の2通りありうる)
        //C[i]がどれだけ答えに寄与するか考える(何回計算されるか)
        //自分より大きいコストを持ったビットがi個
        //  この中からj個が立っているとすると(j + 1)個のときC[i]が選ばれる
        //  (sum_{j = 0}^{i} (j + 1) i_C_j)
        //  = sum_{j = 0}^{i} j i_C_j + sum_{j = 0}^{i} i_C_j
        //  (第一項) = sum_{j = 1}^{i} i * (i-1)_C_(j-1)
        //          = i * sum_{j = 1}^{i} (i-1)_C_(j-1)
        //          = i * sum_{j = 0}^{i} (i-1)_C_(j)
        //          = i * 2 ^ {i - 1}

        int64_t smaller = (i * MODpow(2, i - 1) + MODpow(2, i)) % MOD * MODpow(2, i) % MOD;
        //自分より小さいコストを持ったビットがN - 1 - i個
        //これらは自由、それぞれiと同じが違うかの2通り
        int64_t larger = MODpow(4, N - 1 - i);

        (ans += smaller * larger * 2 % MOD * C[i] % MOD) %= MOD;
    }

    cout << ans << endl;
}

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

using namespace std;

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

	int n, k, i, j;
	
	cin >> n >> k;
	
	int a[n], dp[n];
	
	for(i=0; i<n; i++)
	{
		cin >> a[i];
		
		dp[i] = INT_MAX;
	}
	
	dp[0] = 0;
	
	for(i=1; i<n; i++)
	{
		for(j=i-1; j>=i-k and j>=0; j--)
		{
			dp[i] = min(dp[i], dp[j]+abs(a[j]-a[i]));
		}
	}
	
	cout << dp[n-1];

	return 0;
}


Measured memory_bytes: 1024
import itertools

N = int(input())
MOD = 10 ** 9 + 7

dp = {}
chars = ['A', 'G', 'C', 'T']

for cs in itertools.product(chars, repeat = 3):
    word = ''.join(cs)
    if word == 'AGC' or word == 'ACG' or word == 'GAC':
      dp[(3, word)] = 0
    else:
      dp[(3, word)] = 1
      
def includeagc(word):
  return 'AGC' in word

for i in range(4, N + 1):
  for cs in itertools.product(chars, repeat = 4):
    cs = list(cs)
    word = ''.join(cs)
    words = [word]
    for j in range(3):
      cs[j], cs[j + 1] = cs[j + 1], cs[j]
      words.append(''.join(cs))
      cs[j], cs[j + 1] = cs[j + 1], cs[j]
    if not any(includeagc(word) for word in words):
      dp[(i, word[1:4])] = (dp.get((i, word[1:4]), 0) + dp.get((i - 1, word[0:3]), 0)) % MOD
      
ans = sum([k[1] for k in dp.items() if k[0][0] == N]) % MOD
print(ans)

Measured memory_bytes: 4520
D = int(input())
c = list(map(int, input().split()))
s = []
t = []
for _ in range(D):
  s.append(list(map(int, input().split())))
for _ in range(D):
  t.append(int(input()))


ans = 0
last_date = [0]*26
for day in range(D):
  contest = t[day]-1
  ans += s[day][contest]
  last_date[contest] = day+1
  for j in range(26):
    ans -= c[j] * (day+1 - last_date[j])

  print(ans)



Measured memory_bytes: 74444
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int ans = N / 100 + N % 100 / 10 + N % 10;

		System.out.println(ans);
		reader.close();
	}


}





Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	int flagA = 0, flagB = 0;
	int cnt = 0, max=0;
	char S[100], A[100], B[100];
	for (int i = 0; i < N; i++) cin >> S[i];

	for (int i = 1; i < N; i++) {
		cnt = 0;
		for (int j = 'a'; j <= 'z'; j++) {
			flagA = 0; flagB = 0;
			for (int k = 0; k < i; k++) {
				if (S[k] == j) flagA = 1;
			}
			for (int k = i; k < N; k++) {
				if (S[k] == j) flagB = 1;
			}
			if (flagA == 1 && flagB == 1) cnt++;
		}
		if (max < cnt) max = cnt;
	}
	cout << max << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
  int N = 0;
  int h, h_old;
  int i = 0, n = 0, n_old = 0;
  
  cin >> N;
  
  while (cin >> h) {
    if (i == 0) {
      h_old = h;
      i++;
      continue;
    }
    
    if (h <= h_old) n++;
	else {
      n_old = (n > n_old ? n : n_old);
      n = 0;
    }
		
	h_old = h;
	i++;
    
    if (i >= N) break;
  }
  
  cout <<  (n > n_old ? n : n_old) << endl;
  
  return 0;
}

Measured memory_bytes: 256