akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

mat G(200010);
vector<bool> d(200010,false);
vec res(2);
void DFS(int start){
    d[start]=true; res[0]++;
    ST st; st.push(start);
    while(!st.empty()){
        int s=st.top(); st.pop();
        each(t,G[s]){
            if(d[t]) continue;
            d[t]=true;
            if(t<=100000) res[0]++;
            else          res[1]++;
            st.push(t);
        }
    }
    return;
}

int main(){
    int N; cin>>N;
    rep(i,N){
        int x,y; cin>>x>>y;
        G[x].pb(y+100000);
        G[y+100000].pb(x);
    }
    ll ans=-N;
    rep(i,100000){
        if(d[i]) continue;
        res[0]=res[1]=0;
        DFS(i);
        ans+=res[0]*res[1];
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int a=0,b=0,ans=0;
    for(int i=0;i<(int)s.length();++i)
    {
        if(s[i]=='0')
        a++;
        else
        {
            b++;
        }
        
    }
    cout << 2*min(a,b);

}

Measured memory_bytes: 512
use std::vec::Vec;
use std::cmp;

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()
}

fn main() {
  let (n, a, b, c) = {
    let v: Vec<i64> = read_vec();
    (v[0], v[1], v[2], v[3])
  };

  let mut l: Vec<i64> = Vec::new();

  for _ in 0..n {
    let e: i64 = read();
    l.push(e);
  }



  println!("{:?}", dfs(n-1, &l, (a, b, c), (0, 0, 0), 0));
}

// 愚直なdfsの実装
fn dfs(n: i64, l: &Vec<i64>, a: (i64, i64, i64), e: (i64, i64, i64), cost: i64) -> i64 {
  if n == -1 {

    if e.0 > 0 && e.1 > 0 && e.2 > 0 {
      // ここで切断や延長のマジックポイントを計算している
      // 最初の一本目を選ぶときに
      // 二本以上ないのに合成魔法を使ってマジックポイントを30使っている
      return cost + (e.0 - a.0).abs() + (e.1 - a.1).abs() + (e.2 - a.2).abs() - 30;
    }
    else {
      return 100000;
    }
  }

  let ret1: i64 = dfs(n - 1, &l, a, e, cost);
  let ret2: i64 = dfs(n - 1, &l, a, (e.0 + l[n as usize], e.1, e.2), cost + 10);
  let ret3: i64 = dfs(n - 1, &l, a, (e.0, e.1 + l[n as usize], e.2), cost + 10);
  let ret4: i64 = dfs(n - 1, &l, a, (e.0, e.1, e.2 + l[n as usize]), cost + 10);

  return [ret1, ret2, ret3, ret4].iter().fold(std::i64::MAX, |acc, i| cmp::min(acc, *i))
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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


Measured memory_bytes: 3532
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);    
    int N; cin >> N;
    
    int M; cin >> M;
    
    ll P; cin >> P;
    vector<vpl > graph(N);
    vector<vi > graph2(N);
    F0R(i, M) {
		int A, B, C; cin >> A >> B >> C; A--; B--; C-=P;
		graph[A].pb(mp(B, C)); 
		graph2[B].pb(A);
	}
	
	bool foundEnd[N]; F0R(i, N) foundEnd[i] = false;
	queue<int> q;
	q.push(N-1);
	foundEnd[N-1] = true;
	while (!q.empty()) {
		int cur = q.front(); q.pop();
		F0R(i, sz(graph2[cur])) {
			int nxt = graph2[cur][i];
			if (!foundEnd[nxt]) {
				foundEnd[nxt] = true;
				q.push(nxt);
			}
		}
	}
	
	ll dist[N];
	F0R(i, N) {
		dist[i] = -1000000000000;
	}
	dist[0] = 0;
	
	bool found[N]; F0R(i, N) found[i] = false;
	
	found[0] = true;
	
	F0R(i, N) {
		F0R(j, N) {
			if (dist[j] == -1000000000000) continue;
			F0R(k, sz(graph[j])) {
				int nxt = graph[j][k].f;
				found[nxt] = true;
				if (dist[nxt] < dist[j] + graph[j][k].s) {
					dist[nxt] = dist[j]+graph[j][k].s;
				}
			
			}
		}
	}
	
	/*F0R(i, N) {
		cout << dist[i] << " ";
	} cout << endl;*/
	
	F0R(i, N) {
		F0R(j, sz(graph[i])) {
		
			int k = graph[i][j].f;
			if (dist[k] == -1000000000000 || dist[i] == -1000000000000) continue;
			if (dist[k] < dist[i] + graph[i][j].s && foundEnd[k]) {
				cout << -1 << endl; return 0;
			}
		}
	}
	
	cout << max(0LL, dist[N-1]) << endl;
	
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using ll=long long;
using namespace std;
const auto mod=1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  
  double l; cin >> l;
  cout << l*l*l/27 << endl;
}






Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;

int main(){
	int t,k;
	cin>>t>>k;
	int a[t];
	for(int i=0;i<t;i++){
		cin>>a[i];
	}
	sort(a,a+t);
	int sum=0;
	for(int i=t-1;i>=t-k;i--){
		sum+=a[i];
	}
	cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
using namespace std;
int main(void) {
    int r, c;
    int a[200][200] = {};
    cin >>r>>c;
    for (int i = 1; i<=r; i++) {
        for (int j = 1; j <= c; j++) {
            cin >> a[i][j];
            a[r + 1][j] += a[i][j];
            a[i][c + 1] += a[i][j];
        }
    }
    for (int i=1; i<=r; i++) {
        a[r + 1][c + 1] += a[i][c + 1];
    }
    for (int i= 1; i<= r + 1; i++) {
        for (int j= 1; j<=c; j++) {
            cout << a[i][j] << " ";
        }
        cout << a[i][c + 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3240
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void main() {
  string s = readln.strip;
  foreach (i; 0 .. 26) {
    auto c = (i + 97).to!(char);
    if (s.find (c).empty) {
      writeln (s, c);
      return;
    }
  }
  
  int l = s.length.to!(int);

  auto a = s.map! (c => c.to!(int) - 97).array;
  
  string res = "~"; 
  foreach (i; 0 .. l) {
    foreach (j; 0 .. 26) {
      if (a[0 .. i].find (j).empty && j > a[i]) {
        auto t = s[0 .. i] ~ (j + 97).to!(char);
        if (res > t) {
          res = t;
        }
      }
    }
  }

  if (res == "~") {
    res = "-1";
  }
  writeln (res);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		while(true){
			C -= B;
			if(C <= 0){
				break;
			}
			A -= D;
			if(A <= 0){
				break;
			}
		}
		System.out.println(A > 0 ? "Yes" : "No");
	}
}

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



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


    //問題案Dをmapに保存する。
    map<int, int>  d_map;
    for(int i=0;i<n;i++){
        int wk;
        cin>>wk;
        if(d_map.count(wk))
            d_map.at(wk)++;
        else
            d_map[wk]=1;
    }


    //難易度Tに合った問題案Dがあるか調べる。
    int m;
    cin>>m;
    bool flg=true;
    for(int i=0;i<m;i++){
        int t;
        cin>>t;
        if(d_map.count(t)){
            d_map.at(t)--;
            if(d_map.at(t)<0)
                flg=false;
        }
        else
            flg=false;
    }

    if(flg)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;

    return 0;
}

Measured memory_bytes: 9600
B=[]
for i in range(3):
    A=list(map(int,input().split()))
    B.append(A[0])
    B.append(A[1])
    B.append(A[2])
N=int(input())
for j in range(N):
    b=int(input())
    if b in B:
        B[B.index(b)]=0
if B[0]==0 and B[1]==0 and B[2]==0:
    print('Yes')
elif B[3]==0 and B[4]==0 and B[5]==0:
    print('Yes')
elif B[6]==0 and B[7]==0 and B[8]==0:
    print('Yes')
elif B[0]==0 and B[3]==0 and B[6]==0:
    print('Yes')
elif B[1]==0 and B[4]==0 and B[7]==0:
    print('Yes')
elif B[2]==0 and B[5]==0 and B[8]==0:
    print('Yes')
elif B[0]==0 and B[4]==0 and B[8]==0:
    print('Yes')
elif B[2]==0 and B[4]==0 and B[6]==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 62172
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i = 1; i <= (int)c; i++)
#define ll long long
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;
#define upd_min(miner, updater) if (miner > updater) miner = updater;
const int inf = 1000000000; // 10^9

int main(){
    ll n, r = 0, g = 0, b = 0;
    char s[4100];
    ll ans = 0, cnt = 0;

    cin >> n;
    rep(i, n){
        cin >> s[i];
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else if(s[i] == 'B') b++;
    }

    ans = r * g * b;

    rep(i, n){
        rep(j, (n - i)/2){
            if(s[i] != s[i + j] && s[i] != s[i + 2*j] && s[i + 2 * j] != s[i + j]) cnt++;
        }
    }

    ans -= cnt;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mp(a,b) make_pair(a,b)
#define vi vector<int>
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define vp vector<pair<int,int> >
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define F first
#define S second
#define endl "\n"
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define dom 998244353
#define pi 3.14159265
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define pii pair<int,int> 
#define mini 2000000000000000000
#define time_taken 1.0 * clock() / CLOCKS_PER_SEC
//mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
void shikhar7s(int cas)
{
    int n,i,j,x;
    cin>>n;
    int c,ans=0;
    rep(i,2,sqrt(n)+1)
    {
        if(n%i==0)
        {
            c=0;
            while(n%i==0)
            {
                n/=i;
                c++;
            }
            x=1;
            for(j=1;;j+=x)
            {
                if(j<=c)
                    ans++;
                else
                    break;
                x++;
            }
        }
    }
    if(n!=1)
    {
        ans++;
    }
    cout<<ans;
}
signed main()
{
    fast;
    int t=1;
    //cin>>t;
    int cas=1;
    while(cas<=t)
    {
    shikhar7s(cas);
    cas++;
    }
    return 0;
}

Measured memory_bytes: 3688
#include <cstdio>
#include <iostream>

using namespace std;

//insertionSort(A, n, g)
//    for i = g to n-1
//        v = A[i]
//        j = i - g
//        while j >= 0 && A[j] > v
//            A[j+g] = A[j]
//            j = j - g
//            cnt++
//        A[j+g] = v
//
//shellSort(A, n)
//    cnt = 0
//    m = ?
//    G[] = {?, ?,..., ?}
//    for i = 0 to m-1
//        insertionSort(A, n, G[i])

int cnt = 0;
void insertionSort(int A[], int n, int g) {
	for (int i = g; i < n; ++i) {
		int v = A[i];
		int j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j = j - g;
			cnt++;
		}
		A[j + g] = v;
	}
}

void shellSort(int A[], int n) {
	cnt = 0;
	int g = 0;
	int m = -1;
	while (g <= n) {
		g = g * 3 + 1;
		++m;
	}

	int G[m];
	g = (g - 1) / 3;
	for (int i = 0; i < m; ++i) {
		G[i] = g;
		g = (g - 1) / 3;
	}
	cout << m << endl;
	for (int i = 0; i < m; ++i) {
		if (i != 0)
			cout << " " << G[i];
		else
			cout << G[i];
	}
	cout << endl;
	for (int i = 0; i < m; ++i) {
		insertionSort(A, n, G[i]);
	}
}
int main() {

	int n;
	scanf("%d", &n);

	int A[n];
	for (int i = 0; i < n; ++i) {
		scanf("%d", A + i);
	}

	shellSort(A, n);

	cout << cnt << endl;

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

	return 0;
}

Measured memory_bytes: 7040
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    if (n[0] == n[1] && n[0] == n[2]) {
        puts("Yes");
        return 0;
    }

    if (n[1] == n[2] && n[1] == n[3]) {
        puts("Yes");
        return 0;
    }

    puts("No");

    return 0;
}


Measured memory_bytes: 384
mizuyari=0
n=int(input())
s=list(map(int,input().split()))
def hiku(n):
    return n-1
for i in range(100):
    if s[0]>0:
        mizuyari+=1
    for j in range(n-1):
        if s[j]<=0 and s[j+1]>0:
            mizuyari+=1
    s=list(map(hiku,s))
print(mizuyari)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<cxxabi.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
#define mp make_pair
#define fi first
#define se second
#define All(x) (x).begin(),(x).end()
#define TYPEVS(x) typeid(x).name()
#define TYPEGC(x) abi::__cxa_demangle(typeid(x).name(), 0, 0, 0)
#define Y1 "YES"
#define N1 "NO"
#define ENDL '\n'
#define count2(x) _builtin_popcount(x)
ull yuantofen(string m){
	ull xiaoshu=0;
	ull zhengshu=0;
	int i=0;
	for(i=0;i<m.size()&&m[i]!='.';++i){
		zhengshu=zhengshu*10+m[i]-'0';
	}
	zhengshu*=100;
	if(i<m.size()&&m[i]=='.'){
		i++;
		if(i<m.size())
		xiaoshu=m[i]-'0',xiaoshu*=10,i++;
		if(i<m.size())
		xiaoshu+=m[i]-'0';
	}
	return zhengshu+xiaoshu;
}
int main(){
	ull n;
	string m;
	cin>>n;
	cin>>m;
	ull p=yuantofen(m);
	//cout<<p;
	ull ans=n*p;
	cout<<ans/100;
	/*if(ans%100==0){
		cout<<ans/100;
	} 
	else if(ans%10==0){
		cout<<ans/100<<'.'<<(ans/10)%10;
	}
	else{
		cout<<ans/100<<'.'<<(ans/10)%10<<ans%10;
	}*/
}


Measured memory_bytes: 3628
// AtCoder Regular Contest 081
// E - Don't Be a Subsequence

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;


const int A2Z = 26;

int N;
string s;
stack<int> st;
vector<int> at[A2Z];

int main() {

    int min_i;
    int idx;
    string ans;

    cin >> s;
    N = s.length();
    for (int i = 0; i < N; i++) {
        at[s[i] - 'a'].push_back(i);
    }

    for (int j = 0; j < A2Z; j++) {
        at[j].push_back(N);
    }

    min_i = N;
    while (min_i >= 0) {
        st.push(min_i);
        for (int j = 0; j < A2Z; j++) {
            auto itr = lower_bound(at[j].begin(), at[j].end(), st.top());
            if (itr == at[j].begin()) {
                min_i = -1;
                break;
            }
            itr--;
            min_i = min(min_i, *itr);
        }
    }

    idx = -1;
    while (!st.empty()) {
        for (int j = 0; j < A2Z; j++) {
            auto itr = upper_bound(at[j].begin(), at[j].end(), idx);
            if (*itr >= st.top()) {
                ans.push_back('a' + j);
                idx = *itr;
                break;
            }
        }
        st.pop();
    }

    cout << ans << endl;

    return 0;

}





Measured memory_bytes: 1412
x=y=gets.to_i
*w=z=[]
s=(x-2)**2
$<.map{f,t=_1.split.map &:to_i
x,y,z,w=y,x,w,z if f>1
z[x-=1]=y-2while x>t
s-=z[t]
x,y,z,w=y,x,w,z if f>1}
p s

Measured memory_bytes: 32532
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  ll ans = 0;
  set<ll> st;
  rep(i, n) {
    ans += i + 1;
    st.insert(i + 1);
    if (ans >= n) break;
  }

  ll mar = ans - n;

  for (ll i = ans; i > 0;) {
    if (mar >= i) {
      st.erase(i);
      mar -= i;
      i = mar;
    } else {
      i--;
    }
  }

  for (ll x : st) {
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 3820
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
  
using namespace std;

int main() {
	char s[3];
	int count = 0;
	REP(i,3) {
		cin >> s[i];
		if (s[i] == 'o') count++;
	}
	cout << 700 + 100*count << endl;
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define outa(x, n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const ll INFL = (1L<<61);

int main() {
  ll n, m, L; cin >> n >> m >> L;
  vvl dist(n,vl(n,INFL));
  rep(i,n) dist[i][i] = 0;
  rep(i,m) {
    ll a, b, c; scanf("%lld %lld %lld", &a, &b, &c);
    a--; b--;
    dist[a][b] = dist[b][a] = c;
  }
  rep(k,n) rep(i,n) rep(j,n) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

  vvl ans(n,vl(n,INFL));
  rep(i,n) rep(j,n) if (dist[i][j] <= L) ans[i][j] = 1;
  rep(i,n) ans[i][i] = 0;
  rep(k,n) rep(i,n) rep(j,n) ans[i][j] = min(ans[i][j], ans[i][k] + ans[k][j]);

  ll Q; cin >> Q;
  rep(i,Q) {
    ll s, t; scanf("%lld %lld", &s, &t);
    s--; t--;
    if (ans[s][t] == INFL) {
      cout << -1 << endl;
    } else {
      cout << ans[s][t] - 1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1920
N=int(input())
a=[int(x) for x in input().split()]
Alice=0
Bob=0
for i in range(N):
  if i%2==0:
    Alice=Alice+max(a)
    a.remove(max(a))
  else:
    Bob=Bob+max(a)
    a.remove(max(a))
print(Alice-Bob)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define LOG(...) printf(__VA_ARGS__)
using namespace std;

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

    for (int i = 0; i < a; ++i) {
        char c;
        cin >> c;

        if (c < '0' || c > '9') {
            cout << "No" << endl;
            return 0;
        }
    }

    char c;
    cin >> c;
    if (c != '-') {
        cout << "No" << endl;
        return 0;
    }

    for (int i = 0; i < b; ++i) {
        char c;
        cin >> c;

        if (c < '0' || c > '9') {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
int x[110000];
int dp[110000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%d",x+i);
	for(int i=0;i<=a;i++)dp[i]=mod;
	dp[0]=0;
	for(int i=0;i<a;i++){
		for(int j=1;j<=b;j++){
			if(i+j<a)dp[i+j]=min(dp[i+j],dp[i]+ABS(x[i]-x[i+j]));
		}
		// if(i+1<a)dp[i+1]=min(dp[i+1],dp[i]+ABS(x[i]-x[i+1]));
		// if(i+2<a)dp[i+2]=min(dp[i+2],dp[i]+ABS(x[i]-x[i+2]));
	}
	printf("%d\n",dp[a-1]);
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int dp[100010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    int h[100010];
    rep(i, N) cin >> h[i];
    rep(i, N) dp[i] = INF;
    rep(i, K) dp[i] = abs(h[i] - h[0]);
    REP(i, K, N - 1) {
        REP(d, 1, K) { 
            int stepd = abs(h[i] - h[i - d]);
            dp[i] = min(dp[i], dp[i - d] + stepd);
        }
    }
    cout << dp[N - 1] << endl;


    return 0;
}


Measured memory_bytes: 1024
import numpy as np
import sys
input = sys.stdin.readline
N,W = map(int,input().split())
dp = np.zeros(W+1,dtype=int)
for i in range(N):
    w,v = map(int,input().split())
    dp[w:] = np.maximum(dp[w:],dp[:-w]+v)
print(dp[-1])

Measured memory_bytes: 15420
package main

import (
	"fmt"
	"os"
)

func main() {
	var a int
	var sum int

	for i := 0; i < 3; i++ {
		fmt.Scan(&a)
		if a != 5 && a != 7 {
			fmt.Println("NO")
			os.Exit(0)
		}
		sum += a
	}
	if sum == 17 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


Measured memory_bytes: 512
/********************************************************************************
	
	Code by a weak man who named CYJian, and he hopes the code can get more points.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define ra read_alpha()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline char read_alpha() { char c = ge; while(!isalpha(c) && c != EOF) c = ge; return c; }
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

int n, mod;
int S2[2][3010];
int fac[3010];
int ifac[3010];

inline int fsp(int x, int k, int mod) {
	int s = 1;
	while(k) {
		if(k & 1) s = 1LL * s * x % mod;
		x = 1LL * x * x % mod, k >>= 1;
	} return s;
}

int main() {
#ifdef LOCAL
	FILE("");
#endif
	n = ri, mod = ri;
	int res = 0, o = 0, t = 1;
	S2[0][0] = ifac[0] = fac[0] = 1;
	for(int i = 1; i <= n; i++) ifac[i] = fsp(fac[i] = 1LL * fac[i - 1] * i % mod, mod - 2, mod);
	for(int i = 0; i <= n; i++) {
		for(int j = 1; j <= i + 1; j++)
			S2[t][j] = (S2[o][j - 1] + 1LL * S2[o][j] * j) % mod;
		o ^= 1, t ^= 1, S2[t][0] = 0;
		int prd = fsp(2, fsp(2, n - i, mod - 1), mod);
		int p = fsp(2, n - i, mod), mul = 1, s = 0;
		prd = i & 1 ? mod - prd : prd;
		for(int j = 0; j <= i; j++) {
			s = (s + 1LL * S2[o][j + 1] * mul) % mod;
			mul = 1LL * mul * p % mod;
		} res = (res + 1LL * prd * s % mod * ifac[i] % mod * ifac[n - i] % mod * fac[n]) % mod;
	} cout << res << endl;
	return 0;
}

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

// clang-format off
#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

#define rep(i, n) for (int i = 0; i < (int)(n); ++(i))
#define reps(i, n) for (int i = 1; i <= (int)(n); ++(i))
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --(i))
#define rreps(i, n) for (int i = (int)(n); i > 0; --(i))

#define range(i, l, r) for (int i = (int)l; i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = ((int)(r) - 1); i >= (int)l; --(i))

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)

using int32 = int;
using int64 = long long;

constexpr int mod     = 1e9 + 7;
constexpr int32 inf   = 1001001001;
constexpr int64 infll = 1001001001001001001ll;
constexpr int dx[]    = {0, -1, 1, 0, -1, 1, -1, 1},
              dy[]    = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

template<typename T = int64> T input() { T x; cin >> x; return x; }

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
  int N = input(), x = input();

  vector<int> A(N);
  cin >> A;

  int64 ans = 0;
  range(i, 0, N) {
    if (A[i] > x) {
      ans += A[i] - x;
      A[i] = x;
    }
  }

  range(i, 1, N) {
    if (A[i - 1] + A[i] > x) {
      ans += A[i - 1] + A[i] - x;
      A[i] = x - A[i - 1];
    }
  }

  cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 640
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll table[100001],calc_table[100001];

int main(){

	int N;
	ll T;
	scanf("%d %lld",&N,&T);

	table[0] = 0;
	for(int i = 1; i <= N; i++){
		scanf("%lld",&table[i]);
		table[i] += table[i-1];
	}

	printf("%lld\n",T/table[1]+1);

	if(N == 1){
		return 0;
	}

	calc_table[0] = 0;
	calc_table[1] = 2*table[1];

	ll diff;

	for(int i = 2; i <= N; i++){
		if(calc_table[i-1] >= table[i]){
			calc_table[i] = calc_table[i-1]+(table[i]-table[i-1]);
		}else{
			calc_table[i] = table[i]+(table[i]-table[i-1]);
		}
		if(table[i] > T){
			printf("1\n");
			continue;
		}

		diff = calc_table[i]-table[i];
		printf("%lld\n",(T-table[i])/diff+2);
	}

	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<long long> a(3*N);
    for(int i=0; i<3*N; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<long long>());

    long long ans =0;
    for(int i=0; i<N; i++){
        ans += a[i*2 + 1];
    }

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

Measured memory_bytes: 5632
n = int(input())
a = [int(i) for i in input().split(' ')]
b = [int(i) for i in input().split(' ')]
c = [int(i) for i in input().split(' ')]

result = sum(b)

for i in range(len(a) - 1):
    if a[i + 1] == a[i] + 1:
        result += c[a[i] - 1]

print(result)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int H,W; cin>>H>>W;
  vector<string> S(H);
  rep(i,0,H) cin>>S[i];
  vii dp(H,vi(W));
  rep(i,0,H){
    if(S[i][0]=='#')
      break;
    dp[i][0]=1;
  }
  rep(i,0,W){
    if(S[0][i]=='#')
      break;
    dp[0][i]=1;
    }
  rep(i,1,H){
    rep(j,1,W){
      if(S[i-1][j]=='.')
        dp[i][j]+=dp[i-1][j];
      if(S[i][j-1]=='.')
        dp[i][j]+=dp[i][j-1];
      dp[i][j]%=MOD;
    }
  }
  cout<<dp[H-1][W-1]<<endl;
  }



Measured memory_bytes: 9216
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;
	static int[] par, dep, ch;

	static void solve() {
		out.println((ir.nextInt()-ir.nextInt())%ir.nextInt());
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 21204
n = int(input())
for i in range(1,3501):
  for j in range(1,3501):
    if 4*i*j-n*j-n*i:
      if (n*i*j)/(4*i*j-n*j-n*i) == (n*i*j)//(4*i*j-n*j-n*i) and (n*i*j)//(4*i*j-n*j-n*i) > 0:
        print(i,j,(n*i*j)//(4*i*j-n*j-n*i))
        quit()

Measured memory_bytes: 41068
#include <bits/stdc++.h>
#define MOD 1000000007 
using namespace std;

int n,dp[10000010];
bool vis[30][30];

inline void add(int &x,int y)
{
	x+=y;
	if(x>=MOD) x-=MOD;
}

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>vis[i][j];
		}
	}
	dp[0]=1;
	for(int i=0;i<(1<<n)-1;i++){
		int num=__builtin_popcount(i);
		for(int j=1;j<=n;j++) if(!(i&(1<<(j-1)))){
			if(vis[num+1][j]){
				add(dp[i|(1<<(j-1))],dp[i]);
			}
		}
	}
	cout<<dp[(1<<n)-1]<<endl;
	return 0;
}

Measured memory_bytes: 10496
// #include "exp.hpp"

#include <iostream>
#include <numeric>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  string S, T;
  cin >> S >> T;

  cout << inner_product(S.begin(), S.end(), T.begin(), 0,
                        [](int a, int b) { return a + b; },
                        [](char a, char b) { return a == b ? 1 : 0; })
       << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool isprime(int n){
	if(n==1)return 0;
	if(n==2)return 1;
	for(int i=2;i*i<=n;i++){
		if(n%i==0)return 0;
	}
	return 1;
}
int main(){
//	freopen("a.txt","r",stdin);
	int n,a,res=0;
	cin>>n;
	while(n--){
		cin>>a;
		if(isprime(a))res++;
	}cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3092
#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 FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main(){
	int A,B;
	SCD2(A,B);
	
	int ans = max({A+B,A-B,A*B});
	PRINTD(ans);
	
	
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	ans := ""
	for i := 0; i < len(s); i++ {
		switch {
		case s[i] == '0':
			ans += "0"
		case s[i] == '1':
			ans += "1"
		case s[i] == 'B':
			if ans == "" {
				continue
			}
			ans = ans[:len(ans)-1]
		}
	}
	fmt.Println(ans)
}


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

#define MAXN (100010)
#define mod (1000000007)
#define ll long long

ll n, A, B;
ll f[2][MAXN], pre[2][MAXN], s[MAXN];
std::map<ll, ll> map;

int main(){
	scanf("%lld%lld%lld", &n, &A, &B);
	for(int i = 1; i <= n; ++ i){
		scanf("%lld", &s[i]);
		map[- s[i]] = i;
	}
	f[0][0] = pre[0][0] = 1;
	f[1][0] = pre[1][0] = 1;
	int tmp1 = 0, tmp2 = 0;
	for(int i = 2; i <= n; ++ i){
		std::map<ll, ll>::iterator u;
		int pos;
		
		u = map.lower_bound(B - s[i]);
		if(u == map.end()){
			pos = 0;
		}
		else{
			pos = u -> second;
		}
		if(pos == i - 1){
			-- pos;
		}
		f[1][i - 1] = pre[0][pos];
		
		u = map.lower_bound(A - s[i]);
		if(u == map.end()){
			pos = 0;
		}
		else{
			pos = u -> second;
		}
		if(pos == i - 1){
			-- pos;
		}
		f[0][i - 1] = pre[1][pos];
		
		if(s[i] - s[i - 1] < A){
			for(int j = tmp1; j < i - 1; ++ j){
				f[0][j] = pre[0][j] = 0;
			}
			tmp1 = i - 1;
		}
		
		if(s[i] - s[i - 1] < B){
			for(int j = tmp2; j < i - 1; ++ j){
				f[1][j] = pre[1][j] = 0;
			}
			tmp2 = i - 1;
		}
		
		pre[1][i - 1] = (pre[1][i - 2] + f[1][i - 1]) % mod;
		pre[0][i - 1] = (pre[0][i - 2] + f[0][i - 1]) % mod;
	}
	ll ans = 0;
	for(int i = 0; i < n; ++ i){
		(ans += f[0][i] + f[1][i]) %= mod;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

int N;
unordered_set < int > ans;
const int dt[3] = {7,5,3};

void dfs (vector < int > digit) {
    if (digit.size() > 9) return;
    for (int i = 0; i < 3; i++) {
        vector < int > dd = digit;
        dd.push_back(dt[i]);
        sort(dd.begin(), dd.end());
        dfs(dd);
    }
    do {
        int anst = 0;
        REP(i,digit.size()) {
            anst *= 10;
            anst += digit[i];
        }
        if (anst <= N) {
            ans.insert(anst);
        }
    } while (next_permutation(digit.begin(), digit.end()));
}

int main ()
{
    cin >> N;
    dfs ({3,5,7});

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

    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define INF 1000000100
#define M 1000000007ll
#define INFLL 1000000000000000010ll
#define UQ(x) (x).resize(distance((x).begin(),unique(all((x)))))
#define mid(x,y) (((x)+(y))>>1)

ll l;
int n;
ll a,b;
ll x[200005];
struct fen1 {
	ll ft[200005],off;
	void init() {
		for (int i=1;i<=l;i++) ft[i]=INFLL;
		off=0ll;
	}
	ll query(int p) {
		ll ret=INFLL;
		for (;p;p-=p&-p) ret=min(ret,ft[p]);
		return ret+off;
	}
	void update(int p,ll v) {
		v+=l-p+1-off;
		for (;p<=l;p+=p&-p) ft[p]=min(ft[p],v);
	}
	void add(ll v) {
		off+=v;
	}
};
struct fen2 {
	ll ft[200005],off;
	void init() {
		for (int i=1;i<=l;i++) ft[i]=INFLL;
		off=0ll;
	}
	ll query(int p) {
		p=l-p+1;
		ll ret=INFLL;
		for (;p;p-=p&-p) ret=min(ret,ft[p]);
		return ret+off;
	}
	void update(int p,ll v) {
		p=l-p+1;
		v+=l-p+1-off;
		for (;p<=l;p+=p&-p) ft[p]=min(ft[p],v);
	}
	void add(ll v) {
		off+=v;
	}
};
fen1 s1;
fen2 s2;
ll s[200005];
int main() {
	scanf("%lld%d%lld%lld",&l,&n,&a,&b);
	if (a>b) swap(a,b);
	for (int i=0;i<n;i++) {
		scanf("%lld",&x[i]);
	}
	s1.init();
	s2.init();

	s1.update(a,abs(b-x[0]));
	s1.update(b,abs(a-x[0]));
	s2.update(a,abs(b-x[0]));
	s2.update(b,abs(a-x[0]));

	for (int i=1;i<=l;i++) s[i]=INFLL;
	s[a]=abs(b-x[0]);
	s[b]=abs(a-x[0]);
	ll o=0ll;
	for (int i=1;i<n;i++) {
		

		ll v1=s1.query(x[i])-(l-x[i]+1);
		ll v2=s2.query(x[i])-x[i];

		ll uv=min(v1,v2);

		s1.add(abs(x[i]-x[i-1]));
		s2.add(abs(x[i]-x[i-1]));
		o+=(ll)abs(x[i]-x[i-1]);


		s1.update(x[i-1],uv);
		s2.update(x[i-1],uv);

		s[x[i-1]]=min(s[x[i-1]],uv-o);

	}
	ll ans=o+(*min_element(s+1,s+l+1));
	printf("%lld\n", ans);
}

Measured memory_bytes: 6528
n, k = map(int,input().split())
list = [i for i in range(n+1)]
ans = 0
min = sum(list[0:k-1])
max = sum(list[n+1-k+1:n+1])

for i in range(k,n+2):
    if i == n+1:
        ans += 1
    else:
        min += list[i-1]
        max += list[n+1-i]
        ans += max-min+1

print(ans%(7+10**9))


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

int main() {
	int n;
	cin >> n;
	vector<int> d(n);
	for(int i = 0; i < n; i++) {
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	d.erase(unique(d.begin(), d.end()), d.end());
	cout << d.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+20;
//题意:找到n个串中,共有的字符组成的最长串 
int a[N];// 公共串的字符i 由n个中最小的决定 
string s;
int vis[N];
int main()
{
	int n;
	while(cin>>n)
	{
		for(int i=0;i<26;i++)
			a[i]=1e5;
		for(int i=0;i<n;i++)
		{
			cin>>s;
			memset(vis,0,sizeof(vis));
			for(int k=0;s[k];k++)
				vis[s[k]-'a']++;
			for(int k=0;k<26;k++)
				a[k]=min(a[k],vis[k]);
		}
		for(int i=0;i<26;i++)
		{
			for(int k=0;k<a[i];k++)
				printf("%c",'a'+i);
		}
		printf("\n");
	}
	return 0;
} 

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

int main(){
  int n;
  string s;
  cin>>n>>s;
  int num=0;
  for(int i=0;i<n;i++){
    int ans=0;
    for(char c='a';c<='z';c++){
      bool left=false,right=false;
      for(int j=0;j<i;j++){
        if(s[j]==c) left=true;
      }
      for(int j=i;j<n;j++){
        if(s[j]==c) right=true;
      }
      if(left&&right) ans++;
    }
    num=max(num,ans);
  }
  cout<<num<<endl;
}
     
    


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

int main(int argc, char *argv[]){
  int w,h,x,y,r;
  bool xflag,yflag;
  cin >> w;
  cin >> h;
  cin >> x;
  cin >> y;
  cin >> r;
  
  if(((x-r) >= 0) && ((x+r) <= w)){
    xflag = true;
  }else{
    xflag = false;
  }
  if(((y-r) >= 0) && ((y+r) <= h)){
    yflag = true;
  }else{
    yflag = false;
  }
  if(xflag && yflag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  return 0;
  }
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, n) for (int i = (a); i < (n); ++i)
using namespace std;
using ll = long long;
using uint = unsigned int;
const ll mod = (ll)1e9 + 7;

int main() {
  string s;
  cin >> s;
  ll sum = 0;
  rep(i, s.size()) {
    sum += s[i] - '0';
  }
  if (sum % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,k,e=0;
  cin>>n;
  vector<int> v;
  map<int,int> m;
  for(int i=0;i<n;++i){
    cin>>k;
    if(++m[k]<2)v.push_back(k);
  }
  for(auto& p:m){
    if(p.second>2){
      k=p.second-(2-p.second%2);
      n-=k;
      p.second-=k;
    }
    if(p.second==2)e++;
  }
  cout<<n-e-e%2;
}

Measured memory_bytes: 5368
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_6_C
{
    public class Program

    {
        public static void Main(string[] args)
        {

            int[,,] house = new int[4, 3, 10];
            int[] line;
            long n = ReadLong();

            for(long i = 0; i < n; i++)
            {
                line = ReadIntAr();
                house[line[0]-1, line[1]-1, line[2]-1] += line[3];
            }

            for (int i = 0; i < house.GetLength(0); i++)
            {
                for (int j = 0; j < house.GetLength(1); j++)
                {
                    for (int k = 0; k < house.GetLength(2); k++)
                    {
                        Console.Write(" ");
                        Console.Write(house[i,j,k].ToString());
                    }
                    Console.Write(Environment.NewLine);
                }
                if(i < house.GetLength(0)-1)Console.WriteLine(new string('#', 20));
            }
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



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

int main() {
  
  int N, M;
  cin >> N >> M;
  
  vector<int> a(N);
  double sum = 0;
  for(int i=0; i<N; i++){
    cin >> a.at(i);
    sum += a.at(i);
  }
  
  sort(a.begin(), a.end(), greater<int>());
  if(a.at(M-1)>= sum/(4*M)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256