akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

struct node{
    ll depth;
    vector<pair<ll, ll> > links;
    node(ll GRAPH_MAX){
        depth=GRAPH_MAX;
    }
};


//graph-algorithms
struct graph{
    vector<node> NODES;
    ll MAXVAL;
    deque<ll> bfs01_;
    vector<ll> searching_;
    vector<ll> searched_;
    //initializer
    graph(ll size, ll maxweight){
        rep(i, size){
            MAXVAL=size*maxweight+1;
            node NEWNODE(MAXVAL);
            NODES.push_back(NEWNODE);
        }
    }
    
    //リンク系
    //双方向リンク
    void connect(ll a, ll b, ll weight){
        add_link(a, b, weight);
        add_link(b, a, weight);
    }
    //単方向リンク
    void add_link(ll from, ll to, ll weight){
        NODES[from].links.push_back({to, weight});
    }
    
    //01-BFS
    void bfs01(ll base){
        bfs01_.push_back(base);
        vector<ll> dist(NODES.size(), MAXVAL);
        
                dist[base]=0;
        while(bfs01_.size()){
            int i=bfs01_.front(); bfs01_.pop_front();
            for(auto [j, c] : NODES[i].links){
                int d = dist[i] + c;
                if(d < dist[j]){
                    dist[j] = d;
                    if(c){
                        bfs01_.push_back(j);
                    }else{
                        bfs01_.push_front(j);
                    }
                }
            }
        }
        rep(i, dist.size()) searched_.push_back(dist[i]);
    }
    ll bfs01_result(ll index){
        if(searched_[index]==MAXVAL) return -1;
        return searched_[index];
    }
    
    
};



//確かに改札というアイデアはわかりやすい...
int main(void){
    ll N, M;
    map<ll, ll> platform;
    
    cin>>N>>M;
    ll p[200000], q[200000], c[200000];
    graph g(N+M*2, 1);
    ll mask=1000000;
    rep(i, M){
        cin>>p[i]>>q[i]>>c[i];
        platform[c[i]*mask+p[i]]=1;
        platform[c[i]*mask+q[i]]=1;
    }
    ll t=0;
    for(auto itr : platform){
        platform[itr.first]=t;
        t++;
    }
    rep(i, M){
        g.connect(N+platform[c[i]*mask+p[i]],N+platform[c[i]*mask+q[i]], 0);
        g.add_link(p[i]-1, N+platform[c[i]*mask+p[i]], 1);
        g.add_link(q[i]-1, N+platform[c[i]*mask+q[i]], 1);
        g.add_link(N+platform[c[i]*mask+p[i]], p[i]-1, 0);
        g.add_link(N+platform[c[i]*mask+q[i]], q[i]-1, 0);
    }
    g.bfs01(0);
    cout<<g.bfs01_result(N-1)<<endl;
    return 0;
}


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

vector<bool> d(10, true);

bool isvalid(int n)
{
	int dec = n % 10;
	if(!d[dec]) return false;
	if(n/10 != 0) return isvalid(n/10);
	return true;
}

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

	for (int i = 0; i < k; i++){
		int tmp; cin >> tmp;
		d[tmp] = false;
	}

	while(!isvalid(n)) n++;
	cout << n << '\n';
	return 0;
}

Measured memory_bytes: 3576
input = STDIN.readline.split()
n = input[0].to_i
m = input[1].to_i
x_list = STDIN.readline.split().map{|x|x.to_i}
min = 100000
max = -100000
x_exists = {}
for x in x_list do
    if x < min then
        min = x
    end
    if x > max then
        max = x
    end
    x_exists[x] = 1
end
diff_counts = {}
diff_max = 0
c = 0
for i in Range.new(min + 1, max) do
    c += 1
    if x_exists.has_key?(i) then
        if diff_counts.has_key?(c) then
            diff_counts[c] += 1
        else
            diff_counts[c] = 1
        end
        if c > diff_max then
            diff_max = c
        end
        c = 0
    end
end

sum = 0
for i in Range.new(1, diff_max) do
    if diff_counts.has_key?(i) then
        while m > n && diff_counts[i] > 0 do
            m -= 1
            diff_counts[i] -= 1
            sum += i
        end
    end
end
puts(sum)

Measured memory_bytes: 14604
#include <bits/stdc++.h>
using namespace std;
long long read()
{
    long long f=1,x=0;
    char ss=getchar();
    while(ss<'0'||ss>'9'){if(ss=='-')f=-1;ss=getchar();}
    while(ss>='0'&&ss<='9'){x=x*10+ss-'0';ss=getchar();}
    return f*x;
}
int main()
{
    int n,s=0;
    int a[110];
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    for(int j=i+1;j<=n;j++)
    {
        s+=a[i]*a[j];
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
    int i, N, M, T[101], total = 0;
    scanf("%d", &N);
    for ( i = 1; i <= N; i++ ){
        scanf("%d", &T[i]);
        total += T[i];
    }
    scanf("%d", &M);
    for ( i = 0; i < M; i++ ){
        int p, x;
        scanf("%d %d", &p, &x);
        printf("%d\n", total - T[p] + x);   /* TのかわりにX */
    }
    return 0;
}

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

using namespace std;

const int N = 100005;

int n, res, color[N], fa[N], son[N];
vector<int> g[N];

void dfs(int u, int f) {
  fa[u] = f;
  son[u] = u == n ? n : 0;
  for (auto v : g[u]) {
    if (v != f) {
      dfs(v, u);
      if (son[v]) {
        son[u] = v;
      }
    }
  }
}

void getAns(int u, int f) {
  for (auto v : g[u]) {
    //cout << u << "->" << v << endl;
    if (v != f && color[v] != 2) {
      ++res;
      //cout << v << endl;
      getAns(v, u);
    }
  }
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  color[1] = 1;
  color[n] = 2;
  dfs(1, 1);
  int u = 1, v = n;
  while (u != fa[v]) {
    u = son[u];
    color[u] = 1;
    if (fa[v] != u) {
      v = fa[v];
      color[v] = 2;
    }
  }
  res = 0;
  getAns(1, 1);
  puts(res > n - res - 2 ? "Fennec" : "Snuke");
  return 0;
}


Measured memory_bytes: 13184
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#define rep(i, a, b) for (int(i) = (a); i < (b); i++)
using namespace std;

using ll = long long;

typedef pair<int, int> P;

const int INF = 100000000;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;

ll pow_mod(ll x, ll y, ll mod)
{
	ll ans=1;
	for(;y>0;y>>=1){
		if(y&1)(ans*=x)%=mod;
		(x*=x)%=mod;
	}
	return ans;
}

string s[10010];
ll n;
ll ans;
bool start = false;
ll a,b;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
	cin >> n;
	rep(i, 0, n) cin >> s[i];
	rep(i,0,n){
		ll siz = s[i].size();
		rep(j,0,siz-1){
			if(s[i][j]=='A'&&s[i][j+1]=='B'){
				ans++;
			}
		}
		if(s[i][0]=='B'){
			b++;
		}
		if(s[i][siz-1]=='A'){
			a++;
			if(s[i][0]!='B'){
				start = true;
			}
		}
	}
	ans += min(a, b);
	if (a == b && !start&&a!=0){
		ans--;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  double b=0;
  for(ll i=0;i<a;i++){
    double c;
    cin>>c;
    b+=1/c;
  }
  cout<<fixed<<setprecision(6);
  cout<<1/b<<endl;
  return 0;
}
  
    
  

Measured memory_bytes: 3728
#include <stdio.h>

int main(void)
{
	unsigned int ck_a, ck_b, ck_c;
	unsigned int ck_d;				/* 食べられるおいしいクッキー		*/

	scanf("%d %d %d", &ck_a, &ck_b, &ck_c);

	if ((ck_a + ck_b + 1) >= ck_c) {
		ck_d = ck_b + ck_c;
	} else {
		ck_d = ck_b + ck_a + ck_b + 1;
	}

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

	return 0;
}


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

using namespace std;

set<long long> se;

int main(){
    long long n;
    cin >> n;
    for(long long i = 0; i < n; ++i){
        long long tmp; cin >> tmp;
        if(se.find(tmp) != se.end()){
            se.erase(tmp);
        }else se.insert(tmp);
    }
    cout << se.size();
    return 0;

}


Measured memory_bytes: 4864
n = int(input())
l = list(map(int,input().split()))
d = {}
for i in l:
    if i in d:
        d[i]+=1
    else:
        d[i] = 1
cp = 0
for i in d.values():
    cp+= i*(i-1)//2
for i in l:
    print(cp-d[i]+1)

Measured memory_bytes: 26140
using System;
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                String str = Console.ReadLine();
                if (str == "0")
                {
                    break;
                }
                long sum = 0;
                int n = int.Parse(str);
                if (n == 0) break;
                int[] list = new int[n];
                for (int i = 0; i < n; i++) list[i] = int.Parse(Console.ReadLine());
                long max = -100000;
                for (int i = 0; i < n; i++)
                {
                    for (int j = i; j < n; j++)
                    {
                        sum += list[j];
                        if (sum > max) max = sum;
                    }
                    
                    sum = 0;
                }
                Console.WriteLine(max);
            }
        }
   } 

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

int main(){
    int N,C;

    cin >> N >> C;

    int p[C];

    for(int i=0; i<C; i++){
        cin >> p[i];
    }
    
    int v=0;

    for(int i=0; i<C; i++){
        v = v + p[i];
    }

    int w=0;

    w = v/(N+1);

    if(v%(N+1)>0){
        cout << w+1 << endl;
    }else{
        cout << w << endl;
    }

    return 0;
}


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

int main(){
int S, T;
cin >> S >> T;
    
int ans = 0;
int i = 0;
while (T > 1){
  if ((S-1)*(i)+S < T){
    i++;
  }
  
  else {
    i++;
    break;
  }
} 
  
  if (T== 1){
    i = 0;
  }
  
  cout << i << endl;
}
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int   //used int to avoid mle
#define ulli unsigned long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define spl set<pll>
#define msl multiset <lli>
#define msp multiset <pll>
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
typedef vector<int>		vi;
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
lli mod=1000000007;

int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
   
	lli t,n;
	cin>>t>>n;
	lli s=0;
	for(lli i=0;i<n;i++){
		lli x;cin>>x;
		s+=x;
	}
	if(s>=t)cout<<"Yes";
	else cout<<"No";
   
}

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

// ????¬???????????????°??????????????????????????????????????°?????????
using ll = long long;

struct RMQ {
	using type = int;
	static type id() { return INT_MAX; }
	static type op(const type& l, const type & r) { return min(l, r); }
};

template <typename M>
class node {
	using T = typename M::type;
public:
	T val;
	node<M> *l, *r;
	node(T val_) : val(val_), l(nullptr), r(nullptr) {}
};

template <typename M>
class DynamicSegmentTree {
	using T = typename M::type;
	const ll n;
	node<M> *root;
	T value(node<M> *t) {
		return t ? t->val : M::id();
	}
	T sub(ll l, ll r, node<M>* n, ll lb, ll ub) {
		if (!n || ub <= l || r <= lb) return M::id();
		if (l <= lb && ub <= r) return n->val;
		ll c = (lb + ub) / 2;
		return M::op(sub(l, r, n->l, lb, c), sub(l, r, n->r, c, ub));
	}
	node<M> *suc(ll p, node<M>* t, ll lb, ll ub, T val) {
		if (!t) t = new node<M>(M::id());
		if (lb + 1 == ub) {
			t->val = val;
			return t;
		}
		ll c = (lb + ub) / 2;
		if (p < c) t->l = suc(p, t->l, lb, c, val);
		else t->r = suc(p, t->r, c, ub, val);
		t->val = M::op(value(t->l), value(t->r));
		return t;
	}
public:
	DynamicSegmentTree(ll n_) :
		n(1 << (int)ceil(log2(n_))), root(nullptr) {}
	void update(ll p, T val) {
		root = suc(p, root, 0, n, val);
	}
	T find(ll l, ll r) {
		return sub(l, r + 1, root, 0, n);
	}
};

template <typename M>
class node2 {
	using T = typename M::type;
public:
	DynamicSegmentTree<M> val;
	node2<M> *l, *r;
	node2(ll size) : val(size), l(nullptr), r(nullptr) {}
};

template <typename M>
class DynamicSegmentTree2 {
	using T = typename M::type;
	const ll h, w;
	node2<M> *root;
	T value(node2<M> *t, ll p) {
		return t ? t->val.find(p, p) : M::id();
	}
	T sub(ll li, ll lj, ll ri, ll rj, node2<M>* n, ll lb, ll ub) {
		if (!n || ub <= li || ri <= lb) return M::id();
		if (li <= lb && ub <= ri) return n->val.find(lj, rj);
		ll c = (lb + ub) / 2;
		return M::op(sub(li, lj, ri, rj, n->l, lb, c), sub(li, lj, ri, rj, n->r, c, ub));
	}
	node2<M> *suc(ll pi, ll pj, node2<M>* t, ll lb, ll ub, T val) {
		if (!t) t = new node2<M>(w);
		if (lb + 1 == ub) {
			t->val.update(pj, val);
			return t;
		}
		ll c = (lb + ub) / 2;
		if (pi < c) t->l = suc(pi, pj, t->l, lb, c, val);
		else t->r = suc(pi, pj, t->r, c, ub, val);
		t->val.update(pj, M::op(value(t->l, pj), value(t->r, pj)));
		return t;
	}
public:
	DynamicSegmentTree2(ll h_, ll w_) :
		h(1ll << (ll)ceil(log2(h_))), w(w_), root(nullptr) {}
	void update(ll pi, ll pj, T val) {
		root = suc(pi, pj, root, 0, h, val);
	}
	T find(ll li, ll lj, ll ri, ll rj) {
		return sub(li, lj, ri + 1, rj, root, 0, h);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q, com, x, y;
	cin >> n >> q;
	DynamicSegmentTree2<RMQ> st(1, n);
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", st.find(0, x, 0, y));
		}
		else {
			st.update(0, x, y);
		}
	}
	return 0;
}

Measured memory_bytes: 7044
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	o := getString()
	e := getString()

	ans := ""
	for i := 1; i <= len(o)+len(e); i++ {
		if i%2 == 1 {
			ans += string(o[i/2])
		} else {
			ans += string(e[i/2-1])
		}
	}

	fmt.Println(ans)
}

// 1 3 5 7 9
// 0 1 2 3 4

// 2 4 6 8
// 0 1 2 3

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int main(void){
	vector<int> a;
	int b[100000];
	int c, d;
	int k;
	int n, m;
	int s, t;
	int x, y, z;


	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &x);
		a.push_back(x);
	}
	sort(a.begin(), a.end());
 printf("%d\n",a[n-1]-a[0]);

	return 0;
}

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

const int INF = 1001001001;

int main() {
    int n, m, x, ans = INF;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) cin >> a[i][j];
    }

    for (int b = 0; b < 1 << n; b++) {
        int cost = 0;
        vector<int> d(m);
        for (int i = 0; i < n; i++) {
            if (b >> i & 1) {
                cost += c[i];
                for (int j = 0; j < m; j++) d[j] += a[i][j];
            }
        }
        bool ok = true;
        for (int j = 0; j < m; j++) {
            if (d[j] < x) ok = false;
        }
        if (ok) ans = min(ans, cost);
    }
    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
x, n = map(int, input().split())
p = list(map(int, input().split()))


if not(x in p):
	print(x)
else:
	c = 1
	while True:
		if not(x-c in p):
			print(x-c)
			break
		elif not(x+c in p):
			print(x+c)
			break
		c += 1

Measured memory_bytes: 9176
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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


	ll m1, d1, m2, d2;
	cin >> m1 >> d1 >> m2 >> d2;

	if (m1 != m2) {
		cout << 1 << endl;

	}
	else {
		cout << 0 << endl;
	}

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define All(x) (x).begin(),(x).end()
#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))
#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);


    int n, m, x;

    cin >> n >> m >> x;

    int a[105];
    int y;
    int toZero = 0;
    int toN = 0;

    Mem0(a);

    int i;

    rep(i, n) {
        cin >> y;

        a[y] = 1;
    }

    nep(i, x) if (a[i] == 1) toZero++;
    repi(i, n, x + 1) if (a[i] == 1) toN++;

    Out(min(toZero, toN));

    return 0;
}


Measured memory_bytes: 256
N = int(input())
h = [int(x) for x in input().split()]

ans = 0
a = [h]
while len(a) != 0:
    b = []
    for aa in a:
        v = min(aa)
        ans += v

        tmp = []
        for x in aa:
            xx = x - v
            if xx == 0:
                if len(tmp) > 0:
                    b.append(tmp)
                    tmp = []
            else:
                tmp.append(xx)
        if len(tmp) > 0:
            b.append(tmp)
    a = b
print(ans)


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

    ll sum=0;
    for(ll i=1; i<=K; i++){
        for(ll j=1; j<=K; j++){
            for(ll l=1; l<=K; l++){
                sum+=gcd(i,gcd(j,l));
            }
        }
    }

    cout << sum << endl;
 
}

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

static const int INF = 1001001001;
int n;
static const int MAX = 100000;
vector<int> a[MAX];
int p[MAX];


void bfs(int s){
    queue<int> q;
    int d[n];
    rep(i,n) d[i] = INF;
    d[s] = 0;
    q.push(s);
    
    while( !q.empty() ) {
        int u; u = q.front(); q.pop();
        rep(i,a[u].size()){
            int v = a[u][i];
            if(d[v] != INF) continue;
            d[v] = d[u] + 1;
            p[v] = u;
            q.push(v);
        }
    }
    bool ok = true;
    rep(i,n) if (d[i] == INF)  ok = false;
    if(ok){
        cout << "Yes" << endl;
        for( int i = 1; i < n; i++){ 
            cout << p[i] + 1 << endl;
        }
    }else{
        cout << "No" << endl;
    }
}

int main(){
    int m;
    cin >> n >> m;
    rep(i,m) {
        int s, t;
        cin >> s >> t;
        s--, t--;
        a[s].push_back(t);
        a[t].push_back(s);        
    }
    bfs(0);
    return 0;
}

Measured memory_bytes: 10776
import heapq
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
f.sort()
f.reverse()
l=0;r=max(a)*max(f)
sum=sum(a)
while abs(l-r)>1:
  x=(l+r)//2
  ct=0
  for i in range(n):
    ct+=max(a[i]-(x//f[i]),0)
  if ct<=k:
    r=x
  else:
    l=x+1
x=l
ct=0
for i in range(n):
  ct+=max(a[i]-(x//f[i]),0)
if ct<=k:
  print(l)
else:
  print(r)

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

int main() {
    vector<int> h;
    for (int i = 0; i < 10; i++) {
        int x;
        cin >> x;
        h.push_back(x);
    }
    sort(h.begin(), h.end());
    cout << h[9] << endl;
    cout << h[8] << endl;
    cout << h[7] << endl;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif // LOCAL
using ll = long long ;
ll a[nax], sum[nax];
int n;

int main(){
    scanf("%d", &n);
    for(int i = 1 ; i <= n; i ++){
        scanf("%lld", a + i);
        sum[i] = sum[i - 1] + a[i];
    }
    ll ans = 2e18;
    for(int i = 1 ;i < n ; i ++){
        ll l = sum[i];
        ll r = sum[n] - sum[i];
        ans = min(ans, abs(l - r));
    }
    cout << ans << '\n';
}

/*
    Long time no see!
    Atcoder...
*/


Measured memory_bytes: 3840
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#include<map>
#include <limits>
# include <iomanip>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
int kaizyo(int a) {
	long long ans = 1;
	for (int i = a; i > 0; i--) {
		ans *= i;
		ans = ans % 1000000007;
		//cout << ans << endl;
	}
	ans = ans % 1000000007;
	return ans;
}
int main() {
	long long int N = 0, counter = 0, a = 0, b = 0, c = 0, kaku[100002];
	bool okada = false, okada2 = false;;
	cin >> a;
	for (int i = a-1; i >=0; i--) {
		cin >> kaku[i];
	}
	for (int i = 0; i <a; i++) {
		if (kaku[i+1]-  kaku[i]==1) {
			kaku[i + 1]--;
		}
}

	for (int i = 0; i < a-1; i++) {
		if (kaku[i] < kaku[i + 1]) {
			okada = true;
	}
	}
	if (okada)cout << "No" << endl;
	else{cout<<"Yes"<<endl;}
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	int n, m;
	cin >> n >> m;
	int a[51], b[51], c[51], d[51];
	for(int i = 0; i < n; i++)
	{
		cin >> a[i] >> b[i];
	}
	for(int i = 0; i < m; i++){
		cin >> c[i] >> d[i];
	}
	for(int i = 0; i < n; i++){
		int ans = 0;
		for(int j = 0; j < m; j++){
			if(abs(a[i] - c[ans]) + abs(b[i] - d[ans]) > abs(a[i] - c[j]) + abs(b[i] - d[j])) ans = j;
		}
		cout << ans + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;

int a[10000];
int ans[100][100];

int main()
{
	int H, W, N;
	int color = 1;
	int painted = 0;
	bool forward = true;

	cin >> H >> W >> N;
	rep(i, N) cin >> a[i];

	rep(i, H) {
		if (forward) {
			rep(j, W) {
				ans[i][j] = color;
				painted++;
				if (painted == a[color - 1]) {
					painted = 0;
					color++;
				}
			}
			forward = false;
		}
		else {
			rrep(j, W) {
				ans[i][j] = color;
				painted++;
				if (painted == a[color - 1]) {
					painted = 0;
					color++;
				}
			}
			forward = true;
		}
	}

	rep(i, H) {
		cout << ans[i][0];
		rep1(j, 1, W - 1) {
			cout << " " << ans[i][j];
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){ 
    int a, b, c; cin >> a >> b >> c;
    set<int> st; st.insert(a); st.insert(b); st.insert(c);
    cout << st.size() << ln;
}


Measured memory_bytes: 256
# python 3.4.3
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# library
# -------------------------------------------------------------



# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = 0
for i in range(N):
    ans += max(0, V[i]-C[i])

print(ans)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
  #define REP(i, n) for(int i = 0;i < n;i++)
 #define REPR(i, n) for(int i = n;i >= 0;i--)
 #define FOR(i, m, n) for(int i = m;i < n;i++)
  int N;
  cin >> N;
  int times[N];
  int totalTime = 0;
  REP(i,N){
  	cin >> times[i];
    totalTime += times[i];
  }
  int M;
  cin >> M;
  int P[M],X[M];
  REP(i,M){
  	cin >> P[i] >> X[i];
  }
  REP(i,M){
  	cout << totalTime - times[P[i]-1] + X[i] << endl;
  }
}

Measured memory_bytes: 256
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(__,v.size()){rep(_,v[__].size())cout<<" "<<v[__][_];cout<<endl;}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

signed main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	int sum=0;
	rep(i,n)sum+=in[i];
	int it,mi=inf;
	rep(i,n){
		int sa=abs(sum-in[i]*n);
		if(sa<mi){
			mi=sa;
			it=i;
			
		}
	}
	cout<<it<<endl;
}


















Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>

using namespace std;

int main(){
    int L, R, d;
    cin >> L >> R >> d;
    int cnt=0;
    for(int i=L;i<=R;i++){
        if(i % d == 0){
            cnt ++;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void){
    int K,A,B,a,b,ans;
    
    scanf("%d",&K);
    scanf("%d",&A);
    scanf("%d",&B);
    
    b=B/K;
    a=A/K;
    ans=b-a;
    
    if(A%K==0){
        ans++;
    }
    
    if(ans>0){
        printf("OK\n");
    }else{
        printf("NG\n");
    }
    
    return 0;
}

Measured memory_bytes: 2084
<?php
  $input = explode(' ', fgets(STDIN));

  $a = (int)$input[0];
  $b = (int)$input[1];

  $ans = -1;
  for($i = 1; $i < (100 * 100); $i += 1) {
    $aAns = floor($i * 0.08) == $a;
    $bAns = floor($i * 0.1) == $b;
    if($aAns && $bAns) {
      $ans = $i;
      break;
    }
  }

  printf("%s\n", $ans);
?>


Measured memory_bytes: 4732
N, K = map(int, input().split())
x, y, c = [None] * N, [None] * N, [None] * N
KK = 2 * K
table = [[0] * (KK+1) for i in range(KK+1)]

for i in range(N):
    x[i], y[i], c[i] = input().split()
    x[i], y[i] = int(x[i]), int(y[i])
    if c[i] == 'W':
        x[i] += K
        c[i] = 'B'
    x[i] %= KK
    y[i] %= KK
    table[y[i]+1][x[i]+1] += 1

for i in range(KK+1):
    for j in range(KK):
        table[i][j+1] += table[i][j]
for i in range(KK):
    for j in range(KK+1):
        table[i+1][j] += table[i][j]

def s(x1, x2, y1, y2):
    global table, KK
    MOD = KK + 1
    x1 = x1 % MOD + x1 // MOD
    y1 = y1 % MOD + y1 // MOD
    x2 = x2 % MOD + x2 // MOD
    y2 = y2 % MOD + y2 // MOD
    x11 = x1
    x21 = 0
    y11 = y1
    y21 = 0
    if x1 < x2:
        x12 = x2
        x22 = 0
    else:
        x12 = KK
        x22 = x2
    if y1 < y2:
        y12 = y2
        y22 = 0
    else:
        y12 = KK
        y22 = y2
    f = lambda _x1, _x2, _y1, _y2: \
            table[_y2][_x2] - table[_y2][_x1] \
            - table[_y1][_x2] + table[_y1][_x1]
    # print('x11: %d, x12: %d, y11: %d, y12: %d' % (x11, x12, y11, y12))
    # a1 = f(x11, x12, y11, y12)
    # print('x21: %d, x22: %d, y11: %d, y12: %d' % (x21, x22, y11, y12))
    # a2 = f(x21, x22, y11, y12)
    # print('x11: %d, x12: %d, y21: %d, y22: %d' % (x11, x12, y21, y22))
    # a3 = f(x11, x12, y21, y22)
    # print('x21: %d, x22: %d, y21: %d, y22: %d' % (x21, x22, y21, y22))
    # a4 = f(x21, x22, y21, y22)
    # print(a1, a2, a3, a4)
    return f(x11, x12, y11, y12) + f(x21, x22, y11, y12) \
            + f(x11, x12, y21, y22) + f(x21, x22, y21, y22)

ans = 0
for i in range(KK):
    for j in range(K):
        tmp = s(i, i+K, j, j+K)
        ni, nj = i + K, j + K
        tmp += s(ni, ni+K, nj, nj+K)
        # print('tmp: %d' % tmp)
        ans = max((ans, tmp))
print(ans)


Measured memory_bytes: 98140
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
#define maxn 200005
const ll mod=1e9+7;
using namespace std;
ll fac[maxn];
ll h,w,a,b;

ll quickpow(ll a,ll b)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=ans*a%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans%mod;
}
void init()
{
    fac[0]=fac[1]=1;
    for(int i=2;i<maxn;i++)
        fac[i]=(fac[i-1]*1LL*i)%mod;
}
ll getc(ll n,ll m)
{
    if(m==0||m==n)
        return 1;
    ll res=fac[n];
 res=res*quickpow(fac[n-m],mod-2)%mod;
 res=res*quickpow(fac[m],mod-2)%mod;
 return res;
}
int main()
{
    scanf("%lld%lld%lld%lld",&h,&w,&a,&b);
    init();
    ll res;
    ll ans=0;
    for(ll i=b+1;i<=w;i++)
    {
        res=getc(i-1+h-a-1,h-a-1)*getc(a-1+w-i,a-1)%mod;
        ans=(ans%mod+res%mod)%mod;
    }
    printf("%lld\n",ans);
    return 0;

}


Measured memory_bytes: 1792
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
const int dm = 1 << 17;
char *dn = cn, * di = dn, * owad = dn + dm - 20;
inline void putint(int X) {
	if (owad < di) {
		fwrite(dn, 1, di - dn, stdout);
		di = dn;
	}
	int dig = 1;
	if (X >= 10000) {
		if (X >= 100000) dig = 6;
		else dig = 5;
	}
	else {
		if (X >= 1000) dig = 4;
		else if (X >= 100) dig = 3;
		else if (X >= 10) dig = 2;
	}
	rep1(i, dig) {
		di[dig - i] = '0' + X % 10;
		X /= 10;
	}
	di[dig] = '\n';
	di += dig + 1;
}
const int bm = 500001;
int BIT[bm];
void add(int A) {
	while (A > 0) {
		BIT[A]++;
		A -= A & -A;
	}
}
int query(int A) {
	int ret = 0;
	while (A < bm) {
		ret += BIT[A];
		A += A & -A;
	}
	return ret;
}
int L[500001], R[500001], C[500001], ne[500001];
int are[500001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), Q = getint();
	rep1(i, N) C[i] = getint();
	rep1(i, Q) {
		L[i] = getint();
		int r = getint();
		ne[i] = R[r];
		R[r] = i;
	}
	rep1(i, N) {
		if (are[C[i]]) add(are[C[i]]);
		are[C[i]] = i;
		
		for (int r = R[i]; r; r = ne[r]) {
			L[r] = i - L[r] - query(L[r]) + 1;
		}
	}

	rep1(i, Q) putint(L[i]);
	fwrite(dn, 1, di - dn, stdout);


	Would you please return 0;
}

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

int main(){
  int N;
  float ans = 0;
  
  cin >> N;
  for (int i=0;i<N;i++) {
	float x;
	string u;
	cin >> x >> u;
	if (u == "JPY") {
	  ans += x;
	} else {
	  ans += (x * 380000.0);
	}
  }

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#define SIZE 100005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

vector <int> vec[SIZE];
int deg[SIZE],ord[SIZE];

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n-1+m;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);a--,b--;
		deg[a]++;
		vec[b].push_back(a);
	}
	queue <int> que;
	for(int i=0;i<n;i++)
	{
		if(deg[i]==0)
		{
			que.push(i);
		}
	}
	int sz=0;
	while(!que.empty())
	{
		int v=que.front();que.pop();
		ord[v]=sz++;
		for(int j=0;j<vec[v].size();j++)
		{
			int to=vec[v][j];
			deg[to]--;
			if(deg[to]==0) que.push(to);
		}
	}
	for(int i=0;i<n;i++)
	{
		int mn=SIZE,pos=-1;
		for(int j=0;j<vec[i].size();j++)
		{
			int to=vec[i][j];
			if(mn>ord[to])
			{
				mn=ord[to];
				pos=to;
			}
		}
		printf("%d\n",pos+1);
	}
	return 0;
}


Measured memory_bytes: 7040
N = int(input())
a = list(map(int,(input().split())))
MOD = 10**9 + 7
a.sort()

ans = []
if N%2 == 0:
    for i in range(N):
        ans.append(2*(i//2)+1)
    if ans == a:
        print(pow(2,N//2,MOD))
    else:
        print(0)
else:
    for i in range(N):
        ans.append(2*((i+1)//2))
    if ans == a:
        print(pow(2,(N-1)//2,MOD))
    else:
        print(0)

Measured memory_bytes: 55916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = INT_MAX / 2;
int main() {
    int N, X, Y; cin >> N >> X >> Y;
    X--; Y--;
    vector<vector<int>> dist(N, vector<int>(N, INF));
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            dist[i][j] = abs(j - i);
        }
        
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            dist[i][j] = min(dist[i][j], dist[i][X] + 1 + dist[Y][j]);
        }
    }

    vector<int> ans(N,0);
    for (int i = 0; i < N; i++)
    {
        for (int j = i+1; j < N; j++)
        {
            ans[dist[i][j]]++;
        }
    }
    for (int i = 1; i < N; i++)
    {
        cout << ans[i] << endl;
    }

}

Measured memory_bytes: 16000
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int h = a / 3600;
		int m = (a % 3600) / 60;
		int s = (a % 3600) % 60;
		System.out.println(h + ":" + m +":" + s);
	}

}

Measured memory_bytes: 17352
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> A >> B >> C;
    if (B * C >= A) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
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<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;
 
  int sz;
  vector< Monoid > seg;
 
  const F f;
  const Monoid M1;
 
  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }
 
  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }
 
  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
 
  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
 
  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }
 
  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    SegmentTree<int> seg(n, [](int a, int b) { return min(a, b); }, INT_MAX);
    rep(i, 0, q) {
      int com, x, y;
      cin >> com >> x >> y;
      if (com)
        cout << seg.query(x, y+1) << endl;
      else 
        seg.update(x, y);
    }
    return 0;
}




Measured memory_bytes: 3720
// avvinci - sem_7 
// #include"prettyprint.hpp"
#include<bits/stdc++.h>
using namespace std;

typedef pair<long long int , long long int> P;

#define mod 1000000007 
#define pb push_back
#define mk make_pair
#define fs first
#define sc second
#define ll long long int
#define fr(it,st,en) for(it=st;it<en;it++)
#define all(container) container.begin(),container.end()
#define INP ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ws(x) cout << #x << " = " << x << endl
#define sz(x)  (ll)x.size()
#define N 1000004

const long long infl = 1e18+5;

ll n,m,k,q,x,y,f,val,t=1,i,j;
ll ind = -1,cnt,sz,sm,ans,mx = -1,mn = infl ;
ll a ,b,c,d ;

int main(){
INP
if (fopen("inp.txt", "r")) {
    freopen("myfile.txt","w",stdout);
    freopen("inp.txt", "r", stdin);
}

cin>>a>>b>>c>>d ; cin>>n ;
ans =  min (min(a*8 , b*4 ), min( c*2 , d) ) ; 
ans *= n / 2 ; 
if( n&1 ){
  ans += min(a*4 , min(b*2 ,c )) ; 
}
cout<<ans; 


return 0 ;
}

Measured memory_bytes: 256
import java.util.Scanner;
//072C
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
		int n =sc.nextInt();
		int max =0;
		int min =100002;
		int ans=0;
		int[] numbers =new int[100002];
		for (int i=0;i<n;i++) {
			numbers[sc.nextInt()] ++;
		}
		for (int i=0;i<100000;i++) {
			int count=0;
			count=numbers[i]+numbers[i+1]+numbers[i+2];
			ans =Math.max(count, ans);
		}
		System.out.println(ans);
		
		//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
	}
}

Measured memory_bytes: 50436
#include <cstdio>
#include <vector>
#include <cstring>
using namespace std;
using Graph = vector< vector<int> >;

const int S = 60;
int used[S], ord[S], low[S], ans = 0, it = 0;

void dfs(Graph &G, int cur=0, int par=-1) {
    used[cur] = true;
    ord[cur] = low[cur] = it++;

    for(auto to : G[cur]) {
        if(to == par) continue;
        if(!used[to]) dfs(G, to, cur);
        low[cur] = min(low[cur], low[to]);
    }
}

void get_ans(Graph &G, int cur=0, int par=-1) {
    used[cur] = true;
    for(auto to : G[cur]) {
        if(to == par || used[to]) continue;
        if(ord[cur] < low[to]) ans++;
        get_ans(G, to, cur);
    }
}

int main() {
    int N, M; scanf("%d%d", &N, &M);
    Graph G(N);
    for(int i=0; i<M; i++) {
        int a, b; scanf("%d%d", &a, &b);
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(G);
    memset(used, false, sizeof(used));
    get_ans(G);
    printf("%d\n", ans);
    return 0;
}

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

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

  if (N.at(0) == N.at(1) && N.at(1) == N.at(2))
  {
    cout << "Yes" << endl;
  }
  else if (N.at(1) == N.at(2) && N.at(2) == N.at(3))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int k, t;
    cin >> k >> t;
    vector<int> a(t);
    int csum = 0;
    int cmax = 0;
    rep(i, t){
        cin >> a[i];
        csum += a[i];
        cmax = max(cmax, a[i]);
    }
    int diff = csum - cmax;
    //diff*2+1日まではOK

    int ans;
    if (diff*2 + 1 > k){
        ans = 0;
    } else {
        ans = k - (diff*2+1);
    }

    cout << ans << endl;
}



Measured memory_bytes: 256