akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

string calc(string S){
    int N = S.size()/2;
    vector<int> as, bs, order(2*N), mxi;
    int sum = 0, mx = 0;
    for(int i=0; i<2*N; i++){
        order[i] = (S[i] == 'a' ? as : bs).size();
        (S[i] == 'a' ? as : bs).push_back(i);
        sum += (S[i] == 'a' ? -1 : 1);
        if(sum == mx){
            mxi.push_back(i);
        }else if(sum > mx){
            mx = sum;
            mxi = {i};
        }
    }

    if(mx == 0){
        string ans, ab = "ab";
        int i = 0;
        while(i < 2*N){
            if(S[i] == 'a'){
                ans.append(ab);
                i = bs[order[i]];
            }else{
                i++;
            }
        }
        return ans;
    }

    string ans;
    for(int s : mxi){
        vector<bool> use(2*N);
        for(int i=order[s]-mx+1; i<=order[s]; i++) use[as[i]] = use[bs[i]] = 1;
        string res;
        for(int i=0; i<2*N; i++){
            if(s < i && S[i] == 'b' && i < as[order[i]]){
                use[i] = use[as[order[i]]] = 1;
            }
            if(use[i]){
                res.push_back(S[i]);
            }
        }
        ans = max(res, ans);
    }
    return ans;
}

int main(){
    int N;
    string S;
    cin >> N >> S;
    vector<int> zeros;
    int sum = 0;
    for(int i=0; i<2*N; i++){
        if(sum == 0) zeros.push_back(i);
        sum += (S[i] == 'a' ? -1 : 1);
    }
    zeros.push_back(2*N);
    int sz = zeros.size();
    vector<string> parts;
    for(int k=0; k<sz-1; k++) parts.push_back(calc(S.substr(zeros[k], zeros[k+1]-zeros[k])));
    reverse(parts.begin(), parts.end());
    string ans;
    for(auto s : parts) ans = max(ans, s + ans);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author EDGE
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();

            if (a > 2 * b)
                out.println(a - 2 * b);
            else
                out.println(0);
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
# import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = list(map(int,ipti().split()))
    x = list(map(int,ipti().split()))
    x.sort()

    dist = [abs(x[i+1] - x[i]) for i in range(m-1)]
    dist.sort()

    if m <= n:
        print(0)
    else:
        print(sum(dist[:m-n]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 56800
#include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
#define R(i,a,n) for(int i=a;i>=n;i--)
using namespace std;
int main(){
	int n,a,b,c,s,w;
	while(cin>>n,n){
		s=0;
		while(n--){
			cin>>a>>b>>c;
			if(s<b+c){
				w=a;
				s=b+c;
			}
		}
		cout<<w<<' '<<s<<endl;
	}
}

Measured memory_bytes: 3008
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int N;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	long long H[100002] = {0};

	cin >> N;
	for(int i=1; i<=N; i++){ cin >> H[i]; }

	int ans = 0;
	int count = 0;
	for(int i=1; i<=N-1; i++){
		if(H[i+1] > H[i]){
			if(ans < count){
				ans = count;
			}
			count = 0;
			continue;
		}
		else{
			count++;
			if(i == N - 1){
				if(ans < count){
					ans = count;
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1024
def main():
    n = int(input())+1
    a = [-1]+list(map(int,input().split()))
    for i in range(1,n):
        print ('node %d: key = %d, '%(i,a[i]),end = '')
        if i!=1:print ('parent key = %d, '%a[i//2],end='')
        if i*2<n:print ('left key = %d, '%a[i*2],end='')
        if i*2+1<n:print ('right key = %d, '%a[i*2+1],end='')
        print ()


if __name__ == '__main__':
    main()




Measured memory_bytes: 5684
#include<bits/stdc++.h>
    using namespace std;
    
    int main()
    {
  //  #ifndef ONLINE_JUDGE
    		//freopen("input.txt","r",stdin);
    		//freopen("output.txt","w",stdout);
    	//#endif
    		ios_base::sync_with_stdio(0);
    		cin.tie(0);
    	  long long int a,b,c,i,j,sum=0,ans,k;
          priority_queue<int> num;
          cin>>a>>b;
          for(i=0;i<a;i++){
            cin>>c;
            num.push(c);
          }
          while(b--){
            k=num.top();
            num.pop();
            num.push(k/2);
          }
          while(!num.empty()){
            sum+=num.top();
            num.pop();
          }
          cout<<sum;
    } 

Measured memory_bytes: 892
N=int(input())
L=[]
for i in range(N-1):
    c,s,f=map(int, input().split())
    L.append((c,s,f))

for i in range(N):
    if i==N-1:
        print(0)
    now=0
    for j in range(i,N-1):
        c,s,f=L[j]
        if now<s:
            now+=s-now
        if now%f!=0:
            now+=(f-now%f)
        now+=c
        if j==N-2:
            print(now)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

struct edge{
    int to;
    ll cost;
};

ll depth[100005];
vector<edge> adj[100005];

void dfs(int v, int p, ll d){
    depth[v] = d;
    for(auto &e : adj[v]){
        if(e.to == p) continue;
        dfs(e.to, v, d+e.cost);
    }
}

int main(){
    int n; cin >> n;
    for(int i=0; i<n-1; i++){
        int a,b,c; cin >> a >> b >> c;
        a--; b--;
        adj[a].push_back({b, c});
        adj[b].push_back({a, c});
    }

    int q, k; cin >> q >> k;
    k--;

    dfs(k, -1, 0);

    for(int i=0; i<q; i++){
        int x, y; cin >> x >> y;
        x--; y--;
        cout << depth[x] + depth[y] << endl;
    }
}


Measured memory_bytes: 14336
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  dead_code
)]
//use proconio::fastout;
use proconio::input;
use proconio::marker::*;
use std::cmp::*;
use std::collections::*;
//use std::collections::VecDeque;

fn main() {
  input! {
     N:usize,K:i64,
     mut A:[i64;N]
  }
  A.sort();
  A.reverse();
  // 一番長い丸太A[0]を c回切って、c+1 等分する。
  // A[0]/(c+1) の長さの切り上げ値を d とする。
  // 残りの切断回数で、すべてをd以下にできるかチェック。
  // 可能ならば増やし、不可能ならばcut[i]を減らす。
  if K == 0 {
    println!("{}", A[0]);
    return;
  } else if K == 1 {
    let b = (A[0] + 1) / 2;
    println!("{}", max(b, A[1]));
    return;
  }
  let mut dmax = A[0];
  let mut dmin = 0;
  while dmin + 1 < dmax {
    //println!("min={},max={}", dmin, dmax);
    let d = (dmin + dmax) / 2;
    let mut cuts = 0;
    for i in 0..N {
      cuts += ((A[i] + d - 1) / d) - 1;
    }
    if cuts <= K {
      dmax = d;
    } else {
      dmin = d;
    }
  }
  println!("{}", dmax);
}
// c=1, d=10/2=5,cuts = 1 + 1 .. OK,
// c=2, d=11/3=3,  cuts=1


Measured memory_bytes: 6184
#include<stdio.h>

int main(){
	
	int n, d;
	int i=1;
	
	scanf("%d %d", &n, &d);
	
	while(i*(2*d+1) < n){
		
		i++;
		
	}
	
	printf("%d\n", i);
	
	return 0; 
	
}

Measured memory_bytes: 128
N = int(input())
q = [0]*13
i = 10
n = N
cflag = 0
zflag = 0
str = []
while i != -1:
    q[i] = n // 26 ** i
    mod = n % 26 ** i
    n = mod
    i -= 1
for i in range(12):
    if q[i] == 0:
        zflag = 1
        for j in range(i,13) :
            if q[j] != 0:
                zflag = 0
                break
        if zflag == 1:
             break
        elif cflag == 1:
            str.append("y")
            cflag = 1
        else:
            str.append("z")
            cflag = 1
    elif q[i] == 1 and cflag == 1:
        zflag = 1
        for j in range(i+1,13):
            if q[j] != 0:
                zflag = 0
                break
        if zflag == 1:
            break
        else:
            str.append ("z")
            cflag = 1
    else:
        str.append(chr(q[i] + 96 -cflag))
        cflag = 0

i = len(str) -1
while i >= 0:
    if[str] == '':
        i-=1
        continue
    elif i == 0:
        print(str[i])
        break
    else:
        print(str[i], end="")
        i -= 1



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

int main()
{
    long long N;

    std::cin >> N;

    std::string ans;

    ans = "";
    while(N)
    {
        N--;
        ans = char(N%26 + 'a') + ans;
        N /= 26;
    }

    std::cout << ans << std::endl;
}

Measured memory_bytes: 3624
import math

d, g = [int(_) for _ in input().split(' ')]
p = []
c = []
for _ in range(d):
    temp = [int(_) for _ in input().split(' ')]
    p.append(temp[0])
    c.append(temp[1])

answer = 1001
for i in range(2 ** d):
    sc = 0
    pr = 0
    for j in range(d, 0, -1):
        if i & (1 << (j - 1)) > 0:
            sc += j * 100 * p[j - 1] + c[j - 1]
            pr += p[j - 1]
    for j in range(d, 0, -1):
        if sc < g and i & (1 << (j - 1)) == 0:
            temp = min(math.ceil((g - sc) / (j * 100)), p[j - 1] - 1)
            sc += temp * (j * 100)
            pr += temp
    if sc >= g and pr < answer:
        answer = pr

print(answer)


Measured memory_bytes: 3064
#include<stdio.h>
#define N 200000

int main(void)
{
  int i,j,n;
  int rt[N];
  //int maxv=0;

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

  int maxv = rt[1]-rt[0]; //最大利益
  int minv = rt[0]; //rt[j]の最小値

  for (i=1; i<=n-1; i++) {
    if(maxv<rt[i]-minv){
      maxv = rt[i]-minv;
    }else{
      maxv = maxv;
    }
    if (minv>rt[i]) {
      minv = rt[i];
    }else{
      minv = minv;
    }
  }

/*  for (i=1; i<=n-1; i++) {
    for (j=0; j<=i-1;j++) {
      if(maxv<rt[i]-rt[j]){
        maxv = rt[i]-rt[j];
      }else{
        maxv = maxv;
      }
    }
  }*/
  printf("%d\n", maxv);
  return 0;
}



Measured memory_bytes: 2552
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <utility>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    int nc=n;
    bool ans=true;
    vector<int>d(k);
    for(int i=0;i<k;i++)cin>>d[i];
    while(1){
        int np=nc;
        while(np/10!=0){
            int a=np%10;
            if(binary_search(d.begin(),d.end(),a)==1){
                ans=false;
            }
            np/=10;
        }
        if(binary_search(d.begin(),d.end(),np)==1){
                ans=false;
        }
        if(ans==true){
            cout<<nc;
            return 0;
        }
        ans=true;
        nc++;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <cstring> // memset
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int x, y;
    cin >> x >> y;

    cout << ((x % y == 0) ? -1 : x) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
#define mod 1000000007
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x
  
using namespace std;
signed main()
{

  std::ios::sync_with_stdio(false);
  cin.tie(); cout.tie();
 
    int n;
    cin>>n;
    vector<pair<int,int>> arr;
    for(int i=0;i<n;i++){
    int x,y;
    cin>>x>>y;
    arr.push_back(make_pair(x,y));
    }
    sort(arr.begin(), arr.end());
    int mn = arr[0].first + arr[0].second;
    int mx = arr[0].second - arr[0].first;
    int ans = 0; 
    for(int i = 1 ; i < n ; i++){
      int temp = ans;
      ans = max(arr[i].first + arr[i].second - mn , arr[i].first - arr[i].second + mx);
      ans = max(ans,temp);
      int tmn = arr[i].first + arr[i].second;
      int tmx = arr[i].second - arr[i].first;
      mx = max(mx,tmx);
      mn = min(mn,tmn);

    }

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


Measured memory_bytes: 7468
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    constexpr double pi = 3.141592653589793;
    
    int a, b, x;
    cin >> a >> b >> x;
    
    double left = 0;
    double right = 90;
    while (right - left > 1e-8) {
        double mid = (right + left) / 2, arg = mid / 180 * pi;
        double water;
        if (b / tan(arg) < a) {
            water = b / tan(arg) * b / 2 * a;
        } else {
            water = (a * b - a * a * tan(arg) / 2) * a;
        }
        if (water < x) right = mid;
        else left = mid;
    }
    cout << fixed << setprecision(10) << right << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;
#define rep(i,N) for(int i=0;i<N;i++)
int N,M;
string S;
#define MAXN 100001
int ans[MAXN];
int k;
void solve(){
    int count = 0;
    rep(i,N+1){
        if(S[i]=='1')count++;
        if(S[i]=='0')count = 0;
        if(count>=M){
            ans[0] = -1;
            k  = 1;
            return;
        }
    }
    k=0;
    for(int i=N;i>=0;i--){
        int start;
        if(i-M<0)start = 0;
        else start = i-M;
        for(int j=start;j<=i;j++){
            if(i==0&&j==0)return;
            if(S[j]=='0'){
                ans[k] = i-j;
                i -= (ans[k]-1);
                k++;
                j = i+1;
            }
            
        }
    }

}


int main(){
    cin >> N >> M;
    cin >> S;
    solve();
    for(int i=k-1;i>=0;i--){
        cout << ans[i] <<" ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
//52行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

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

template<class T> void debugger(vector<vector<T> >& a,int n = -1,int m = -1){
    if(n == -1 && m == -1)n = a.size(),m = a[0].size();
    rep(i,n){ rep(j,m){ cerr << setw(5) << (a[i][j] >= 9999 ? 9999 : a[i][j]); } cerr << endl; }
}
template<class T> void debugger(vector<T> & a,int n = -1){
    if(n == -1)n = a.size();
    rep(i,n){cerr << setw(5) << (a[i] >= 9999 ? 9999 : a[i]);} cerr << endl;
}
///////////////////////////////////////////////////////////

int n,m;
int a[1010],b[1010],c[1010];
int dist[110][110];

int main(void){
    cin >> n >> m;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            if(i == j)dist[i][j] = 0;
            else dist[i][j] = 1e8;
        }
    }
    rep(i,m){
        cin  >> a[i] >> b[i] >> c[i];
        a[i]--,b[i]--;
        chmin(dist[a[i]][b[i]],c[i]);
        chmin(dist[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++){
                chmin(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }

    int ans = m;
    for(int i = 0;i < m;i++){
        for(int s = 0;s < n;s++){
            //cerr << dist[s][b[i]] << ' ' << dist[s][a[i]] << ' ' << dist[a[i]][b[i]] << endl;
            if(dist[s][b[i]] == (dist[s][a[i]] + c[i])){
                ans--;
                break;
            }
        }
    }
    cout << ans << '\n';
}

/*
 *!!CHECK!! 
 * 制約をよく読め：まず最も愚直な解法を考えろ
 * intの掛け算をしてる場合：overflowは大丈夫？
 * 制約の下限・上限は大丈夫？
 * 木構造は一直線にした時TLEしない？
 * */


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define Maxn 100000
#define Inf 0x3f3f3f3f
int f[Maxn+5][15];
int p[Maxn+5][15];
int tmp[Maxn+5];
int mx(int a,int b){
	return a>b?a:b;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=10;j++){
			scanf("%d",&f[i][j]);
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<=10;j++){
			scanf("%d",&p[i][j]);
		}
	}
	int ans=-Inf;
	int now;
	for(int i=1;i<(1<<10);i++){
		memset(tmp,0,sizeof tmp);
		for(int j=1;j<=n;j++){
			for(int k=1;k<=10;k++){
				if(f[j][k]&&((1<<(k-1))&i)){
					tmp[j]++;
				}
			}
		}
		now=0;
		for(int j=1;j<=n;j++){
			now+=p[j][tmp[j]];
		}
		ans=mx(ans,now);
	}
	printf("%d\n",ans);
	return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  string s; std::cin >> s;
  int ans = 0;
  for (auto &c : s) {
    if (c == '+') ans++;
    else ans--;
  }
  std::cout << ans << "\n";
}


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

int n;
vector<int> a;
vector<int> b;
vector<int> c;


int main()
{
	cin >> n;
	a.resize(n);
	b.resize(n);
	c.resize(n - 1);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> b[i];
	}
	for (int i = 0; i < n - 1; i++)
	{
		cin >> c[i];
	}
    
    int ans = b[a[0] - 1];
    for (int i = 1; i < n; i++)
    {
        ans += b[a[i] - 1];
        if (a[i] == a[i - 1] + 1)
        {
            ans += c[a[i - 1] - 1];
        }
    }
    cout << ans;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC109.A
{
    class Program
    {
        static void Main()
        {
            var sc = new Scanner();
            var n = sc.Nextint();
            var X = sc.NextLong();
            var x = sc.ArrayLong(n);
            Array.Resize(ref x, x.Length + 1);
            x[x.Length - 1] = X;
            Array.Sort(x);
            var min = Math.Abs(x[0] - x[1]);
            for (int i = 1; i < n; i++)
            {
                min = Gcd(min, Math.Abs(x[i] - x[i + 1]));
            }
            Console.WriteLine(min);
        }

        public static long Gcd(long a, long b)
        {
            var r = Math.Min(a, b);
            while (a != b && r != 0)
            {
                if (a > b) r = a %= b;
                else r = b %= a;
            }
            return Math.Max(a, b);
        }
    }
    class Scanner
    {
        string[] s;
        long i;

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

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

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

        public int Nextint()
        {
            return int.Parse(Next());
        }
        public int[] Arrayint(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

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

        public double NextDouble()
        {
            return double.Parse(Next());
        }

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

        public decimal NextDecimal()
        {
            return decimal.Parse(Next());
        }

        public decimal[] ArrayDecimal(long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal();
            }
            return Array;
        }
    }
}


Measured memory_bytes: 17760
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	long long n;
	string ans="Yes";
    cin>>n;
    vector<long long>h(n);
    rep(i,n)cin>>h[i];
    for(int j=n-1;j>0;j--){
        if(h[j-1]==h[j]+1)h[j-1]--;
        else if(h[j-1]>h[j]+1){
            ans="No";
            break;
        }
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 1152
n,m,l = map(int,input().split())
A = [[int(i) for i in input().split()] for i in range(n)]
B = [[int(i) for i in input().split()] for i in range(m)]
result = [[0 for i in range(l)] for i in range(n)]
 
for i in range(n):
    for j in range(m):
        for k in range(l):
            result[i][k] += A[i][j] * B[j][k]
 
for i in range(n):
        print(" ".join(map(str,result[i])))


Measured memory_bytes: 6876
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <limits>
#include <set>
#define MAX 100000
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;
typedef long long int lli;

int main(void)
{
	int N; cin >> N;
	vector<int> A(N + 2, 0); rep(i, 1, N + 1)cin >> A[i];
	vector<lli> D(N);

	lli sum = 0;
	rep(i, 0, N + 1)sum += abs(A[i] - A[i + 1]);
	rep(i, 1, N + 1)D[i - 1] = sum + abs(A[i - 1] - A[i + 1]) - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]);

	rep(i, 0, N)cout << D[i] << endl;

	return 0;
}

Measured memory_bytes: 2432
#include "bits/stdc++.h"
using namespace std;
#define MAX 100000
typedef long long llong;
int n,k;
llong T[MAX];

//?????§?????????P???K??°?????????????????§?????????????????????????????????
int check(llong P){
	int i=0;
	for (int j = 0; j < k; ++j) {
		llong s=0;
		while(s+T[i]<=P){
			s+=T[i];
			i++;
			if(i==n)return n;
		}
	}
	return i;
}

int solve(){
	llong left=0;
	llong right=100000*10000;
	llong mid;
	while(right-left>1){
		mid=(left+right)/2;
		int v=check(mid);
		if(v>=n)right=mid;
		else left=mid;
	}
	return right;
}


int main() {
cin>>n>>k;
for (int i = 0; i < n; ++i) {
	cin>>T[i];
}
llong ans =solve();
cout<<ans<<endl;
}

Measured memory_bytes: 3856
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int n;
string s[1000];
vector<int> g[1000];

ll dfs(int v, int p){
  if (s[v] == "E"){
    ll res = 1;
    each(u, g[v]){
      if (u == p) continue;
      (res *= dfs(u, v)) %= mod;
    }
    return res;
  }
  if (s[v] == "E?"){
    ll res = 1;
    each(u, g[v]){
      if (u == p) continue;
      (res *= dfs(u, v)) %= mod;
    }
    return (res + 1) % mod;
  }
  if (s[v] == "R"){
    vector<ll> a;
    each(u, g[v]) if (u != p) a.push_back(dfs(u, v));
    ll res = 0;
    rep(i, 1, 1 << a.size()){
      ll t = 1;
      rep(j, a.size()) if (i >> j & 1) (t *= a[j]) %= mod;
      (res += t) %= mod;
    }
    return res;
  }
  if (s[v] == "R?"){
    vector<ll> a;
    each(u, g[v]) if (u != p) a.push_back(dfs(u, v));
    ll res = 0;
    rep(i, 1, 1 << a.size()){
      ll t = 1;
      rep(j, a.size()) if (i >> j & 1) (t *= a[j]) %= mod;
      (res += t) %= mod;
    }
    return (res + 1) % mod;
  }
  if (s[v] == "A"){
    ll res = 0;
    each(u, g[v]) if (u != p) (res += dfs(u, v)) %= mod;
    return res;
  }
  if (s[v] == "A?"){
    ll res = 0;
    each(u, g[v]) if (u != p) (res += dfs(u, v)) %= mod;
    return (res + 1) % mod;
  }
}

int main(){
  cin >> n;
  rep(i, n) cin >> s[i];
  rep(i, n - 1){
    int s, t;
    cin >> s >> t, s--, t--;
    g[s].push_back(t);
    //g[t].push_back(s);
  }
  cout << dfs(0, -1) << endl;
}

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

#define endl '\n'

using namespace std;
using ll = long long int;

int main(){

    string s, t;
    cin >> s >> t;

    int ans = INT_MAX;

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

        int localAns = 0;

        for (int j=0; j<(int)t.size(); j++){
            if (i + j >= s.size()) {
                cout << ans;
                return 0;
            }
            if (s[i + j] != t[j]) localAns++;
        }

        ans = min(localAns, ans);

    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N;
vector<int> g[55];
vector<pair<int,int>> edges;
int M;
vector<pair<int,int>> con;

vector<vector<int>> path;

bool dfs(int now,int par,int tar,vector<int> &res){
  if(now==tar){
    res.push_back(tar);
    return true;
  }
  for(auto nex:g[now]){
    if(nex==par) continue;
    if(dfs(nex,now,tar,res)){
      res.push_back(now);
      return true;
    }
  }
  return false;
}

void setPath(){
  for(int i=0;i<M;i++){
    dfs(con[i].first,-1,con[i].second,path[i]);
    reverse(path[i].begin(),path[i].end());
  }
}

int main(){
  cin>>N;
  rep(i,N-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    if(a>b) swap(a,b);
    edges.push_back(mkp(a,b));
    g[a].push_back(b);
    g[b].push_back(a);
  }
  cin>>M;
  rep(i,M){
    int a,b;
    cin>>a>>b;
    a--;b--;
    if(a>b) swap(a,b);
    con.push_back(mkp(a,b));
  }

  path.resize(M);
  setPath();

  map<pair<int,int>,int> mp;
  rep(i,N-1) mp[edges[i]]=i;

  ll ans=0;
  for(int bit=0;bit<(1<<M);bit++){
    vector<int> used(N-1,0);
    for(int i=0;i<M;i++){
      if(bit&(1<<i)){
        int pre=con[i].first;
        for(int j=1;j<path[i].size();j++){
          int a=pre,b=path[i][j];
          if(a>b) swap(a,b);
          used[mp[mkp(a,b)]]=1;
          pre=path[i][j];
        }
      }
    }

    ll num=1;
    rep(i,N-1) if(used[i]==0) num*=2;

    if(__builtin_popcount(bit)%2) ans-=num;
    else ans+=num;
  }

  cout<<ans<<endl;

  

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
constexpr int INF = (numeric_limits<int>::max() == INT_MAX ? (int)1e9 : (long long)1e18);
constexpr long double eps = 1e-6;
const string el = "\n";
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;using pii = pair<int,int>;using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void fast_io(){ios::sync_with_stdio(false); cin.tie(nullptr);}
int out(int a){cout << a << el; return 0;}
int out(string s = "NO"){cout << s << el; return 0;}
template <class T>
inline int out(vector<T>&v,string c = " "){
    for(int i = 0; i < v.size(); ++i){
        if(i) cout << c; cout << v[i];
    } cout << el;return 0;
}
signed main(){
    string s; cin >> s;
    auto t = s;
    for(int i = 0; i + 1 < s.size(); ++i){
        t.erase(prev(t.end()));
        if(t.size() % 2 != 0) continue;
        bool f = true;
        for(int j = 0; j < t.size() / 2; ++j)
            if(t[j] != t[t.size() /2 + j])f = false;
        if(f){
            out(t.size());
            return 0;
        }
    }
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    String S=gs();
	    String abc="abcdefghijklmnopqrstuvwxyz";

        if(S.length()<26) {
        	char c='z';
        	for(int i=0; i<abc.length();i++) {
        		if(!S.contains(abc.subSequence(i, i+1))) {
        			c=abc.charAt(i);
        			break;
        		}
        	}
		    System.out.println(S+c);
        } else {
        	char bc=S.charAt(S.length()-1);
        	StringBuilder sb=new StringBuilder();
        	sb.append(bc);
        	boolean f=false;
        	for(int i=S.length()-2; i>=0;i--) {
        		char c=S.charAt(i);
        		if(c>bc) {
                    bc=c;
                    sb.append(c);
        		} else {
        			f=true;
        			break;
        		}
        	}
        	
        	if(f) {
        		String a=sb.toString();
        		String so=S.substring(0, S.length()-a.length()-1);
        		char c='z';
            	for(int i=0; i<abc.length();i++) {
            		c=abc.charAt(i);
            		if(a.contains(abc.subSequence(i, i+1)) && c>S.charAt(S.length()-a.length()-1)) {
            			
            			break;
            		}
            	}
        		System.out.println(so+c);
        	} else {
        		System.out.println(-1);
        	}
        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 38944
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL<<60LL)
typedef long long ll;

using namespace std;



int main() {
	string s; cin >> s;
	rep(i,s.size()-1)
		if (s[i] == s[i + 1]) {
			cout << i+1 << " " << i + 2 << endl;
			exit(0);
		}
	rep(i, s.size() - 2)
		if (s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			exit(0);
		}
	cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
const ll INF = 1000000007;
#define PI 3.1415926535
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}
bool seen[100000];
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする
 
    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}
 
//dpTable
ll dp[100050];
int main(){
    int N,M;
    cin >> N >> M;
    vector<int> a(M);
    vector<bool> b(100050,true);
    rep (i,M) {
        cin >> a.at(i);
        b.at(a.at(i)) = false;
    }
    dp[0] = 1;
    if (b.at(1)) dp[1] = 1;
    for (int i = 2; i <= 100010; i++) {
        if (b.at(i)) {
            dp[i] = dp[i - 1] + dp[i - 2];
        }
        dp[i] %= INF;
    }
    cout << dp[N] << endl;
    return 0;
}


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

int main()
{
    int N;
    cin >> N;
    vector<double> A(N);
    rep(i, N)
    {
        cin >> A.at(i);
        A.at(i) = 1. / A.at(i);
    }
    double ans = 0;
    rep(i, N)
    {
        ans += A.at(i);
    }
    ans = 1. / ans;
    cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int MAXN = 100005;
int dp[MAXN], visited[MAXN];

int n;

vector<vector<int>> adj;

void dfs(int u) {
    visited[u] = 1;

    dp[u] = 0;

    for (auto& v : adj[u]) {
        if (!visited[v]) {
            dfs(v);
            dp[u] ^= (dp[v] + 1);
        }
    }
}

int main() {
    GI(n);

    int u, v;

    adj.resize(n+1);

    FORN(i, n-1) {
        GI(u);
        GI(v);

        adj[u].PB(v);
        adj[v].PB(u);
    }

    memset(visited, 0, sizeof visited);
    dfs(1);

//    DEBUG(dp[1]);

    if (dp[1] == 0) {
        printf("Bob\n");
    }
    else {
        printf("Alice\n");
    }

    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vec x(n),y(n);
  for(ll i=0;i<n;i++) cin >> x[i] >> y[i];
  for(ll i=0;i<n;i++) {
    vector<double> d;
    for(ll j=0;j<n;j++) {
      if(i==j) continue;
      d.push_back(atan2(y[j]-y[i],x[j]-x[i]));
    }
    sort(d.begin(),d.end());
    double r=0;
    ll k=d.size();
    for(ll j=0;j<k;j++) {
      d.push_back(d[j]+2*acos(-1));
    }
    for(ll j=0;j<k;j++) {
      r=max(r,acos(-1)-d[j+k]+d[j+1]);
    }
    cout << fixed << setprecision(10) << r/2./acos(-1) << endl;
  }
}

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

int N, M;
priority_queue<int> pq;

int main() {
  cin >> N >> M;
  int Ai;
  rep(i, N) {
    scanf("%d", &Ai);
    pq.push(Ai);
  }
  rep(i, M) {
    int top = pq.top();
    pq.pop();
    pq.push(top/2);
  }
  long long sum=0;
  while(!pq.empty()) {
    sum += pq.top();
    pq.pop();
  }
  cout << sum << endl;
  return 0;
}



Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> A(n);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		sum += A[i];
	}
	if (sum == k) {
		cout << n;
	}
	else if (sum < k) {
		cout << n - 1;
	}
	else {
		sort(all(A));
		ll cur = 0;
		for (int i = 0; i < n; i++) {
			cur += A[i];
			if (cur > k) {
				cout << i;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
	int i, j;
	scanf("%d", &n);
	for(i=1; i<=n; i++) {
		if(i%3==0) printf(" %d", i);
		else {
			for(j=i; j>0; j/=10) {
				if(j%10==3) {
					printf(" %d", i);
					break;
				}
			}
		}
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;




int main(void) {

	string s;
	cin>>s;
	vll v(s.size()+1,-1);
	vi point;
	if(s[0]=='<')point.push_back(0);
	if(s[s.size()-1]=='>')point.push_back(s.size());
	for(int i=0;i<s.size()-1;i++){
		if(s[i]=='>'&&s[i+1]=='<')point.push_back(i+1);
	}
	for(int i=0;i<point.size();i++){
		v[point[i]]=0;
	}
	for(int I=0;I<point.size();I++){
		int start=point[I];
		//左
		for(int i=start;i>0;i--){
			if(s[i-1]=='>')v[i-1]=max(v[i-1],v[i]+1);
			else {
				break;
			}
		}
		//右
		for(int i=start;i<v.size()-1;i++){
			if(s[i]=='<'){
				v[i+1]=max(v[i+1],v[i]+1);
			} else {
				break;
			}
		}
	}
	ll sum=0;
	for(int i=0;i<v.size();i++){
		sum+=v[i];
	}
	fin(sum);


}



Measured memory_bytes: 5380
import Foundation

let (x, k, d) = readInts().mapToTuple()

let abs = x.abs
let ope: (Int, Int) -> Int = x > 0 ? { $0 - $1 } : { $0 + $1 }
let times = abs/d
let min = Swift.min(times, k)

let near = ope(x, min*d)

if min == k {
    print(near.abs)
} else {
    if (k - min).isMultiple(of: 2) {
        print(near.abs)
    } else {
        print(ope(near, d).abs)
    }
}




// MARK: -----------------------------------------------------------------------


func readInt() -> Int {
    Int(readLine()!)!
}

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

extension Collection {
    func mapToTuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }
    
    func safe(at index: Index) -> Element? {
        self.indices.contains(index) ? self[index] : nil
    }
}

struct DP<Argument: Hashable, Element> {
    var dictionary = [Argument: Element]()
    
    var expression: (Argument, (Argument) -> Element) -> Element
    
    init(expression: @escaping (_ argument: Argument, _ note: (Argument) -> Element) -> Element) {
        self.expression = expression
    }
    
    subscript(_ argument: Argument) -> Element {
        mutating _read {
            if let note = dictionary[argument] {
                yield note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                yield result
            }
        }
    }
}

extension Dictionary {
    init(_ initialize: (inout Self) -> ()) {
        var dictionary = Self()
        initialize(&dictionary)
        self = dictionary
    }
}


extension Int {
    var abs: Int {
        self < .zero ? -self : self
    }
}


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

int main(){
  int a,N,K,x;
  a=0;
  cin>>N>>K;
  for(int i=0;i<N;i++){
    cin>>x;
    if(x<=K/2){
      a +=x;
    }
    else{
      a +=(K-x);
    }
  }
  cout<<2*a<<endl;
}
        

Measured memory_bytes: 764
n, k, q = list(map(int, input().split()))
a = [int(input()) for _ in range(q)]

b = [0] * (10**5 + 1)
for x in a:
  b[x] += 1

base = k - q
for i in range(n):
  i += 1
  if base + b[i] > 0:
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 8644
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
 
using namespace std;
int main(){
  string str;
  cin>>str;
  int fr=-1,to=-1;
  for(int i=0;i<str.size()-1;i++){
    if(str[i]==str[i+1]){
      fr=i+1;to=i+2;
      break;
    }
  }
  for(int i=0;i<str.size()-2;i++){
    if(str[i]==str[i+2]){
      fr=i+1;to=i+3;
      break;
    }
  }
  cout<<fr<<" "<<to<<endl;
  return 0;
}

Measured memory_bytes: 512
# @author 

import sys

class BOrdinaryNumber:
    def solve(self):
        n = int(input())
        p = [int(_) for _ in input().split()]
        ans = 0
        for i in range(1, n - 1):
            if min(p[i - 1], p[i + 1]) < p[i] < max(p[i - 1], p[i + 1]):
                ans += 1
        
        print(ans)

solver = BOrdinaryNumber()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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

bool f(vector<ll> A,vector<ll> F,ll x,ll K){
	ll cnt = 0;
	REP(i,sz(A)){
		if(A[i]*F[i]>x){
			cnt+=A[i]-x/F[i];
		}
	}

	return cnt<=K;
}

int main()
{
	ll N,K;
	cin >> N >> K;
	VEC(ll,A,N);
	VEC(ll,F,N);
	sort(ALL(A));
	sort(ALL(F));
	reverse(ALL(F));

	ll ok=1000000000000;
	ll ng=-1;
	while(abs(ok-ng)>1){
		ll mid=(ok+ng)/2;
		if(f(A,F,mid,K)){
			ok=mid;
		}else{
			ng=mid;
		}
	}

	cout << ok << endl;
}


Measured memory_bytes: 9524
#include<iostream>

int main(void){
	int a, b, c, divi, count = 0;
	
	std::cin >> a >> b >> c; 
	divi = a;
	
	while (a <= divi && divi <= b){
		if ( c % divi == 0) count += 1;
		divi += 1;
	}
	std::cout << count <<  std::endl;
	
	return 0;
}

Measured memory_bytes: 1160