akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter;
import java.util.*;

public class Main {
		public static void main(String[] args) {
			Scanner stdin = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out);
			
			int A = Integer.parseInt(stdin.next());
			int B = Integer.parseInt(stdin.next());
			int C = Integer.parseInt(stdin.next());

			if(C-(A-B)<0) {
				System.out.println(0);
			}
			else {
			System.out.println(C-(A-B));
			}
			
			out.flush();
	}
}




Measured memory_bytes: 22996
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){ 
            int a = sc.nextInt(); 
            String op = sc.next(); 
            int b = sc.nextInt(); 
            if(op.equals("?")) break; 
            if(op.equals("+")) System.out.println(a + b); 
            if(op.equals("-")) System.out.println(a - b); 
            if(op.equals("*")) System.out.println(a * b); 
            if(op.equals("/")) System.out.println(a / b); 
        } 
    } 
}


Measured memory_bytes: 26216
#include<iostream>
#include<vector>
#include<utility>
#include<math.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int> > vp;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define For(i, a, n) for(int i = a; i < (n); i++)
#define out(n) cout << n << endl;
#define vut(v) rep(i, v.size()) out(v[i]);

int main(){
  double a, b;
  cin >> a >> b;

  out((a > b ? "GREATER" : a < b ? "LESS" : "EQUAL"))
}


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

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ON_SEGMENT = 0;
static const int ONLINE_FRONT = 2;
static const int ONLINE_BACK = -2;
const double EPS = 1e-10;

bool equals(double a, double b) {
	return fabs(a - b) < EPS;
}

class Point {
public:
	double x, y;

	Point(double x = 0, double y = 0): x(x), y(y) {}

	Point operator + (Point p) {
		return Point(x + p.x, y + p.y);
	}
	Point operator - (Point p) {
		return Point(x - p.x, y - p.y);
	}
	Point operator * (double k) {
		return Point(k * x, k * y);
	}
	Point operator / (double k) {
		return Point(x / k, y / k);
	}

	double norm() {
		return x * x + y * y;
	}
	double abs() {
		return sqrt(norm());
	}

	bool operator < (const Point &p) const {
		return x != p.x ? x < p.x : y < p.y;
	}

	bool operator == (const Point &p) const {
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}
};

typedef Point Vector;

double dot(Vector a, Vector b) {
	return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
	return a.x * b.y - a.y * b.x;
}

class Segment {
public:
	Point p1, p2;
	Segment(Point p1, Point p2): p1(p1), p2(p2) {};

	Point project(Point p) {
		Vector a = Vector(p.x - p1.x, p.y - p1.y);
		Vector b = Vector(p2.x - p1.x, p2.y - p1.y);
		return p1 + p2 * (dot(a, b) / b.norm());
	}

	Point refrect(Point p) {
		Point pro = project(p);
		return pro * 2 - p;
	}
};

int check(Vector v0, Vector v1) {
	double c = cross(v0, v1);
	if (equals(c, 0)) {
		if (dot(v0, v1) < 0) return ONLINE_BACK;
		else if (v1.norm() > v0.norm()) return ONLINE_FRONT;
		else return ON_SEGMENT;
	} else if (c > 0) {
		return COUNTER_CLOCKWISE;
	} else {
		return CLOCKWISE;
	}
}

int intersect(Segment s1, Segment s2) {
	Point p1 = s1.p1, p2 = s1.p2, p3 = s2.p1, p4 = s2.p2;
	Vector v0 = Vector((p2 - p1).x, (p2 - p1).y);
	Vector v1 = Vector((p3 - p1).x, (p3 - p1).y);
	Vector v2 = Vector((p4 - p1).x, (p4 - p1).y);
	Vector v3 = Vector((p4 - p3).x, (p4 - p3).y);
	Vector v4 = Vector((p1 - p3).x, (p1 - p3).y);
	Vector v5 = Vector((p2 - p3).x, (p2 - p3).y);
	if (check(v0, v1) * check(v0, v2) <= 0 && check(v3, v4) * check(v3, v5) <= 0) return 1;
	return 0;
}

int main() {
	int q;
	cin >> q;
	int x0, y0, x1, y1, x2, y2, x3, y3;
	for (int i = 0; i < q; i++) {
		cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		Segment s1 = Segment(Point(x0, y0), Point(x1, y1));
		Segment s2 = Segment(Point(x2, y2), Point(x3, y3));
		cout << intersect(s1, s2) << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<int, int>> ab(n), a(n), b(n);
    vector<bool> ate(n, false);
    set<int> ae, be;
    int aidx = 0, bidx = 0;
    ll asum = 0, bsum = 0;
    rep(i, n) {
        cin >> ab[i].first >> ab[i].second;
        a[i].first = ab[i].second + ab[i].first;
        b[i].first = ab[i].first + ab[i].second;
        a[i].second = b[i].second = i;
    }
    sort(all(a), greater<pair<int, int>>());
    sort(all(b), greater<pair<int, int>>());
    rep(i, n) {
        if (i % 2 == 0) {
            while(ate[a[aidx].second]) aidx++;
            ate[a[aidx].second] = true;
            ae.insert(a[aidx].second);
        }
        else {
            while(ate[b[bidx].second]) bidx++;
            ate[b[bidx].second] = true;
            be.insert(b[bidx].second);
        }
    }
    for (auto x : ae) {
        asum += ab[x].first;
    }
    for (auto x : be) {
        bsum += ab[x].second;
    }
    cout << (asum - bsum) << endl;
    return 0;
}

Measured memory_bytes: 7296
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int N, ans = 0;
	cin >> N;
	vector<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];
	}
	for (int i = 0; i < N; i++){
		
		ans += B[A[i]];
		if ((A[i] == (A[i-1]+1))&&i>0){
			ans += C[A[i-1]];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    ans = 0

    fac = 2
    e = 1
    while pow(fac, 2) <= n:
        while n % (div := pow(fac, e)) == 0:
            n //= div
            ans += 1
            e += 1

        while n % fac == 0:
            n //= fac

        e = 1
        fac += 1

    if n != 1:
        ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
#include<bits/stdc++.h>
#pragma optimizer(O2)
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
//#define MXN 300000
#define N 100005
vector<int> v[2005];
int dfs(int x,int f,int k){
    if(k==0)return 1;
    int res=1;
    for(auto it:v[x]){
        if(it!=f){
            res=res+dfs(it,x,k-1);
        }
    }
    return res;
}
int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    pii p[2005];
    for(int i = 1;i<n;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        v[x].pb(y);
        v[y].pb(x);
        p[i]=mp(x,y);
    }
    if(k&1){
        int ans=0;
        for(int i = 1;i<n;i++){
            ans=max(ans,dfs(p[i].x,p[i].y,k/2)+dfs(p[i].y,p[i].x,k/2));
        }
        printf("%d\n",n-ans);
    }
    else{
        int ans=0;
        for(int i = 1;i<=n;i++){
           ans=max(ans,dfs(i,0,k/2));
        }
        printf("%d\n",n-ans);
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll mod = 1'000'000'007;
// constexpr int max_n = 200'000 + 5;

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    int n;
  cin >> n;
    ll res = 0;
    rep(i, n+1) {
        if (i % 3 != 0 && i % 5 != 0) {
            res += i;
        }
    }
    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T, std::size_t N>
struct make_vector_type {
	using type =
		typename std::vector<typename make_vector_type<T, (N - 1)>::type>;
};

template <typename T>
struct make_vector_type<T, 0> {
	using type = typename std::vector<T>;
};

template <typename T, size_t N>
auto make_vector_impl(const std::vector<std::size_t>& ls, T init_value) {
	if constexpr(N == 0) {
		return std::vector<T>(ls[N], init_value);
	} else {
		return typename make_vector_type<T, N>::type(
			ls[N], make_vector_impl<T, (N - 1)>(ls, init_value));
	}
}

template <typename T, std::size_t N>
auto make_vector(const std::size_t (&ls)[N], T init_value) {
	std::vector<std::size_t> dimensions(N);
	for(int i = 0; i < N; i++) {
		dimensions[N - i - 1] = ls[i];
	}
	return make_vector_impl<T, N - 1>(dimensions, init_value);
}

template <typename T>
std::vector<T> make_vector(std::size_t size, T init_value) {
	return std::vector<T>(size, init_value);
}

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	ll x, k, d;
	cin >> x >> k >> d;

	x = abs(x);
	ll l = x / d;

	if(k > l) {
		if((k - l) % 2 == 0) {
			cout << abs(x - (l * d)) << endl;
		} else {
			cout << abs(x - ((l + 1) * d)) << endl;
		}
	} else {
		cout << abs(x - (k * d)) << endl;
	}
	return 0;
}

Measured memory_bytes: 3596
#[allow(unused_imports)]
use std::cmp;

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

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

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

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

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

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

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

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

fn eratosthenes(n: i64) -> Vec<i64> {
  let mut primes = vec![];
  for i in 2 .. n + 1 {
    let mut is_prime = true;
    for &p in &primes {
      if p * p > i {
        break;
      }
      if i % p == 0 {
        is_prime = false;
        break;
      }
    }
    if is_prime {
      primes.push(i);
    }
  }
  primes
}

fn count_prime(mut n: i64, p: i64) -> i64 {
  let mut exp = 0;
  while n % p == 0 {
    exp += 1;
    n /= p;
  }
  exp
}

fn count_prime_all(n: i64, p: i64) -> i64 {
  (1..n+1).map(|x| count_prime(x, p)).sum()
}

fn main() {
  input! {
    n: i64,
  }
  let primes = eratosthenes(n);
  let prime_count = primes.iter().map(|p| count_prime_all(n, *p)).collect::<Vec<_>>();
  let c74 = prime_count.iter().filter(|&c| *c >= 74).count();
  let c24 = prime_count.iter().filter(|&c| *c >= 24).count();
  let c14 = prime_count.iter().filter(|&c| *c >= 14).count();
  let c4 = prime_count.iter().filter(|&c| *c >= 4).count();
  let c2 = prime_count.iter().filter(|&c| *c >= 2).count();
  let ans = c74 +
            c24 * (c2 - 1) +
            c14 * (c4 - 1) +
            c4 * (c4 - 1) * (c2 - 2) / 2;

  println!("{}", ans);
}


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

using namespace std;

int Top(int j, vector<int> &H) //j番目までの最大値を求める
{ int max_height = 0;
  for(int k = 0; k < j ; k++)//j番目はo-indexedでj-1だからk=j-1まで調べればいい
{ max_height = max (max_height, H[k]);}
 return max_height;
}

int main()
{ int N; vector<int> H(N);
 cin >> N;
 for(int l = 0; l < N; l++)
 {cin >> H[l];}
 
 int cnt = 0;
 
 for(int i = 1; i < N; i++)
 {
   if(Top(i,H) <= H[i]){cnt++;}}
 //cnt に、０番目（無条件）も考慮する
 
 cout << cnt+1 <<endl;
 
 return 0;
}


Measured memory_bytes: 16640
//#include<bits/stdc++.h>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <cassert>
#include <cstdint>
#include <map>
using namespace std;

#define rep(i, j) for (int i = 0; i < (int)j; i++)
#define repeat(i, j, k) for (int i = (j); i < (k); i++)
#define all(v) begin(v), end(v)

const int INF = 1 << 30;  // 10E10

//????????????
int rec(map<char, int>::iterator itr, map<char, int>::iterator end, const set<char> &tops, vector<bool> &used, int sum) {
    if(itr == end) return sum == 0;
    char c = itr->first;
    int weight = itr->second;
    itr++;
    int ret = 0;
    rep(i, 10) {
        if(used[i]) continue;
        if(i == 0 and tops.count(c)) continue;
        used[i] = true;
        ret += rec(itr, end, tops, used, sum + weight * i);        
        used[i] = false;
    }
    return ret;
}

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;

        map<char, int> coefficient;
        set<char> tops;

        rep(i, n) {
            string s;
            cin >> s;
            if(s.size() > 1) tops.insert(s.front());
            
            for(int j = s.size() - 1, k = 1; j >= 0; j--, k *= 10) {
                coefficient[s[j]] += k * (i != n - 1 ? 1 : -1);
            }
        }
        vector<bool> used(10);
        int ans = rec(coefficient.begin(), coefficient.end(), tops, used, 0);

        cout << ans << endl;
    }
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int k,s;
    cin>>k>>s;
  int aiyan=0;
    for (int x=0; x<=k; x++){
        for (int y=0; y<=k; y++){
      
            if(s-x-y>=0&&s-x-y<=k)
            aiyan+=1;
          }
        }
    
  cout<<aiyan<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void puts_all(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void puts_all(const T &value, const Args&... args){std::cout << value << " ";puts_all(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int N, K; cin >> N >> K;
  vector<LLI> a(N); cin >> a;

  LLI ans = LLONG_MAX;

  REP(i,1<<N){
    if(popcount(i) < K) continue;

    LLI cost = 0;

    LLI m = 0;

    REP(j,N){
      if(i & bit(j)){
        LLI d = max(0LL, m - a[j] + 1);
        cost += d;
        chmax(m, a[j] + d);
      }
      chmax(m, a[j]);
    }

    chmin(ans, cost);
  }

  puts_all(ans);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define TRACE
#ifdef TRACE
#define tr(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define tr(...)
#endif

#define ll long long
#define ld long double 
#define endl "\n"
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (ll)(a.size())
#define all(a) a.begin(), a.end() 
#define fr(i,n) for(i=1;i<=n;++i)
#define rp(i,n) for(i=0;i<n;++i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());      // Remove _64 for 32 bit random nos.

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// use pair if duplicates are there 
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the pointer to kth element.(0-based)
typedef pair<ll, ll> ii;
typedef vector<ll> vl;
typedef vector<ii> vii;
const ll N = 200010;
ll mod=1e9+7;

ll ffmod(ll x, ll y, ll mod)
{
    ll rt=1;
    while(y)
    {
        if(y&1ll) rt=(rt*x)%mod;
        x=(x*x)%mod, y/=2ll;
    }
    return rt;
}

ll a[N], b[N], x[N], y[N], c[N];

int main()
{
    FIO;
    ll n, m, i, t, mn1=1e18, mn2=1e18, mn;
    cin>>n>>m>>t;
    fr(i,n) cin>>a[i], mn1=min(mn1, a[i]);
    fr(i,m) cin>>b[i], mn2=min(mn2, b[i]);
    fr(i,t) cin>>x[i]>>y[i]>>c[i];
    mn=mn1+mn2;
    fr(i,t) mn=min(mn, a[x[i]]+b[y[i]]-c[i]);
    cout<<mn<<endl; 
    return 0;
}


Measured memory_bytes: 6400
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, a, b, c, x;
    while (cin >> n >> a >> b >> c >> x && n){
        VI y(n);
        REP(i,n) cin >> y[i];
        int j = 0, f = 1;
        REP(i,10001){
            if (x == y[j]) j++;
            if (j == n){
                cout << i << endl;
                f = 0;
                break;
            }
            x = (a * x + b) % c;
        }
        if (f) cout << -1 << endl;
    }
    return 0;
}

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

struct Card { char suit, value;};

void bubble(struct Card A[], int N) {
	for ( int i = 0; i < N; i++) {
		for ( int j = N-1; j >= i + 1; j--){
			if ( A[j].value < A[j - 1].value){
				Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
			}
		}
	}
} 

void selection(struct Card A[], int N){
	for ( int i = 0; i < N; i++ ) {
		int minj = i;
		for ( int j = i; j < N; j++){
			if (A[j].value < A[minj].value ) minj = j;
		}
		Card t = A[i]; A[i] = A[minj]; A[minj] = t;
	}
}

void print(struct Card A[], int N){
	for (int i = 0; i < N; i++){
		if ( i > 0 ) cout << " ";
		cout << A[i].suit << A[i].value;
	}
	cout << endl;
}

//比较冒泡排序和选择排序的结果
bool isStable(struct Card C1[], struct Card C2[], int N) {
	for ( int i = 0; i < N; i++) {
		if ( C1[i].suit != C2[i].suit ) return false;
	}
	return true;
} 

int main(){
	Card C1[100], C2[100];
	int N;
	char ch;
	
	cin >> N;
	for ( int i = 0; i < N; i++){
		cin >> C1[i].suit >> C1[i].value;
	}
	
	for ( int i = 0; i < N; i++) C2[i] = C1[i];
	
	bubble(C1, N);
	selection(C2, N);
	
	print(C1, N);
	cout << "Stable" << endl;
	print (C2, N);
	if ( isStable(C1, C2, N) ) {
		cout << "Stable" << endl;
	} else {
		cout << "Not stable" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3112
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var nums = InputNumList();
            int cnt = 0;
            var h = new HashSet<int>();
            foreach (var num in nums)
            {
                if (h.Add(num)) cnt++;
            }
            WriteLine(cnt);
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}



Measured memory_bytes: 13268
#include <stdio.h>

int GCD(int a,int b){
	int c=1;
	while(c){
		c=a%b;
		a=b;
		b=c;
	}
	return a;
}

main(){
	int a,b,Gcd,k;
	while(scanf("%d%d",&a,&b)!=EOF){
		if(a<b){
			k=a;
			a=b;
			b=k;
		}
		Gcd=GCD(a,b);
		k=a*(b/Gcd);
		printf("%d %d\n",Gcd,k);
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
string str;
int ans=1000;
int n;
int main()
{
  cin>>str;
  n=str.length();
  int ck=0;
  for (int i=1;i<n;i++)
  {
    if (str[i-1]!=str[i]) ck=1;
  }
  if (ck==0)
  {
    printf("0\n");
    return 0;
  }
  for (char w='a';w<='z';w++)
  {
    string c=str;
    for (int i=1;i<=n;i++)
    {
      int tmp=0;
      for (int j=0;j<n-i;j++)
      {
        if (c[j]==w||c[j+1]==w)
        {
          c[j]=w;
        }else{
          tmp=1;
        }
      }
      if (tmp==0)
      {
        ans=min(ans,i);
        break;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
/*
 * atcoder/abc134_2nd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * すべて1だとすると
 *                   10の倍数の箱に入っている数の偶奇
 * 1 2 3 4 5 6 7 8 9 10
 * 1 0 1 0 0 1 1 1 1 1
 *
 * 後ろから決めていけば必ず作れそう
 *
 * 作れるが、O(N^2)になりそう.
 * 後ろから約数分解してそれに+1していけばO(sqrt(N)NlogN)になりそう
 * いや、よく考えるとO(NlogN)だ.
 */
int N;
vector<int> A, B;
vector<int> C;
void solve() {
  cin >> N;
  A.resize(N+1);
  B.assign(N+1, 0);
  loop(n,1,N+1) cin >> A[n];
  for (int i=N; i>=1; i--) {
    int num1 = 0;
    for (int j=i*2; j<=N; j += i) num1 += B[j];
    if (A[i] == num1%2) B[i] = 0;
    else {
      B[i] = 1;
      C.push_back(i);
    }
  }
  sort(C.begin(), C.end());
  cout << C.size() << endl;
  for (auto&&c: C) cout << c << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+50,inf=1e9;
int gi(){
    char ch=getchar(); int x=0,q=0;
    while(ch<'0'||ch>'9') q=ch=='-'?1:q,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return q?-x:x;
}
int a[N];
int main(){
    int n=gi(),mn=inf,mx=-inf;
    for (int i=1; i<=n; ++i)
	a[i]=gi(),mn=min(mn,a[i]),mx=max(mx,a[i]);
    int flag=0;
    if (mx==mn){
	if (mx==n-1) flag=1;
	else if (mx*2<=n) flag=1;
    }
    else if (mx==mn+1){
	int s=0;
	for (int i=1; i<=n; ++i)
	    if (a[i]==mn)
		++s;
	if (s<mx&&2*(mx-s)<=n-s) flag=1;
    }
    puts(flag?"Yes":"No");
    return 0;
}


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

int main(void){
  int a,b,j=0; cin>>a>>b;
  rep(i,100){
   if((a-1)*i+1>=b){
     j=i;
     break;
     
   }
  }
	cout<<j<<endl;
}

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

int main() {
	string X, Y;
	cin >> X >> Y;
	
	map<string, int> hex;
	hex["A"] = 10; hex["B"] = 11; hex["C"] = 12;
	hex["D"] = 13; hex["E"] = 14; hex["F"] = 15;
	
	char c;
	if(hex[X] == hex[Y]) c = '=';
	else if(hex[X] > hex[Y]) c= '>';
	else if(hex[X] < hex[Y]) c = '<';
	
	cout << c;
	cout << endl;
	
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  bool check = false;
  int ans = 0;
  for (int x = 1; x <= N; x++) {
    int pre = x*1.08;
    if (pre == N) {
      check = true;
      ans = x;
      break;
    }
  }
  if (check) {
    cout << ans << endl;
  }
  else {
    cout << ":(" << endl;
  }
}

    
      


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<vector<int>> a(2,vector<int>(n));
	rep(i,2)rep(j,n) cin>>a[i][j];
	int ans=0;
	rep(i,n){
		int now=0;
		rep(j,i+1) now+=a[0][j];
		FOR(j,i,n) now+=a[1][j];
		chmax(ans,now);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll a, b;
    char op;
    cin >> a >> op >> b;
    if(op == '+'){
        cout << a + b << endl;
    }else{
        cout << a - b << endl;
    }
    return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;
  ll res, q = 8 * Q, h = 4 * H, s = 2 * S;
  if (min({q, h, s, D}) == D && N >= 2)
    res = D * (N / 2) + (N % 2) * min({q / 2, h / 2, s / 2});
  else
    res = N * min({q / 2, h / 2, s / 2});
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC optimize("tree-vectorize")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using int64 = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

void fastin(int64 &num) {
  bool negative = false;
  int64 c;
  num = 0;
  c = getchar_unlocked();
  if (c == '-') {
    negative = true;
    c = getchar_unlocked();
  }
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
  if (negative) num *= -1;
}

void fastout(int64 &n) {
  int64 N = n, rev, count = 0;
  rev = N;
  if (N == 0) { 
    putchar_unlocked('0');
    putchar_unlocked('\n');
    return;
  }
  while ((rev % 10) == 0) { 
    ++count; rev /= 10;
  }
  rev = 0;
  while (N != 0) { 
    rev = (rev << 3) + (rev << 1) + N % 10;
    N /= 10;
  }
  while (rev != 0) { 
    putchar_unlocked(rev % 10 + '0');
    rev /= 10;
  }
  while (count--) putchar_unlocked('0');
  putchar_unlocked('\n');
}

int main(){
    int64 n, m; fastin(n); fastin(m);
    int64 x[m];
    rep(i, m) fastin(x[i]);

    sort(x, x + m);

    int64 diff[m - 1];
    rep(i, m - 1){
        diff[i] = x[i + 1] - x[i];
    }

    sort(diff, diff + m - 1);

    int64 ans = 0;
    int range = m - n;
    for (int i = 0; i < range; ++i){
        ans += diff[i];
    }

    fastout(ans);
    
    return 0;
}


Measured memory_bytes: 1792
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>

#define INF (1LL << 60)

using namespace std;

int main()
{
    int V, E, X, A, B, C;

    scanf("%d", &V);
    scanf("%d", &E);
    scanf("%d", &X);

    vector<long long> R(V);

    vector<vector<pair<int, long long> > > G(V);
 
    for (int i = 0; i < V; i++)
    {
        scanf("%lld", &R[i]);
    }

    for (int i = 0; i < E; i++)
    {
        scanf("%d", &A);
        scanf("%d", &B);
        scanf("%d", &C);

        G[A - 1].push_back(make_pair(B - 1, C));
        G[B - 1].push_back(make_pair(A - 1, C));
    }

    vector<long long> D(V, INF); D[0] = 0;
    vector<long long> F(V, INF); F[0] = X;

    queue<int> que; que.push(0); // node

    while (!que.empty())
    {
        int node = que.front(); que.pop();

        int high = F[node];

        for (int i = 0; i < G[node].size(); i++)
        {
            int went = G[node][i].first;
            int cost = G[node][i].second;

            if (R[node] >= cost)
            {
                if (high - cost <= 0)
                {
                    long long t = D[node] + (cost - high) + cost; // high --> cost --> 0 meters

                    if (t < D[went])
                    {
                        D[went] = t;
                        F[went] = 0;

                        que.push(went);
                    }
                }
                else if(high - cost <= R[went])
                {
                    long long t = D[node] + cost; // high --> high --> (high - cost) meters

                    if (t < D[went])
                    {
                        D[went] = t;
                        F[went] = high - cost;

                        que.push(went);
                    }
                }
                else
                {
                    long long t = D[node] + high - R[went]; // high --> (R[went] + cost) --> R[went] meters

                    if (t < D[went])
                    {
                        D[went] = t;
                        F[went] = R[went];

                        que.push(went);
                    }
                }
            }
        }
    }

    printf("%lld\n", D[V - 1] != INF ? D[V - 1] + R[V - 1] - F[V - 1] : -1);

    return 0;
}

Measured memory_bytes: 23408
def main():
  s = input()

  ans = ""

  for c in s:
    if(c == "0"):
      ans += "0"
    elif(c == "1"):
      ans += "1"
    elif(c == "B"):
      if(ans != ""):
        ans = ans[0:len(ans) - 1]

  print(ans)

if __name__ == "__main__":
    main()

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

int main(){
  string n;
  cin >> n;
  if((n[0]==n[1] && n[1]==n[2])||(n[1]==n[2] && n[2]==n[3])) cout << "Yes" << endl;
  else cout << "No" << endl;
    
  
  return 0;

}


Measured memory_bytes: 256
N, M = map(int, input().split())

ans = []
diff = M
now = 1
while diff >= 1:
  ans.append([now, now+diff])
  diff -= 2
  now += 1

diff = M-1
now = N
while diff >= 1:
  ans.append([now-diff, now])
  diff -= 2
  now -= 1

for a in ans:
  print(*a)

Measured memory_bytes: 22608
S = list(input().replace("BC", "D"))
l = []
ans = 0
a_cnt = 1
d_cnt = 1
for i in range(len(S)-1):
    if (S[i] == "A" and S[i + 1] == "D"):
        ans += a_cnt
        S[i] = "D"
        S[i + 1] = "A"
    else:
        if(S[i] == "A" and S[i+1] == "A"):
            a_cnt += 1
        else:
            a_cnt = 1

print(ans)


Measured memory_bytes: 4840
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		long[] A = new long[N];
		for(int i = 0;i < N;i++) {
			A[i] = scn.nextLong();
		}
		Arrays.sort(A);
		int ans = 0;
		int count = 0;
		long buf = 0;
		for(int i = 0;i < N;i++) {
			if(buf == A[i]) {
				count++;
			}else {
				if(count%2==1 && count!=0) {
					ans++;
				}
				count = 1;
				buf = A[i];
			}
		}
		if(count%2==1) {
			ans++;
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 51724
# N=総数、A=青、B=赤
N, A, B = map(int, input().split())

# A+Bの商
n = N // (A+B)
# A+Bのあまり
r = N % (A+B)

# A+BのあまりがAより大きい場合は、Aとする
if(r > A):
    b_r = A
else:
    b_r = r

# 青の個数 = 商*A + あまり(0~A)
blue = n * A + b_r

print(blue)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define nl cout<<"\n"
#define pb push_back
#define se second
#define fi first
#define pi =3.14159265358979323846264338327950L;
typedef long long int ll;


int main(){
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
	int n;
	cin>>n;
	int ar[n];
	for(int i=0;i<n;i++) cin>>ar[i];
	vector<int> dp(n,INT_MAX);
	dp[0]=0;
	dp[1]=abs(ar[1]-ar[0]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i],abs(ar[i]-ar[i-1])+dp[i-1]);
		dp[i]=min(dp[i],abs(ar[i]-ar[i-2])+dp[i-2]);
	}
	cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
long long x1[100];
long long x2[100];
long long y1[100];
long long y2[100],dist,cnt,n,m;
long long mn=INT_MAX;
cin>>n>>m;
for(int i=0;i<n;i++)
cin>>x1[i]>>y1[i];
for(int i=0;i<m;i++)
cin>>x2[i]>>y2[i];
for(int i=0;i<n;i++){
    for(int j=0;j<m;j++)
        {
            dist=abs(x1[i]-x2[j])+abs(y1[i]-y2[j]);
            if(dist<mn){
                mn=dist;
                cnt=j+1;
                }
        }
        mn=INT_MAX;
        cout<<cnt<<"\n";
}
}


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

using namespace std;

#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i=(a); i<(n); i++)

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    
    vector<long> a, b, c;
    rep(_, x) { long tmp; cin >> tmp; a.push_back(tmp); }
    rep(_, y) { long tmp; cin >> tmp; b.push_back(tmp); }
    rep(_, z) { long tmp; cin >> tmp; c.push_back(tmp); }
    
    sort(a.begin(), a.end(), greater<long>());
    sort(b.begin(), b.end(), greater<long>());
    sort(c.begin(), c.end(), greater<long>());
    
    vector<long> ab;
    rep(i, x) rep(j, y) ab.push_back(a[i] + b[j]);
    sort(ab.begin(), ab.end(), greater<long>());
    
    vector<long> ans;
    rep(i, min(k, x*y)) rep(j, min(k, z)) ans.push_back(ab[i] + c[j]);
    sort(ans.begin(), ans.end(), greater<long>());
    
    rep(i, k) cout << ans[i] << endl;
}

Measured memory_bytes: 43384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define F first
#define S second
#define ld long double
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int h,w; cin >> h >> w;
    vstr s(h);
    rep(i,h) cin>>s[i];
    vvint dist(h,vint(w,-1));
    dist[0][0]=0;
    queue<P> que;
    que.push(MP(0,0));
    while(!que.empty()){
        int y=que.front().F;
        int x=que.front().S;
        que.pop();
        rep(i,4){
            int ny=y+dy[i];
            int nx=x+dx[i];
            if(ny<0||ny>=h||nx<0||nx>=w||s[ny][nx]=='#') continue;
            if(dist[ny][nx]!=-1) continue;
            dist[ny][nx]=dist[y][x]+1;
            que.push(MP(ny,nx));
        }
    }
    int white=0;

    rep(i,h)rep(j,w)if(s[i][j]=='.') white++;
    if(dist[h-1][w-1]==-1) cout<<-1<<endl;
    else cout<<white-dist[h-1][w-1]-1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

//int n;
//int a[100100];
//int dp[100100];
////dp[i]:?????????a[i]????????£????????????????¢??????¨???????????????
//
//int main() {
//	cin >> n;
//	for (int i = 0; i < n; i++) {
//		cin >> a[i];
//		dp[i] = 1;
//	}
//	for (int i = 0; i < n; i++) {
//		for (int j = 0; j < i; j++) {
//			if (a[j] < a[i]) {
//				dp[i] = max(dp[i], dp[j] + 1);
//			}
//		}
//	}
//	int ans = 0;
//	for (int i = 0; i < n; i++) {
//		ans = max(ans, dp[i]);
//	}
//	cout << ans << endl;
//}

const int inf = 1001000000;
int n;
int a[100100];
int dp[100100];
//dp[i]:???????¢??????¨?????????i???????????°??????????°????

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		dp[i] =inf;
	}
	for (int i = 0; i < n; i++) {
		auto it = lower_bound(dp, dp + n, a[i]);
		*it = a[i];
	}
	int ans = lower_bound(dp, dp + n, inf) - dp;
	cout << ans << endl;
}

Measured memory_bytes: 3876
n=int(input())
s=list(input())
a=[0]*n
new=[]
for i in range(n):
	if i==n-1:
		a[n-1]=1
		break
	if s[i]==s[i+1]:
		a[i]=0
	else:
		a[i]=1

for i in range(n):
	if a[i]==1:
		new.append(s[i])	
			

print(len(new))

Measured memory_bytes: 5420
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <stack>
#include <list>
using namespace std;


int main()
{

	int n;
	string a;
	int b;
	list<int>L;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a[0] == 'i') {
			cin >> b;
			L.push_front(b);
			continue;
		}
		else if (a[0] == 'd') {
			if (a.length() > 6) {
				if (a[6] == 'F')
					L.pop_front();
				else if (a[6] == 'L')
					L.pop_back();
			}
			else {
				cin >> b;
				for (list<int>::iterator it = L.begin(); it != L.end(); it++) {
					if (*it == b) {
						L.erase(it);
						break;
					}
				}
			}
		}
	}
	int j = 0;
	for (list<int>::iterator it = L.begin(); it != L.end(); it++) {
		if (j++)
			cout << " ";
		cout << *it;
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 34264
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int k,i;
		int count = 0;
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.nextLine());
		int array[] = new int[n];
		for(i=0;i<n;i++)array[i] = Integer.parseInt(in.next());
		for (k=0;k<n;k++){
			if (isprime(array[k])){
				count++;
		}
	}
		System.out.println(count);
}

	public static boolean isprime(int x) {
		int i = 3;
		if (x == 2)
				return true;
		if (x < 2 || x % 2 == 0 )
				return false;
		while (i <= Math.sqrt(x)){
			if (x % i == 0){
				return false;
			}
			i = i+2;
		}
		return true;
	}
}

Measured memory_bytes: 40988
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;




int main() 
{

 fast();
  
  // #ifndef ONLINE_JUDGE
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt","w",stdout);
  // #endif
  ll a;
  cin>>a;
  vector<pa>q;
  ll x,y;
  f(i,0,a)
  {
    cin>>x>>y;
    q.pb({y,x});
  }
  sort(all(q));
  ll c=0;
  f(i,0,a)
  {
    c+=q[i].S;
    if(c<=q[i].F)
      continue;
    else
    {
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
  


  


    




    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

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

long long mod = 1e9 + 7;

long long pow(long long a, long long x){
    if(x == 0){
        return 1;
    }
    a %= mod;
    return pow(a * a % mod, x / 2) * ((x % 2) ? a : 1) % mod;
}

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    K--;

    long long row[9] = {};
    for(int w = 0; w <= 8; w++){
        for(int i = 0; i < (1 << w); i++){
            bool ok = true;
            for(int bit = 0; bit < w - 1; bit++){
                if((i & (1 << bit)) && (i & (1 << (bit + 1)))){
                    ok = false;
                }
            }
            if(ok){
                row[w]++;
            }
        }
        row[w] %= mod;
    }

    
    long long dp[101][8] = {};
    dp[0][0] = 1;
    for(int h = 1; h <= H; h++){
        for(int w = 0; w < W; w++){
            if(w > 0){
                long long left = 1;
                if(w > 2){
                    left = row[w - 2];
                }
                long long right = 1;
                if(w <= W - 3){
                    right = row[W - w - 2];
                }
                dp[h][w] += dp[h-1][w-1] * left % mod * right % mod;
                dp[h][w] %= mod;
            }
            if(w < W - 1){
                long long left = 1, right = 1;
                if(w >= 1){
                    left = row[w - 1];
                }
                if(w <= W - 3){
                    right = row[W - w - 3];
                }
                dp[h][w] += dp[h-1][w+1] * left % mod * right % mod;
                dp[h][w] %= mod;
            }
            long long left = 1, right = 1;
            if(w >= 1){
                left = row[w - 1];
            }
            if(w <= W - 2){
                right = row[W - w - 2];
            }
            dp[h][w] += dp[h-1][w] * left % mod * right % mod;
            dp[h][w] %= mod;
        }
    }
    cout << dp[H][K] << endl;
}


Measured memory_bytes: 256