akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<iomanip>
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll = long long int;

int main(void) {
    int n; cin >> n;
    vector<pair<long double, long double>> t;
    REP(i, n) {
        long double x, y; cin >> x >> y;
        t.push_back(make_pair(x, y));
    }
    vector<int> v(n);
    REP(i, n) v[i] = i;
    long double dist = 0, cnt = 0;
    do {
        REP(i, n - 1) {
            dist += sqrt(pow(t[v[i]].first - t[v[i + 1]].first, 2) + pow(t[v[i]].second - t[v[i + 1]].second, 2));
        }
        cnt++;
        //REP(i, n) cout << v[i];
        //cout << endl;
    } while (next_permutation(ALL(v)));
    //cout << cnt << endl;
    cout << fixed << setprecision(7) << dist / cnt << endl;
}

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

#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;
int main() {

	int n, k;
	cin >> n >> k;
	vector<int> x(n);


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

	sort(ALL(x));

	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (x[i] < (k - x[i] )) {
			ans += x[i] * 2;
		}
		else {
			ans += (k - x[i]) * 2;
		}
		
	}

	cout << ans << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int main()
{
	boost;
	int n, m, z, i, j;
	cin >> n >> m >> z;
	char arr[n][m], b[n][m];
	fo(i, 0, n) {
		fo(j, 0, m)
		cin >> arr[i][j];
	}
	
	int ans = 0;
	for(int i = 0; i < (1 << n); i++) {
		for(int j = 0; j < (1 << m); j++) {
			for(int k = 0; k < n; k++) {
				for(int k1 = 0; k1 < m; k1++)
				b[k][k1] = arr[k][k1];
			}
			
			for(int k = 0; k < n; k++) {
				if(i >> k & 1) {
					for(int k1 = 0; k1 < m; k1++)
					b[k][k1] = '.';
				}
			}
			
			for(int k = 0; k < m; k++) {
				if(j >> k & 1) {
					for(int k1 = 0; k1 < n; k1++)
					b[k1][k] = '.';
				}
			}
			
			int cnt = 0;
			for(int k = 0; k < n; k++) {
				for(int k1 = 0; k1 < m; k1++)
				cnt += (b[k][k1] == '#');
			}
			if(cnt == z) ++ans;
		}
	}
	cout << ans;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define inar ll ar[n];for(ll i=0;i<n;i++) cin>>ar[i];
#define loop for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL);
  #define endl "\n"
  #define inf ll(1e19)
  #define mod int(1e9 +7)
typedef long long int ll;
using namespace std;

#define INFI LLONG_MAX
int32_t main()
{
	int n;
	int k;
	cin>>n>>k;
	cout<<(int)(floor(log(n)/log(k))+1);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define MOD 1000000007
#define INF 1e9
#define eps 1e-6
typedef long long ll;
using namespace std;

ll n, a[300010], sum[300010], s, ans, cnt[110];

ll qpow(ll a, ll b){
	ll t = 1;
	while(b){
		if(b & 1) t = t * a % MOD;
		a = a * a % MOD;
		b >>= 1; 
	} 
	return t;
}

int main(){

	cin >> n;
	for(ll i = 1; i <= n; i++){
		cin >> a[i];
		for(int j = 0; j <= 61; j++)
			if(a[i] & (1ll << j))
				cnt[j]++;
	}
	for(ll i = 0; i < 61; i++){
		//printf("%lld\n", cnt[i]);
		ans = (ans + (n - cnt[i]) * cnt[i] % MOD * qpow(2, i) % MOD) % MOD;
	}
	printf("%lld\n", ans  % MOD);

	return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

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;
}

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<int>a(N);
  REP(i,N){
    cin>>a[i];
  }
  int mi=*min_element(ALL(a)),ma=*max_element(ALL(a));
  int mii=min_element(ALL(a))-a.begin()+1, mai=max_element(ALL(a))-a.begin()+1;
  if(mi < 0 && ma > 0){
    cout<<2*N-1<<endl;
    if(abs(mi)>=ma){
      REP(i,N){
        cout<<mii<<" "<<i+1<<endl;
      }
    }else{
      REP(i,N){
        cout<<mai<<" "<<i+1<<endl;
      }
    }
  }else{
    cout<<N-1<<endl;
  }

  //すべて負のとき
  if(abs(mi)>=ma || ma<=0){
    REP(i,N-1){
      cout<<N-i<<" "<<N-i-1<<endl;
    }
  }else{
    REP(i,N-1){
      cout<<i+1<<" "<<i+2<<endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;


int main(){
  int n,m;
  cin >> n >> m;
  vector<int> x(m);
  rep(i,m) cin >> x[i];
  sort(x.begin(),x.end());
  
  vector<int> y(m-1);
  
  for (int i=0; i < m-1; i++){
    y[i] = x[i+1] - x[i];
  }
  
  sort(y.begin(), y.end());
  
  int ans = 0;
  
  rep(i,m-1-(n-1)) ans += y[i];
  
  cout << ans;
  
  
  return 0;
}

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

int main() {
    int now;
    double n,k;
    cin>>n>>k;
    double ans=0,res;
    for (int i=1; i<=n; i++) {
        res=1.0/n;
        now=i;
        while(now<k) {
            now*=2;
            res/=2;
        }
        ans+=res;
    }
    printf("%.12f\n",ans);
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d  long double
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define N 200003
#define inf (int)1e18
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int mod=1e9+7;
int c[10001];
 
 
signed main()
{
    haha
    int n,m;
    cin>>n>>m;
    if(m<n)
    cout<<"No";
    else
    cout<<"Yes";
    
    
}

Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
int sum[200001];

int main(int argc, char const* argv[])
{
  string s;
  cin >> s;
  rep(i, s.size()){
    if(i > 0)sum[i] = sum[i - 1];
    if(s[i] == 'W'){
      sum[i]++;
    }
  }
  ll res = 0;
  rep(i, s.size()){
    if(s[i] == 'B'){
      res += sum[s.size() - 1];
      if(i > 0)res -= sum[i - 1];
    }
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

ll mod_pow(ll x, ll n, ll mod=INFLL) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

int main () {
  int n, m;
  cin >> n >> m;
  cout << mod_pow(2,m)*(1900*m+100*(n-m)) << endl;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
s=set()
flag=True
buf=""
for i in range(n):
    str=input()
    if buf!="" and str[0]!=buf[-1:]:
        flag=False
    if str in s:
        flag=False
    s.add(str)
    buf=str

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#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++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 200005

const int INF = 1e9+7;

int main(){

    int n,m;
    cin >> n >> m;
    vector<int> cnt(m,0);
    for(int i = 0;i < n;i++){
        int k;
        cin >> k;
        for(int j = 0;j < k;j++){
            int a;
            cin >> a;
            cnt[a-1]++;
        }
    }
    int ans = 0;
    for(int i = 0;i < m;i++){
        if(cnt[i] == n){
            ans++;
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
    using namespace std;
      
    int main() {
    int cards[4][13];
    for(int i=0; i<4; i++){
        for(int j=0; j<13 ;j++){
            cards[i][j]=0;
        }
    }
    int n;
    cin >> n ;
    for(int h=0; h<n ;h++){
        int num ;
        char mar ;
        cin>> mar >> num ;
        if(mar == 'S'){
            cards[0][num-1]=1;
        }
        if(mar == 'H'){
            cards[1][num-1]=1;
        }
        if(mar == 'C'){
            cards[2][num-1]=1;
        }
        if(mar == 'D'){
            cards[3][num-1]=1;
        }
    }
    for (int i=0; i<4 ; i++){
        for (int j=0 ; j<13 ; j++){
            if(cards[i][j] == 0){
                if(i == 0){cout<< "S " <<j+1 <<endl;}
                if(i == 1){cout<< "H " <<j+1 <<endl;}
                if(i == 2){cout<< "C " <<j+1 <<endl;}
                if(i == 3){cout<< "D " <<j+1 <<endl;}
            }
        }
    }
    return 0;
    }

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long

const int ALP = 26;

vector<int> w[ALP];

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

	string s, t;
	cin >> s >> t;
	int n = (int)s.size();
	for (int i = 0; i < n; i++) {
		w[s[i] - 'a'].push_back(i);
	}
	int pnt = -1;
	int full = 0;
	for (auto x : t) {
		int c = x - 'a';
		if (w[c].empty()) {
			cout << -1 << endl;
			return 0;
		} 
		if (w[c].back() <= pnt) {
			full++;
			pnt = w[c].front();
		} else {
			pnt = *upper_bound(w[c].begin(), w[c].end(), pnt);
		}
	}
	cout << full * n + pnt + 1 << endl;
} 


Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl 

const int Num = 1e5+10;
bool primes [Num+5];
vector <int> p = {2};

void sieve (){

    memset( primes , true , Num );

    primes[0] = primes[1] = false;

    for (int i = 4 ; i <= Num ; i += 2)
        primes[i] = false;

    int sq = sqrt(Num);
    for (int i = 3 ; i <= sq ; i += 2){
        if (primes[i]){
            p.push_back(i);
            for (int j = i*i ; j <= Num ; j += i)
                primes[j] = false;
        }
    }

    for (int i = (sq + (sq&1^1)) ; i < Num ; i += 2)
        if (primes[i])
            p.push_back(i);

}


void Suhaib_Sawalha (){

    sieve();
    int n;
    cin >> n;
    cout << *lower_bound(p.begin(),p.end(),n);

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}

Measured memory_bytes: 3844
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<pair<int,int>> vip;

#define ZOOM ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define LOOP_IT(s) for(auto it=(s).begin();it!=(s).end();++it)


int main(int argc,char* argv[])
{
    ZOOM

    int a,h;
    cin>>h>>a;
    if(h%a==0)
        cout<<h/a;
    else
        cout<<h/a+1;

    return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int[] cnt = new int[4];
      for(int i = 0;i < 6;i++){
        int a = sc.nextInt();
        cnt[a-1]++;
      }
      if(cnt[0]==0||cnt[0]==3||cnt[1]==0||cnt[1]==3||cnt[2]==0||cnt[2]==3||cnt[3]==0||cnt[3]==3)System.out.println("NO");
      else System.out.println("YES");
    }
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll x; cin >> x;
    ll div = x/11;
    int mod = x % 11;
    if(mod == 0)cout << div*2 << endl;
    else if(mod<= 6) cout << div*2+1 << endl;
    else cout << div*2+2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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; }
const ll INF = 1LL << 60;
int main(){
    int n,m; cin >> n >> m;
    int now[3];
    rep(i,3) now[i]=-1; //iは桁数
    rep(i,m){
        int s,c;
        cin >> s >> c;
        s--;
        if(c==0 && s==0) {
            if(n==1) cout << 0 << endl;
            else cout << -1 << endl;
            return 0;
        }
        if(now[s]==-1 || now[s]==c) now[s]=c;
        else {
            cout << -1 << endl;
            return 0;
        }
    }
    rep(i,n){
        if(i==0 && now[i]==-1 && n!=1) cout << 1;
        else if(now[i]==-1) cout << 0;
        else cout << now[i];
    }
    return 0;
}

Measured memory_bytes: 256
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        var c = new int[361];
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var m = int.Parse(line[0]);
            var d = int.Parse(line[1]);
            var a = int.Parse(line[2]);
            var s = int.Parse(line[3]);
            setC(c, m, d, a, s);
        }
        var ans = getAns(c);
        Console.WriteLine(ans);
    }
    static int getAns(int[] c)
    {
        var ans = int.MaxValue;
        for (int i = 1; i <= 360; i++) ans = Min(ans, c[i]);
        return ans;
    }
    static void setC(int[] c, int m, int d, int a, int s)
    {
        var w = (m - 1) * 30 + d;
        for (int i = 1; i <= s - 1; i++)
        {
            var t = w - i;
            while (t < 1) t += 360;
            c[t] = Max(c[t], s - i);
            var t2 = w + a - 1 + i;
            while (t2 > 360) t2 -= 360;
            c[t2] = Max(c[t2], s - i);
        }
        for (int i = w; i <= w + a - 1; i++)
            if (i > 360) c[i - 360] = Max(c[i - 360], s);
            else c[i] = Max(c[i], s);
    }
}



Measured memory_bytes: 17976
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

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

constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<ll, ll> a, tuple<ll, ll> b) {
		return (get<1>(a) > get<1>(b));
	}
};

using tll = tuple<ll, ll>;
using tlll = tuple<ll, ll, ll>;

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	cout << setprecision(18) ;
	//cout << fixed;
	ll n, m, s, t;
	cin >> n >> m >> s >> t;
	s--; t--;
	vector<vector<tlll>> g(n);
	vl u(m), v(m), a(m), b(m);
	rep(i, m) {
		cin >> u[i] >> v[i] >> a[i] >> b[i];
		u[i]--; v[i]--;
		g[u[i]].push_back(tlll(v[i], a[i], b[i]));
		g[v[i]].push_back(tlll(u[i], a[i], b[i]));
	}
	vb vstd(n, false);
	vl en(n, LINF), sn(n, LINF);
	priority_queue<tll, vector<tll>, compare> q;
	q.push(tll(s, 0));
	while (!q.empty()) {
		ll to, dist;
		tie(to, dist) = q.top(); q.pop();
		if (vstd[to])continue;
		vstd[to] = true;
		en[to] = dist;
		rep(i, g[to].size()) {
			ll next = get<0>(g[to][i]);
			ll cost = get<1>(g[to][i]);
			if (en[next] < dist + cost)continue;
			q.push(tll(next, dist + cost));
		}
	}
	fill(all(vstd), false);
	priority_queue<tll, vector<tll>, compare> q2;
	q2.push(tll(t, (ll)0));
	while (!q2.empty()) {
		ll to, dist;
		tie(to, dist) = q2.top(); q2.pop();
		if (vstd[to])continue;
		vstd[to] = true;
		sn[to] = dist;
		rep(i, g[to].size()) {
			ll next = get<0>(g[to][i]);
			ll cost = get<2>(g[to][i]);
			if (sn[next] < dist + cost)continue;
			q2.push(tll(next, dist + cost));
		}
	}
	ll mn = LINF;
	vl ans(n);
	rep(i, n) {
		mn = min(mn, en[n - i - 1] + sn[n - i - 1]);
		ans[n - i - 1] = mn;
	}
	rep(i, n) {
		cout << 1e15 - ans[i] << endl;
	}
}



Measured memory_bytes: 17272
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() 
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); cout.tie(NULL);
	int n,r,ans;
	cin>>n>>r;
	if(n >= 10)
		ans = r;
	else
		ans = r + (10-n)*100;
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h)cin >> s[i];
    ll cnt = 0;
    rep(i, h)rep(j, w)if(s[i][j] == '#')cnt++;
    if(cnt-1 == h + w - 2)cout << "Possible";
    else cout << "Impossible";
}      

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>;

int main() {
    int x, y;
    bool f = false;
    cin >> x >> y;
    if (y%2==0){
        for (int i = 0; i <= x; i++){
            if((i * 2 + (x - i) * 4) == y){
                f = true;
            }
        }
        if(f){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3640
from collections import Counter
import copy


def LI():
    return list(map(int, input().split()))


N = int(input())
A = LI()
B = Counter(A)
A = copy.copy(B)

for k, v in B.items():

    if k-1 in A:
        A[k-1] += v
    else:
        A[k-1] = v
    if k+1 in A:
        A[k+1] += v
    else:
        A[k+1] += v

print(max(A.values()))

Measured memory_bytes: 25000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair



int main() {
    int N, K; cin >> N >> K;
    vector<int> p(N);
    REP(i, N) cin >> p[i];    
    sort(p.begin(), p.end());
    int ans = 0;
    REP(i, K) ans += p[i];
    PRINT(ans);
    return 0;
}

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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

inline void Main() {
  // code
  string s;
  cin >> s;
  rep(i, s.size()) {
    if(i % 2 == 0) {
      if(!(s.at(i) == 'R' || s.at(i) == 'U' || s.at(i) == 'D')) {
        cout << "No" << endl;
        return;
      }
    } else {
      if(!(s.at(i) == 'L' || s.at(i) == 'U' || s.at(i) == 'D')) {
        cout << "No" << endl;
        return;
      }
    }
  }

  cout << "Yes" << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


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

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var t = cin.nextInt();
            var x = cin.nextDouble();
            Console.WriteLine(t / x);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

using ll = int;
using vi = vector<ll>;
using vvi = vector<vi>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

//ll INF = 1ll << 60;

void chmin(ll &a, ll b){
  if(a > b)
    a = b;
}
void chmax(ll &a, ll b){
  if(a < b)
    a = b;
}

int main(){
  ll n, k;
  cin >> n >> k;
  vi a(n);
  rep(i, 0, n)
    cin >> a[i];
  
  rep(i, 0, k){
    vi b(n, 0);
    rep(j, 0, n){
      ll l, r;
      l = max(0, j-a[j]);
      r = min(n-1, j+a[j]);
      b[l]++;
      if(r+1 < n)
        b[r+1]--;
    }
    
    rep(j, 1, n)
        b[j] += b[j-1];
    
    a = b;
    
    bool c = true;
    
    rep(j, 0, n){
      if(a[j] != n)
        c = false;
    }
    if(c)
      break;
    
  }
  
  rep(i, 0, n)
    cout << a[i] << " ";
  cout << endl;
  
  return 0;
  
}

Measured memory_bytes: 4828
#include<bits/stdc++.h>
using namespace std;
#define N 200005
#define LL long long

char s[N];
int tot[N][26],f[N];
int n,T;

LL calc(LL len,int ch){
	if(len<=n) return tot[len][ch];
	LL num1=tot[n][ch],num2=tot[T][ch];
	LL len1=n,len2=T;
	while(len1+len2<=len){
		num1=num1+num2,num2=num1-num2;
		len1=len1+len2,len2=len1-len2;
	}
	return num1+calc(len-len1,ch);
}

int main(){
	scanf("%s",s+1);
	n=strlen(s+1)/2;
	f[0]=0;f[1]=0;tot[1][s[1]-'a']=1;
	for(int i=2,p;i<=n;i++){
		p=f[i-1];
		while(p&&s[p+1]!=s[i]) p=f[p];
		f[i]=s[p+1]!=s[i] ? 0:p+1;
		memcpy(tot[i],tot[i-1],sizeof(tot[i]));
		tot[i][s[i]-'a']++;
	}
	T=n-f[n];
	LL l,r;
	cin>>l>>r;
	for(int i=0;i<26;i++)	cout<<calc(r,i)-calc(l-1,i)<<" ";
	return 0;
} 

Measured memory_bytes: 12288
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define sec second
#define pb push_back
#define pf push_front
#define po pop_back
#define fast ios_base::sync_with_stdio(false)
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pi pair<ll,ll>
#define map map<ll,ll>
#define set set<ll>
#define tostr to_string
#define toint stoi
#define gcd __gcd
 
 
int main()
{
  ll a,b;cin>>a>>b;
  if((a<=9)&&(b<=9))
    cout<<a*b<<endl;
  else
    cout<<-1<<endl;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
c = 0
ans = 0

for i in range(n-1, 0, -1):
  if h[i-1] >= h[i]:
    c += 1
    if c > ans:
      ans = c
  elif h[i-1] < h[i]:
      c = 0
      
print(ans)

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
int main() {
	fast;
	char a;
	cin>>a;
	if(isupper(a))
	{
		cout<<"A";
	}
	else
	{
		cout<<"a";
	}
	
	return 0;
}

Measured memory_bytes: 3636
import java.util.*;
public class Main {

  public static void main (String[] args) {
	
    Scanner sc = new Scanner(System.in);
    int W = sc.nextInt();
    int H = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    sc.close();

    double max = (double) W * (double) H / 2;

    int check = 0;

    if(x + x == W && y + y == H){
      check = 1;
    }

    System.out.println(max + " " + check);

  }

}

Measured memory_bytes: 23124
// **** WHEN THE GOING GETS TOUGH, THE TOUGH GETS GOING. ****
#include<bits/stdc++.h>
using namespace std;
#define fi              first
#define se              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pll             pair<ll,ll>
#define vll              vector<int>
#define mll             map<ll,ll>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define md             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
void hi()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
void bye()
{
    #ifndef ONLINE_JUDGE
    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
    #endif
}
void solve()
{
    ll n,ma=0,c=0; cin>>n; ll a[n];
    for(int i=0;i<n;i++) cin>>a[i],ma=max(ma,a[i]);
    bool p[1000005];
    memset(p,true,sizeof(p));
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        if(i>0 && a[i]==a[i-1]) p[a[i]]=false;
        if(p[a[i]])
        for(int j=a[i]+a[i];j<=ma;j+=a[i])
            p[j]=false;
        if(i<n-1 && a[i]==a[i+1]) p[a[i]]=false;
    }
    for(int i=0;i<n;i++)
    if(p[a[i]]) c++;
    cout<<c<<"\n";
}
int main()
{
    hi();
    solve();
    bye();
    return 0;
}

Measured memory_bytes: 6156
#include <stdio.h>
using namespace std ; 
int main() {
	int a;
	int b;
	char op;
	scanf("%d %c %d", &a, &op, &b);
	
	if (op == '+')
	{
		printf("%d\n", a + b);
	}
	else if (op == '-')
	{
		printf("%d\n", a - b);
	}
}


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

lint N;
map<lint, lint> yes;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	REP(i, 1000) {
		yes[(i + 1) * (i + 2) / 2] = (i + 1);
	}
	if (yes.find(N) == yes.end()) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	lint len = yes[N];
	vector<vector<lint>> matrix(yes[N], vector<lint>(yes[N]));
	lint idx = 1;
	REP(i, len) {
		REP(j, len) {
			matrix[i][j] = idx;
			idx++;
			if (i == j) break;
		}
	}
	REP(i, len) {
		REP(j, len) {
			if (matrix[i][j] == 0) matrix[i][j] = matrix[j][i];
		}
	}
	cout << len + 1 << endl;
	REP(i, len) {
		cout << len << " ";
		REP(j, len) {
			cout << matrix[i][j] << " ";
		}
		cout << endl;
	}
	cout << len << " ";
	REP(i, len) {
		cout << matrix[i][i] << " ";
	}
	cout << endl;
}


Measured memory_bytes: 3072
#参考：https://atcoder.jp/contests/arc097/submissions/9281415

s = input()
K = int(input())
#辞書順でk番目に小さいｓのsubstringを出力する

#set型で集合演算
seta = set()

for i in range(len(s)):
    for j in range(1,6):
        seta.add(s[i:i+j])
        #print(s[i:i+j])
lista = sorted(list(seta))

#print()
#print(lista)
print(lista[K-1])

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

int main() {
  int x, y;
  cin >> x>> y;
  //cin >> y;

  if (x%2==0 || y%2==0) 
      {
        cout << "Even" << endl;
      }

   else  //(x%500 > y)
         {
          cout << "Odd" << endl;
        }
   //else 
   //{
    //cout << "Yes" << endl;
   //}
   return 0;
    //else
        //{
         // cout << "No" << endl;
       // }
  

  //cout << "終了" << endl;
}



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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int h[] = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		Arrays.sort(h);
		int min = Integer.MAX_VALUE;
		for (int i = 0; i + k - 1 < n; i++) {
			min = Math.min(min, h[i + k - 1] - h[i]);
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 50600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
ll inv(ll a);
ll fastpow(ll a, ll n);
ll C(ll n, ll m);
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, a, b;
	cin >> n >> a >> b;
	ll ans = fastpow(2, n) - 1 - C(n, a) - C(n, b);
	cout << (ans + 2 * MOD) % MOD << endl;
	return 0;
}
ll fastpow(ll a, ll n)
{
	if (n < 0)return 0;
	ll res = 1;
	a %= MOD;
	while (n) {
		if (n & 1)res = (res * a) % MOD;
		a = (a * a) % MOD;
		n >>= 1;
	}
	return res % MOD;
}
ll inv(ll a)
{
	return a == 1l ? 1l : (ll)(MOD - MOD / a) * inv(MOD % a) % MOD;
}
ll C(ll n, ll m)
{
	if (m < 0)return 0;
	if (n < m)return 0;
	if (m > n - m)m = n - m;
	ll up = 1, down = 1;
	for (ll i = 0; i < m; i++)
	{
		up = up * (n - i) % MOD;
		down = down * (i + 1) % MOD;
	}
	return up * inv(down) % MOD;
}

Measured memory_bytes: 384
#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>;
using Graph = vector<vector<int>>;

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

int main(){
    string T, ans;
    cin >> T;
    int a=T.size();
    if(T[0]=='?'){
        T[0]='D';
    }
    for(int i=1; i<a-1; ++i){
        if(T[i]=='D' || T[i]=='P') continue;
        else{
            if(T[i-1]=='P'){
                T[i]='D';
            }else if(T[i-1]=='D' && T[i+1]=='D'){
                T[i]='P';
            }else{
                T[i]='D';
            }
        }
    }
    if(T[a-1]=='?'){
        T[a-1]='D';
    }
    cout << T << "\n";
    return 0;
}

Measured memory_bytes: 3756
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define M 1001
 
int getLCS(char*, char*);
int C[1001][1001];
  
int main(){
    char x[M], y[M];
    int n, i;
  
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%s%s", x, y);
        printf("%d\n", getLCS(x, y));
    }
    return 0;
}
  
int getLCS(char *x, char *y){
    int i, j, lenX, lenY;
  
    lenX = strlen(x);
    lenY = strlen(y);
  
    for (i = 0; i < lenX; i++){
        for (j = 0; j < lenY; j++){
            if (x[i] == y[j]) C[i + 1][j + 1] = C[i][j] + 1;
            else C[i + 1][j + 1] = ((C[i][j+1] > C[i+1][j])?  C[i][j+1] : C[i+1][j]);
        }
    }
  
    return C[lenX][lenY];
}



Measured memory_bytes: 5756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
 
ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}
int main(){
    ll n;
    cin>>n;
    ll ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
    ans%=mod;
    ans=(ans+mod)%mod;
    cout<<ans<<"\n";
}

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

#ifndef __TOPCYBERFLOWER
#define debug(...) 0
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

using namespace std;
#define TYPEMAX(type)   numeric_limits<type>::max()
#define TYPEMIN(type)   numeric_limits<type>::min()
typedef long long ll;
typedef pair<int,int> pii;
class Lazy_Seg{
private:
    const int SZ=1000005;
    int n;
    vector<ll> seg,lazy;
public:
    Lazy_Seg(int n){
        this->n=n;
        seg.resize(4*n,0);
        lazy.resize(4*n,0);
    }
    void upd_lazy(int idx, int l, int r){
        seg[idx]+=(ll)(r-l+1)*lazy[idx];
        if(l!=r){
            lazy[2*idx]+=lazy[idx];
            lazy[2*idx+1]+=lazy[idx];
        }
        lazy[idx]=0LL;
    }
    void seg_update(int idx, int l, int r, int fl, int fr, ll plus){
        upd_lazy(idx,l,r);
        if(r<fl || fr<l) return;
        if(fl<=l && r<=fr){
            seg[idx]+=(ll)(r-l+1)*plus;
            if(l!=r){
                lazy[2*idx]+=plus;
                lazy[2*idx+1]+=plus;
            }
            return;
        }
        seg_update(2*idx,l,(l+r)/2,fl,fr,plus);
        seg_update(2*idx+1,(l+r)/2+1,r,fl,fr,plus);
        seg[idx]=seg[2*idx]+seg[2*idx+1];
    }
    ll seg_find(int idx, int l, int r, int fl, int fr){
        upd_lazy(idx,l,r);
        if(r<fl || fr<l) return 0LL;
        if(fl<=l && r<=fr) return seg[idx];
        return seg_find(2*idx,l,(l+r)/2,fl,fr)+seg_find(2*idx+1,(l+r)/2+1,r,fl,fr);
    }
};
int idx(vector<ll> &arr, ll x){
    return lower_bound(arr.begin(),arr.end(),x)-arr.begin();
}
int main(void){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n,d,a; cin>>n>>d>>a;
    vector<pair<ll,ll>> arr;
    vector<ll> xidx;
    for(int i=0;i<n;i++){
        ll x,y; cin>>x>>y;
        arr.push_back({x,y});
        xidx.push_back(x);
    }
    sort(xidx.begin(),xidx.end());
    sort(arr.begin(),arr.end());
    Lazy_Seg seg=Lazy_Seg(n);
    vector<int> vidx(n);
    for(int i=0;i<n;i++){
        vidx[i]=idx(xidx, arr[i].first);
        seg.seg_update(1,1,n,i+1,i+1,arr[i].second);
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ll rem=seg.seg_find(1,1,n,i+1,i+1);
        if(rem<=0) continue;
        ll xx=(rem+a-1)/a;
        ans+=xx;
        int up=upper_bound(xidx.begin(),xidx.end(),arr[i].first+2*d)-xidx.begin()-1;
        seg.seg_update(1,1,n,i+1,up+1,-xx*a);
    }
    cout<<ans;
    return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> h(N);
  for (int i = 0; i < N; i++) cin >> h.at(i);
  const int INF = 1000000007;
  vector<int> dp(N, INF);
  dp.at(0) = 0;
  for (int i = 0; i < N-1; i++) {
    if (i+1 < N) {
      dp.at(i+1) = min(dp.at(i+1), dp.at(i) + abs(h.at(i) - h.at(i+1)));
    }
    if (i+2 < N) {
      dp.at(i+2) = min(dp.at(i+2), dp.at(i) + abs(h.at(i) - h.at(i+2)));
    }
  }
  cout << dp.at(N-1) << endl;
}

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

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;

        while ((line = br.readLine()) != null) {
            String[] input = line.split(" ");
            double[] d = new double[8];
            for (int i = 0; i < 8; i++) {
                d[i] = Double.parseDouble(input[i]);
            }

            // (d[3]-d[1])*(d[7]-d[5]) == -1 * (d[2]-d[0]) * (d[6]-d[4])
            if (Math.abs((d[3] - d[1]) * (d[7] - d[5]) + (d[2] - d[0]) * (d[6] - d[4])) < 1e-10) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }

    }
}


Measured memory_bytes: 24412
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)

int main(){
    int a,b;
    cin>>a>>b;
    
    if(a<b){
        cout<<"a < b"<<endl;
    }else if(a>b){
        cout<<"a > b"<<endl;
    }else{
        cout<<"a == b"<<endl;
    }
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string S,K;
const int n = 1<<8;

int getlen(){
  int mx[n],res=1e9;
  memset(mx,-1,sizeof(mx));
  for(int i=0;i<S.size();i++){
    int ch = S[i];
    mx[ch] = max(mx[ch],i);
    int c=0,l=1e9;
    for(int j=0;j<K.size();j++)c+=mx[K[j]]>=0,l=min(l,mx[K[j]]);
    if(c<K.size()) continue;
    res=min(res,i-l);
  }
  return res;
}

int count(int len){
  int cnt[n]={},res=0;
  for(int i=0;i<S.size();i++){
    cnt[S[i]]++;
    int c=0;
    for(int j=0;j<K.size();j++)c+=cnt[K[j]]>0;
    if(c==K.size())res++;
    if(i-len>=0) cnt[S[i-len]]--;
  }
  return res;
}

string getstr(int len){
  int cnt[n]={},res=0;
  for(int i=0;i<S.size();i++){
    cnt[S[i]]++;
    int c=0;
    for(int j=0;j<K.size();j++)c+=cnt[K[j]]>0;
    if(c==K.size()) return S.substr(i-len,len+1);
    if(i-len>=0) cnt[S[i-len]]--;
  }
  return "";
}

int main(){
  while(1){
    S.clear();
    while(1){
      string s; 
      getline(cin,s);
      if(s.empty()) break;
      S+=s;
    }
    if(S.empty())break;
    getline(cin,K);
    
    int len = getlen();
    cout<<count(len)<<endl;
    string str = getstr(len);
    for(int i=0;i<str.size();i++){
      if(i!=str.size()-1&&i%72==0)cout<<endl;
      cout<<str[i];
    }
    cout<<endl;
    if(len<1e9)cout<<endl;
    getline(cin,K);      
  }
  return 0;
}

Measured memory_bytes: 3376
n,y=map(int,input().split())

ans=0

for i in range(y//10000,-1,-1):

    nokori=(y-i*10000)

    for j in range(min(n-i,nokori//5000),-1,-1):
 
        nokori2=nokori-j*5000
    
        if 10000*i+5000*j+1000*(n-i-j)==y:
            print(i,j,n-i-j)
            ans=1
            break
            
    else:
        continue
    break
    
          
if ans==0:
    print(-1,-1,-1)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;

int main() {
  int N,M,X;
  cin >> N >> M >> X;
  vector<int> C(N);
  int A[N][M];
  rep(i,N){
    cin >> C.at(i);
    rep(j,M){
      cin >> A[i][j];
    }
  }
  
  int ans=INF;
  rep(s,1<<N){
    int cost=0;
    vector<int> D(M);
    rep(i,N){
        if(s>>i&1){ //sのiビット目が1の時 
          cost += C[i];
          rep(j,M){
            D[j] += A[i][j];
          }
        }
    }
    bool ok = true;
    rep(j,M){
      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: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

struct edge{
    int to;
    int id;
    int color;
};

int K;

vector<edge> G[MAX];

void DFS(int start,int which,int p){
    for(edge &e:G[start]){
        if(e.to==p) continue;
        e.color=which;
        which++;
        if(which==K+1) which=1;
        DFS(e.to,which,start);
    }
}

int main(){
    
    int N;cin>>N;
    
    for(int i=0;i<N-1;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        G[a].push_back({b,i,0});
        G[b].push_back({a,i,0});
    }
    int maxi=0,start=-1;
    
    for(int i=0;i<N;i++){
        if(maxi<G[i].size()){
            maxi=G[i].size();
            start=i;
        }
    }
    
    K=maxi;
    
    DFS(start,1,-1);
    
    vector<int> ans(N-1);
    
    for(int i=0;i<N;i++){
        for(edge e:G[i]){
            if(e.color!=0) ans[e.id]=e.color;
            //cout<<e.color<<endl;
        }
    }
    
    cout<<maxi<<endl;
    for(int i=0;i<N-1;i++){
        cout<<ans[i]<<endl;
    }
    
}



Measured memory_bytes: 8448
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
// 素因数分解
typedef pair<long long, long long> P;
vector<P> prime_factorize(long long n)
{
vector<P> res;
for (long long p = 2; p * p <= n; ++p)
{
if (n % p != 0)
continue;
int num = 0;
while (n % p == 0)
{
++num;
n /= p;
}
res.push_back(make_pair(p, num));
}
if (n != 1)
res.push_back(make_pair(n, 1));
return res;
}
// 因数分解
long long gcd(long long x, long long y)
{
  if (y == 0)
  {
    return x;
  }
  else
  {
    return gcd(y, x % y);
  }
}
const int MOD = 1000000007;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

bool is_prime(int x){
    if(x<=1){
        return false;
    }
    for (int i = 2; i * i < x;i++){
        if(x%i==0){
            return false;
        }
    }
    return true;
}

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

    while(!is_prime(x)){
        x++;
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 3636
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2] != 1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]
def mod_inv(a,mod):
    x = extgcd(a,mod)[0]
    return (mod + x % mod)% mod
def comb(n,k,mod):
    c = 1
    for i in range(k):
        c = c*(n-i)%mod
        c = c*mod_inv(i+1,mod)%mod
    return c
n,a,b = map(int,input().split())
mod = 10**9+7
p = comb(n,a,mod)
q = comb(n,b,mod)
c = 1
k = 2
ans = 1
while n > 0:
    if n % (c*2) == c:
        n -= c
        ans *= k
        ans %= mod
    c *= 2
    k = k*k
    k %= mod
print((ans-p-q-1)%mod)

Measured memory_bytes: 42844