akhauriyash/Code-Regression huggingface dataset:
#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(){
  double L;
  cin>>L;
  
  double ans =pow(L/3,3);
 
  printf("%.12f",ans);

}


Measured memory_bytes: 256
n = int(input())
ab_list = [[int(i) for i in input().split()] for _ in range(n)]
ab_list.sort(key=lambda x:x[1])
t_sum = 0
flag = 0
a_before = 0
for a, b in ab_list:
  t_sum += a
  if b < t_sum:
    print("No")
    exit()
print("Yes")


Measured memory_bytes: 41172
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;
int par[100010];
int rnk[100010];

void init(int n){
    for(int i=0;i<n;i++){
        par[i] = i;
        rnk[i] = 0;
    }
}

int find(int x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
}

void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rnk[x] < rnk[y]) par[x] = y;
    else{
        par[y] = x;
        if(rnk[x] == rnk[y]) rnk[x]++;
    }
}

bool same(int x,int y){
    return find(x) == find(y);
}
signed main(){
    int n,m;
    cin >> n >> m;
    init(n);
    rep(i,m){
        int x,y,z;
        cin >> x >> y >> z;
        unite(x,y);
    }
    int ans[100010] = {0};
    rep(i,n)ans[find(i)] = 1;
    int cnt = 0;
    rep(i,n)cnt += ans[i];
    cout << cnt << endl;
    
    

    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc126.contest.atcoder.jp/tasks/abc126_a

Measured memory_bytes: 2560
#include <iostream>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

int a[200007];
int main(){
    int n,k;
    long long sum = 0;

    cin >> n >> k;
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    for(int i = 0;i < n-k;i++){
        sum+=a[i];
    }
    cout << sum;
}


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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  string s;cin>>s;
  dump((int)'a');
  dump((int)'A');

  if (s[0]!='A') {
    cout << "WA" << endl;
    return 0;
  }
  int cnt=0;

  rep(i, 2, sz(s)-1){
    if (s[i]=='C') cnt++;
  }
  if (cnt!=1) {
    cout << "WA" << endl;
    return 0;
  }

  cnt = 0;
  rep(i, sz(s)){
    if (s[i]<=96) cnt++;
  }
  if (cnt!=2) {
    cout << "WA" << endl;
    return 0;
  }

  cout << "AC" << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N;
vector<int> L;

signed main(){
	cin >> N;
	L.resize(N);
	rep(i, N) cin >> L[i];
	sort(all(L));

	int ans = 0;
	rep(i, N-2){
		rep(j, N-1){
			if(i >= j) continue;
			int a = L[i];
			int b = L[j];
			ans += lower_bound(L.begin()+j+1, L.end(), a+b) - upper_bound(L.begin()+j+1, L.end(), max(a-b, b-a));
		}
	}
	cout << ans << endl;
}

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

#define N 100000
#define INF 1000000
#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
  int ans = INF;
  long long sum, s;
  int n, l, r, a[N];
  
  cin >> n >> s;
  for (int i=0; i<n; i++){
    cin >> a[i];
  }
  l = r = 0;
  sum = a[0];
  while (true){
    while (r<n && sum < s){
      sum += a[++r];
    }
    if (r==n) break;
    ans = MIN(ans, r-l+1);
//    cout << l << " to " << r << " = " << sum;
//    cout << " (" << ans << ")" << endl;
    sum -= a[l++];
  }
  cout << (ans==INF?0:ans) << endl;
  return 0;
}
  
  



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    vll x(n);
    rep(i,n) cin>>x[i];
    ll ans=1e10;
    rep(i,n-k+1){
        ll cand = min(abs(x[i]), abs(x[i+k-1]));
        cand += abs(x[i]-x[i+k-1]);
        chmin(ans, cand);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


def fetch_ints_inputs(times):
    return [fetch_int_input() for _ in range(times)]

N = int(fetch_one_line())
s_t = fetch_inputs(N)
X = fetch_one_line()

flag = False
sum_time = 0
for tmp in s_t:
    s, t = tmp.split(" ")
    if not flag and s == X:
        flag = True
        continue

    t = int(t)
    if flag:
        sum_time += t

print(sum_time)



Measured memory_bytes: 38384
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int num_reversed(int original)
{
int reversed = 0;

while (original > 0) {
reversed = original % 10 + reversed * 10;
original = original / 10;
}
return reversed;
}

int main(){

  int A,B,cnt=0;
  cin>>A>>B;
  for(int i=A;i<=B;i++){
    if(num_reversed(i)==i)cnt++;
  }
  cout<<cnt<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int w[2005][2005],b[2005][2005];
int jisuan(int x1,int y1,int x2,int y2,int t[][2005]){
    if(x1>x2||y1>y2)
        return 0;
    return t[x2][y2]-t[x1-1][y2]-t[x2][y1-1]+t[x1-1][y1-1];
}
int main() {
    int n,k,x,y;
    char z;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d%d %c",&x,&y,&z);
        if(z=='W')
            w[x%(2*k)+1][y%(2*k)+1]++;
        else
            b[x%(2*k)+1][y%(2*k)+1]++;
    }
    for(int i=1;i<=2*k;i++)
        for (int j=1;j<=2*k ;j++) {
            w[i][j]=w[i-1][j]-w[i-1][j-1]+w[i][j-1]+w[i][j];
            b[i][j]=b[i-1][j]-b[i-1][j-1]+b[i][j-1]+b[i][j];
        }
    int mmax=0;
    int t1,t2;
    for( x=0;x<k;x++)
        for(y=0;y<k;y++)
        {
            t1=jisuan(x+1,y+1,x+k, y+k,w)+jisuan(1,1,x,y,w)+jisuan(x+k+1, y+k+1,2*k,2*k,w)+jisuan(x+k+1, 1,2*k,y,w)+jisuan(1, k+y+1,x,2*k,w);//百色最多五种
            t1+=jisuan(1, y+1, x, y+k, b)+jisuan(x+1,1,x+k, y, b)+jisuan(x+k+1, y+1, 2*k, y+k, b)+jisuan(x+1, y+k+1, x+k, 2*k, b);//黑色有4种
            
            //反着来一下
            t2=jisuan(x+1,y+1,x+k, y+k,b)+jisuan(1,1,x,y,b)+jisuan(x+k+1, y+k+1,2*k,2*k,b)+jisuan(x+k+1, 1,2*k,y,b)+jisuan(1, k+y+1,x,2*k,b);
            t2+=jisuan(1, y+1, x, y+k, w)+jisuan(x+1,1,x+k, y, w)+jisuan(x+k+1, y+1, 2*k, y+k, w)+jisuan(x+1, y+k+1, x+k, 2*k, w);
            
            mmax=max(t1, max(t2, mmax));
        }
    printf("%d\n",mmax);
    return 0;
}


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

#define ll long long int
#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1e9
#define MOD 1e9 + 7
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define mt make_tuple
#define fi first
#define se second
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define sum(v) accumulate(all(v), 0)
#define cinv(v, n) rep(i, n) cin >> v[i]
#define prec(n) fixed << setprecision(n)
#define odd(n) (n) % 2
#define even(n) !((n) % 2)

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (0 <= a) {
    cout << "Positive" << endl;
    return 0;
  }
  if (a < 0 && 0 <= b) {
    cout << "Zero" << endl;
    return 0;
  }
  cout << (odd(b - a) ? "Positive" : "Negative") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    char S[4];
    int renzoku=0;
    scanf("%s",S);
    if(S[0]=='R'){
        renzoku=1;
    }
    for(int i=1;i<3;i++){
        if(S[i]=='R'){
            if(S[i-1]=='R'){
                renzoku+=1;
            }else{
                renzoku=1;
            }
        }
    }
    printf("%d\n",renzoku);
}

Measured memory_bytes: 1736
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N,M,C;
  cin >> N >> M >> C;
  int B[M];
  for(int i=0;i<M;i++) cin >> B[i];
  int A[N][M];
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++) cin >> A[i][j];
  }

  int cnt = 0;
  for(int i=0;i<N;i++){
    int sum = 0;
    for(int j=0;j<M;j++){
      sum += A[i][j]*B[j];
    }
    sum += C;
    if(sum>0) cnt++;
  }

  cout << cnt << endl;
  return 0;

}


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


int main(){
    int n;
    cin >> n;
    bool ans = false;
    REP(i, n + 1){
        bool fin = false;
        int x = i * 4;
        while (x <= n){
            if(x == n){
                ans = true;
                fin = true;
                break;
            } 
            x += 7;
        }
        if (fin) break;
    }

    if(ans) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);++i)


#define huge 1000000007
typedef long long ll;

int main(void) {
	
	ll N = 0;
	ll A = 0;
	ll X = 0;
	ll Y = 0;
	char x[4] = {};
	//string w;
	int count = 0;
	int sum = 0;
	
	cin >> x;

	rep(i, 0, 4) {
		if (x[i] == '+')
			sum++;
		else
			sum--;
	}

	cout << sum << endl;
	return 0;
	
}

Measured memory_bytes: 256
s = list(input())
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

mae = a*10 + b 
ushiro = c*10 + d
if mae <= 12 and mae != 0:
    if ushiro <= 12 and ushiro != 0:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if ushiro <= 12 and ushiro != 0:
        print("YYMM")
    else:
        print("NA")

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

int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  for(ll i=1;i<n+1;i++){
    if(i%5!=0 && i%3!=0) ans += i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
using namespace std;
 
#define f0r(a, b) for (long long a = 0; a < (b); a++)
#define f1r(a, b, c) for (long long a = (b); a < (c); a++)
#define f0rd(a, b) for (long long a = (b); a >= 0; a--)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define mp make_pair
#define f first
#define s second
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vpl = vector<pll>;
 
void fio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); 
  cout.tie(0);
}
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const long double pi = 3.14159265358979323846;



void solve() {
  ll n; cin >> n;
  ll a[n]; f0r(i, n) cin >> a[i];
  ll c = 0;
  f0r(i, n) {
    if (i % 2 == 0 && a[i] % 2 == 1) ++c;
  }
  cout << c << '\n';
}
 
int main() {
  fio();
  
  int T = 1;
  // cin >> T;
  while (T--) solve();
} 

Measured memory_bytes: 3632
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let p: u64 = read();
    let s: String = read();
    let v: Vec<u64> = s.chars().rev().map(|c| ((c as u8) - b'0') as u64).collect();
    
    let mut count = 0;
    if p == 2 {
        for i in 0..n {
            if v[i] % 2 == 0 {
                count += n - i;
            }
        }
    } else if p == 5 {
        for i in 0..n {
            if v[i] % 5 == 0 {
                count += n - i;
            }
        }
    } else {
        let mut ruisekiwa: Vec<u64> = vec![0; n+1];

        let mut ten = 1;
        for i in 0..n {
            let a = v[i] * ten % p;
            ruisekiwa[i+1] = if i == 0 {
                v[0] % p
            } else {
                (ruisekiwa[i] + a) % p
            };
            ten *= 10; ten %= p;
        }
        
        let mut cnt = vec![0; p as usize];
        for i in 0..n+1 {
            count += cnt[ruisekiwa[i] as usize];
            cnt[ruisekiwa[i] as usize]+=1;
        }
    }

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


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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

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

void solve()
{
    string s;
    in(s);
    int ans = 700;
    rep(i, 3)
    {
        if (s[i] == 'o')
        {
            ans += 100;
        }
    }
    out(ans);
}

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

int main(){
    string s; cin >> s;
    stack<char> stk;
    rep(i,s.size()){
        if(s[i] == 'B'){
            if(!stk.empty()) stk.pop();
        }else{
            stk.push(s[i]);
        }
    }
    string ans = "";
    while(!stk.empty()){
        ans = ans + stk.top();
        stk.pop();
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int mod=1e9+7;
ll quick(ll a,ll b)
{
    ll ret=1;
    while(b)
    {
        if(b&1) ret=ret*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ret;
}
const int maxn=1005;
vc<tuple<int,int,int>> edge;
int fa[maxn];
int n,m;
void init()
{
    for(int i=0;i<=n;i++) fa[i]=i;
}
int Find(int x)
{
    return x==fa[x]?x:fa[x]=Find(fa[x]);
}
void Union(int x,int y)
{
    x=Find(x);
    y=Find(y);
    fa[y]=x;
}
ll kruskal(tuple<int,int,int> e)
{
    int u,v,w;
    init();
    tie(u,v,w)=e;
    ll ret=w;
    Union(u,v);
    for(auto ed:edge)
    {
        tie(u,v,w)=ed;
        if(Find(u)!=Find(v))
        {
            Union(u,v);
            ret+=w;
        }
    }
    return ret;
}
int main()
{
    cin>>n>>m;
    ll x;
    cin>>x;
    for(int i=0,u,v,w;i<m;i++)
    {
        cin>>u>>v>>w;
        edge.emplace_back(u,v,w);
    }
    sort(edge.begin(),edge.end(),[&](tuple<int,int,int> a,tuple<int,int,int> b){int u,v,w,u2,v2,w2;tie(u,v,w)=a;tie(u2,v2,w2)=b;return w<w2;});
    ll tar=kruskal(tuple<int,int,int> {0,0,0});
    //dbg(tar);
    if(tar==x)
    {
        int a=0;
        for(auto u:edge)
            if(kruskal(u)==x) a++;
        print((quick(2,a)-2)*quick(2,m-a)%mod);
    }
    else if(tar<x)
    {
        int a=0,b=0;
        for(auto u:edge)
        {
            ll cur=kruskal(u);
            if(cur==x) b++;
            else if(cur>x) a++;
        }
        //dbg(a,b);
        print(2*(quick(2,b)-1)*quick(2,a)%mod);
    }
    else print(0);

}

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

int main()
{

        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX;
        long long x=0,y=0,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr; string str,ttr,ntr;

        //scanf("%lld",&n);

        cin>>str;  sz=str.size();

        for(i=0;i<sz;i++)
        {
            x++; if(str[i]=='L')cnt++;

            if(str[i]=='L'&& str[i+1]=='R')
            {
                h=x/2; g=h; if(x%2==1)g=h+1; if(cnt%2==1)swap(g,h);

                for(j=y;j<=i;j++)
                {
                    if(str[j]=='R' && str[j+1]=='L' ){printf("%lld ",g);}
                    else if(str[j]=='L' && str[j-1]=='R'){printf("%lld ",h);}
                    else{  printf("0 "); }
                }

                y=i+1; x=0; cnt=0;
            }


        }

        h=x/2; g=h; if(x%2==1)g=h+1; if(cnt%2==1)swap(g,h);


        for(j=y;j<sz;j++)
        {
                if(str[j]=='R' && str[j+1]=='L' ){printf("%lld ",g);}
                else if(str[j]=='L' && str[j-1]=='R'){printf("%lld ",h);}
                else{  printf("0 "); }
        }








    return 0;
}





Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
string s,t;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>s>>t;
	int len=s.length(),ans=0;
	for(int i=0;i<len;i++)ans+=(s[i]!=t[i]);
	cout<<ans<<endl;
}


Measured memory_bytes: 3780
def main():
    N, K = (int(i) for i in input().split())
    bi = [2**i for i in range(21)]
    ans = 0
    for i in range(1, N+1):
        if K <= i:
            ans += 1/N
        else:
            for j, b in enumerate(bi):
                if K <= b*i:
                    ans += (1/N)*(1/2)**j
                    break
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39280
#include <iostream>

using namespace std;

int main() {
  int c1, c2, c3;
  bool flag[11];
  int count = 0;
  
  while (true) {
    cin >> c1 >> c2 >> c3;
    if (-1 == c1) break;
    
    for (int i = 1; i < 11; i++) flag[i] = true;
    flag[c1] = flag[c2] = flag[c3] = false;
    
    // over false
    for (int i = 1; i < 11; i++) if (flag[i] && (i + c1 + c2 <= 20)) count++;
    
    cout << (count >= 4 ? "YES" : "NO") << endl;
    
    count = 0;
    c1 = -1;
  }
  return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename Container>
int SZ(const Container& S) { return S.size(); }

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

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg_var(x) clog << #x  << ": " << x << endl;
    #define dbg_array(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg_var(x)
    #define dbg_array(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!
    int N;
    cin >> N;
    vector<LL> pref(N+1);
    pref[0] = 0;
    for (int i = 1; i <= N; i++) {
        cin >> pref[i];
        pref[i] += pref[i-1];
    }
    sort(pref.begin(), pref.end());
    LL res = 0;
    for (int i = 0; i < N+1; i++) {
        int j = i;
        while (j < N+1 and pref[i] == pref[j]) j++;
        LL l = j-i;
        res += l*(l-1) / 2ll;
        i = j-1;
    }
    cout << res << "\n";
}



Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string.h>
#include <queue>
#include <functional>
const int INF =1e5;
const int MOD = 1e9 + 7;
using namespace std;
typedef pair<int,int> P;
typedef long long lint;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fill(x,y) memset(x,y,sizeof(x))
#define all(x) (x).begin(),(x).end()
#define pb push_back
int s[1001]={0};
void eli(int p){
	for(int i=p*p;i<=1000;i*=p)
	{
		s[i]=1;
	}
}
int main(){
    int x;
    cin>>x;
    s[1]=1;
    for(int i=2;i<=1000;i++){
		eli(i);
	}
    for(int i=x;i>=1;i--){
        if(s[i]==1){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;

}


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

public class Main {

	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> h = new ArrayList<Integer>();
		ArrayList<Integer> w = new ArrayList<Integer>();

		int a, b;

		while ((a = sc.nextInt()) != 0 | (b = sc.nextInt()) != 0) {
			h.add(a);
			w.add(b);
		}

		for(int i = 0; i < h.size(); i++) {

			for(int j = 0; j < h.get(i); j++) {

				for(int k = 0; k < w.get(i);k++) {

					if(j != 0 && j != h.get(i)-1 && k != 0 && k != w.get(i)-1) {
						System.out.print(".");
					} else {
						System.out.print("#");
					}

				}
				System.out.println();

			}
			System.out.println();

		}

	}

}





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

vector<int> e[2010];
int a[2010];
bool vis[2010];

vector<int> merge(vector<int> &x,vector<int> &y){
	int xidx=0,yidx=0;
	vector<int> z;
	while(xidx<x.size()&&yidx<y.size())
		if(x[xidx] > y[yidx])
			z.emplace_back(x[xidx++]);
		else
			z.emplace_back(y[yidx++]);
	while(xidx<x.size())
		z.emplace_back(x[xidx++]);
	while(yidx<y.size())
		z.emplace_back(y[yidx++]);
	return z;
}

vector<int> dfs(int x){
	vis[x]=true;
	vector<int> res;
	for(int u:e[x])
		if(!vis[u]){
			vector<int> cur = dfs(u);
			res = merge(res,cur);
		}
	if(x!=0){
		res.emplace_back(0);
		for(int i=(int)res.size()-1;i>0;i--)
			res[i] = res[i-1];
		res[0] = x;
	}
	return res;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		e[0].emplace_back(i);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(gcd(a[i],a[j]) != 1)
				e[i].emplace_back(j);
	vector<int> res = dfs(0);
	for(int x:res)
		cout<<a[x]<<' ';
	cout<<endl;
}


Measured memory_bytes: 19412
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

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

int main(){
	vector<int> ms, msp;
	for(int i=1; i*7+1<50000; i++) {
		ms.push_back(i*7-1);
		ms.push_back(i*7+1);
	}
	for(int i=0; i<ms.size(); i++) {
		if(ms[i]>0) {
			for(int j=i+1; j<ms.size(); j++) {
				if(ms[j]%ms[i]==0) ms[j] = 0;
			}
			msp.push_back(ms[i]);
		}
	}

    int n;
    while( cin >> n, n!=1 ) {
		set<int> out;
        cout << n << ':';
		for(int i=0; i<msp.size(); i++) {
			if(n%msp[i]==0) {
				out.insert(msp[i]);
			}
		}
		for(set<int>::iterator it=out.begin(); it!=out.end(); it++) {
			cout << ' ' << *it;
		}
		if(out.size()==0)
			cout << ' ' << n;
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1344
#include <bits/stdc++.h>
using namespace std;
#define lli long long int 
#define pb push_back
#define vi vector<int>

int main()
{
	long long int k;
	int a,b,c;
	cin>>a>>b>>c>>k;
	int diff = a - b;
	if( k % 2 == 1 )
	{
		diff = diff * -1;
		cout<<diff<<"\n";
	}
	else
	{
		cout<<diff<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int H,W;
    cin>>H>>W;
    vector<vector<pii>> P(H,vector<pii>(W));
    vvi S(H,vi(W,0));
    for(int i=0;i<H;i++){
        string si;
        cin>>si;
        int begin=-1,count=0;
        for(int j=0;j<W;j++){
            S[i][j]=(si[j]=='.')?1:0;
            if(S[i][j]){
                if(begin==-1){
                    begin=j;
                    count=1;
                }else{
                    count++;
                }
                if(j==W-1){
                    for(int k=0;k<count;k++){
                        P[i][begin+k].first=count;
                    }
                }
            }else{
                for(int k=0;k<count;k++){
                    P[i][begin+k].first=count;
                }
                begin=-1;
                count=0;
            }
        }
    }
    for(int j=0;j<W;j++){
        int begin=-1,count=0;
        for(int i=0;i<H;i++){
            if(S[i][j]){
                if(begin==-1){
                    begin=i;
                    count=1;
                }else{
                    count++;
                }
                if(i==H-1){
                    for(int k=0;k<count;k++){
                        P[begin+k][j].second=count;
                    }
                }
            }else{
                for(int k=0;k<count;k++){
                    P[begin+k][j].second=count;
                }
                begin=-1;
                count=0;
            }
        }
    }

    int ans=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            ans=max(ans,P[i][j].first+P[i][j].second-1);
        }
    }
    cout<<ans<<endl;
    // for(int i=0;i<H;i++){
    //     for(int j=0;j<W;j++){
    //         cout<<P[i][j].first<<" ";
    //     }
    //     cout<<endl;
    // }
    // cout<<endl;
    // for(int i=0;i<H;i++){
    //     for(int j=0;j<W;j++){
    //         cout<<P[i][j].second<<" ";
    //     }
    //     cout<<endl;
    // }
    // cout<<endl;
}


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

using namespace std;

vector<int> G[50];

int main() {
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    for (int i = 0; i < N; i++)
        cout << G[i].size() << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

  int a,b,n,m,in,inmax,flag,i;

  scanf("%d",&n);

  scanf("%d",&m);

  in = m;
  inmax = m;
  flag = 0;
  for(i=0;i<n;i++) {

    scanf("%d %d",&a,&b);

    in = in + a - b;

    if(in > inmax ) inmax = in;

    if(in < 0) flag = 1;
  }

  if(flag == 0) printf("%d\n",inmax);
  else printf("0\n");

  return 0;

}

		

    

Measured memory_bytes: 596
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

# define INF 0x3f3f3f3f

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

int num[10] = {};

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

  string s;
  cin >> s;
  REP(i, s.size()) {
    num[i] = s[i] - '0';
  }
  ll ma = 0;
  REP(i, 1 << (s.size() - 1)) {
    // cout << i;
    ll m = 0;
    ll c = 0;
    // cout << "--" << i << "--" << endl;
    REP(j, s.size()) {
      c += num[j];
      if ((i & (1 << j)) > 0 || j == s.size() - 1) {
        m += c;
        // cout << m << endl;
        c = 0;
      }
      c *= 10;
    }
    // m += c;
    // cout << m << endl;
    ma += m;
  }

  cout << ma << endl;
  return 0;
}


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

m = dict()
sm = 0
for a in A:
    sm += a
    sm %= MOD
    if sm in m:
        m[sm] += 1
    else:
        m[sm] = 1

ans = 0
for key,r in m.items():
    ans += r*(r-1)//2
    if key == 0:
        ans += r

print(ans)


Measured memory_bytes: 62576
#include <stdio.h>

int main(void){
  int x = 0,k = 0;
  int sumx = 0;
  
  scanf("%d",&x);
  do{
    sumx += x;
    k++;
  }while(sumx % 360);
  
  printf("%d",k);
  
  return 0;
}

Measured memory_bytes: 1660
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<iterator>
#include<iomanip>
#include<string>
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<long long int>fac(n+1,0);
    int i=1;
    while(i<=n)
    {
        int j=1;
        while (i*j<=n)
        {
            fac[i*j]++;
            j++;
        }
        i++;
    }
    i=1;
    long long int sum=0;
    while(i<=n)
    {
        sum=sum+fac[i]*i;
        i++;
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 81392
#include <iostream>
#include <unordered_map>

using namespace std;

typedef long long ll;

ll N,M;
ll A[100000];
unordered_map<ll,ll> B;

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

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

    B[0]++; // because B_0 = 0
    for (int i=0; i<N; i++) {
        B[A[i] % M]++;
    }

    ll answer = 0;
    for (auto it = B.begin(); it != B.end(); it++) {
        answer += it->second * (it->second-1)/2;
    }

    cout << answer << endl;
}


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

int main(){
  
int N,n,i;
  cin >> N;
 vector <int> H(N);
  rep(i,N){
    cin >> H.at(i);
  }
  
  for(i=N-1;i>0;i--){
    if(H.at(i-1)-H.at(i)>1)
      break;
    else if(H.at(i-1)-H.at(i)==1){
      H.at(i-1)--;
    }
  }

  
  if(i==0)
    cout << "Yes"  << endl;
  else
    cout << "No" << endl;
  
 
  
}




Measured memory_bytes: 768
main(n){
	double x,y,z=atan2(1,0),u;
	for(;scanf("%d",&n),--n>0;printf("%f\n%f\n",x,y))
		for(x=1,y=0;n--;x+=cos(z+u),y+=sin(z+u))u=atan2(y,x);
	exit(0);
}

Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	auto np = vector<pair<int, int>>(n);
	auto mp = vector<pair<int, int>>(m);
	for(auto& q : np) cin >> q.first >> q.second;
	for(auto& q : mp) cin >> q.first >> q.second;
	auto ans = vector<int>(n);
	for(auto i = 0; i < (int)np.size(); ++i){
		int s = 500000000;
		int nx = np[i].first;
		int ny = np[i].second;
		for(auto j = 0; j < (int)mp.size(); ++j){
			int mx = mp[j].first;
			int my = mp[j].second;
			int d = abs(nx - mx) + abs(ny - my);
			if(d < s){
				s = d;
				ans[i] = j + 1;
			}
		}
	}
	for(auto a : ans){
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math/big"
	"strconv"
	"strings"
)

func main() {
	var a string
	var b string
	fmt.Scanf("%v %v", &a, &b)

	f1, _ := strconv.ParseInt(a, 10, 64)
	f11 := big.NewInt(f1)
	f2 := toBig(b)
	f22 := big.NewInt(int64(f2))
	f11.Mul(f11, f22)
	f11.Div(f11, big.NewInt(100))

	fmt.Printf("%v\n", f11)

}

func toBig(s string) uint64 {
	pos := strings.Index(s, ".")
	if pos < 0 {
		s = s + "00"
	} else {
		l := len(s[pos + 1:])
		switch l {
		case 0:
			s = s + "00"
		case 1:
			s = s + "0"
		case 2:
		}
	}
	s = strings.Replace(s, ".", "", 1)
	//fmt.Printf("s=%v\n", s)

	r, _ := strconv.ParseUint(s, 10, 64)
	return r
}


Measured memory_bytes: 1976
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
struct edge{
    int to,cost;
};
V<edge>graph[20];
int main(){
  int n;
  cin>>n;
  n--;
  for(int i=0;i<19;i++){
      graph[i].emplace_back(edge{i+1,0});
  }
  int ind=-1;
  for(int i=19;i>=0;i--){
      if(n&(1<<i)){
          ind=i;
          break;
      }
  }
  if(ind!=-1){
  for(int i=18;i>=0;i--){
      if(18-i!=ind)graph[i].emplace_back(edge{i+1,(1<<(18-i))});
      else break;
  }
  graph[0].emplace_back(edge{19,(1<<ind)});
  int x=(1<<ind);
  for(int i=ind-1;i>=0;i--){
      if(n&(1<<i)){
          graph[0].emplace_back(edge{19-i,x+1});
          x+=(1<<i);
      }
  }
  }
  int sum=0;
  for(int i=0;i<20;i++)sum+=(int)graph[i].size();
  cout<<20<<" "<<sum<<"\n";
  for(int i=0;i<20;i++){
      for(int j=0;j<graph[i].size();j++){
          cout<<i+1<<" "<<graph[i][j].to+1<<" "<<graph[i][j].cost<<"\n";
      }
  }
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let p = read_vec::<usize>()
        .iter()
        .map(|&x| x - 1)
        .collect::<Vec<_>>();
    let mut a = (1i64..n as i64 + 1).collect::<Vec<_>>();
    let mut b = a.clone();
    b.reverse();

    let mut sum_along_a = vec![0; n];
    let mut sum_along_b = vec![0; n];

    for (i, pidx) in p.into_iter().enumerate() {
        let adding = (2 * (n - i)) as i64;
        if pidx == 0 {
            sum_along_a[pidx + 1] = adding;
        } else if pidx == n - 1 {
            sum_along_b[pidx - 1] = adding;
        } else {
            sum_along_a[pidx + 1] = adding;
            sum_along_b[pidx - 1] = adding;
        }
    }
    for i in 1..n {
        sum_along_a[i] += sum_along_a[i - 1];
    }
    for i in (0..n - 1).rev() {
        sum_along_b[i] += sum_along_b[i + 1];
    }
    for i in 0..n {
        a[i] += sum_along_a[i];
        b[i] += sum_along_b[i];
    }
    print_array(&a);
    print_array(&b);
    let c = a.iter()
        .zip(b.iter())
        .map(|(&x, &y)| x + y)
        .collect::<Vec<_>>();
    debug!(c);
}

fn print_array<T: std::string::ToString>(array: &Vec<T>) {
    println!(
        "{}",
        array
            .iter()
            .map(|ref x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 6780
#include <iostream>
#include <map>

using namespace std;

int main(void) {
	int n, i, a;
	map<int, int> mp;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf("%d", &a);
		mp[a]++;
	}
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf("%d", &a);
		if (mp[a] == 0) {
			printf("NO\n");
			return 0;
		}
		mp[a]--;
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 9728
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };
typedef tuple<ll, ll, ll>T;
typedef pair<int, int>pint;


vector<ll>dev;
void devisor(ll n) {
	for (ll i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			if (i == n / i) {
				dev.push_back(i);
			}
			else {
				dev.push_back(i);
				dev.push_back(n / i);
			}
		}
	}
}

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

	ll ans = 0;
	rep(i, 0, dev.size()) {
		ll temp = n / dev[i];
		ll m = temp - 1;
		if (dev[i] < m)ans += m;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      int a,b,c,d;
      cin >> a >> b >>c >> d;
      cout << min(a,b)+min(c,d) << endl;
      return 0;}

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

struct edge{
	int v; LL w;
};

vector<vector<edge>> adj;
vector<LL> dist;

void bfs(int root){
	queue<int> frontier;
	dist[root] = 0;
	frontier.push(root);
	while(not frontier.empty()){
		int here = frontier.front(); frontier.pop();
		for (edge& e : adj[here]){
			if (dist[e.v] == -1){
				dist[e.v] = dist[here] + e.w;
				frontier.push(e.v);
			}
		}
	}
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	int N; cin >> N;
	adj.resize(N+1);
	dist.assign(N+1, -1);
	int a, b, c;
	for (int i = 0; i < N-1; ++i){
		cin >> a >> b >> c;
		adj[a].push_back({b, (LL)c});
		adj[b].push_back({a, (LL)c});
	}
	int T, K; cin >> T >> K;
	bfs(K);
	int x, y;
	while(T-->0){
		cin >> x >> y;
		cout << dist[x] + dist[y] << endl;
	}

    return 0;
}

Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
const int MOD=998244353;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> l(k),r(k),dp(n+5),sum(n+5);
    rep(i,k){
      cin>>l[i]>>r[i];
    }
  
    dp[1]++;sum[1]++;
    for(int i=2;i<=n;i++){
        rep(j,k){
            int a=i-r[j];
            int b=i-l[j];
            a=max(a,1);
            if(b<0) continue;
            dp[i]+=sum[b]-sum[a-1];
            dp[i]=(dp[i]%MOD+MOD)%MOD;
        }
        sum[i]=dp[i]+sum[i-1];
        sum[i]=(sum[i]%MOD+MOD)%MOD;
    }
    cout<<(dp[n]+MOD)%MOD<<endl;
    return 0;
}


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

int main(){
	double a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << fixed << setprecision(10) << sqrt((a - c) * (a - c) + (b - d) * (b - d)) << endl;
}

Measured memory_bytes: 3232
#include<iostream>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;


#define rep(i, a, b) for(ll i=(a); i<(b); i++)

int main(){
  ll N, now = 0;
  cin >> N;
  priority_queue<pair<ll, ll> > Q;
  rep(i,0,N){
    ll a,b;
    cin >> a >> b;
    Q.push(make_pair(-b,a));
  }
  rep(i,0,N){
    pair<ll, ll > q = Q.top(); Q.pop();
    now += q.second;
    if(now > -q.first){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 6256
n,p=map(int,input().split())
if p==2 or p==5:
  print(sum(i+1 for i,x in enumerate(input()) if int(x)%p==0))
  exit()
t=1
y=0
c=[0]*p
for x in map(int,input()[::-1]):
  y+=t*x
  y%=p
  c[y]+=1
  t*=10
  t%=p
print(sum(i*(i-1)//2 for i in c)+c[0])


Measured memory_bytes: 3636
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	VI L(N);
	REP(i, N)cin >> L[i];

	int ans = 0;

	REP(i, N) {
		FOR(j, i + 1, N) {
			FOR(k, j + 1, N) {

				int a = L[i], b = L[j], c = L[k];
				if (a + b > c && a + c > b && b + c > a && a!=b&&b!=c&&a!=c) {
					ans++;
					//cout << i << " " << j << " " << k << endl;
				}

			}
		}
	}

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



Measured memory_bytes: 3648