akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int N, K;
    cin >> N >> K;
    lint ret = 0;
    FOR(b, 1, N + 1) {
        // a % b >= K, 1 <= a <= N
        if (b - 1 < K)
            continue;

        // [1 ... b] has (b - K) candidates.
        ret += (N / b) * (b - K);
        if (N % b > 0) {
            // 1 .. N % b
            if (N % b >= K) {
                if (K > 0)
                ret += N % b - K + 1;
                else
                    ret += N % b;
            }
        }
    }

    cout << ret << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 508
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>

using namespace std;

int main() {
	double a, b, c,S,L,h;

	cin >> a >> b >> c;

	c = c * M_PI / 180;

	S = ((a * b) * sin(c)) / 2;
	L = a + b + sqrt(pow(a, 2) + pow(b, 2) - (2 * a * b * cos(c)));
	h = b * sin(c);
	cout.precision(15);
	cout << S << endl;
	cout << L << endl;
	cout << h;

	return 0;
}

Measured memory_bytes: 1328
#include <iostream>

using namespace std;

int main()
{
	uint64_t H, W;
	cin >> H;
	cin >> W;
	uint64_t answer;
	if ((H == 1) || (W == 1)) {
		answer = 1;
	}
	else {
		if (H & 1) {
			if (W & 1) {
				answer = (((H - 1) / 2) * (W - 1)) + ((H + W) / 2);
			}
			else {
				answer = (((H - 1) / 2) * W) + (W / 2);
			}
		}
		else {
			if (W & 1) {
				answer = (((W - 1) / 2) * H) + (H / 2);
			}
			else {
				answer = (H * (W / 2));
			}
		}
	}
	cout << answer << 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>
#include <string>
#include <cmath>
#include <cassert>

#define SIZE 100005
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

using namespace std;


int main()
{	
	ll N;
	scanf("%lld", &N);
	ll b[N];
	for(ll i=0;i<N;i++){
		scanf("%lld", &b[i]);
	}
	ll answer[N];
	ll sonzai=1;
	ll count=0;
	ll soeji;
	ll tansaku;
	for(ll j=N-1;j>=0;j--){	//jは残っている配列の長さだと思えばよい
		soeji=j;
		tansaku=1;
		
		while((sonzai==1)&&(tansaku==1)&&(soeji>=0)){
		
			if(b[soeji]>soeji+1){
				sonzai=0;
			}
			else{
				if(b[soeji]==soeji+1){
					answer[count]=b[soeji];
					count++;
					for(ll k=soeji;k<j;k++)
					{
						b[k]=b[k+1];
					}
					tansaku=0;
				//	printf("%lld %lld %lld %lld \n", soeji, b[0], b[1], b[2]);
				}
				else
				{
					soeji--;
				}
			}
		}
	}
	
	if(sonzai==0)
	{
		printf("%lld", sonzai-1);
	}
	else
	{
		for(ll i=N-1;i>=0;i--)
		{
			printf("%lld \n", answer[i]);
		}
	}
}


Measured memory_bytes: 128
n = int(input())
s = input()
ans = 0
for i in range(1,n) :
	cnt = 0
	l = s[:i]
	r = s[i:]
	for j in l :
		if j in r :
			cnt += 1
			r = r.replace(j, '')
	ans = max(cnt ,ans)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#define int long long

signed main(){
	int N, M, d;
	scanf("%lld%lld%lld", &N, &M, &d);
	printf("%.12lf\n", (M - 1) * (d == 0 ? 1 : 2) * (N - d) / (double)(N * N));
	return 0;
}

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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1LL<<62)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int cnt = 0, n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a % 2 == 1) cnt++;
  }
  if (cnt % 2 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        s: String
    }
    let mut ans = vec![];
    for c in s.chars() {
        if c == '0' || c == '1' {
            ans.push(c);
        } else {
            ans.pop();
        }
    }
    for c in ans{
        print!("{}",c);
    }
    println!();
}


Measured memory_bytes: 2188
/**
 * @author torith
 * @date 2018-11-03
 */
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main(){
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    ll ans = 0;
    for (int i = 0; i < S.size(); ++i) {
        int j = 1;
        while(i + j <= S.size()){
            int left = pow(2, max(0, i - 1));
            int right = pow(2, max(0, (int)S.size() - i - j - 1));
            ans += stoll
              (S.substr(i, j)) * left * right;
            j++;
        }
    }
 
    cout << ans << "\n";
 
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> M >> T;
	vector< int > r(T);
	rep(i, T) {
		cin >> r[i];
		--r[i];
	}
	vector< vector< int > > G(N, vector< int >(N, INF));
	rep(i, M) {
		int A, B, C;
		cin >> A >> B >> C;
		--A;
		--B;
		chmin(G[A][B], C);
		chmin(G[B][A], C);
	}
	rep(k, N) rep(i, N) rep(j, N) {
		chmin(G[i][j], G[i][k] + G[k][j]);
	}
	vector< int > p(T);
	rep(i, T) p[i] = i + 1;
	int ans = LINF;
	do {
		int tmp = 0;
		rep(i, T - 1) tmp += G[r[p[i] - 1]][r[p[i + 1] - 1]];
		chmin(ans, tmp);
	} while (next_permutation(p.begin(), p.end()));
	cout << ans << endl;
	return 0;
}

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

int main() {
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<ll> a(x);
  rep(i, x) cin >> a[i];
  vector<ll> b(y);
  rep(i, y) cin >> b[i];
  vector<ll> c(z);
  rep(i, z) cin >> c[i];

  priority_queue<ll> q;
  rep(i, x) {
    rep(j, y) { q.push(a[i] + b[j]); }
  }

  priority_queue<ll> q2;
  rep(i, k) {
    if (q.empty()) break;
    ll ab = q.top();
    q.pop();
    rep(j, z) { q2.push(ab + c[j]); }
  }

  rep(i, k) {
    ll ans = q2.top();
    q2.pop();
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 42728
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vll2 = vector<vector<ll>>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
P v[200000];
ll sum, res, n, d, a;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> d >> a;
    for (int i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
        v[i].second = v[i].second / a + (v[i].second % a > 0);
    }
    sort(v, v + n);
    queue<P> q;
    for (int i = 0; i < n; i++) {
        while (!q.empty() && q.front().first < v[i].first) {
            sum -= q.front().second;
            q.pop();
        }
        ll t = max(0LL, v[i].second - sum);
        sum += t;
        res += t;
        q.push(P(v[i].first + 2LL * d, t));
    }
    cout << res << '\n';
}


Measured memory_bytes: 6656
#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>;

int main() {
  string S;
  cin>>S;
  
  string ans="";
  
  for(int i=0;i<S.size();i++){
    if(S[i]=='0'){
      ans.push_back('0');
    }else if(S[i]=='1'){
      ans.push_back('1');
    }else if(S[i]=='B' && ans.size()>0){
      ans.pop_back();
    }
  }
 
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    reverse(arr.begin(), arr.end());
    vector<int> LIS = {};
    for(int i = 0; i < n; i++) {
        auto it = upper_bound(LIS.begin(), LIS.end(), arr[i]);
        if (it == LIS.end())
            LIS.push_back(arr[i]);
        else
            *it = arr[i];
    }
    cout << LIS.size() << endl;
    return 0;
}


Measured memory_bytes: 1276
#include<iostream>
using namespace std;
int main(){
    long long int L,R;
    int min=2019;
    cin>>L>>R;
    if(R-L<2018){
        for(long long int i=L;i<=R;i++){
            for(long long int j=L;j<=R;j++){
                if(j==i){
                    continue;
                }
                if(i*j%2019<min){
                    min=i*j%2019;
                }
            }
        }
        cout<<min<<endl;
    }
    else{
        cout<<0<<endl;
    }
    return 0;
}


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

using namespace std;

string replaceAll(string replacedStr, string from, string to) {
    unsigned int pos = replacedStr.find(from);
    int toLen = to.length();

    if (from.empty()) {
        return replacedStr;
    }

    while ((pos = replacedStr.find(from, pos)) != std::string::npos) {
        replacedStr.replace(pos, from.length(), to);
        pos += toLen;
    }
    return replacedStr;
}

int main() {
    string s;
    cin >> s;
    long long count = 0;
    for(long long i = 0; i < s.size() - 1; i++){
        if(s[i] == 'B' && s[i + 1] == 'C'){
            s[i] = 'D';
            s[i + 1] = 'D';
        }
    }
    string S[200020];
    long long tmpC = 0;
    for(long long i = 0; i < s.size();i++){
        if(s[i] == 'B' || s[i] == 'C'){
            tmpC++;
            continue;
        }
        S[tmpC] = S[tmpC] + s[i];
    }

    for(long long i = 0; i < s.size(); i++){
        long long tmp = 0;
        long long c = 0;
        for(long long j = 0; j < S[i].size(); j++){
            if(S[i][j] == 'A'){
                tmp++;
            }else{
                c += tmp;
                j++;
            }
        }
        count += c;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 4356
//Author- Vaibhav singh
//will be expert soon 
// *#####################################################################################*
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=n;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define mp make_pair
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define re return 0;
// *#######################################################################################*
// *#########################################################################################*
    //      ll ans=0,b[5000005]={0},a[5000005],i,n,x=0;                
    

int main()
{
      
      fast
    
   
    
    ll a,c;
    char b;
    cin>>a>>b>>c;
    ll z=0;
    if(b=='+')
    {
        z=a+c;
    }
    
    else
    {
        z=a-c;
    }
    
        o(z)
        
        
        
	re
}

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

ll func(ll num)
{
        ll sum = 0;
        ll s = num;
        vector<ll> v;
        while (1) {
                ll amari = s % 10;
                v.push_back(amari);
                sum += amari;
                s /= 10;
                if (s == 0) break;
        }
        return sum;
}

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

        ll ans = 0;
        ll A, B;
        ll min = 0;
        for (int i = 1; i < N; ++i) {
                A = i;
                B = N - i;
                ll tmp = func(A) + func(B);
//              cout << "A = " << A << ",B = " << B << ",tmp= " << tmp << endl;
                if (i == 1) {
                        min = tmp;
                }
                else if (min > tmp) {
                        min = tmp;
                }


        }

        cout << min << endl;

}


Measured memory_bytes: 3564
n = gets.to_i
cs, ss, fs = [], [], []
(n-1).times do
  c, s, f = gets.split.map(&:to_i)
  cs << c; ss << s; fs << f
end

(0...n).each do |start|
  time = 0
  (start...(n-1)).each do |i|
    dept = (time <= ss[i]) ? ss[i] : (time.to_f / fs[i]).ceil * fs[i]
    time = dept + cs[i]
  end
  puts time
end


Measured memory_bytes: 3836
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include<algorithm>
#include <iomanip>
#include <math.h>

using namespace std;
typedef long long ll;
///定義場所///
ll i, j, k, l, m, n;
ll N, M, K, H, W, T, P;
ll MOD = 1000000007;
ll ans = 0;
//関数リスト//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
//(注)pairの型・比較する場所(first/second)は毎回変えて使用する
bool pairCompare(const pair<int ,int> firstElof, pair<int,int> secondElof)
{
	return firstElof.second < secondElof.second;
}
int Keta(ll F) {
	int keta = 1;
	while (F/10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
//////////////

int main() {
	cin >> N;
	vector<int> D(N);
	for (i = 0; i < N; i++) {
		cin >> D[i];
	}
	sort(D.begin(), D.end());
	cout << D[N / 2] - D[(N / 2) - 1];
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main () {
	char str[3][3];
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			cin >> str[i][j];
		}
	}
	
	for(int i = 0; i < 3; i++){
		cout << str[i][i];
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pi M_PI
#define inf 1<<30
#define eps (1e-11)
#define MAX 700
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;

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

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

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

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}

struct edge{ 
  int to,cap;
  double cost;
  int rev;
};

int v;
vector<edge> e[MAX];
double h[MAX];
double dist[MAX];
int prevv[MAX],preve[MAX];

void add_edge(int from,int to,int cap,double cost){
  e[from].push_back((edge){to,cap,cost,(int)e[to].size()});
  e[to].push_back((edge){from,0,-cost,(int)e[from].size()-1});
}

typedef pair<int,double> P;

double min_cost_flow(int s,int t,int f){
  double res=0.0;
  fill(h,h+v,0);
  while(f>0){
    priority_queue<P,vector<P>,greater<P> > pq;
    fill(dist,dist+v,inf);
    dist[s]=0;
    pq.push(P(0,s));
    while(pq.size()){
      P p=pq.top();
      pq.pop();
      int u=p.second;
      if(dist[u]-p.first<-eps)continue;
      for(int i=0;i<e[u].size();i++){
        edge &E=e[u][i];
        if(E.cap>0 && (dist[u]+E.cost+h[u]-h[E.to])-dist[E.to]<-eps){
          dist[E.to]=dist[u]+E.cost+h[u]-h[E.to];
          prevv[E.to]=u;
          preve[E.to]=i;
          pq.push(P(dist[E.to],E.to));
        }
      }
    }
    if(dist[t]==inf)return -1;
    for(int i=0;i<v;i++)h[i]+=dist[i];

    int d=f;
    for(int u=t;u!=s;u=prevv[u]){
      d=min(d,e[prevv[u]][preve[u]].cap);
    }
    f-=d;
    res+=(double)d*h[t];
    for(int u=t;u!=s;u=prevv[u]){
      edge &E=e[prevv[u]][preve[u]];
      E.cap-=d;
      e[u][E.rev].cap+=d;
    }
  }
  return res;
}

int main()
{
  int n;
  vector<Segment> vs,vt;
  Point st;
  double ans=0.0;

  cin>>n;
  cin>>st.x>>st.y;
  for(int i=0;i<n;i++){
    Point a,b;
    cin>>a.x>>a.y>>b.x>>b.y;
    Segment s(a,b);
     vt.push_back(Segment(a,b));
    ans+=abs(b-a);
  }

  int s=vt.size()*2;
  int t=s+1;
  v=t+1;
  for(int i=0;i<vt.size();i++){
    for(int j=0;j<vt.size();j++){ 
      add_edge(i,j+vt.size(),1,abs(vt[i].p2-vt[j].p1));
    }
  }
  for(int i=0;i<vt.size();i++){
    add_edge(s,i,1,0);
    add_edge(i+vt.size(),t,1,0);
  }
  printf("%.10f\n",ans+min_cost_flow(s,t,vt.size()));
  return 0;
}

Measured memory_bytes: 8496
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{

	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		String input = reader.readLine();
		String str[] = input.split(" ");
		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);

		if (a < b) {
			System.out.println("a < b");
		} else if (a > b) {
			System.out.println("a > b");
		} else if (a == b) {
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 24252
def cal_cost(co, h, i, j):
    return co + abs(h[i]-h[j])

n, k = map(int, input().split())
h = [int(i) for i in input().split(" ")]
lis = [0 for i in range(n)]
for i in range(1, n):
    a = min([cal_cost(lis[i-j], h, i-j, i) for j in range(1, k+1) if j<=i])
    lis[i] = a
print(lis[-1])

Measured memory_bytes: 55520
#include<bits/stdc++.h>
using namespace std;
int a[3][3];
bool b[3][3];
bool check(){
  for(int i=0;i<3;i++) if(b[i][0] && b[i][1] && b[i][2]) return(true);
  for(int i=0;i<3;i++) if(b[0][i] && b[1][i] && b[2][i]) return(true);
  if(b[0][0] && b[1][1] && b[2][2]) return(true);
  if(b[2][0] && b[1][1] && b[0][2]) return(true);
  return(false);
}
  
int main(){
  memset(b,false,sizeof b);
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++) cin>>a[i][j];
  int n;
  cin>>n;
  while(n--){
    int x;
    cin>>x;
    for(int i=0;i<3;i++) for(int j=0;j<3;j++) if(a[i][j]==x) b[i][j]=true;
  }
  if(check()) cout<<"Yes";
  else cout<<"No";
}
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#define ll long long

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

int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    int ans = 0;
    for (auto i : s)
    {
        if (i == 'R')
        {
            cnt++;
        }
        else
        {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    cout << ans << endl;
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int a[3] = {0};

    rep(i, s.size()) a[s[i] - 'a']++;
    sort(a, a + 3);

    if (a[2] - a[0] <= 1)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 200010;

int n, m, k;
char s[N], t[N];

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif

  scanf("%d%d%d", &n, &m, &k);
  int x, y;
  scanf("%d%d", &x, &y);
  scanf("%s%s", s + 1, t + 1);
  int l = 1, r = n, d = 1, u = m;
  for (int i = k; i; --i) {
    if (t[i] == 'D')
      l = max(1, l - 1);
    else if (t[i] == 'U')
      r = min(n, r + 1);
    else if (t[i] == 'R')
      d = max(1, d - 1);
    else
      u = min(m, u + 1);
    if (s[i] == 'U')
      ++l;
    else if (s[i] == 'D')
      --r;
    else if (s[i] == 'L')
      ++d;
    else
      --u;
    if (l > r || d > u)
      break;
  }
  //LOG("%d %d %d %d\n", l, r, d, u);
  if (l <= x && x <= r && d <= y && y <= u)
    puts("YES");
  else
    puts("NO");

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define float long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define endl '\n'
#define pii pair<int, int>
#define min3(a,b,c) min(a, min(b, c))
#define max3(a,b,c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define fill(a,b) memset(a, b, sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

signed main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int n,m,k; cin>>n>>m>>k;
    string mat[n];
    int ans=0;
    for(int i=0;i<n;i++) cin>>mat[i];
    for(int mi=0;mi<(1<<n);mi++){
        for(int mj=0;mj<(1<<m);mj++){
            int cnt=0;
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    if(mat[i][j]=='#' && ((1<<i)&mi)==0 && ((1<<j)&mj)==0) cnt++;
                }
            }
            if(cnt==k) ans++;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
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;
}

#ifdef DEBUG
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
#else
template <class T, class... Args>
void debug(const T &x, const Args &... args) {}
template <class T> void debugVector(const vector<T> &v) {}
#endif

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

void solve() {
    int N;
    cin >> N;
    vector<ll> a(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    string s;
    cin >> s;
    reverse(ALL(a));
    reverse(ALL(s));
    vector<ll> base;
    for(int i = 0; i < N; i++) {
        ll v = a[i];
        sort(RALL(base));
        for(ll e : base) {
            chmin(v, v ^ e);
        }
        if(v) {
            if(s[i] == '0') {
                base.emplace_back(v);
            } else {
                cout << 1 << "\n";
                return;
            }
        }
    }
    cout << 0 << "\n";
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t;
    cin >> t;
    for(int i = 0; i < t; i++) {
        solve();
    }
}

Measured memory_bytes: 3628
(let* ((n (read))
       (ai (loop repeat n
                 collect (read)))
       (hash (make-hash-table))
       (max 0))
  (mapc (lambda (x)
          (setf (gethash x hash) (1+ (gethash x hash 0)))
          (setf (gethash (1+ x) hash) (1+ (gethash (1+ x) hash 0))) 
          (setf (gethash (1- x) hash) (1+ (gethash (1- x) hash 0)))) 
        ai)
  (maphash (lambda (key value)
             (when (> value max)
               (setf max value)))
           hash)
  (format t "~A~%" max))

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

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

  vi a(n);
  rep(i, 0, n) cin >> a[i];

  vector<multiset<int>> cnt(m);
  rep(i, 0, n){
    cnt[a[i]%m].insert(a[i]);
  }

  int ans = sz(cnt[0])/2;
  rep(i, 1, m/2+1){
//    cout << i-1 << " " << ans << endl;
    if(m%2 == 0 and i == m/2){
      ans += sz(cnt[m/2])/2;
      continue;
    }

    int t = sz(cnt[i]) - sz(cnt[m-i]);
    if(t < 0){
      t = -t;
      swap(cnt[i], cnt[m-i]);
    }

    ans += sz(cnt[m-i]);

    int k = 2, prev = -1;
    for(int j : cnt[i]){
      if(k > t) break;
      if(prev == j){
        ans += 1;
        k += 2;
        prev = -1;
      }else{
        prev = j;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
  int A;
  cin >> A;
  while (A >= 10) {
    A %= 10;
  }
  if (A == 3)
    cout << "bon" << endl;
  else if (A == 0 || A == 1 || A == 6 || A == 8)
    cout << "pon" << endl;
  else
    cout << "hon" << endl;
}


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

using namespace std;

int main(void)
{
    string s,k;

    cin >> s;
    cin >> k;

    if(k.substr(0,s.length()) == s) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int R, D, X;
    cin >> R >> D >> X;
    rep(i, 10) {
        X = R * X - D;
        printf("%d\n", X);
    }
    return 0;
}

Measured memory_bytes: 3652
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
bool ispallindrome(string s)
{
    string x=s;
    reverse(all(x));
    if(x==s)
    {
        return true;
    }
    return false;
}
int main()
{
fast;
string s;
cin>>s;
ll n=s.size();
ll len=(n-1)/2;
string a=s.substr(0,len);
string b=s.substr(len+1,len);
if(ispallindrome(s)&&ispallindrome(a)&&ispallindrome(b))
{
    cout<<"Yes"<<endl;
}else
{
    cout<<"No"<<endl;
}

return 0;
}


Measured memory_bytes: 256
def dfs(i,val):
    global s,n,sum
    val+=s[i-1]
    if i==n:
        sum+=eval(val)
        return
    dfs(i+1,val+"+")
    dfs(i+1,val)
s=input()
n=len(s)
val = ""
sum=0
dfs(1,val)
print(sum)

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

const int INF=1001001001;
vector<int>to[100005];

int main(){
   int n,m;
   cin>>n>>m;
   rep(i,m){
       int a,b;
       cin>>a>>b;
       --a;  --b;
       to[a].push_back(b);
       to[b].push_back(a);
    }
    queue<int>q;
    vector<int>dist(n,INF);
    vector<int>pre(n,-1);
    dist[0]=0;
    q.push(0);
    while(!q.empty()){
        int v=q.front(); q.pop();
        for(int u : to[v]){
            if(dist[u]!=INF)continue;
            dist[u]=dist[v]+1;
            pre[u]=v;
            q.push(u);

        }
    }
    cout<<"Yes"<<endl;
    rep(i,n){
        if(i==0)continue;
        int ans=pre[i];
        ans++;
        cout<<ans<<endl;
    }
    return 0;      
}

Measured memory_bytes: 10616
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

//H-そのまま
//D-逆

int main(){
    string a, b;
    cin>>a>>b;
    cout << (a[0]=='H'?b[0]:(b[0]=='H'?'D':'H')) << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  int H[N];
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    cin >> H[i];
    for (int j = i; j >= 0; j--) {
      if (H[i] < H[j]) {
        break;
      }
      if (j == 0) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <vector>
#include <queue>
#include <bitset>
#include <cmath>
#include <time.h>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <deque>
#include <iomanip>
#include <complex>
//#include <ext/rope>

using namespace std;
//using namespace __gnu_cxx;

//defines
typedef long long ll;
typedef long double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define fast_read cin.sync_with_stdio(0)
#define PREX(number) cout << fixed << setprecision(number)
#define nul point(0, 0)
#define random srand(time(NULL))
#define rand_int abs((rand() << 15) | rand())
#define str_to_int(stroka) atoi(stroka.c_str())
#define str_to_ll(stroka) atoll(stroka.c_str())
#define str_to_double(stroka) atof(stroka.c_str())
#define what_is(x) cerr << #x << " is " << x << endl
#define solve_system int number; cin >> number; forn(i, 0, number) solve()
#define solve_system_scanf int number; scanf("%d", &number); forn(i, 0, number) solve()

//easy functions
template< typename T >
T gcd(T a, T b) { return a ? gcd(b % a, a) : b; }
template< typename T >
T lcm(T a, T b) { return (a / gcd(a, b)) * b; }
bool is_down(char x) { return ('a' <= x && x <= 'z'); }
bool is_upper(char x) { return ('A' <= x && x <= 'Z'); }
bool is_digit(char x) { return ('0' <= x && x <= '9'); }

//constants
const ld pi = 3.141592653589793238462643383279;
const ld log23 = 1.58496250072115618145373894394781;
const ld eps = 1e-8;
const ld zero = 0;
const ll INF = 1e18;
const int COUT = 30;
const int prost = 239;
const ll prost64 = 239;
const int two = 2;
const int thr = 3;
const ll sr = 31;
const int MOD = 1e9 + 7;
const int BIG = 2 * 1e9 + 1;
const int alf = 26;
const int MAX_N = 2 * 1e5 + 10;
const int MAX_M = 1011;
const int MAX_T = (1 << 20);
const int BLOCK = trunc(sqrt(MAX_N)) + 1;
const int MAX_LOG = 19;
const int km = (1 << 18);
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int bit_max = 32;
const int dig = 10;
const string str_alf = "abcdefghijklmnopqrstuvwxyz";
const string str_alf_big = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int bt = 31;

// Code starts here

int t[MAX_N], n, x[MAX_N], y[MAX_N];

int main()
{   /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif /**/
    fast_read;
    cin >> n;
    x[0] = 0;
    y[0] = 0;
    t[0] = 0;
    for (int i = 0; i < n; i++)
        cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
    for (int i = 0; i < n; i++)
    {
        int tm = t[i + 1] - t[i];
        int be = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
        if (be > tm)
        {
            cout << "No";
            return 0;
        }
        if ((be - tm) & 1)
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


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

using namespace std;

long count = 0;
vector<int> G;
int exInsertionSort( int A[], int N, int g)
{
    if( g < 1 )
        return g;
    
    for( int i = g; i < N; i++)
    {
        int v = A[i];
        int j = i - g;
	while( j >= 0 && A[j] > v )
        {
            A[j + g] = A[j];
	    j -= g;
	    count++;
        }

        A[j + g] = v;
    }
    return 1;
}

void shellSort( int A[], int N )
{
    for( int h = 1; h <= N; h = 3 * h + 1 )
    {
        G.push_back(h);
    }

    for( int i = G.size() - 1; i >= 0; i--)
    {
        exInsertionSort( A, N, G[i] );
    }
}

int main()
{
    int N;
    int A[1000000];

    cin >> N;

    for( int i = 0; i < N; i++)
        cin >> A[i];

    shellSort( A, N );

    cout << G.size() << endl;

    for( int i = G.size() - 1; i >= 0; i-- )
    {
        cout << G[i];
	if( i )
            cout << ' ';
    }

    cout << endl;

    cout << count << endl;

    for ( int i = 0; i < N; i++ )
    {
        cout << A[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 6992
# -*- coding: utf-8 -*-

N = int(raw_input())
a = map(int, raw_input().split())

def is_odd(n):
    return True if (n%2!=0) else False

def is_s_even(n):
    return True if (n%4!=0 and n%2==0) else False

def is_w_even(n):
    return True if (n%4==0) else False

# 奇数配列p[] 4の倍数配列r[] どちらもない配列q[]
p, q, r = [], [], []
for i in range(N):
    if is_odd(a[i]):
        p.append(a[i])
    elif is_w_even(a[i]):
        r.append(a[i])
    else:
        q.append(a[i])

# 条件を満たすように並べる配列s[]
s = []
if len(p) > 0:
    s.append(p.pop())
elif len(q) > 0:
    s.append(q.pop())
else:
    s.append(r.pop())

for i in range(1,N):
    if is_odd(s[i-1]):
        if len(r) > 0:
            s.append(r.pop())
        else:
            print 'No'
            exit()
    elif is_s_even(s[i-1]):
        if len(q) > 0:
            s.append(q.pop())
        elif len(r) > 0:
            s.append(r.pop())
        else:
            print 'No'
            exit()
    else:
        if len(p) > 0:
            s.append(p.pop())
        elif len(q) > 0:
            s.append(q.pop())
        elif len(r) > 0:
            s.append(r.pop())
            
print 'Yes'


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

int main() {
	string S;
	cin >> S;
	int cnt = 1;
	string pre = S.substr(0, 1);
	for (int i = 1; i < (int)S.size(); i++) {
		string t = S.substr(i, 1);
		if (pre == t) {
			if (i == (int)S.size() - 1) break;
			t += S.at(i + 1);
			i++;
		}
		pre = t;
		cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>

int desc(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}
 

int main()
{
  int n,m;
  scanf("%d %d",&n,&m);
  int a[n];
  int sum=0;
  for(int i=0;i<n;i++) scanf("%d",&a[i]);
  qsort(a, sizeof(a) / sizeof(int), sizeof(int), desc);
  for(int j=0;j<n;j++) sum = sum + a[j];
  if(a[m-1]< (double)sum/(double)(4*m)) puts("No");
  else puts("Yes");

  return 0;
}

Measured memory_bytes: 128
import Data.List

solve' :: Int -> [Int] -> [Int]	-> [Int] -> String
solve' _ _ [] hb = unwords $ map show hb
solve' n x (y:ys) [h,b]
  | elemIndex y x == Nothing = solve' (n+1) x ys [h,b]
  | elemIndex y x == Just n = solve' (n+1) x ys [h+1,b]
  | otherwise = solve' (n+1) x ys [h,b+1]

solve :: [[Int]] -> [String]
solve [] = []
solve (x:y:xs) = solve' 0 x y [0,0] : solve xs

main = getContents >>= putStr . unlines . solve . map (map read . words) . lines

Measured memory_bytes: 4052
// う　し　た　ぷ　に　き　あ　く　ん　王　国　笑　国　民
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> e(N+1);
    vector<int> w(N+1);
    for (int i = 0; i < N; i++) {
        if(S[i] == 'E') {
            e[i+1] = e[i] + 1;
        }
        else {
            e[i+1] = e[i];
        }
    }
    for(int i = 0; i < N; i++) {
        if(S[i] == 'W') {
            w[i+1] = w[i] + 1;
        }
        else {
            w[i+1] = w[i];
        }
    }
    int ans = N;
    for (int i = 1; i <= N; i++) {
        ans = min(ans , w[i-1]+(e[N]-e[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3076
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
s = S()
c = s[-1]
if c in ['2', '4', '5', '7', '9']:
    print('hon')
elif c in ['0', '1', '6', '8']:
    print('pon')
else:
    print('bon')

Measured memory_bytes: 68392
#include <stdio.h>
int a[100001];
int main()
{
  int n,m,i,j,p=0,l=0;
  scanf("%d%d",&n,&m);
  for(i=1;i<n;i++){
    scanf("%d",&a[i]);
    a[i] += a[i-1];
  }
  for(i=0;i<m;i++){
    scanf("%d",&j);
    if(j>0) l += a[p+j] - a[p];
    else l += a[p] - a[p+j];
    l %= 100000;
    p += j;
  }
  printf("%d\n",l);
  return 0;
}

Measured memory_bytes: 752
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
 
using namespace std;
 
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
 
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).end()) i=(c).end(); i!=(c).begin(); --i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
 
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
 
#define PB(a) push_back(a)
#define PF(a) pop_front(a)
 
#define MP(a,b) make_pair(a,b)
 
#define FS first
#define SE second
 
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
 
//------show vector---------
template <typename T>
void showV(vector < T > a){
  EACH(i,a){
    cerr << *i << ',';
  }  
  cerr << endl;
}
 
//------show matrix---------
template <typename T>
void showVV(vector < vector < T > > a){
  EACH(i,a){
    showV(*i);
  }  
}
//grobal var
//------------------------------------------
LL dp[2000][2000];
 
int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------
  int N,D;
  while(cin >> N >> D){
    int ans = N/(2*D+1);
    if(N%(2*D+1)!=0) ans++;
    cout << ans << endl;
  }
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;
constexpr int MAX = 2000200;
constexpr double EPS = 1E-11;

using namespace std;

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

	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i * j == n) {
				cout << "Yes" << endl;
				return 0;
			}

		}
	}
	cout << "No" << endl;
}




Measured memory_bytes: 256
from collections import deque


def bfs():
    d = [[float("inf")] * w for i in range(h)]

    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    que = deque([])
    que.append((sx, sy))
    d[sx][sy] = 0

    while que:
        p = que.popleft()
        if p[0] == gx and p[1] == gy:
            break
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]

            if 0 <= nx < h and 0 <= ny < w and maze[nx][ny] != "#" and d[nx][ny] == float("inf"):
                que.append((nx, ny))
                d[nx][ny] = d[p[0]][p[1]] + 1

    return d[gx][gy]


h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]
sx, sy = 0, 0
gx, gy = h - 1, w - 1

# 白いマスを数える
white = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] == ".":
            white += 1

res = bfs()
if 0 < res < float("inf"):
    # 白いマスの数から最短経路でかかるコスト分を引く
    # ゴールを黒いマスに変えることはできないためその分も引く
    print(white - res - 1)
else:
    print(-1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    lint N, K;
    cin >> N >> K;
    map<lint, lint> num_occurances;
    range(i, 0, N) {
        lint a, b;
        cin >> a >> b;
        num_occurances[a] += b;
    }
    vec<lint> value;
    vec<lint> number;
    lint cur_num = 0;
    for (const auto item : num_occurances) {
        lint val = item.first, num = item.second;
        value.emplace_back(val);
        cur_num += num;
        number.emplace_back(cur_num);
    }
    lint idx = lower_bound(number.begin(), number.end(), K) - number.begin();
    cout << value.at(idx) << "\n";
}

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> snuke(n);
  for(int i=0;i<k;i++){
    int tmp;
    cin >> tmp;
    for(int j=0;j<tmp;j++){
      int tmp2;
      cin >> tmp2;tmp2--;
      snuke[tmp2]++;
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(snuke[i]==0)ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<algorithm>
#include<unordered_set>
#include<vector>
#include<math.h>
#include<iomanip>

using namespace std;

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

	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> c(n + 1, 0);
	
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		c[v[i]]++;
	}

	long long ans = 0;
	for (auto x:c) {
		ans += 1L * x * (x - 1) / 2;
	}

	for (int i = 0; i < n; i++) {
		int x = c[v[i]];
		cout << ans - x + 1 << '\n';
	}
	
}

Measured memory_bytes: 4224