akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int v[100002];
int n, maxx, sol;

int main()
{
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    maxx = max(maxx, v[i]);
  }
  int p = 1;
  while (v[p] != maxx)
    p++;
  v[p] = -1;
  int nr1, nr2;
  if (maxx & 1)
    nr1 = maxx / 2, nr2 = maxx / 2 + 1;
  else
    nr1 = nr2 = maxx / 2;
  int dist = maxx + 2;
  for (int i = 1; i <= n; i++) {
    if (v[i] != -1) {
      int t = min(abs(v[i] - nr1), abs(v[i] - nr2));
      if (dist > t) {
        dist = t;
        sol = v[i];
      }
    }
  }
  cout << maxx << " " << sol;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include<vector>
using namespace std;
int main(void){
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> a(n);
    
    for(int i = 0;i < q;i++){
        int t;
        cin >> t;
        t--;
        a[t]++;
    }
    
    for(int i = 0;i < n;i++){
        if(k + a[i] - q > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
using pii = pair<int,int>;

int M = 1000*1000*1000+7;
int result[2001];

int f(int s){
    if(s<3)
        return 0;
    else if (s<6)
        return 1;
    else {
        if(result[s])
            return result[s];
        long long sum = 0;
        for(int i=3;i<=s-3;i++){
            sum += f(s-i);
            sum%=M;
        }
        sum++;
        sum%=M;
        result[s] = sum;
        return sum;
    }
}

int main(int argc, const char** argv) {
    int s;
    cin>>s;
    cout<<f(s);
    
    return 0;
}

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

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

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

    ll N ;
    cin >> N;
    vector<ll> p(N) ;
    rep(i, N) cin >> p[i];
    
    ll ans = 0 ;
    for(ll i = 1; i < N-1; i++){
        if(p[i-1] < p[i] && p[i] < p[i+1] ) ans ++;
        if(p[i-1] > p[i] && p[i] > p[i+1] ) ans ++;
    }
    cout << ans << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

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

    int n;
    cin >> n;

    vector<int> vec(n);

    for(int i = 0; i < n; i++){
        cin >> vec[i];
    }

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

    vector<int> count;

    int c = 1;
    int t = vec[0];
    for(int i = 1; i < n; i++){
        if(t == vec[i]){
            c++;
        }else{
            count.push_back(c);
            c = 1;
            t = vec[i];
        }
    }

    count.push_back(c);

    int i = 0;
    int j = count.size() - 1;

    while(i < j){
        while(count[i] <= 1 && i < n){
            i++;
        }

        while(count[j] <= 1 && j >= 0){
            j--;
        }
        if(i < j){
            count[i]--;
            count[j]--;
        }
    }

    if(i == j){
        if(count[j] > 0){
            if(count[j] % 2 == 1){
                count[j] = 1;
            }else{
                count[j] = 0;
            }
        }
    }

    int result = 0;

    for(int l = 0; l < count.size(); l++){
        if(count[l] == 1){
            result++;
        }
    }

    cout << result << endl;
    
    return 0;
}

Measured memory_bytes: 1276
def f(n)
    n.even? ? n/2 : 3*n+1
end
 
s = gets.to_i
if s == 1 or s == 2
    puts 4
    exit
end
 
count = 0
val = s
while val != 4
    val = f(val)
    count += 1
end
 
puts count+4

Measured memory_bytes: 1788
#include <iostream>
#include <queue>
#include <map>
using namespace std;

class Point2{
public:
  int tx;
  int ty;
  int kx;
  int ky;
};

int mk(Point2 p)
{
  return (((p.tx-1)*50+(p.ty-1))*50+(p.kx-1))*50+(p.ky-1);
}

int main()
{
  while(true){
    int W, H;
    cin >> W >> H;

    if(W==0 && H==0)
      break;

    Point2 p;
    cin >> p.tx >> p.ty;
    cin >> p.kx >> p.ky;

    int d[52][52];
    for(int y=0; y<=H+1; y++){
      for(int x=0; x<=W+1; x++){
	d[y][x] = 1;
      }
    }

    for(int y=1; y<=H; y++){
      for(int x=1; x<=W; x++){
	cin >> d[y][x];
      }
    }

    queue<Point2> que;
    que.push(p);

    map<int, int> n;
    n[mk(p)] = 0;

    while(true){
      if(que.empty()){
	cout << "NA" << endl;
	break;
      }

      p = que.front(); que.pop();

      if(n[mk(p)]>=100){
	cout << "NA" << endl;
	break;
      }

      if(p.tx==p.kx && p.ty==p.ky){
	cout << n[mk(p)] << endl;
	break;
      }

      Point2 q;

      //東
      q = p;
      if(d[q.ty][q.tx+1]==0){
	q.tx = q.tx+1;
      }
      if(d[q.ky][q.kx-1]==0){
	q.kx = q.kx-1;
      }
      if(n.find(mk(q))==n.end()){
	que.push(q);
	n[mk(q)] = n[mk(p)]+1;
      }

      //西
      q = p;
      if(d[q.ty][q.tx-1]==0){
	q.tx = q.tx-1;
      }
      if(d[q.ky][q.kx+1]==0){
	q.kx = q.kx+1;
      }
      if(n.find(mk(q))==n.end()){
	que.push(q);
	n[mk(q)] = n[mk(p)]+1;
      }

      //南
      q = p;
      if(d[q.ty+1][q.tx]==0){
	q.ty = q.ty+1;
      }
      if(d[q.ky-1][q.kx]==0){
	q.ky = q.ky-1;
      }
      if(n.find(mk(q))==n.end()){
	que.push(q);
	n[mk(q)] = n[mk(p)]+1;
      }

      //北
      q = p;
      if(d[q.ty-1][q.tx]==0){
	q.ty = q.ty-1;
      }
      if(d[q.ky+1][q.kx]==0){
	q.ky = q.ky+1;
      }
      if(n.find(mk(q))==n.end()){
	que.push(q);
	n[mk(q)] = n[mk(p)]+1;
      }
    }
  }

  return 0;
}

    



Measured memory_bytes: 11460
//***Little by little one travels far***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main()
{
 ll a,b,c;
 cin>>a>>b>>c;

 if((a+b+c)>=22) cout<<"bust";
 else cout<<"win";
}

Measured memory_bytes: 256
/*input
7 4 4
1 2
2 3
2 5
6 7
3 5
4 5
3 4
6 7
*/

#include <iostream>
#include <vector>
#include <numeric>
#include <map>

using namespace std;

class UnionFind{
private:
	vector<int> group;
	vector<int> size;
public:
	UnionFind(int N);
	int get(int n);
	void merge(int a, int b);
};

UnionFind::UnionFind(int N){
	group.resize(N);
	iota(group.begin(), group.end(), 0);
	size.resize(N);
	fill(size.begin(), size.end(), 1);
}

int UnionFind::get(int n){
	if(n == group[n]) return n;
	int g = group[n];
	group[n] = get(g);
	return group[n];
}

void UnionFind::merge(int a, int b){
	if(group[a] == group[b]) return;
	a = get(a);
	b = get(b);
	if(size[a] < size[b]) swap(a,b);
	group[b] = a;
	size[a] += size[b];
}

int main()
{

	int N, K, L;
	cin >> N >> K >> L;

	UnionFind road_group(N);
	for(int k=0;k<K;k++){
		int p,q;
		cin >> p >> q;
		road_group.merge(p-1,q-1);
	}

	UnionFind rail_group(N);
	for(int l=0;l<L;l++){
		int r,s;
		cin >> r >> s;
		rail_group.merge(r-1,s-1);
	}

	// for(int n=0;n<N;n++){
	// 	cout << "road:" << road_group.get(n) <<
	// 			" rail:" << rail_group.get(n) << endl;
	// }

	map<pair<int, int>, int> pair_array;
	for(int n=0;n<N;n++){
		pair_array[make_pair(road_group.get(n), rail_group.get(n))]++;
	}

	// show result
	for(int n=0;n<N;n++){
		int c = pair_array[make_pair(road_group.get(n), rail_group.get(n))];
		cout << c;
		if(n != N-1) cout << " ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 15104
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (int)(n); ++i)
#define repk(i,k, n) for (ll i = k; i < (int)(n); ++i)
#define MAX 5000010
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll sum,cnt;
ll N;


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

	rep(i, s.size()) {
		//cout <<"s[i]: " <<s[i] << endl;
		rep(j, N) {
			if (s[i] == 'Z') {
				s[i] = 'A';
			}
			else {
				//cout << s[i] << endl;
				s[i]++;
			}
		}
	}


	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int h,w,m;
  cin >> h >> w >> m;
  int cnt[w];
  rep(i,w)cnt[i]=0;
  int cn[h];
  rep(i,h)cn[i]=0;
  vector<set<int>> k(h);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    cnt[b]++;
    cn[a]++;
    k[a].insert(b);
  }
  int ans=0;
  vector<pair<int,int>> p(w);
  rep(i,w)p[i]=make_pair(-1*cnt[i],i);
  sort(p.begin(),p.end());
  rep(i,h){
    for(pair<int,int> o: p){
      if(k[i].count(o.second)){
        ans=max(ans,cn[i]-o.first-1);
      }
      else{
        ans=max(ans,cn[i]-o.first);
        break;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 35988
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
-- import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace

solve :: Int -> [Int] -> Int
solve n as = sum (map (`div` 2) nums)
  where
  nums = unfoldr f as
    where f [] = Nothing
          f (x:xs) = Just (1 + length ss, ds)
            where (ss, ds) = span (== x) xs

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_n]:remLines1 = remLines0
      n = readBInt bs_n
      line2:remLines2 = remLines1
      as = map readBInt line2
  in solve n as

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents


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

const long long mod = 1e9 + 7;

long long n, k;
long long fact[200001];

long long add_mod (long long x, long long y) {
	return (x + y) % mod;
}

long long mul_mod (long long x, long long y) {
	return (x * y) % mod;
}

long long sub_mod (long long x, long long y) {
	return (x + mod - y) % mod;
}

long long pow_mod (long long x, long long y) {
	long long res = 1LL, t = x;
	while (y) {
		if (y & 1)
			res = mul_mod(res, t);
		t = mul_mod(t, t);
		y >>= 1;
	}
	return res;
}

long long div_mod (long long x, long long y) {
	return mul_mod(x, pow_mod(y, mod - 2));
}

long long c_mod (long long x, long long y) {
	return div_mod(fact[x], mul_mod(fact[x - y], fact[y]));
}

void precalc () {
	fact[0] = 1;
	for (long long i = 1; i <= 200000; ++i)
		fact[i] = mul_mod(fact[i - 1], i);
}

long long ans (long long x, long long y) {
	long long res = 0LL;
	for (long long m = max(x - y, 1LL); m <= x; ++m) 
		res = add_mod(res, mul_mod(c_mod(x, m), c_mod(x - 1, m - 1)));
	return res;
}

signed main () {
	precalc();
	
	cin >> n >> k;
	cout << ans(n, k) << '\n';
}


Measured memory_bytes: 1792
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
	try{
	    double AB, dr;
	    int n = Integer.valueOf(sc.readLine());
	    double[] x = new double[6];
	    for(int i=0; i<n; i++){
		String[] st = sc.readLine().split(" ");
		for(int j=0; j<6; j++)
		    x[j]=Double.valueOf(st[j]);
		AB = Math.sqrt((x[3]-x[0])*(x[3]-x[0])+(x[4]-x[1])*(x[4]-x[1]));
		if(AB<=(x[2]+x[5])){
		    if(AB<x[2]-x[5])
			System.out.println(2);
		    else if(AB<x[5]-x[2])
			System.out.println(-2);
		    else
			System.out.println(1);
		}
		else
		    System.out.println(0);
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

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

int main() {
  double lsum = 0,n;
  cin >> n;
  vector<double>x(n);
  vector<double>y(n);
  for(int i = 0;i < n;i++){
    cin >> x[i] >> y[i];
  }
  for(int i = 0;i < n-1;i++){
    for(int j = i+1;j < n;j++){
      lsum += pow((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]),0.5);
    }
  }
  std::cout << std::fixed;
  std::cout << std::setprecision(8) << 2*lsum/n << endl;;
}


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

int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;
    if (N & 1) {
        cout << "No" << endl;
        return 0;
    }
    int n = N / 2;
    for (int i = 0; i < n; i++) {
        if (S[i] == S[i + n])
            continue;
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

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

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

    vector<pair<int,int>> ba(100010);
    rep(i, M){
        cin >> ba[i].second >> ba[i].first;
        ba[i].first--; ba[i].second--;
    }

    sort(ba.begin(), ba.begin()+M);

    int ans = 0, before = -1;

    rep(i, M){
        //cout << before << " " <<   ans << endl;
        if(ba[i].second <= before && before < ba[i].first){
            continue;
        }

        before = ba[i].first - 1;
        ans++; 
    }

    cout << ans << endl;
}

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

using namespace std;

int main(){
    string s;
    cin >> s;
    int ans = 0,front=0,back=s.size()-1;
    while(front<=back){
        if(s[front]!=s[back]){
            if(s[front]=='x'){
                ans++;
                front++;
            }else if(s[back]=='x'){
                ans++;
                back--;
            }else{
                cout << -1 << endl;
                return 0;
            }
        }else{
            front++;
            back--;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int[] k = new int[ALF];
        for(int i=0;i<s.length();i++)
            k[s.charAt(i)-'a']++;
        for(int i=0;i<ALF;i++){
            if(k[i]==0){
                System.out.println((char)('a'+i));
                return;
            }
        }
        System.out.println("None");
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 23380
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
int mod = 1e9 + 7;

int main(void)
{
    int k, n;
    cin >> n >> k;
    int h[212345];
    for (int i = 0; i < n;i++){
        cin >> h[i];
    }
    sort(h, h + n);
    int ans = mod;
    for (int i = 0; i < n - k + 1; i++){
        ans = min(ans, h[i + k - 1] - h[i]);
    }
    cout << ans << endl;
    return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int64 N;
vector<int> G[210];

vector<int> color;

bool dfs(int v, int c) {
    bool ok = 1;
    color[v] = c;
    REP(i, G[v].size()) {
        if (color[G[v][i]] != -1 && color[G[v][i]] == c) {
            return 0;
        } else {
            if (color[G[v][i]] != -1) continue;
            ok = ok && dfs(G[v][i], 1-c);
        }
    }
    return ok;
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	int d[210][210] = {};
	REP(i, N) {
	    REP(j, N) {
	        d[i][j] = INF;
	    }
	}
	REP(i, N) {
	    string s;
	    cin >> s;
	    REP(j, N) {
	        if (s[j] == '1') G[i].push_back(j);
	        if (s[j] == '1') d[i][j] = 1;
	    }
	    d[i][i] = 0;
	}
	color.resize(N, -1);
	REP(i, N) {
	    if (color[i] == -1) {
	        if (!dfs(i, 0)) {
	            cout << -1 << endl;
	            return 0;
	        }
	    }
	}
	REP(k, N) {
	    REP(i, N) {
	        REP(j, N) {
	            if (d[i][j] > d[i][k] + d[k][j]) d[i][j] = d[i][k] + d[k][j];
	        }
	    }
	}
	int res = 0;
	REP(i, N) {
	    REP(j, N) {
	        res = max(res, d[i][j]);
	    }
	}
	cout << res+1 << endl;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
		public static void main(String[] args) {
		
	   Scanner sc = new Scanner(System.in);
	   
	   int r = sc.nextInt();
	   int g = sc.nextInt();
	   int b = sc.nextInt();
	   
	   int a = 100*r + 10*g + b;
	   if(a % 4 == 0) {
		   System.out.println("YES");
	   }else if(a % 4 != 0) {
		   System.out.println("NO");
	   }

		}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i, ball, balls, num_ball_type;
    int ball_type[210000] = {0};
    int counter = 0;
    int number_of_changed_type = 0;

    cin >> balls >> num_ball_type;

    for (i=0; i<balls; i++) {
        cin >> ball;
        ball_type[ball]++;
    }

    sort(ball_type, ball_type+210000, greater<int>());
    
    for (i=0; i<210000; i++) {

        if(ball_type[i] == 0) {
            break;
        }
        if(counter >= num_ball_type) { //ボールの種類をカウントしている．カウンターがK以上になった場合(0から)，変更するボールを数え始める
            number_of_changed_type += ball_type[i];
        } else {
            counter++;
        }
    }

    cout << number_of_changed_type << endl;

    return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

while True:
    n = input()
    lst = []
    if n == 0:
        break
    if n == 1:
        num = input()
        print num
        continue
    for loop in range(n):
        S = raw_input()
        lst.append((len(S), S[-1]))
    if lst[0][1] == '+':
        lst.append((0, '0'))
    else:
        lst.append((0, '1'))
    n += 1
    
    c_lst = [0 for i in range(1000)]
    v_lst = [0 for i in range(1000)]

    rank = 1
    for i in range(n):
        r = lst[i][0]
        c = lst[i][1]
        while r < rank:
            if c_lst[rank - 1] == '+':
                v_lst[rank - 1] += v_lst[rank]
            else:
                v_lst[rank - 1] *= v_lst[rank]
            rank -= 1
        if c == '+':
            r += 1
            c_lst[r] = '+'
            v_lst[r] = 0
            rank += 1
            continue
        elif c == '*':
            r += 1
            c_lst[r] = '*'
            v_lst[r] = 1
            rank += 1
            continue
        if c_lst[r] == '+':
            v_lst[r] += int(c)
        else:
            v_lst[r] *= int(c)
    print v_lst[2]
    


Measured memory_bytes: 5076
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  REP(i,n) cin >> v[i];

  sort(ALL(v));

  double ans = v[0];
  // if(n == 1){
  //   cout<< fixed << setprecision(10) << ans << endl;
  //   return 0;
  // }

  for(int i = 1; i < n; ++i){
    ans =  (ans + v[i])/2;
  }

  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll N,sum=0;
  cin>>N;
  vector<ll> A(N);
  map<ll,ll> mp;
  for(ll i=0;i<N;i++){
    cin>>A.at(i);
    mp[A.at(i)]++;
    sum+=A.at(i);
  }
  ll Q;
  cin>>Q;
  for(ll i=0;i<Q;i++){
    ll a,b;
    cin>>a>>b;
    mp[b]+=mp[a];
    sum-=a*mp[a];
    sum+=b*mp[a];
    mp[a]=0;
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 10092
from collections import deque

n = int (input())
roots = [[] for _ in range(2*n)]
color = [0] * 2 * n

for i in range(n-1):
    u, v, w = [int(i) for i in input().split()]
    u = u - 1
    v = v - 1

    if (w % 2 == 1):
        roots[u].append(v)
        roots[v].append(u)
    else:
        roots[u].append(u+n)
        roots[u+n].append(v)
        roots[v].append(v+n)
        roots[v+n].append(u)

d = deque()
d.append(0)
color[0] = 1

while(len(d)):
    temp = d.popleft()
    for i in roots[temp]:
        if(color[i] == 0):
            color[i] = color[temp] * (-1)
            d.append(i)

for i in range(n):
    print(max(0,color[i]))

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

using namespace std;

int main()
{
    int n,k,i,count=0;
    scanf("%d %d",&n,&k);
    i=0;
    while(count<n)
    {
        count+=(k-1)*pow(k,i);
        i++;
    }
    printf("%d\n",i);
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

static int N;
static int B[100];

int search(int i, int *data) {
  if(i == 0) {
    return 1;
  }

  for(int j = (i-1); j >= 0; j--) {
    if(data[j] == (j+1)) {
      int newdata[100];
      int dst = 0;
      int OK =1;
      for(int k = 0; k < i; k++) {
	if(k != j) {
	  newdata[dst++] = data[k];
	  if(data[k] >= i) {
	    OK = 0;
	    break;
	  }
	}
      }
      if(OK == 0) continue;
      int ret = search(i-1, newdata);
      if(ret == 1) {
	printf("%d\n", (j+1));
	return 1;
      }
    }
  }
  return 0;
}

int main(void) {
  scanf("%d", &N);

  int OK = 1;
  for(int i = 0; i < N; i++) {
    scanf("%d", &B[i]);
    if(B[i] > (i+1)) {
      OK = 0;
    }
  }
  if(OK == 0) {
    printf("-1\n");
  } else if(search(N, B) == 0) {
    printf("-1\n");
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ0056
{
    class Program
    {
        static void Main()
        {
            var primeTable = GeneratePrimeTable(50100);

            foreach (var n in ReadInput())
            {
                var count = 0;

                var position1 = 0;
                var position2 = 0;
                for (; primeTable[position2] < n; position2++)
                {
                }

                while (true)
                {
                    int value;
                    for (; position1 <= position2 && (value = primeTable[position1] + primeTable[position2]) >= n; position2--)
                    {
                        if (value == n) count++;
                    }

                    for (; position1 <= position2 && (value = primeTable[position1] + primeTable[position2]) <= n; position1++)
                    {
                        if (value == n) count++;
                    }

                    if (position1 > position2) break;
                }

                Console.WriteLine(count);
            }
        }

        public static IEnumerable<int> ReadInput()
        {
            string line;
            while ((line = Console.ReadLine()) != null && line != "0")
            {
                yield return int.Parse(line);
            }
        }

        private static int[] GeneratePrimeTable(int max)
        {
            var primeTable = new bool[max + 1];

            for (var i = 2; i <= max; i++)
            {
                primeTable[i] = true;
            }

            for (var i = 4; i <= max; i += 2)
            {
                primeTable[i] = false;
            }

            var currentPrime = 3;
            while (currentPrime <= max)
            {
                for (var i = currentPrime * 2; i <= max; i += currentPrime)
                {
                    primeTable[i] = false;
                }

                for (currentPrime += 2; currentPrime <= max; currentPrime += 2)
                {
                    if (primeTable[currentPrime]) break;
                }
            }

            return (from n in Enumerable.Range(0, max + 1)
                    where primeTable[n]
                    select n).ToArray();
        }
    }
}

Measured memory_bytes: 6044
#include <bits/stdc++.h>
using namespace std;
const int N=2e6+10;
long long  a[N],b[N];
int main()
{
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
	int n;
	cin>>n;
	for(int i=1;i<=100;i++)
		for(int j=1;j<=100;j++)
		for(int k=1;k<=100;k++)
	{
		if(i*i+j*j+k*k+i*j+i*k+j*k>1e4)continue;
		else {
				if(i==j&&j==k)a[i*i+j*j+k*k+i*j+i*k+j*k]++;
				else a[i*i+j*j+k*k+i*j+i*k+j*k]+=1;
		}
	}
	for(int j=1;j<=n;j++)
		cout<<a[j]<<endl;

}


Measured memory_bytes: 3660
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 998244353, INF = 1e16;

lint N, T;
lint prv = 0, A;
int main() {
	cin >> N >> T;
	lint sum = T;
	REP(i, N) {
		cin >> A;
		sum += min(T, (A - prv));
		prv = A;
	}
	cout << sum << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

int main() {
    int N; cin >> N;
    string s; cin >> s;
    int ans = INF;

    int r = 0,w = 0;
    rep(i,N) {
        if (s[i] == 'R') r++;
        if (s[i] == 'W') w++;
    }
    ans = min(r,w);

    int cnt = 0;
    rep(i,r) {
        if (s[i] == 'W') ++cnt;
    }
    ans = min(ans,cnt);
    cout << ans << '\n';
    return 0;
}

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

const int N = 51;
const int mod = 1e9 + 7;

typedef long long LL;

inline int Pow(int x, int y) {
    int res = 1;
    for (; y; y >>= 1, x = (LL)x * x % mod) if (y & 1) res = (LL)res * x % mod;
    return res;
}

int frac[N], inv[N];

inline int C(int n, int r) {
    return (LL)frac[n] * inv[r] % mod * inv[n - r] % mod;
}

int dp[N][N]; // 已经挂了i个点，最后一层有j个点有奇数个儿子，还未考虑儿子的挂法

int main() {
    int n; scanf("%d", &n), frac[0] = inv[0] = 1;
    for (int i = 1; i <= n; i++) frac[i] = (LL)frac[i - 1] * i % mod, inv[i] = Pow(frac[i], mod - 2);
    dp[1][1] = dp[1][0] = n;
    for (int i = 1; i < n; i++)
        for (int j = 1; j <= n - i; j++) // 当前这一层的点数
            for (int k = 0; k <= j; k++) { // 上一层奇数个儿子的点的数量
                if ((j - k) & 1) continue;
                int delta = (j - k) / 2; // 未考虑下一层时，这一层有多少个点与父亲符号不同
                for (int t = 0; t <= j; t++) { // 实际有多少个符号不同
                    int tmp = abs(t - delta); // 这一层有奇数个儿子的点的数量
                    dp[i + j][tmp] = (dp[i + j][tmp] + (LL)dp[i][k] * C(n - i, j) % mod * C(j, t)) % mod;
                }
            }
    printf("%d\n", dp[n][0]);
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        scaffold : [isize; n],
    }

    let mut dp = vec![isize::max_value(); n];
    dp[0] = 0;
    for i in 1..n {
        let mut tmp = dp[i-1];
        chmin(&mut dp[i], (scaffold[i-1]-scaffold[i]).abs() + tmp);
        //println!("diff {}", (scaffold[i-1]-scaffold[i]).abs());
        //println!("dp[{}]: {}",i,  dp[i]);
        for j in 2..k+1 {
            if i > j-1 {
                tmp = dp[i-j];
                chmin(&mut dp[i], (scaffold[i-j]-scaffold[i]).abs() + tmp);
            }
        }
    }
    println!("{}", dp[n-1]);
}

fn chmin<T: Ord> (a: &mut T, b: T) -> bool {
    if *a > b {
        *a = b;
        return true; 
    }
    false
}

Measured memory_bytes: 6396
from sys import stdin

N = int(stdin.readline())
B = list(map(int, stdin.readline().split()))

sum = 0
for i in range(N-1):
    if N == 1:
        sum = B[i] * 2
        break
    if i == 0:
        sum += B[0]
    if i == N-2:
        sum += B[i]
    else:
        sum += min(B[i], B[i+1])

print(sum)


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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    int n;
    string a,b,c;
    cin >> n;
    cin >> a >> b >> c;
    int cc=0;

    FOR(i,0,n){
        char x=a[i],y=b[i],z=c[i];
        if((x==y && y!=z && z==x) || (y==z && x!=z && x==y) ||
                (x!=y && x==z && y==z) || (x==z && x!=y && z!=y) ||
                (x!=y && x!=z && y==z) || (x==y && x!=z && y!=z))
            cc++;
        else if(x!=y && x!=z && z!=y)
            cc+=2;
    }

    cout << cc << endl;

    return 0;
}


Measured memory_bytes: 256
n, c = [int(i) for i in input().split()]
m = [[int(j) for j in input().split()] for i in range(n)]

sum = 0
r = [0]
for x, v in m:
    sum += v
    r.append(sum-x)

sum = 0
l = [0]
for x, v in m[::-1]:
    sum += v
    l.append(sum-(c-x))

def right():
    max_ = r[0]
    for i in r:
        if max_ < i:
            max_ = i
        yield max_

def left():
    max_ = l[0]
    for i in l:
        if max_ < i:
            max_ = i
        yield max_

rm = [[0, 0]] + m
lm = m + [[c, c]]

rpath = list(right())
lmax = max([l[i]+rpath[-(i+1)]-(c-lm[-(i+1)][0]) for i in range(n)])

lpath = list(left())
rmax = max([r[i]+lpath[-(i+1)]-rm[i][0] for i in range(n)])


print(max(rmax, lmax))

Measured memory_bytes: 36704
#!/usr/bin/python3
# -*- coding: utf-8 -*-

from collections import Counter

n = int(input())
a = list(map(int, input().split()))
b = sorted(list(set(a)), reverse=True)
c = Counter(a)
d = []
for x in b:
    if c[x] >= 4:
        print(d[0] * x if len(d) else x * x)
        exit(0)
    elif c[x] >= 2:
        d.append(x)
        if len(d) == 2:
            print(d[0] * d[1])
            exit(0)
print(0)


Measured memory_bytes: 21028
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;


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

	int r, d, x;
	cin >> r >> d >> x;
	int xx[10];
	for (int i = 0; i < 10; i++)
	{
		if(i == 0)
			xx[i] = x * r - d;
		else
			xx[i] = xx[i-1] * r - d;
	}


	for (int i = 0; i < 10; i++)
		cout << xx[i] << '\n';
	return 0;
}


Measured memory_bytes: 256
K,N=map(int, input().split())
Alist=list(map(int, input().split()))
diflist = []
def whichside(K,A1,A2):
    diff = A2-A1
    diff = K-diff if K-diff<diff else diff
    return diff
diflist.append(whichside(K,Alist[0],Alist[-1]))
for i in range(1,len(Alist)):
    diff = whichside(K,Alist[i-1],Alist[i])
    diflist.append(diff)
print(K-max(diflist))

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x) ((int) x.size())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define makeunique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define endl '\n'

typedef pair<int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<string> vs;

template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }

const double pi = acos(-1.);
const int mod = 1e9 + 7;
const int N = 3e5 + 17;

int n, m;

ll dp[500][500];
ll degs[500][500];
int a[500], b[500], C;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> C;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];

	for (int i = 0; i < n; i++) { 
	    vll cur(b[i] - a[i] + 1, 1);
		for (int j = 0; j <= C; j++) {
			for (int k = a[i]; k <= b[i]; k++) {
				int pos = k - a[i];
				degs[i][j] += cur[pos];
				cur[pos] = cur[pos] * k % mod;
			}
			degs[i][j] %= mod;
		}
	}

	for (int i = 0; i < 500; i++)
		for (int j = 0; j < 500; j++)
			dp[i][j] = -1;
	dp[0][0] = 1;
	for (int i = 0; i < n; i++)
		for (int j = 0; j <= C; j++) {
		    ll ans = 0;
		    bool ok = 0;
			for (int k = 0; k <= j; k++)
				if (dp[i][j - k] >= 0) {
					ok = 1;
					ans += degs[i][k] * dp[i][j - k] % mod;
			  	}
			if (!ok) dp[i + 1][j] = -1;
			else dp[i + 1][j] = ans % mod;
		}
	cout << dp[n][C];
}


Measured memory_bytes: 7124
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int

struct edge
{
  int to, cost;
};
typedef std::vector<std::vector<edge>> graph;
const ll MOD = 1000000007;
using namespace std;

int main()
{
  int h, w;
  cin >> h >> w;
  int grid[50][50] = {};
  int score[50][50] = {};
  int wnum = 0;
  REP(i, h)
  {
    string s;
    cin >> s;
    REP(j, s.length())
    {
      score[i][j] = -1;
      if (s[j] == '.')
      {
        wnum++;
        grid[i][j] = 0;
      }
      else
      {
        grid[i][j] = 1;
      }
    }
  }

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

  queue<pair<int, int>> q;
  q.push(make_pair(0, 0));
  score[0][0] = 1;
  grid[0][0] = -1;
  while (!q.empty())
  {
    auto p = q.front();
    q.pop();
    REP(i, 4)
    {
      int ny = p.first + dy[i];
      int nx = p.second + dx[i];
      if (0 <= ny && ny < h && 0 <= nx && nx < w && grid[ny][nx] == 0)
      {
        score[ny][nx] = score[p.first][p.second] + 1;
        grid[ny][nx] = -1;
        q.push(make_pair(ny, nx));
      }
    }
  }

  if (score[h - 1][w - 1] == -1)
  {
    cout << -1 << endl;
  }
  else
  {
    cout << wnum - score[h - 1][w - 1] << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,A,B,C,D;
	scanf("%d%d%d%d%d",&n,&A,&B,&C,&D);
	if(A>B)swap(A,B);
	bool f=false;
	if(1ll*(n-1)*D<B-A)f=0;
	else if(B-A>=1ll*(n-1)*C)f=1;
	else{
		for(int sub=0;sub<=n-1;++sub){//sub*[-D,-C],n-1-sub*([C,D])
			if(1ll*(n-1-sub)*C-1ll*sub*D<=B-A&&B-A<=1ll*(n-1-sub)*D-1ll*sub*C)
				f=1;//B<A+(n-1)*C
		}
	}
	puts(f?"YES":"NO");
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    ll L[n + 1];
    L[0] = 2;
    L[1] = 1;
    for (int i = 2; i <= n; i++) {
        L[i] = L[i - 1] + L[i - 2];
    }

    cout << L[n] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << 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...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int dp[110000][2];
const int mod = 1000000007;
signed main(){
    string s;cin >> s;
    int n = s.size();
    dp[0][0] = 1;
    rep(i,n){
        int d = s[i] - '0';
        if( d == 0){
            {
                //dp[i][0]からの遷移
                dp[i+1][0] = (dp[i+1][0] + dp[i][0])%mod;

            }
            {
                //dp[i][1]からの遷移
                dp[i+1][1] = (dp[i+1][1] + dp[i][1]*3)%mod;
            }

        }
        else if(d == 1){
            {
                //dp[i][0]からの遷移
                dp[i+1][1]  = (dp[i+1][1]+dp[i][0])%mod;

                dp[i+1][0] = (dp[i+1][0] + dp[i][0]*2)%mod;
            }
            {
                //dp[i][1]からの遷移
                dp[i+1][1] = (dp[i+1][1] + dp[i][1]*3)%mod;
            }

        }


    }
    cout << (dp[n][0] + dp[n][1])%mod << endl;
    return 0;
}

Measured memory_bytes: 5320
#include <iostream>
#include <vector>
#include <queue>

int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<std::vector<int>> graph(N);
  for (int i = 0; i < M; ++i) {
    int A, B;
    std::cin >> A >> B;
    A -= 1;
    B -= 1;
    graph[A].push_back(B);
    graph[B].push_back(A);
  }

  // BFS のためのデータ構造
  std::vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
  std::queue<int> que;

  // 初期条件 (頂点 0 を初期ノードとする)
  dist[0] = 0;
  que.push(0); // 0 を橙色頂点にする

  int counter = 1;
  // BFS 開始 (キューが空になるまで探索を行う)
  while (!que.empty()) {
    const int v = que.front(); // キューから先頭頂点を取り出す
    que.pop();
    // v から辿れる頂点をすべて調べる
    for (const int next : graph[v]) {
      if (dist[next] != -1) {
        continue; // すでに発見済みの頂点は探索しない
      }
      // 新たな白色頂点 nv について距離情報を更新してキューに追加する
      dist[next] = v + 1;
      que.push(next);
      counter += 1;
    }
  }

  if (counter != N) {
    std::cout << "No" << std::endl;
  } else {
    std::cout << "Yes" << std::endl;
    for (int i = 1; i < N; ++i) {
      std::cout << dist[i] << std::endl;
    }
  }
  return 0;
}


Measured memory_bytes: 10096
import java.io.*;

public class Main{
    public static void main(String[]args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        int n = Integer.parseInt(br.readLine());
        String[] str2 = br.readLine().split(" ");
        long sum=0;
        int max=-1000000, min=1000000, tmp=0;
        for(int i=0;i<n;i++){
            tmp=Integer.parseInt(str2[i]);
            if(tmp>max)max=tmp;
            if(tmp<min)min=tmp;
            sum=sum+tmp;
        }
        System.out.println(min+" "+max+" "+sum);
    }
}

Measured memory_bytes: 25584
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int a,b;
	cin >> a >> b;
	for(int i = 0;i < 100000;i++){
		if(i * 8 / 100 == a && i * 10 / 100 == b){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n;
    cin >> n;
    cout << (n+1)/2-1 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {



	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String ans = "NO";
		int[] setu = new int[3];
		for(int i = 0 ;i < setu.length;i++) {
			setu[i] = sc.nextInt();
		}
		for(int i = 0; i < setu.length;i++) {
			for(int j = i; j < setu.length;j++) {
				if(setu[i] > setu[j]) {
					int hoge = setu[i];
					setu[i] = setu[j];
					setu[j] = hoge;
				}
			}
		}
		if(setu[0] == 5 && setu[1] == 5 && setu[2] == 7) {
			ans = "YES";
		}
		System.out.println(ans);
		if(!(sc == null)) sc.close();
	}
}

Measured memory_bytes: 22740