akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);

void print(int x, int y){
    if (x > 0) REP(i, x) cout << "R";
    else if (x < 0) REP(i, -x) cout << "L";
    if (y > 0) REP(i, y) cout << "U";
    else if (y < 0) REP(i, -y) cout << "D";
}

int main(){
    int sx, sy, tx, ty;
    sc(sx) sc(sy) sc(tx) sc(ty)
    int x = tx - sx, y = ty - sy;
    print(x, y);
    print(-x, -y);
    if (y > 0 && x > 0){
        cout << "D";
        print(x + 1, y + 1);
        cout << "LU";
        print(-x - 1, -y - 1);
        cout << "R" << endl;
    }else if (y > 0 && x < 0){
        cout << "D";
        print(x - 1, y + 1);
        cout << "RU";
        print(-x + 1, -y - 1);
        cout << "L" << endl;
    }else if (y < 0 && x > 0){
        cout << "U";
        print(x + 1, y - 1);
        cout << "LD" << endl;
        print(-x - 1, -y + 1);
        cout << "R" << endl;
    }else{
        cout << "U";
        print(x - 1, y - 1);
        cout << "RD" << endl;
        print(-x + 1, y - 1);
        cout << "L" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip> 
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int l , r , d , ans ;
int main(){
fcin;
    cin >> l >> r >> d;
    for(int i = 1 ; i <= r ; i++){
        if(i%d==0 && i>=l)ans++;
    }
    cout << ans << "\n";


}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
main()
{
   int i,j,k,l;
    while(cin>>l){
  int x[200000]={0};
    i=0;
    while(1){ i++;
       x[l]++;
       if(x[l]==2) {  break;}
       if(l%2==0) l/=2;
       else l=((3*l)+1);
    }
    cout<<i<<endl;
    } return 0;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin >> A >> B;
  bool ans = false;
  bool a = false;
  for (int i = 1; i <= 9; i++){
    if (A == i) ans = true;
  }
  for (int i = 1; i <= 9; i++){
    if (B == i) a = true;
  }
  if (ans == true && a == true) cout << A * B << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 256
let _inputLines;
let _lineNumber = 0;
let inputReader = _inputReader ();

function _main() {
	
	_inputLines = _inputData.trim().split('\n').map((string) => {
		return string.trim();
	});;
	
	let [a, b, c] = inputReader.readArray();
	//console.log(typeof c);
	a = parseInt(a);
	b = parseInt(b);
	c = parseInt(c);
	
	let obj={};
	obj[a]=obj[a] +1 ||1; 
	obj[b]=obj[b] +1 ||1; 
	obj[c]=obj[c] +1 ||1;
	if(obj[5]===2 && obj[7]===1)
		console.log('YES');
	else
		console.log("NO");
	
	
	
	// let input = inputReader.readLine().split(' ');
	// let a = input[0];
	// let b = input[1];
	// //let b = inputReader.readLine().split('');
	// //console.log(a,b);
	
	// let res = '';
	// for(let i=0;i<size;i++){
	//     res +=a[i];
	//     res+=b[i];
	// }
	// console.log(res);
	
	//console.log(noOfTestCases,typeof noOfTestCases);
	// while(noOfTestCases--){
	//     let [a,b] = inputReader.readNumberArray();
	//     let count = 1;
	//     if(a<=2){
	//         console.log(1);
	//         continue;
	//     }
	//     let floor;
	//     if((a-2)%b===0)
	//         floor = (a-2)/b +1;
	//     else
	//          floor = Math.ceil((a-2)/b)+1;
	//     console.log(floor);
	
	// }

}

var _inputData = '';
function cacheInput(data) {
	_inputData += data;
}

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', cacheInput).on('end', _main);

function _inputReader () {
	function readArray() {
		return _inputLines[_lineNumber++].split(' ');
	}
		
	function readLine(){
		return _inputLines[_lineNumber++];
	}
		
	function readNumberArray(){
		return _inputLines[_lineNumber++].split(' ').map(val => Number(val));
	}
		
	
	return {
		readArray,
		readLine,
		readNumberArray,
	}
}

Measured memory_bytes: 29908
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

n = int(input())
a = list(map(int, input().split()))

ans = 0
while True:
    for i in range(n):
        if (a[i] % 2 != 0):
            print(ans)
            exit()
    for i in range(n):
        a[i] //= 2
    ans += 1



Measured memory_bytes: 9168
//2018年  3月 21日 水曜日 21:48:00 JST-22:05:00	
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, C;
int S[100010][30];

void solve() {
	cin >> N >> C;
	rep(i, 0, N) {
		int s, t, c;
		cin >> s >> t >> c;
		c--; s--; t--;
		S[s][c]++;
		S[t + 1][c]--;
	}
	rep(i, 0, C) {
		rep(j, 1, 100000 + 1) {
			S[j][i] += S[j - 1][i];
		}
	}
	int res = 0;
	rep(i, 0, 100000) {
		int tmp = 0;
		rep(j, 0, C) {
			tmp += (S[i][j] != 0);
		}
		MAX(res, tmp);
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 12032
N = int(input())
A, B = map(int, input().split())
P = map(int, input().split())

q = [0, 0, 0]
for p in P:
    if 1 <= p <= A:
        q[0] += 1
    elif A < p <= B:
        q[1] += 1
    elif B < p:
        q[2] += 1

print(min(q))


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
    int h,n; cin >> h >> n;
    vector<int> dp(h+1,1e9);
    dp[0]=0;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        rep(j,h+1){
            int x=min(h,j+a);
            dp[x]=min(dp[x],dp[j]+b);
        }
    }
    cout << dp[h] << endl;
}




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

using namespace std;
int main()
{
    int n,ans=0;
    cin>>n;
    int arr[n+2];
    arr[0]=0;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    arr[n+1]=0;
/*
    cout<<arr[n+1]<<endl;
    for(int i=0;i<n+2;i++)
    {
        cout<<arr[i]<<" ";
    }
    cout<<endl; */
    for(int i=0;i<n+1;i++)
    {
        ans+=abs(arr[i]-arr[i+1]);
    }
   // cout<<ans<<endl;
   // ans=ans+abs(0-arr[i])+abs(arr[n-1]-0);
    for(int t=1;t<n+1;t++)
    {
       // cout<<arr[t-1]<<" "<<arr[t]<<" "<<arr[t+1]<<endl;
        int result=ans-((abs(arr[t-1]-arr[t])+abs(arr[t]-arr[t+1]))-abs(arr[t-1]-arr[t+1]));
        cout<<result<<endl;
    }
}


Measured memory_bytes: 1664
const input = require('fs').readFileSync('/dev/stdin', 'utf8').trim()
const lines = input.trim().split("\n")
while (lines.length > 2) {
    const s1 = lines.shift().trim(), _s1 = s1.split('"')
    const s2 = lines.shift().trim(), _s2 = s2.split('"')
    if(s1 === s2) {
        console.log('IDENTICAL')
    } else {

        if(_s1.length !== _s2.length) {
            console.log('DIFFERENT')
        } else {
            let rs
            let dif = false
            const l = _s1.length
            for (let i = 0; i < l; i++) {
                if(_s1[i] !== _s2[i]){
                    if(i%2) {
                        if(dif) {
                            rs = 'DIFFERENT'
                        } else {
                            dif = true
                        }
                    } else {
                        rs = 'DIFFERENT'
                        break
                    }
                }
            }
            console.log(rs === 'DIFFERENT'? rs: 'CLOSE')
        }
    }
}


Measured memory_bytes: 16196
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n; cin >> n;
  vector<ll> a(n);
  rep(i,n){
      cin >> a[i];
  }
  ll ans = 0;
  FOR(i,1,n){
      if(a[i] == a[i-1]){
          a[i] = LINF;
          ans++;
      }
  }
  cout << ans << endl;
  


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <ll, pair<int, int>> P;

const ll MOD=1000000007;
const int MAX_N=100000;
struct edge{
    int to;
    ll cost;
};
int N, M;
ll X[100000];
P p[100000];
vector<edge> E[100000];
struct UF{
    int par[MAX_N];
    int sizes[MAX_N];
    ll c[MAX_N];
    void init (int n){
        for (int i=0;i<n;i++){
            par[i]=i;
            sizes[i]=1;
            c[i]=X[i];
        }
    }
    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 (sizes[x] < sizes[y]) swap(x,y);
        par[y]=x;
        sizes[x]+=sizes[y];
        c[x]+=c[y];
    }
    bool same (int x, int y){
        return find(x) == find(y);
    }
    int size(int x){
        return sizes[find(x)];
    }
};
UF uf;
int ans=0;
bool used[100000];
void dfs(int x, ll k){
    if(used[x]==0){
        used[x]=1;
        for(edge e: E[x]){
            if(e.cost<=k){
                ans++;
                dfs(e.to, k);
            }
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>M;
    rep(i,0,N) cin>>X[i];
    uf.init(N);
    rep(i,0,M){
        int a,b;
        ll y;
        cin>>a>>b>>y;
        a--; b--;
        p[i]=make_pair(y,make_pair(a, b));
        E[a].pb(edge{b,y});
        E[b].pb(edge{a,y});
    }
    sort(p,p+M);
    vector<int> v;
    rep(i,0,M){
        uf.unite(p[i].sc.fr, p[i].sc.sc);
        if(uf.c[uf.find(p[i].sc.fr)]>=p[i].fr) v.pb(i);
    }
    rer(i,sz(v),0){
        dfs(p[v[i]].sc.fr, p[v[i]].fr);
    }
    cout <<M-ans/2<<"\n";
}

Measured memory_bytes: 15480
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int a[100010] = {0};
int main(){
	int N,M;
	scanf("%d%d",&N,&M);
	for(int i = 1;i <= N;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+N);
	long long ans = 0;
	for(int i = 1;i <= M;i++)ans += a[i];
	printf("%lld\n",ans);
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
vector<int> graph[100001];
int dp[100001];
int solve(int src)
{
	if(dp[src]!=-1)
		return dp[src];
	bool leaf = 1;
	int bestChild = 0;
	//if the node is the leaf node we'll be skipping the for loop directly
	for(auto child: graph[src])
	{
		leaf = 0;
		bestChild = max(bestChild, solve(child));
	}
	return dp[src] = leaf? 0 : 1 + bestChild;
}

int main()
{
	int n, m;
	cin >> n >> m;
	memset(dp, -1, sizeof dp);
	for(int i = 0; i < m; i++)
	{
		int v1, v2;
		//making of the graph is done here
        cin>>v1>>v2;
		graph[v1].push_back(v2);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		ans = max(ans, solve(i));
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 11536
S = input()

word = ['dream', 'erase']

while len(S) > 0:
    if S[-2:] == 'er':
        if S[-6:] == 'eraser':
            S = S[:len(S)-len(S[-6:])]
        elif S[-7:] == 'dreamer':
            S = S[:len(S)-len(S[-7:])]
        else:
            break
    else:
        if S[-5:] in word:
            S = S[:len(S)-len(S[-5:])]
        else:
            break

if len(S) == 0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3316
q = int(input())


def isParallel(u, v):
    if u[0] == 0 or v[0] == 0:
        if u[0] == 0 and v[0] == 0:
            return True
        else:
            return False
    else:
        if u[0]*v[1] == u[1]*v[0]:
            return True
        else:
            return False


def isOrthogonal(u, v):
    if u[0]*v[0] + u[1]*v[1] == 0:
        return True
    else:
        return False


for qi in range(q):
    x_p0, y_p0, x_p1, y_p1, x_p2, y_p2, x_p3, y_p3= [int(i) for i in input().split()]
    u = [x_p1-x_p0, y_p1-y_p0]
    v = [x_p3-x_p2, y_p3-y_p2]
    if isParallel(u, v):
        print(2)
    elif isOrthogonal(u, v):
        print(1)
    else:
        print(0)



Measured memory_bytes: 5624
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const double EPS=1e-10;
const ll INF=1000000000;
const ll MAX=100010;
int main(){
    int a0,l;
    while(cin>>a0>>l,a0+l){
        int a[100010];
        a[0]=a0;
        for(int i=0;i<50;i++){
            int d[7]={};
            int t=a[i];
            for(int j=0;j<l;j++){
                d[j]=t%10;
                t/=10;
            }
            sort(d,d+l);
            int ma=0;int mi=0;
            for(int j=0;j<l;j++){
                ma*=10;
                mi*=10;
                ma+=d[l-1-j];
                mi+=d[j];
            }
            a[i+1]=ma-mi;
            bool f=false;
            for(int j=0;j<=i;j++){
                if(a[j]==a[i+1]){
                    f=true;
                    cout<<j<<" "<<a[j]<<" "<<i+1-j<<endl;
                    break;
                }
            }
            if(f){
                break;
            }
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
int par(int i){
  return i / 2;
}
int lef(int i){
  return i * 2;
}
int rig(int i){
  return 2 * i + 1;
}
//-----------------------------------------

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n;
  cin >> n;
  vll a(n+1);
  REP(i,n) cin >> a[i+1];
  for(int i=1;i<=n;i++){
    cout << "node " << i << ": ";
    cout << "key = "<< a[i] <<", ";
    if(i != 1) cout << "parent key = " << a[par(i)] << ", ";
    if(lef(i) <= n) cout << "left key = " << a[lef(i)] <<", ";
    if(rig(i) <= n) cout << "right key = " << a[rig(i)] << ", ";
    cout <<endl;
  }




  return 0;
}



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

int main()
{int N, M;
 long long ans=0;
 priority_queue<int> q;
 cin >> N >> M;
 rep(i, N){
   int a;
   cin >> a;
   q.push(a);
 }
 rep(i, M){
 int a;
 a=q.top(); q.pop();
   q.push(a/2);
 }
 rep(i, N){
   int a;
   a=q.top(); q.pop();
   ans += a; 
 }
 cout << ans << endl;
}

Measured memory_bytes: 892
strInput = input()

isGood = True
strPreChar = ""
for intIdx in range(len(strInput)):
    if intIdx == 0:
        strPreChar = strInput[intIdx]
    else:
        if strPreChar == strInput[intIdx]:
            isGood = False
            break
        else:
            strPreChar = strInput[intIdx]

print("Good") if isGood else print("Bad")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=998244353;
const int maxn=1e5+50;
const int inf=0x3f3f3f3f;
int  main()
{
	int a,b,ans=0;
	scanf("%d%d",&a,&b);
	if(b==1)ans=0;
	else if(a>=b)ans=1;
	else if((b-a)%(a-1)==0)ans=(b-a)/(a-1)+1;
	else ans=(b-a)/(a-1)+2;
	printf("%d\n",ans);
}

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

int main(void){
    int a, b, c, N;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> a >> b >> c;
        if((a*a + b*b == c*c) || (b*b + c*c == a*a) || (c*c + a*a == b*b)){
            cout << "YES" << endl;
        }
        else cout << "NO" << endl;
    }
    return 0;
}
    



Measured memory_bytes: 3016
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

int N;

int t[100010];
int x[100010];
int y[100010];

int main()
{
    cin >> N;
    for(int i = 1;i <= N;i++)
    {
        cin >> t[i] >> x[i] >> y[i];
    }

    for(int i = 1;i <= N;i++)
    {
        int dist = 0;
        dist += abs(x[i] - x[i - 1]);

        dist += abs(y[i] - y[i - 1]);

        int limit = t[i] - t[i - 1];

        if(dist <= t[i] && limit % 2 == dist % 2)
        {

        }
        else
        {
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";
    return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 左括弧 */
	private static final char LEFT = '(';

	/** 右括弧 */
	private static final char RIGHT = ')';

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			scanner.nextInt();
			int current = 0, noLeft = 0;
			char[] s = scanner.next().toCharArray();
			for (char c : s) {
				if (LEFT == c) {
					if (current >= 0) {
						current++;
					} else {
						noLeft -= current;
						current = 1;
					}
				} else {
					current--;
				}
			}
			if (current < 0) {
				noLeft -= current;
				current = 0;
			}
			System.out.println(repeat(LEFT, noLeft) + String.valueOf(s) + repeat(RIGHT, current));
		}
	}

	/**
	 * @param c 文字
	 * @param n 数
	 * @return 文字をn回繰り返した文字列
	 */
	private static String repeat(char c, int n) {
		StringBuilder sb = new StringBuilder();
		IntStream.range(0, n).forEach(i -> sb.append(c));
		return sb.toString();
	}
}


Measured memory_bytes: 28884
N = int(input())
s = [int(input()) for _ in range(N)]
S = sorted(s)
Res = sum(s)
flag = False

if Res % 10 == 0:
    for i in S:
        if (Res - i) % 10 != 0:
            Res -= i
            flag = True
            break
else:
    flag = True

print(Res if flag else 0)

Measured memory_bytes: 3064
#include <iostream>


using namespace std;

int main() {
	int n;
	int p[20];

	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> p[i];
	}
	int count = 0;
	for (int i = 1; i < n - 1; i++) {
		if (p[i - 1] < p[i] && p[i] < p[i + 1]) {
			count++;
		} else if (p[i + 1] < p[i] && p[i] < p[i - 1]) {
			count++;
		}
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 888
s = list(input())
n = len(s)
if s[n - 1] == "1" or s[0] == "0":
    print(-1)
    exit()
for i in range((n - 1) // 2):
    if not s[i] == s[n - 2 - i]:
        print(-1)
        exit()
l = n - s.count("0") + 1
x = [0] * l
j = 0
for i in range(n // 2):
    if s[i] == "1":
        j += 1
    else:
        x[j] += 1
        x[l - 1 - j] += 1
        if j == l - 1 - j and n % 2 == 0 and i == (n - 1) // 2:
            x[j] -= 1
for i in range(l - 1):
    print(i + 1, i + 2)
k = n - s.count("0") + 2
for i in range(l):
    for _ in range(x[i]):
        print(i + 1, k)
        k += 1

Measured memory_bytes: 6112
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <algorithm>
#define MOD 1000000007
#define forn(a, n) for(int a = 0; a<(int) (n); ++a)
#define dforn(a, n) for(int a = (n)-1; a>=0; --a)
#define forall(a, all) for(__typeof(all.begin()) a = all.begin(); a != all.end(); ++a)
#define EPS 0.000000000001
typedef long long tint;
using namespace std;

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	int ans = n;
	forn(i, n/2) {
		if(s[i] != s[n-i-1] || (i+1 < n && s[i]!=s[i+1])) ans = n-i-1;
	}
	cout << ans << endl;
	
	return 0;
}


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

long long f(long long n, long long x) {
	if (n < 0)return 0;
	else return (n / x) + 1;
}

int main() {
	long long A, B, X;
	cin >> A >> B >> X;
	cout << f(B, X) - f(A - 1, X) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;


struct Node{
    ll key;
    struct Node *left, *right, *parent;
};
Node *root,*NIL;

void preorder(Node * node){
  if(node == NIL){
    return;
  }
  cout << " " << node->key;
  preorder(node->left);
  preorder(node->right);

}
void inorder(Node * node){
  if(node == NIL){
    return;
  }
  inorder(node->left);
  cout << " " << node->key;
  inorder(node->right);
}
void print(){
  inorder(root);
  cout << endl;
  preorder(root);
  cout << endl;
}

Node* find(Node* node,ll k){
  if(node == NIL){
    return NIL;
  }
  if(node->key == k){
    return node;
  }else if(node->key > k){
    return find(node->left,k);
  }else{
    return find(node->right,k);
  }
}

void deleteNode(ll k){
  Node *z = find(root,k);
  Node *x,*y;
  if(z == NIL){
    return;
  }
  if(z->left == NIL && z->right == NIL){
    y = z->parent;
    if(y != NIL){
      if(y->left == z){
        y->left = NIL;
      }else{
        y->right = NIL;
      }
    }
    free(z);
  }else if(z->right == NIL || z->left == NIL){
    y = z->parent;
    if(z->right != NIL){
      x =z->right;
    }else{
      x = z->left;
    }
    if(y != NIL){
      if(y->left == z){
        y->left = x;
      }else{
        y->right = x;
      }
      x->parent = y;
    }
    free(z);
  }else{
    y = z->right;
    while(y != NIL){
      x = y;
      y = y->left;
    }
    ll tmp = x->key;
    deleteNode(x->key);
    z->key = tmp;
  }
}

void insert(ll k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }else{
    if(z->key < y->key){
      y->left = z;
    }else{
      y->right = z;
    }
  }
}
int main(){
  ll n;
  cin >> n;
  string str;
  rep(i,n){
    cin >> str;
    if(str == "insert") {
      cin >> t1;
      insert(t1);
    }else if(str == "find") {
      cin >> t1;
      Node *n1 = find(root,t1);
      if (n1 != NIL) {
        cout << "yes" << endl;
      } else {
        cout << "no" << endl;
      }
    }else if(str == "delete"){
      cin >> t1;
      deleteNode(t1);
    }else{
      print();
    }
  }
}


Measured memory_bytes: 21808
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;



int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;

	ll n, m;
	cin >> n >> m;
	vector<ll> h(n);
	rep(i, n)
	{
		cin >> h[i];
	}
	vector<ll> ok(n, 1);

	vector<ll> a(m), b(m);
	rep(i, m)
	{
		cin >> a[i] >> b[i];
		if (h[a[i] - 1] < h[b[i] - 1])
			ok[a[i] - 1] = 0;
		if (h[b[i] - 1] < h[a[i] - 1])
			ok[b[i] - 1] = 0;
		if (h[a[i] - 1] == h[b[i] - 1])
		{
			ok[a[i] - 1] = 0;
			ok[b[i] - 1] = 0;
		}
	}
	ll ans = 0;
	rep(i, n)
	{
		if (ok[i] == 1)
			ans++;
	}
	cout << ans << endl;


	return 0;
}

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

#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define fi first
#define se second
#define mp make_pair

LL r,c,n,sum;
LL ans[10];
vector<pair<int,int> >  p;
set<pair<int,int> > vis,has;

inline bool yes(int x,int y)
{
	return x>0 && y>0 && x <= r && y <= c;
}

inline void cal(int x,int y)
{
//	printf("%d %d\n",x,y);
	F(i,0,2)
		F(j,0,2)
		{
			int tx = x - i,ty = y - j;
			if(yes(tx,ty) && yes(tx+2,ty+2) && vis.find(mp(tx,ty)) == vis.end())
			{
				int cur = 0;
				F(k,tx,tx+2) F(l,ty,ty+2)
				{
				   	if(has.find(mp(k,l)) != has.end())
					{
					   	++cur;
					}
				}
				vis.insert(mp(tx,ty));
				ans[cur]++;
			}
		}
}

int main()
{
	//freopen("input.txt","r",stdin);
	scanf("%lld %lld %lld",&r,&c,&n);
	sum = (r-2) * (c-2);
	F(i,1,n)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		p.push_back(mp(x,y));
		has.insert(mp(x,y));
	}
	for(int i=0;i<p.size();++i)
		cal(p[i].fi,p[i].se);
	F(i,1,9) sum -= ans[i];
	ans[0] = sum;
	F(i,0,9) printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 47860
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int A[n-1];
    
    for(int i=0;i<n-1;i++)
        cin >> A[i];
        
        int B[n+1];
        for(int i=0;i<=n;i++)
            B[i]=0;
            
            for(int i=0;i<n-1;i++)
            {
                B[A[i]]=B[A[i]]+1;
            }
            
            for(int i=1;i<=n;i++)
                cout << B[i] << endl;
                
                return 0;
}

Measured memory_bytes: 5180
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a==1){
        a=14;
    };
    if(b==1){
        b=14;
    };
    if(a>b){
        printf("Alice");
    };
    if(a<b){
        printf("Bob");
    };
    if(a==b){
        printf("Draw");
    };
    return 0;
};


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

int main(){
  int n,max=-1000,x; cin>>n;
  int a[100];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      x=abs(a[j]-a[i]);
      if(max<x){
        max=x;
      }
   }
  }
  cout<<max<<endl;
  return 0;
}

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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

class dsu {
private:
	int *id;
	int* sz;

	int root(int i) {
		while (i != id[i]) {
			id[i] = id[id[i]];
			i = id[i];
		}
		return i;
	}
public:
	int n;
	dsu(int v) {
		n = v;
		id = new int[n];
		sz = new int[n];

		for (int i = 0; i < n; i++) {
			id[i] = i;
			sz[i] = 0;
		}
	}

	bool find(int p , int q) {
		return root(p) == root(q);
	}

	void join(int p , int q) {
		int i = root(p);
		int j = root(q);
		if (i == j) {
			return;
		}
		if (sz[i] < sz[j]) {
			id[i] = j ;
			sz[j] += sz[i];
		}
		else {
			id[j] = i;
			sz[i] += sz[j];
		}
	}
};

class BIT {
private:
	int* FT;
	int n;
public:
	void updateBIT(int index , int val) {
		index += 1;
		while (index <= n) {
			FT[index] += val;
			index += (index & (-index));
		}
	}

	int getSum(int index) {
		index += 1;
		int sum = 0 ;
		while (index > 0) {
			sum += FT[index];
			index -= (index & (-index));
		}
		return sum;
	}


	BIT(int* a , int v) {
		n = v ;
		FT = new int[n + 1];
		for (int i = 1 ; i <= n ; i++) {
			FT[i] = 0 ;
		}
		for (int i = 0 ; i < n ; i++) {
			updateBIT(i, a[i]);
		}
	}
};

int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

int modPower(int x, int y , int p) {
	//Used to calculate (x^y)%p
	int res = 1;
	if (y == 0) {
		return 1;
	}

	x = x % p;
	if (x == 0) {
		return 0  ;
	}

	while (y > 0) {
		if (y & 1) {
			res = (res * x) % p;
		}

		y >>= 1;
		x = (x * x) % p;
	}
	return res ;

}

int32_t main() {
	FIO;



	int ans = 0 ;
	string s ;
	cin >> s;
	for (int i = 0 ; i < s.length() ; i++) {
		if (s[i] == '+') {
			ans++;
		}
		else {
			ans--;
		}
	}
	cout << ans;







	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,M,R;
    cin>>N>>M>>R;

    int r[R];
    int A[M],B[M],C[M];
    vector<vector<int>> dp(N,vector<int>(N,INF));
    rep(i,N) dp[i][i]=0;
    rep(i,R){
        cin>>r[i];
        r[i]--;
    }
    rep(i,M){
        cin>>A[i]>>B[i]>>C[i];
        A[i]--;
        B[i]--;
        dp[A[i]][B[i]]=min(dp[A[i]][B[i]],C[i]);
        dp[B[i]][A[i]]=min(dp[B[i]][A[i]],C[i]);
    }
    

    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++)dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
        }
    }
    int ans=INF;
    sort(r,r+R);
    do {
        int sum=0;
        rep(i,R-1){
            sum+=dp[r[i]][r[i+1]];
        }
        ans=min(ans,sum);
    }while (next_permutation(r, r+R));

    cout << ans << endl;

    


    



}


Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int m = scanner.nextInt();

        final List<Pair> pairs = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            final int days = scanner.nextInt();
            final int value = scanner.nextInt();
            pairs.add(new Pair(days, value));
        }

        pairs.sort((o1, o2) -> o2.getValue() - o1.getValue());

        final List<Integer> checked = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            checked.add(i);
        }

        int res = 0;
        for (final Pair pair : pairs) {
            int days = pair.getDays() - 1;

            final int index = extendedBinarySearch(checked, days);
            if (index != checked.size()) {
                checked.remove(index);
                res += pair.getValue();
            }
        }

        System.out.println(res);
    }

    static class Pair {
        private final int days;
        private final int value;

        Pair(final int days, final int value) {
            this.days = days;
            this.value = value;
        }

        int getDays() {
            return days;
        }

        int getValue() {
            return value;
        }
    }

    @SuppressWarnings("unchecked")
    private static int extendedBinarySearch(final Object indexes, final int value) {
        final int rawIndex;
        if (indexes instanceof int[]) {
            rawIndex = Arrays.binarySearch((int[]) indexes, value);
        } else {
            rawIndex = Collections.binarySearch((List<Integer>) indexes, value);
        }

        if (rawIndex >= 0) {
            return rawIndex;
        }

        return -(rawIndex + 1);
    }
}


Measured memory_bytes: 78248
import string
from heapq import heapify, heappop, heappush


def judge():
    import Levenshtein
    import subprocess

    ans = 'OQqZbgyIYiB59fqHVsXu0PZVEWy1sApStRxCJFMeNkr5O0U4jEX9ksBTpKw7Z3ylYd3Hnd'
    query_count = 0
    with subprocess.Popen(['python', __file__, 'EXE'],
                          stdin=subprocess.PIPE,
                          stdout=subprocess.PIPE,
                          stderr=subprocess.PIPE) as p:
        while True:
            query = p.stdout.readline().decode().strip()
            print(query)
            if query[0] == '?':
                d = Levenshtein.distance(query[2:], ans)
                print(d)
                p.stdin.write(f'{d}\n'.encode())
                p.stdin.flush()
                query_count += 1
            elif query[0] == '!':
                print(query[2:] == ans)
                print(query_count)
                break
            else:
                pass


# import sys
#
# if len(sys.argv) == 1:
#     print('Interactive Test Mode')
#     judge()
#     exit()

STR = string.ascii_letters + string.digits
counter = {}
for c in STR:
    print(f'? {c * 128}')
    a = int(input())
    if a == 128:
        continue
    counter[c] = 128 - a

l = sum(counter.values())
q = [(cnt, [c] * cnt) for c, cnt in counter.items()]
heapify(q)

while len(q) > 1:
    l1, t1 = heappop(q)
    l2, t2 = heappop(q)
    i = 0
    j = 0
    while i < len(t1) and j < l2:
        t1.insert(i, t2[j])
        s = ''.join(t1)
        print(f'? {s}')
        a = int(input())
        if len(t1) > l - a:
            t1.pop(i)
        else:
            j += 1
        i += 1
    if j < len(t2):
        t1.extend(t2[j:])

    heappush(q, (l1 + l2, t1))

_, t = q[0]
s = ''.join(t)
print(f'! {s}')


Measured memory_bytes: 9996
import sys
c = list(map(int, input().split()))
c += list(map(int, input().split()))
c += list(map(int, input().split()))
# 値の確定
a = [0]*3
b = [0]*3
a[0] = 0
b[0] = c[0]
a[1] = c[3] - b[0]
b[1] = c[4] - a[1]
a[2] = c[6] - b[0]
b[2] = c[8] - a[2]

index = 0
for i in range(3):
  for j in range(3):
    if a[i] + b[j] != c[index]:
      print('No')
      sys.exit()
    index += 1
print('Yes')

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

typedef long long int ll ;

ll gcd(ll aaa,ll bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

ll lcm(ll m,ll n)
{
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}

int main() {

	long N;
	cin >> N;
	long a[N],s[N+1];
	s[0] = 0;
	for(long i = 0; i < N; i++) {
		cin >> a[i];
		s[i+1] = a[i] + s[i];
	}

	long M = 1e20;
	for(long i = 1; i < N; i++) {
		M = min(M,abs(s[i] - (s[N] - s[i])));
	}
	cout << M << endl;

	return 0;
}


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

int main(){
    string S;
    cin >> S;
    int value = 700;
    if (S[0] == 'o')
        value += 100;
    if (S[1] == 'o')
        value += 100;
    if (S[2] == 'o')
        value += 100;
    cout << value << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			String s = sc.next();
			if (s.equals("0")) break;
			int N = s.length();
			int[] v = new int[N];
			for (int i = 0; i < N; ++i) {
				v[i] = s.charAt(N - 1 - i) - '0';
				if (i % 2 == 1) v[i] *= -1;
			}
			int[] c = new int[11];
			c[0] = 1;
			long ans = 0;
			int sum = 0;
			for (int i = 0; i < N; ++i) {
				sum += v[i];
				if (sum > 10) sum -= 11;
				if (sum < 0) sum += 11;
				if (v[i] != 0) ans += c[sum];
				c[sum]++;
			}
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 32644
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>
#include <unordered_map>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

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

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int bit[1 << 18 + 1];
int sum(int i) {
	int s = 0;
	while(i > 0) {
		s += bit[i];
		i -= i & -i;
	}
	return s;
}
void add(int i, int x) {
	while(i <= (1 << 18)) {
		bit[i] += x;
		i += i & -i;
	}
}

ll S[1<<18];

int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> a(N);
	rep(i,N) { cin >> a[i]; a[i] -= K; }
	vector<ll> t;
	t.push_back(0);
	rep(i,N) {
		S[i+1] += S[i] + a[i];
		t.push_back(S[i+1]);
	}
	sort(all(t));
	t.erase(unique(all(t)), t.end());

	unordered_map<ll,int> f;
	rep(i,t.size()) f[t[i]] = i+2;

	ll res = 0;
	rrep(i,N) {
		add(f[S[i+1]], 1);
		res += (i+1) - sum(f[S[i]] -1);
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 15216
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

double sqr(double x) {
  return x * x;
}

int main() {
  int a, b;
  cin >> a >> b;
  int h, m;
  cin >> h >> m;
  double x = 2 * M_PI * (h * 60 + m) / 12 / 60;
  double y = 2 * M_PI * m / 60;
  array<double, 2> v1 = {a * cos(x), a * sin(x)};
  array<double, 2> v2 = {b * cos(y), b * sin(y)};
  double ret = sqrt(sqr(v1[0] - v2[0]) + sqr(v1[1] - v2[1]));
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define nl '\n'
#define vec vector<ll>
#define pr pair<ll,ll>
#define vecp vector< pr >
#define pq priority_queue<ll>
#define pqp priority_queue<pr>
#define ff first
#define ss second
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define fa(x,v) for(auto x:v)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define max4(a,b,c,d) max(a,max3(b,c,d))
#define min4(a,b,c,d) min(a,min3(b,c,d))
#define PI 3.14159265
 const ll MOD=1000000007;
 ll powerm(ll a, ll b, ll MOD) {
    a %= MOD;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}
ll power(ll a, ll b) {

  ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a ;
        a = a * a ;
        b >>= 1;
    }
    return res;
}
ll binarySearch(ll a[],ll low,ll high,ll key){
    while(low<=high)
    {
        ll mid=low+((high-low)/2);
        if(a[mid]<key)
        {
            low=mid+1;
        }
        else if(a[mid]>key)
        {
            high=mid-1;
        }
        else
        {
            return mid;
        }
    }
    return -1;
}
ll gcd(ll a, ll b) {
   if (b == 0)
      return a;
   return gcd(b, a % b);
}
vec sieve;
void Sieve(int N) {
    const ll maxn = N+1;
    sieve.resize(maxn);
    f(i,0,maxn) sieve[i] = i;
    sieve[1] = -1;
    sieve[0] = -1;
    f(i, 2, maxn) if (i == sieve[i]) for (ll j = 2 * i ; j < maxn ; j += i) if (sieve[j] == j) sieve[j] = i;
}
ll dp[3001][3001];
ll recur(ll n,ll m,string &s1,string &s2)
{
	if(dp[n][m]!=-1)
	return dp[n][m];
	if(n==0||m==0)
	{
	dp[n][m]=0;
	return 0;
}
if(s1[n-1]==s2[m-1])
dp[n][m]=1+recur(n-1,m-1,s1,s2);
else
dp[n][m]=max(recur(n-1,m,s1,s2),recur(n,m-1,s1,s2));

return dp[n][m];	
}
int main()
{
	fast
string s1,s2;
cin>>s1>>s2;
ll n=s1.length();
ll m=s2.length();
f(i,0,n+1)
f(j,0,m+1)
dp[i][j]=-1;
ll lcs=recur(n,m,s1,s2);
string final="";
if(lcs>=1)
{
while(n>0 && m>0)
{
	if(s1[n-1]==s2[m-1])
	{
		final+=s1[n-1];
		m--;
		n--;
	}
	else
	{
		if(dp[n-1][m]>dp[n][m-1])
		{
			n--;
		}
		else
		{
			m--;
		}
	}
}
for(ll i=final.length()-1;i>=0;i--)
{
	cout<<final[i];
}
}
else
cout<<""<<nl;
return 0;
}



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

int main()
{
	int N, M, C;
	scanf("%d%d%d", &N, &M, &C);
	int count{};
	std::vector<int> B(M);
	for (auto& e: B) scanf("%d", &e);
	for (int i{}; i < N; i++)
	{
		int sum{C};
		for (int j{}; j < M; j++)
		{
			int A;
			scanf("%d", &A);
			sum += A * B[j];
		}
		if (sum > 0) count++;
	}
	printf("%d\n", count);

	return 0;
}

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

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;

int main(){
    int n,q;
    cin >> n;
    vector<int> s(n);
    for (int i = 0;i < n;i++) cin >> s[i];
    sort(s.begin(),s.end());
    cin >> q;
    vector<int> t(q);
    for (int i = 0;i < q;i++) cin >> t[i];
    int ans = 0;
    
    for (int i  = 0;i < q;i++){
        int l = 0,r = n;
        while(l < r - 1){
            int mid = (l + r) / 2;
            if (s[mid] <= t[i]) l = mid;
            else r = mid;
        }
        if (s[l] != t[i]) continue;
        ans++;
    }

    cout << ans << endl;

    return 0;
}   


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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

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

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main(){
    int a, b, c; cin >> a >> b >> c;
    if( a < c && c < b || b < c && c < a ) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256