akhauriyash/Code-Regression huggingface dataset:
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void) {
    int n, k;
    cin >> n >> k;
    COMinit();
    for(int i = 1; i <=k; i++) {
        cout << COM(k-1, i-1) * COM(n-k+1, i) % MOD << endl;
    }
    return 0;
}


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

// MY TOOLS
#define let long long int
#define async ios_base::sync_with_stdio(false);cin.tie(NULL);
#define i_upto( n ) for( int i = 0 ; i < n ; i++ )
#define ij_upto( n, m ) for( int i = 0 ; i < n ; i++ ) for( int j = 0 ; j < m ; j++ )
template<class T>
T ** array2D( let R , let C ){
	T ** t = new T * [R] ;
	for( int i = 0 ; i < R ; i++ ){
		t[i] = new T[C] ;
	}
	return t ;
}
template<class T>
T ** array2D( let R , let C, T value ){
	T ** t = new T * [R] ;
	for( int i = 0 ; i < R ; i++ ){
		t[i] = new T[C] ;
	}
    ij_upto( R, C ) t[i][j] = value ;
	return t ;
}
template<class T>
T * array1D( let N, T value ){
    T * t = new T[N] ;
    i_upto(N) t[i] = value ;
    return t ;
}
template<class T>
T * array1D( let N ){
    T * t = new T[N] ;
    return t ;
}
template<class T>
vector<vector<T>> vector2D( let N, let M ){
	return vector<vector<T>>(N,vector<T>(M)) ;
}
template<class T>
vector<vector<T>> vector2D( let N, let M, let Value ){
	return vector<vector<T>>(N,vector<T>(M,Value)) ;
}
class graph{
    public:
        vector<pair<int, int>> * v ;
        int number_of_nodes ;
        graph( int n ){
            v = new vector<pair<int, int>> [n+1] ;
            number_of_nodes = n ;
        }
        void add_edge( int f, int t, int w ){
            v[f].push_back( {w, t} ) ;
        }
        int weight_between( int f, int t ){
            return v[f][t].first ;
        }
        int number_of_childs( int f ){
            return v[f].size() ;
        }
        int get_child_at( int f, int i ){
            return v[f][i].second ;
        }
};
//

// main
// write your code here
int main(){
	async ;
    int N, mod = 1e9 + 7 ;
    cin >> N ;
    auto can = vector2D<int>( N, N ) ;
    ij_upto( N, N ) cin >> can[i][j] ;
    vector<int> dp( 1 << N ) ;  // 2^N
    dp[0] = 1 ;
    for( int mask = 0 ; mask < (1<<N)-1 ; mask++ ){
        int a = __builtin_popcount(mask) ;  //number of already assigned persons
        for( int b = 0 ; b < N ; b++ ){
            if( can[a][b] && ((mask & ( 1 << b ))==0) ) {   // it means bth is not assigned
                int m2 = mask | ( 1 << b ) ; // assigning woman to man
                dp[m2] = ( dp[m2] + dp[mask]) % mod  ;
            }
        }
    }
    cout << dp[(1<<N)-1] << "\n" ;
   
    return 0 ;
}

Measured memory_bytes: 11380
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<string>
//#include<string>
//#include<sstream>
#include<iomanip>
using namespace std;
int main() {
	int N,W,H,x,y,i,j,a;
	int color[100][100]={0};
	scanf("%d%d%d",&W,&H,&N);
	for(i=0;i<N;i++){
		scanf("%d%d%d",&x,&y,&a);
		if(a==1){
			for(int i=0;i<x;i++){
				for(j=0;j<H;j++){
					color[j][i]=1;
				}
			}
		}
		else if(a==2){
			for(int i=x;i<W;i++){
				for(j=0;j<H;j++){
					color[j][i]=1;
				}
			}
		}
		else if(a==3){
			for(int i=0;i<y;i++){
				for(j=0;j<W;j++){
					color[i][j]=1;
				}
			}
		}
		else if(a==4){
			for(int i=y;i<H;i++){
				for(j=0;j<W;j++){
					color[i][j]=1;
				}
			}
		}
	}
	int sum=0;
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			if(color[i][j]!=1) sum++;
		}
	}
	printf("%d\n",sum);
}

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

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

  string s;
  cin >> s;
  cout << s.substr(0,4) << " " << s.substr(4, 8) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int total=0;
    int n;
    cin >> n;
    VI a(n);
    REP(i,n) {
        cin >> a[i];
        total+=a[i];
    }
    if ( total%10 ) {
        cout << total << endl;
        return 0;
    }
    int ans=0;
    REP(i,n) {
        ans=max(ans, ((total-a[i])%10? total-a[i] : 0));

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

Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"3
3 1 2
2 5 4
3 6"# => "14",

r#"4
2 3 4 1
13 5 8 24
45 9 15"# => "74",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
        a: [usize; n],
        b: [usize; n],
        c: [usize; n - 1],
    }

    let mut ans = 0;
    let mut last = 100;
    for i in 0..n {
        ans += b[a[i] - 1];
        if last + 1 == a[i] {
            ans += c[last - 1];
        }
        last = a[i];
    }
    ans.to_string()
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,m,x,y; cin>>n>>m>>x>>y;
    vector<ll> a(n),b(m);
    rep(i,n) cin>>a[i];
    rep(i,m) cin>>b[i];
    sort(all(a));
    sort(all(b));
    bool can=false;
    for(int i=x+1;i<=y;i++){
        if(a[n-1]<i && i<=b[0]) can=true;
        else continue;
    }

    cout<<(can?"No War":"War")<<endl;
    return 0;
}

Measured memory_bytes: 3524
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif /* __DEBUG__ */

int main()
{
  ulli N;
  std::cin >> N;
  
  std::vector<ulli> A(N), B(N), C(N);
  
  N_TIMES(n, N) { std::cin >> A[n]; }
  std::sort(A.begin(), A.end());
  
  N_TIMES(n, N) { std::cin >> B[n]; }
  std::sort(B.begin(), B.end());
  
  N_TIMES(n, N) { std::cin >> C[n]; }
  std::sort(C.begin(), C.end());
  
  ulli s = 0;
  
  for (ulli n = 0; n < N; ++n) {
    auto itrA = std::lower_bound(A.begin(), A.end(), B[n]);
    ulli p = std::distance(A.begin(), itrA);
    
    auto itrC = std::upper_bound(C.begin(), C.end(), B[n]);
    ulli q = std::distance(itrC, C.end());
    
    s += p * q;
  }
  
  std::cout << s << std::endl;
  
  return 0;
}

Measured memory_bytes: 2560
import           Control.Monad
import           Control.Monad.ST
import           Data.Array
import           Data.Array.ST
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe
import qualified Data.Vector           as V
import qualified Data.Vector.Mutable   as M

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

main=do
    getLine
    a <- getIntList
    let cnt = runST $ do
            vec <- V.thaw $ V.replicate m 0
            forM_ a $ \ai ->
                forM_ (primeFactor ai) $ \j ->
                    M.modify vec (+1) j
            V.freeze vec
    putStrLn$
        if V.and $V.map (<=1) cnt
        then "pairwise coprime"
        else if foldl1 gcd a == 1
            then  "setwise coprime"
            else  "not coprime"
m = 10^6+1

table :: V.Vector Int
table = runST $ do
    vec <- V.thaw $ V.fromList [0..m]
    forM_ (takeWhile (\i -> i*i < m) [2..]) $ \i -> do
        arri <- M.read vec i
        when (arri >= i)$
            forM_ [i,i+i..m-1] $ \j -> do
                v <- M.read vec j
                when (v == j) $ M.write vec j i
    V.freeze vec

primeFactor :: Int -> [Int]
primeFactor 1 = []
primeFactor n = if null prev || head prev /= p
    then p:prev
    else prev
    where p = table V.! n
          prev = primeFactor (n `div` p)


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

int main(){
    string s; cin >> s;

    ll cnt = 0;

    for(int i = 0; i < s.size()-1; i++){
        if(s[i] != s[i+1]) cnt++;
    }
    //if(cnt > 1) cnt++;
    put(cnt);
}

Measured memory_bytes: 3692
import std.stdio, std.range, std.conv, std.string, std.array, std.functional, std.math;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;
import std.container.binaryheap;

void main()
{
    auto N = readln().strip.to!(long);
    
    long[4][4][4][] memo;
    memo.length = N+1;
    memo[0][3][3][3] = 1;

    foreach(i; 0..N) {
        foreach(c1; 0..4) {
            foreach(c2; 0..4) {
                foreach(c3; 0..4) {
                    foreach(a; 0..4) {
                        if(a==2&&c1==1&&c2==0)continue;
                        if(a==2&&c1==0&&c2==1)continue;
                        if(a==1&&c1==2&&c2==0)continue;
                        if(a==2&&c1==1&&c3==0)continue;
                        if(a==2&&c2==1&&c3==0)continue;
                        memo[i+1][a][c1][c2] += memo[i][c1][c2][c3];
                        memo[i+1][a][c1][c2] %= pow(10, 9) + 7;
                    }
                }
            }
        }
    }

    long res;
    foreach(c1; 0..4) {
        foreach(c2; 0..4) {
            foreach(c3; 0..4) {
                res += memo[N][c1][c2][c3];
                res %= pow(10, 9) + 7;
            }
        }
    }
    writeln(res);
}


Measured memory_bytes: 316
H, W = map(int, raw_input().split())
s = []
w = 0
for i in range(H):
  l = raw_input()
  s.append(l)
  w += l.count(".")
C = []
for i in range(H):
  C.append([10000]*W)
C[0][0]=1
q = [(0,0)]
while q:
  i, j = q.pop(0)
  for d in [(+1,0),(-1,0),(0,+1),(0,-1)]:
    ni = i+d[0]
    nj = j+d[1]
    if 0<=ni<H and 0<=nj<W and s[ni][nj]=="." and C[i][j]+1<C[ni][nj]:
      C[ni][nj] = C[i][j]+1
      q.append((ni,nj))
if C[H-1][W-1]==10000:
  print -1
else:
  print w-C[H-1][W-1]

Measured memory_bytes: 2696
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}
int main()
{
    ios;
    int n;
    cin>>n;
   int a[n],b[n],c[n-1];
   for(int i=0;i<n;i++)
    cin>>a[i],--a[i];
   for(int i=0;i<n;i++)
    cin>>b[i];
   for(int i=0;i<n-1;i++)
    cin>>c[i];
    ll s=0;
    for(int i=0;i<n;i++)
    {
        s+=b[a[i]];
        if(a[i]==a[i-1]+1&&i>0)
            s+=c[a[i-1]];
    }
    cout<<s<<endl;

}
//Alhamdulillah

















Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int d[] = new int[N];
		for(int i=0;i<N;i++) {
			d[i]=sc.nextInt();
		}
		
		int ans = 0;
		int i=0;
		int j=0;
		for(int deli:d) {
			j=0;//ここで初期化が必要
			for(int deli2:d) {
				if(i==j) {
					//DO NOTHING
				}else {
					ans+=deli*deli2;
				}
				j++;
			}
			i++;
		}
		
		ans /= 2;
	
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 21460
def gcd(x, y):  #最大公約数を求める
    if y == 0:
        return x
    else:
        return gcd(y, x % y) #再帰定義


if __name__ == "__main__":
    a, b, c, d =  map(int, input().split())
    
    
    
    bai_c = int(b // c)
    bai_d = int(b // d)

    l  = int((c * d) / gcd(c, d))
    b_duplicated = int(b // l)

    bai_c2 = int((a - 1) // c)
    bai_d2 = int((a - 1) // d)
    
    l2 = int((c * d) / gcd(c, d))
    a_duplicated = int((a - 1) // l2)
    
    ans = (b - (bai_c + bai_d - b_duplicated)) - ((a - 1) - (bai_c2 + bai_d2 - a_duplicated))
    print(int(ans))
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N, T;
    cin >> N >> T;
    vector<int> c( N ), t( N );
    REP( i, N )
    {
        cin >> c[ i ] >> t[ i ];
    }
    int res = INT_MAX;
    REP( i, N )
    {
        if( t[ i ] <= T )
        {
            res = min( res, c[ i ] );
        }
    }
    cout << ( res == INT_MAX ? "TLE" : to_string( res ) ) << endl;
    return 0;
}

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

template <typename A, typename B>string to_string(pair<A, B> p);template <typename A, typename B, typename C>string to_string(tuple<A, B, C> p);template <typename A, typename B, typename C, typename D>string to_string(tuple<A, B, C, D> p);string to_string(const string& s) {  return '"' + s + '"';}string to_string(const char* s) {  return to_string((string) s);}string to_string(bool b) {  return (b ? "true" : "false");}string to_string(vector<bool> v) {  bool first = true;  string res = "{";  for (int i = 0; i < static_cast<int>(v.size()); i++) {    if (!first) {      res += ", ";    }    first = false;    res += to_string(v[i]);  }  res += "}";  return res;}template <size_t N>string to_string(bitset<N> v) {  string res = "";  for (size_t i = 0; i < N; i++) {    res += static_cast<char>('0' + v[i]);  }  return res;}template <typename A>string to_string(A v) {  bool first = true;  string res = "{";  for (const auto &x : v) {    if (!first) {      res += ", ";    }    first = false;    res += to_string(x);  }  res += "}";  return res;}template <typename A, typename B>string to_string(pair<A, B> p) {  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A, typename B, typename C>string to_string(tuple<A, B, C> p) {  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";}template <typename A, typename B, typename C, typename D>string to_string(tuple<A, B, C, D> p) {  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";}void debug_out() { cerr << endl; }template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {  cerr << " " << to_string(H);  debug_out(T...);}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define set0(x) memset(x,0,sizeof(x))
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> void read(T &x){
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
template<typename T, typename... Args> void read(T &first, Args& ... args) {
    read(first);
    read(args...);
}

int h1,m1,h2,m2,k;
int main() {
    read(h1,m1,h2,m2,k);
    cout<<(h2*60+m2-h1*60-m1-k)<<endl;
    return 0;
}


Measured memory_bytes: 3628
/*Template by hemnath_d(Enlightened by chamow)*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec vector<ll>
#define pll pair<ll,ll>
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fx first
#define sx second
#define inf 100000000000000
#define minf -100000000000000

int main()
{
    fastread;
    ll n,temp;
    cin>>n;
    vec arr(n),pref(n);
    for(ll i=0;i<n;i++)
    {
    	cin>>temp;
    	arr[i]=(temp-(i+1));
    }
    sort(arr.begin(),arr.end());
    pref[0]=arr[0];
    for(ll i=1;i<n;i++)
    	pref[i]=arr[i]+pref[i-1];
    ll ans=inf;
    for(ll i=0;i<n;i++)
    {
    	//cout<<"at i "<<i<<endl;
    	ll tans=0;
    	temp=arr[i];
    	if(i!=0)
    		tans+=(i*temp)-pref[i-1];
    	tans+=pref[n-1]-pref[i]-(n-i-1)*temp;
    	//cout<<pref[n-1]-pref[i]<<" "<<temp<<endl;
    	//cout<<abs(tans)<<endl;
    	ans=min(ans,abs(tans));

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

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

template <typename T> int LIS(const vector<T> &a) {
    vector<T> dp(a.size(), numeric_limits<T>::max());
    for (int i = 0; i < (int)a.size(); ++i) {
        *upper_bound(dp.begin(), dp.end(), a[i]) = a[i];
    }
    return lower_bound(dp.begin(), dp.end(), numeric_limits<T>::max()) - dp.begin();
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    reverse(a.begin(), a.end());
    cout << LIS(a) << endl;
}

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

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

    int n, m, q;
    cin >> n >> m >> q;
    vector<vector<int>> s(n + 1, vector<int>(n + 1, 0));
    for (int i = 0; i < m; i++) {
        int l, r; cin >> l >> r;
        s[l][r]++;
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) s[i][j] += s[i][j - 1];
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) s[i][j] += s[i - 1][j];
    }

    for (int i = 0; i < q; i++) {
        int p, q; cin >> p >> q; p--;
        int ans = s[q][q] - s[p][q] - s[q][p] + s[p][p];
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define endl "\n"
#define float long double
#define int long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define LB lower_bound
#define UB upper_bound
#define g(t, n) get<n>(t)
#define fp(x, y) fixed<<setprecision(y)<<x
#define PI 3.141592653589793238462643383279502884
using namespace std;

const int M = (int)2e5+5;
const int mod = (int)1e9+7;

int n, k;
int a[M];
bool func(int l)
{
	int ans = 0;
	f(i, 0, n) ans += (a[i]+l-1)/l - 1;
	return ans <= k;
}

void solve()
{
	int ans = 1e10;
    cin>>n>>k;
    f(i, 0, n) cin>>a[i];
    int l = 1, r = 1e10;
    while(l <= r)
    {
    	int mid = (l+r)/2;
    	if(func(mid)) ans = min(ans, mid), r = mid-1;
    	else l = mid+1;
    }
    cout<<ans<<endl;
}

int32_t main()
{
    IOS
    int t = 1;
    // cin>>t;
    f(tno, 1, t+1)
    {
        // cout<<"Case #"<<tno<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 5168
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == '+')
        {
            ans++;
        }
        else ans--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int N;
string S;
int z_algorithm[5005];


int main(){

	scanf("%d",&N);

	cin >> S;

	int ans = 0;

	for(int i = 0; i < N-1; i++){

		int P_length = N-i;
		z_algorithm[0] = P_length;
		int index = 1,diff = 0,diff_2;

		while(index < P_length){
			while(index+diff < P_length && S[i+index+diff] == S[i+diff])diff++; //不一致箇所はP[diff]とP[index+diff]
			z_algorithm[index] = diff;

			if(diff == 0){ //1文字も一致しない場合
				index++;
				continue;
			}else{ //先頭からdiff文字一致したという事実を利用する

				diff_2 = 1;

				//一致長が[比較の先頭をずらした分だけ]減っていく間、以前の計算結果を再利用する
				while(index+diff_2 < P_length && z_algorithm[diff_2] < diff-diff_2){

					z_algorithm[index+diff_2] = z_algorithm[diff_2];
					diff_2++;
				}

				index += diff_2;
				diff -= diff_2;
			}
		}

		for(int k = 0; k < P_length-1; k++){
			if(z_algorithm[k] > 0 && z_algorithm[k] <= k){

				ans = max(ans,z_algorithm[k]);
			}
		}
	}

	printf("%d\n",ans);

	return 0;
}




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

const int N = 4e5 + 9;

int Q, X, K, r[N], t[N], a[N], pr[N], tr, t1[N], t2[N], mx[N], mi[N];
bool u2[N];

#define L (x<<1)
#define R (x<<1|1)

void Build (int x, int l, int r) {
	if (l == r) return (void)(mx[x] = mi[x] = pr[l]);
	int mid = (l + r) >> 1;
	Build(L, l, mid);
	Build(R, mid + 1, r);
	mi[x] = mi[L]; mx[x] = mx[R];
}

void set2 (int x, int t) {
	t2[x] = mx[x] = mi[x] = t;
	u2[x] = 1; t1[x] = 0;
}

void set1 (int x, int t) {
	mx[x] += t; mi[x] += t;
	if (u2[x]) t2[x] += t;
	else t1[x] += t;
}

void pushdown (int x) {
	if (u2[x]) {
		set2(L, t2[x]);
		set2(R, t2[x]);
		u2[x] ^= 1;
	} else if (t1[x]) {
		set1(L, t1[x]); 
		set1(R, t1[x]);
		t1[x] = 0;
	}
}

void Modify (int x, int l, int r, int ql, int qr, int t) {
	if (mx[x] + t <= 0) return set2(x, 0);
	if (mi[x] + t >= X) return set2(x, X);
	if (mx[x] + t <= X && mi[x] + t >= 0) return set1(x, t);
	int mid = (l + r) >> 1; pushdown(x);
	if (qr <= mid) Modify(L, l, mid, ql, qr, t);
	else if (ql > mid) Modify(R, mid + 1, r, ql, qr, t);
	else Modify(L, l, mid, ql, mid, t), Modify(R, mid + 1, r, mid + 1, qr, t); 
	mi[x] = mi[L]; mx[x] = mx[R];
}

void Query (int x, int l, int r, int z) {
	int mid;
	while (l != r) {
		mid = (l + r) >> 1; pushdown(x);
		if (z <= mid) x = L, r = mid;
		else x = R, l = mid + 1;
	}
	printf("%d\n", mx[x]);
}

int main () {
	scanf("%d%d", &X, &K);
	for (int i = 1; i <= K; ++i) scanf("%d", &r[i]);
	scanf("%d", &Q);
	for (int i = 1; i <= Q; ++i) scanf("%d%d", &t[i], &a[i]), pr[++tr] = a[i];
	sort(pr + 1, pr + tr + 1);
	tr = unique(pr + 1, pr + tr + 1) - pr - 1;
	Build(1, 1, tr);
	int la = 0, fx = -1;
	for (int i = 1, j = 1; i <= Q; ) {
		if (j <= K && r[j] <= t[i]) {
			Modify(1, 1, tr, 1, tr, fx * (r[j] - la));
			la = r[j];
			fx = -fx;
			++j;
		} else {
			Modify(1, 1, tr, 1, tr, fx * (t[i] - la));
			la = t[i];
			Query(1, 1, tr, lower_bound(pr + 1, pr + tr + 1, a[i]) - pr);
			++i;
		}
	}
	return 0;
}

Measured memory_bytes: 12672
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int t = sc.nextInt();
        int total = 0;
        for(int i = 1; i < t + 0.5; i++) {
            if(i % a == 0) total += b;
        }
        System.out.println(total);
    }
}


Measured memory_bytes: 22868
#include <iostream>
#include <math.h>
#include <algorithm>
#define ll long long
#define DIV 1000000007

using namespace std;

int s;
ll dp[2001], p[2001];

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

	cin >> s;
	dp[3] = 1, p[3] = 1;
	dp[4] = 1, p[4] = 2;
	dp[5] = 1, p[5] = 3;

	for (int i = 6; i <= s; i++) {
		dp[i] = p[i - 3] - p[2] + 1 + DIV;
		dp[i] %= DIV;
		p[i] = p[i - 1] + dp[i];
		p[i] %= DIV;
	}
	cout << dp[s];
	return 0;
}

Measured memory_bytes: 3104
#include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;

void trace(int N, int A[]) {
    for(int i = 0; i < N; i++) {
        if(i >= 1) {
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;
}
int main() {
    int N;
    cin >> N;
    int data[N];
    for(int i = 0; i < N; i++) {
        cin >> data[i];
    }
    trace(N, data);
    for(int i = 1; i < N; i++) {
        int v = data[i];
        int j = i-1;
        while(j>=0 && v < data[j]){
            data[j+1] = data[j];
            j--;
        }
        data[j+1] = v;
        trace(N, data);
    }
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
using namespace std;

int main(void) {
    double a,b; cin >> a >> b;
    if (a >= 13) {
        cout << b << endl;
    } else if (a >= 6) {
        cout << b / 2 << endl;
    } else {
        cout << 0 << endl;    
    }
}

Measured memory_bytes: 3780
#include<iostream>
#include<vector>
#include<iomanip>
#include<cstring>
using namespace std;

double dp[305][305][305];
bool vis[305][305][305];

double f(int one, int two, int three, int n)
{
  if (one < 0 or two < 0 or three < 0)
    return 0;
  if (one == 1 and two == 0 and three == 0)
    return n;
  if (one == 0 and two == 0 and three == 0)
    return 0;
  auto& ret = dp[one][two][three];
  if (vis[one][two][three])
    return ret;
  vis[one][two][three] = true;
  ret = 1;
  double p = ((double)n - one - two - three)/n;
  return ret = ((1 + f(one - 1, two, three, n) * (double)(one)/n + f (one + 1, two - 1 , three, n) * (double)two / n + f (one, two + 1, three - 1, n) * (double)three/n))/(1-p);
}

// 2/3 * f(1,0,0,3)

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> cnt(4);
  for (int i = 0 ; i < n; ++i) {
    int x;
    cin >> x;
    cnt[x]++;
  }
  memset(dp, -1, sizeof dp);
 // cout << cnt[1] << ' ' << cnt[2] <<' '<< cnt[3] <<'\n';
  cout << setprecision(15) << f(cnt[1], cnt[2], cnt[3], n) << '\n';

  return 0;
}


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

int k;
int a,b,c;

int ksm(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=ans*x;
		x=x*x;
		y>>=1;
	}
	return ans;
}

signed main(){
	scanf("%d%d%d%d",&a,&b,&c,&k);
	if(b<c) b^=c^=b^=c;
	if(a<b) a^=b^=a^=b;
	printf("%d\n",a*ksm(2,k)+b+c);
	return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

const int MOD = 1000000007;
const int INF = LLONG_MAX / 2;

int n;
int l[100010];
int r[100010];

int must[100010];

int solve() {
    fill(must, must + n, -1);

    must[n - 1] = r[n - 1];
    for (int i = 0; i < n; i++) {
        if (i == 0 || l[i - 1] < l[i]) {
            must[i] = l[i];
        }
    }
    for (int i = n - 1; i >= 0; i--) {
        if (i == n - 1 || r[i] > r[i + 1]) {
            if (must[i] != -1 && r[i] != must[i]) {
                return 0;
            }
            must[i] = r[i];
        }
    }

    ll ans = 1;
    for (int i = 0; i < n; i++) {
        int ub = min(l[i], r[i]);
        if (must[i] != -1){
            if (must[i] > ub) {
                return 0;
            }
        } else {
            ans *= ub;
            ans %= MOD;
        }
    }
    return ans;
}

signed main() {
    while (cin >> n) {
        for (int i = 0; i < n; i++) {
            cin >> l[i];
        }
        for (int i = 0; i < n; i++) {
            cin >> r[i];
        }

        // WA in case which solve() != 0
        cout << solve() << endl;
    }
}
 


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

long long A[200005];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int N;
    cin >> N;

    long long sum = 0;

    for(int i=1; i<=N; i++)
    {
        cin >> A[i];
        sum += A[i];
    }

    long long ans = (long long) 1e18 * 2, curr = 0;

    for(int i=1; i<=N; i++)
    {
        curr += A[i];
        ans = min(ans, abs(sum - curr - curr));
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node{int p, l, r;};
Node T[MAX];
int n, D[MAX];

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

  if (T[u].p == NIL) cout << "root, ";
  else if (T[u].l == NIL) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";

  for (int i = 0, c = T[u].l; c != NIL; i ++, c = T[c].r) {
    if (i) cout << ", ";
    cout << c;
  }
  cout << "]" << endl;
}

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

int main() {
  int i, j, d, v, c, l, r;
  cin >> n;
  for (i = 0; i < n; i ++) T[i].p = T[i].l = T[i].r = NIL;

  for (i = 0; i < n; i ++) {
    cin >> v >> d;
    for (j = 0; j < d; j ++) {
      cin >> c;
      if (j == 0) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  for (i = 0; i < n; i ++) {
    if (T[i].p == NIL) r = i;
  }

  rec(r, 0);

  for (i = 0; i < n; i ++) print(i);

  return 0;
}



Measured memory_bytes: 7636
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

var lines = [];
reader.on('line',(line) => {
          lines.push(line);
});

reader.on('close', () => {
          var s = lines[0];
  var a = [s];
  for (var i = 0; i < 1000010; i++){
    if (a[i] % 2 == 0){
     a.push( a[i] / 2 );
    } else {
      a.push( a[i]*3+1 );
    }
    for (var j = 0; j < i;j++){
      if (a[i] == a[j]){
         console.log(i+1);
        return;
      }
    }
  }
});

Measured memory_bytes: 9676
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] d = new int[n];
        for (int i = 0; i < n; i++) {
            d[i] = sc.nextInt();
        }
        Arrays.sort(d);
        System.out.println(d[n/2] - d[n/2 -1]);
        sc.close();

    }

}


Measured memory_bytes: 51340
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;
int main() {

	int n,k;
	cin >> n>>k;
	vector<int>a(n+1, 0);
	set<int>r;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		a[t]++;
		r.insert(t);
	}
	
	sort(a.begin(), a.end());
	int z = 0;
	if (r.size() <= k)cout << 0 << endl;
	else {
		int y = r.size();
		for (int i = 0; i < n; i++) {
			if (!a[i])continue;
			y--;
			z += a[i];
			if (y <= k)break;
		}
		cout << z << endl;
	}

	return 0;
}

Measured memory_bytes: 10368
#include <iostream>

using namespace std;

int main(void) {

	int a, b;

	cin >> a >> b;

	if (a + b == 15) { cout << "+" << endl; }
	else if (a*b == 15) { cout << "*" << endl; }
	else { cout << "x" << endl; }

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
h, w = map(int, input().split())
if h == 1 or w == 1:
    print('1')
elif h % 2:
    if w % 2:
        print(h//2*w+(w//2+1))
    else:
        print(h//2*w+w//2)
else:
    print(h//2*w)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ll N=2e5+5;
const ld pi=3.14159265359;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(a) (ll)a.size()



int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	char c;
	cin>>c;
	cout<<(char)(c+1)<<"\n";
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define fi first
#define se second
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // order_of_key
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int maxx = 3000000;
#define PI 3.14159265
int n,c,k;
int main()
{
    fastio;
    cin>>n>>k>>c;
    string s;
    cin>>s;
    int f[n+2],b[n+2];
    f[0] = 0;
    b[n+1] = 0;
    for(int i=1;i<=n;i++)
    {
        if(s[i-1]=='x')
        {
            f[i] = f[i-1];
        }
        else
        {
            f[i] = f[max(i-(c+1),0)] + 1;
        }
    }
    vector<int>ans;
    for(int i=n;i>=1;i--)
    {
        if(s[i-1]=='x')
        {
            b[i] = b[i+1];
        }
        else
        {
            int temp = b[i+1];
            //trace3(i,f[i],temp);
            if(temp+f[i-1]<k)
                ans.pb(i);
            b[i] = b[min(n+1,(i+c+1))] + 1;
        }
    }
    for(int i=0;i<n;i++)
    {
        //trace3(i,f[i],b[i]);
    }
    //cout<<ans.size()<<endl;
    sort(all(ans));
    for(int i : ans)
        cout<<i<<" ";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 4236
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  auto hs = readln.chomp.split.to!(int[]);
  int res;
  int thr;
  foreach (h; hs) {
    if (h >= thr) {
      res++;
      thr = h;
    }
  }
  res.writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

int     main()
{
	char a;
	cin >> a;
	if (a < 'a')
		cout << 'A' << endl;
	else
		cout << 'a' << endl;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define repr(i, a, n) for (ll i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  int a, b, k;
  cin >> a >> b >> k;
  set<int> st;
  rep(i, a, b + 1) {
    if (i < a + k) {
      st.insert(i);
    }
    if (i > b - k) {
      st.insert(i);
    }
  }
  for (auto &a : st)
    cout << a << endl;
}

int main() {
  std::cin.tie(nullptr);                 // 標準入出力高速化
  std::ios_base::sync_with_stdio(false); // CとC++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15); // 小数を10進数表示
  Main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>>N;
    string A,B,C;
    cin>>A>>B>>C;
    int ans=0;
    rep(i,0,N){
        set<char> s;
        s.insert(A[i]);
        s.insert(B[i]);
        s.insert(C[i]);
        ans+=s.size()-1;
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ull bin(ull a, ull b)
{
    if(a%mod==0) return 0;
    ull res = 1;
    a %= mod;
    while(b)
    {
        if(b&1) res = (res*a)%mod;
        b >>= 1;
        a *= a;
        a%=mod;
    }
    return res%mod;
}

int main()
{
    ull h;
    cin>>h;
    ull a = log2(h)+1;
    cout<<(((ull)(1)<<a) - 1)<<endl;
}

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

int main(void) {
	int n, m;
	int ans = 0;
	string b[100], r[100];
	cin >> n;
	for (int i = 0; i < n; i++) cin >> b[i];
	cin >> m;
	for (int i = 0; i < m; i++) cin >> r[i];
	
	for (int i = 0; i < n; i++) {
		string st = b[i];
		int yen = 0;
		for (int j = 0; j < n; j++) {
			if (st == b[j]) yen++;
		}
		for (int k = 0; k < m; k++) {
			if (st == r[k]) yen--;
		}
		ans = max(yen, ans);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	Scanner sc = new Scanner(System.in);
	
	//---入力に必要な変数---
	//要素数を示す変数
	int n;
	//n個の整数を格納する配列
	int[] S;
	
	//---マージ、マージソートに必要な変数---
	int n1,n2;
	int i,j;
	int counter=0;
	
	public void input() {
		n = sc.nextInt();
		S = new int[n];
		for(int i=0; i<n; i++) {
			S[i] = sc.nextInt();
		}
	}
	
	public void output() {
		mergeSort(S, 0, n);
		System.out.print(S[0]);
		for(int i=1; i<n; i++) {
			System.out.print(" "+S[i]);
		}
		System.out.println("\n"+counter);
	}
	
	//整列された配列をマージ（結合）するメソッド
	public void merge(int[] A, int left, int mid, int right) {
		n1 = mid - left;
		n2 = right - mid;
		
		int[] L = new int[n1+1];
		//0...n1の配列Lを宣言した。
		int[] R = new int[n2+1];
		//0...n2の配列Rを宣言した。
		
		//配列L,Rに要素を代入する。
		for(int i=0; i<=n1-1; i++) L[i] = A[left+i];
		for(int i=0; i<=n2-1; i++) R[i] = A[mid+i];
		
		L[n1] = (int) Double.POSITIVE_INFINITY;
		R[n2] = (int) Double.POSITIVE_INFINITY;
		//配列L,Rの最後に最も大きい値（正の∞）を代入した。
		
		i = 0;
		j = 0;
		
		for(int k=left; k<=right-1; k++) {
			if(L[i] <= R[j]) {
				A[k] = L[i];
				i++;
				counter++;
			}else {
				A[k] = R[j];
				j++;
				counter++;
			}
		}
	}
	
	//対象の配列をマージソートするメソッド
	public void mergeSort(int[] A, int left, int right) {
		int mid;
		if(left+1 < right) {
			mid = (left + right) / 2;
			mergeSort(A, left, mid);
			mergeSort(A, mid, right);
			merge(A, left, mid, right);
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
		obj.output();
	}
}



Measured memory_bytes: 169672
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <utility>
#include <algorithm>
typedef long long ll;

//double t[100000];

using namespace std;

ll order[100000];
ll P[100000];
ll X[100000];
vector<pair<ll, ll> > yearToCity;
int main(){
        ll N,M,Y;
        scanf("%lld %lld",&N,&M);
        for(int i = 0; i < M; i++){
                scanf("%lld %lld",P+i,&Y);
                yearToCity.push_back(make_pair(Y,i));
        }

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

        memset(order,sizeof(order),0);

        vector<pair<ll, ll> >::iterator it = yearToCity.begin();

        while(it != yearToCity.end()){
                X[it->second] = order[P[it->second]]++;
                ++it;
        }

        for(int i = 0; i < M; i++){
                printf("%06lld%06lld\n",P[i],X[i]+1);
        }

}

Measured memory_bytes: 5488
import java.util.*;

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

      int n = stdIn.nextInt();
      Map<String,String> map = new HashMap<String,String>();

      for (int i=0; i<n; i++) {
         String s = stdIn.next();
         String str = stdIn.next();
         if (s.equals("insert")) {
            map.put(str,str);
         }else {
            if(map.containsKey(str))
               System.out.println("yes");
            else
               System.out.println("no");
         }
      }
   }
}


Measured memory_bytes: 257092
#include<bits/stdc++.h>
using namespace std;
#define MAXN 400005
#define MOD 998244353
#define LL long long int
LL ans,res,C[MAXN],fac[MAXN],revfac[MAXN];
int n,m,k;
LL qpow(LL a,int b)
{
    LL tmp=1;
    while(b)
    {
        if(b&1)
        tmp=tmp*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return tmp%MOD;
}
void facrev()
{
    C[0]=1;
    C[1]=(n-1);
    fac[1]=1;
    fac[0]=1;
    revfac[0]=1;
    revfac[1]=1;
    for(int i=2;i<=n;i++)
    {
        fac[i]=fac[i-1]*i%MOD;
        C[i]=C[i-1]*(n-i)%MOD;
    }
    revfac[n]=qpow(fac[n],MOD-2);
    for(int i=n-1;i>=1;i--)
    {
        revfac[i]=revfac[i+1]*(i+1)%MOD;
        C[i]=C[i]*revfac[i]%MOD;
    }
}
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    facrev();
    int p=n-k;
    res=m;
    for(int i=1;i<=p-1;i++)
    {
        res=res*(m-1)%MOD;
    }
    ans=res*C[p-1]%MOD;
    for(int j=p+1;j<=n;j++)
    {
        res=res*(m-1)%MOD;
        ans=(ans+res*C[j-1]%MOD)%MOD;
    }
    printf("%lld\n",ans);
    return 0;
}

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

using namespace std;

 int check(int n){

    int flag=0;
    for(int k=2;k<=n/2;k++){
        if(n%k==0){
            flag=1;
            return flag;
        }
    }

    return flag;

}

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

    int flag=check(n);
    while(true)
    {

     if(flag==0){
        cout<<n;
        break;
      }
     else{
         n=n+1;
         flag=check(n);
         }

    }

}


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

nx=[-1,-1]
while 1:
    ans=0
    nx=list(map(int,input().split()))
    testlst=[i for i in range(1,nx[0]+1)]
    lst=list(combinations(testlst, 3))
    if nx==[0,0]:
        break
    # print(lst)
    for i in range(len(lst)):
        if sum(lst[i])==nx[1]:
            ans+=1
    print(ans)


Measured memory_bytes: 32712
from collections import defaultdict, Counter
import math
N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


decomp_dic = defaultdict(int)

for n in range(2, N + 1):
    c = Counter(prime_factorize(n))
    for key, value in c.items():
        decomp_dic[key] += value

for key in decomp_dic.keys():
    decomp_dic[key] += 1

ans = 0
above_25 = 0
above_15 = 0
above_5 = 0
above_3 = 0
for value in decomp_dic.values():
    if value >= 75:
        ans += 1
    if value >= 25:
        above_25 += 1
    if value >= 15:
        above_15 += 1
    if value >= 5:
        above_5 += 1
    if value >= 3:
        above_3 += 1

ans += above_25 * (above_3 - 1)
ans += above_15 * (above_5 - 1)

ans += (above_3 - 2) * above_5 * (above_5 - 1) // 2

print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{  
	ll one,zero,nege;
   ll k;
  ll ans=0;
  cin>>one>>zero>>nege>>k;
  if(k>=one)
  {
    k-=one;
    ans+=one;
  }
  else
  { ans+=k;
    k=0;}
  if(k>=zero && k!=0)
  { 
    k-=zero;
  }
  else
    k=0;
  ans-=(k);
  cout<<ans<<endl;
    
}


Measured memory_bytes: 3560