akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <sstream>
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <queue>

using namespace std;


class Main {
public:
	int maxPoint(string str) {
		int gCnt = 0;
		int pCnt = 0;
		int point = 0;
		for (int i = 0;i < str.size();i++) {
			if (pCnt < gCnt) {
				pCnt++;
				point += str[i] == 'p' ? 0 : 1;
			}
			else {
				gCnt++;
				point += str[i] == 'p' ? -1 : 0;
			}
		}
		return point;
	}
};


int main()
{
	Main m;
	string str;

	cin >> str;

	cout << m.maxPoint(str) << endl;

    return 0;
}



Measured memory_bytes: 512
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const S = arg[1].split("");
    
    const countW = S.filter(s=>s==="W").length;
    const countE = N - countW;
    
    const left  = {W: 0, E: 0};
    const right = {W: countW, E: countE};
    
    let answer = Infinity;
    
    for(let i=0; i<N; i++) {
        let now = S[i];
        
        if(now === "W") right.W--;
        if(now === "E") right.E--;
        
        answer = Math.min(answer, right.E + left.W);
        
        if(now === "W") left.W++;
        if(now === "E") left.E++;
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 20628
import java.util.Scanner;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        System.out.println(solve(A, B, C) ? "Yes" : "No");

        sc.close();
    }

    static boolean solve(int A, int B, int C) {
        return C >= A && C <= B;
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main(){
	//ios::sync_with_stdio(false);
	//cin.tie(0);cout.tie(0);
	long double a, b;
	cin >> a >> b;
	ll ans = a / 100 * ((ll)(b * 100) % 10) + a / 10 * ((ll)(b * 100) / 10 % 10) + a * ((ll) (b * 100) / 100);
	printf("%lld", (ll)floor(a * b));
	return 0;
}

Measured memory_bytes: 3792
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let a: usize = sc.read();
    let b: usize = sc.read();
    if a <= 5 {
        println!("{}", 0);
    } else if a >= 6 && a <= 12 {
        println!("{}", b / 2);
    } else {
        println!("{}", b);
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

public class Main {

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

		//標準入力取得
		int num = sc.nextInt();
		int edge[] = new int[num];
		for (int i = 0; i < num; i++) {
			edge[i] = sc.nextInt();
		}

		Arrays.sort(edge);

		int triangle = 0;
		for (int i = 0; i < num - 2; i++) {
			for (int j = i + 1; j < num - 1; j++) {
				for (int k = j + 1; k < num; k++) {
					if (condition(edge[i], edge[j], edge[k])) {
						triangle++;
					} else {
						break;
					}
				}
			}
		}
		System.out.println(triangle);

		sc.close();

	}

	private static boolean condition(int i, int j, int k) {
		boolean result = false;

		if (i < j + k && j < k + i && k < i + j) {
			result = true;
		}
		return result;
	}

}


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

int main()
{ 
      ios::sync_with_stdio(0);
      cin.tie(0);
     
      int n;cin>>n;
    
      if((n>=400) && (n<=599))
      cout<<"8";
    
      else if((n>=600) && (n<=799))
      cout<<"7";
       
      else if((n>=800) && (n<=999))
      cout<<"6";
    
      else if((n>=1000) && (n<=1199))
      cout<<"5";
    
      else if((n>=1200) && (n<=1399))
      cout<<"4";
    
      else if((n>=1400) && (n<=1599))
      cout<<"3";
      
      else if((n>=1600) && (n<=1799))
      cout<<"2";
    
      else if((n>=1800) && (n<=1999))
      cout<<"1";
    
    
    
      
                                                              
      return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int k, q;
    cin >> k >> q;
    V<ll> d(k);
    read(d);
    while (q--) {
        ll n, x, m;
        cin >> n >> x >> m;
        x %= m;
        ll res = n - 1, sum = x;
        for (int i = 0; i < k; i++) {
            if (i >= n - 1) continue;
            if (d[i] % m == 0) {
                res -= 1LL + (n - 2 - i) / k;
            } else {
                sum += (1LL + (n - 2 - i) / k) * (d[i] % m);
            }
        }
        sum++;
        res -= sum / m - 1LL + (sum % m > 0LL);
        cout << res << newl;
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 200500000000000
#define MOD 1000000007
#define N 100005
#define M 1000005
#define LOG 18
#define KOK 4000000
using namespace std;

struct state {

	int anc;
	int cur;
	ll cost;

	bool operator<(const state& oth) const {

		return cost>oth.cost;

	}

};

int n,m,s,t,a,b,c;
int dp[2][N],vis[2][N];
ll dis[2][N];
vector<ii> v[N];

void solve(int w,int node) {

	priority_queue<state> q;

	dp[w][0]=1;

	q.push({0,node,0});

	while(!q.empty()) {

		state now=q.top();

		q.pop();

		if(vis[w][now.cur]) {

			if(now.cost==dis[w][now.cur]) {

				dp[w][now.cur]=(dp[w][now.cur]+dp[w][now.anc])%MOD;

			}

			continue ;

		}

		vis[w][now.cur]=1;

		dp[w][now.cur]=dp[w][now.anc];

		dis[w][now.cur]=now.cost;

		for(ii go:v[now.cur]) {

			q.push({now.cur,go.st,now.cost+go.nd});

		}

	}

}

int main() {

//	freopen("input.txt","r",stdin);

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

	scanf("%d %d",&s,&t);

	for(int i=1;i<=m;i++) {

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

		v[a].pb({b,c});
		v[b].pb({a,c});

	}

	solve(0,s);
	solve(1,t);

	int ans=1ll*dp[0][t]*dp[0][t]%MOD;

	for(int i=1;i<=n;i++) {

		if(dis[0][i]*2==dis[0][t] && dis[1][i]*2==dis[0][t]) ans=(ans-1ll*dp[0][i]*dp[1][i]%MOD*dp[0][i]%MOD*dp[1][i]%MOD+MOD)%MOD;

		for(ii go:v[i]) {

			if(dis[0][i]+go.nd+dis[1][go.st]==dis[0][t] && dis[0][i]*2<dis[0][t] && dis[0][go.st]*2>dis[0][t]) {

				ans=(ans-1ll*dp[0][i]*dp[1][go.st]%MOD*dp[0][i]%MOD*dp[1][go.st]%MOD+MOD)%MOD;

			}

		}

	}

	printf("%d",ans);

}



Measured memory_bytes: 19484
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
typedef long long ll;
using namespace std;
const int maxn = 200009;
const double pi = acos(-1.0);
int n,s[maxn];
int main(){
    scanf("%d",&n);
    for(int i = 2,tmp; i <= n; i++) scanf("%d",&tmp),s[tmp]++;
    for(int i = 1; i <= n; i++) printf("%d\n",s[i]);
    return 0;
}

Measured memory_bytes: 4612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var ps = new List<int>();
            for (var i = 2;; i++)
            {
                var isPrime = true;
                var sqrtI = Math.Sqrt(i);
                foreach (var p in ps)
                {
                    if (i % p == 0)
                    {
                        isPrime = false;
                        break;
                    }
                    else if (p > sqrtI)
                    {
                        break;
                    }
                }
                if (isPrime)
                {
                    if (i >= n)
                    {

                        Console.WriteLine(i);
                        return;
                    }
                    else
                        ps.Add(i);
                }
            }
        }
    }
}

Measured memory_bytes: 27832
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 998244353
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    if(n&1){
        n--;
        for(int i=0;i<m;i++){
            cout<<i+1<<" "<<n-i<<endl;
        }
    }
    else{
        
        for(int i=0;i<m;i++){
            if(i<(m+1)/2)cout<<i+1<<" "<<n-i<<endl;
            else cout<<i+1<<" "<<n-i-1<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var line = consoleReader.SplitInt32();
            return line[0] * line[1] / 2;
        }
        string ToNumString(int[] ketaNum, int[] A)
        {
            var sb = new System.Text.StringBuilder();
            for (int i = A.Length - 1; i >= 0; i--)
            {
                sb.Append((char)('0' + A[i]), ketaNum[A[i]]);
            }
            return sb.ToString();
        }

        const int mod = 1000000007;
        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc());
        public static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
    }

    public class ConsoleReader
    {
        public virtual string String() => Console.ReadLine();
        public int Int32() => int.Parse(String());
        public long Int64() => long.Parse(String());
        public ulong UInt64() => ulong.Parse(String());
        public double Double() => double.Parse(String());
        public string[] Split() => String().Split().ToArray();
        public int[] SplitInt32() => String().Split().Select(int.Parse).ToArray();
        public long[] SplitInt64() => String().Split().Select(long.Parse).ToArray();
        public ulong[] SplitUInt64() => String().Split().Select(ulong.Parse).ToArray();
        public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray();

        public IEnumerable<string> Repeat(int count)
        {
            for (int i = 0; i < count; i++)
                yield return String();
        }
        public IEnumerable<int> RepeatInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Int32();
        }
        public IEnumerable<long> RepeatInt64(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Int64();
        }
        public IEnumerable<string[]> RepeatSplit(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Split();
        }
        public IEnumerable<int[]> RepeatSplitInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return SplitInt32();
        }
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;
import java.util.stream.*;
import java.util.Arrays;
  
public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true){
      final int n = sc.nextInt();
      final int r = sc.nextInt();
      if ( n == 0 && r == 0 )break;
      int[] a = new int[n];
      for( int i=0; i<n; ++i ){ a[i] = n-i; }
      for( int i=0; i<r; ++i ){
        final int p = sc.nextInt() - 1;
        final int c = sc.nextInt();
        int[] t = new int[p];
        for(int j=0; j<p; j++ ){ t[j]=a[j]; }
				for(int j=0; j<c; j++ ){ a[j]=a[j+p]; }
				for(int j=0; j<p; j++ ){ a[j+c]=t[j]; }
      }
      System.out.println( a[0] );
    }
  }
  
}


Measured memory_bytes: 37108
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);
    int[] list = new int[26];
    String alphabet = "abcdefghijklmnopqrstuvwxyz";

    while (scan.hasNextLine()) {

      String str = scan.nextLine();

      for (int i = 0; i < str.length(); i++) {
        char ch = str.charAt(i);
        int index = Character.getNumericValue(ch) - 10;
        if (index >= 0) {
          list[index]++;
        }
      }

    }
    
    for (int i = 0; i < 26; i++) {
      System.out.println(alphabet.charAt(i) + " : " + list[i]);
    }

  }

}


Measured memory_bytes: 26172
/* ~ Programmer >> Tushar Mahajan */
#include <iostream>
#include <bits/stdc++.h> 
using namespace std;
#define ll unsigned long long
#define MOD 1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL); 

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


Measured memory_bytes: 3624
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();

        int target = Integer.valueOf(a+b);
        boolean isSquare = false;

        for (int i = 1; i <= 100100; i++) {
            if (target == i*i) {
                isSquare = true;
                break;
            }
        }

        if (isSquare) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 21972
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
int a,b;
while(scanf("%d %d",&a,&b)!=EOF){
    long long int z=(long long)a*b;
    if(a<b)swap(a,b);
    while(b){
        int d=b;
        b=a%b;
        a=d;
    }
    printf("%d %lld\n",a,z/a);
}


return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin(), x.begin()+n)
// #define int long long
#define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;

signed main(void) {
  	ll A, B;
  	cin >> A >> B;

  	if (abs(A) == abs(B)) {
  		cout << 0 << endl;
  	} else {
  		ll K = (A + B)/2;
  		long double k = (A + B)/2.0;
  		if ((A-K)*(B-K) < 0 && K == k) {
  			cout << K << endl;
  		} else {
  			cout << "IMPOSSIBLE" << endl;
  		}
  	}

	return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
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;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int a, b;
  std::cin >> a >> b;
  if (a + b < 10)
    print(a + b);
  else
    std::cout << "error" << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	string s;
	cin >> s;
	sort(&s[0],&s[s.length()]);
	if(s == "abc") cout << "Yes" << endl;
	else cout << "No" << endl; 
	return 0;
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, length):
        self.r = [-1] * length

    def root(self, x):
        rx = self.r[x]
        if (rx) < 0:
            return x

        return self.root(rx)

    def is_root(self, x):
        rx = self.r[x]
        return rx < 0

    def unit(self, x, y):
        x = self.root(x)
        y = self.root(y)

        if x == y:
            return False
        r = self.r

        if r[x] > r[y]:
            x, y = y, x

        r[x] += r[y]
        r[y] = x

        return True

    def size(self, x):
        return -self.r[self.root(x)]

    def debug(self):
        print(self.r)


N, M = map(int, input().split())

union_find = UnionFind(N)

for _ in range(M):
    A, B = map(int, input().split())
    union_find.unit(A-1, B-1)

count_union = 0
for i in range(N):
    if union_find.is_root(i):
        count_union += 1

print(count_union-1)


Measured memory_bytes: 10976
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>
 
using namespace std;
typedef long long ll;


ll ans,mx,mn,sum;
int main(){
	int n;
	cin>>n;
	for(int i=1; i<=n; i++) ans+=i;
	cout<<ans<<endl;
}

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

public class Main{
	static final Scanner s=new Scanner(System.in);
	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}
	static IntStream REPS(int l,int r){
		return IntStream.rangeClosed(l,r);
	}
	static IntStream INS(int n){
		return REPS(n).map(i->getInt());
	}
	static int getInt(){
		return Integer.parseInt(s.next());
	}

	public static void main(String[]$){
		long[]v=INS(getInt()).asLongStream().toArray();
		long sum=Arrays.stream(v).sum();
		Arrays.parallelPrefix(v,Long::sum);
		System.out.println(Arrays.stream(v).limit(v.length-1).map(i->Math.abs((sum-i)-i)).min().getAsLong());
	}
}


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

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

fn main() {
    let w: i32 = read();
    let h: i32 = read();
    let x: i32 = read();
    let y: i32 = read();
    let r: i32 = read();
    let ans: String;

    if x < 0 || y < 0 {
        ans = "No".to_string()
    }else if w >= x + r && h >= y + r {
        ans = "Yes".to_string()
    } else {
        ans = "No".to_string()
    }

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


Measured memory_bytes: 5028
#include "bits/stdc++.h"

using namespace std;


int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	vector<int> C(N);

	
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int v = 0;
	for (int i = 0; i < N; i++) {
		cin >> B[i];
		v += B[i];
		//cerr << B[i] << endl;
	}
	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}

	for (int i = 0; i < N-1; i++) {
		if (A[i]+1 == A[i + 1]) {
			v += C[A[i]-1];
			//cerr << C[A[i] - 1] << endl;
		}
	}
	cout << (v);
	return 0;
}


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

#define F first
#define S second
#define pb push_back
#define ld  double
#define ll long long
#define int long long


using namespace std;

const int MAXN = 10001 * 1001 , MOD = 1e9 + 7  ;


int32_t main()
{
   ios::sync_with_stdio(0);cin.tie(0);
   int a , b , c;
   cin >> a >> b >> c ;
   if(a%2==0||b%2==0||c%2==0)
    return cout<<0,0 ;
   cout<<min({a*b,b*c,c*a});

}


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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
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;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int k, x;
  cin >> k >> x;
  vector<int> r;
  for(int i = max(-1000000, x - k + 1); i <= min(1000000, x + k - 1); i++){
    r.pb(i);
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
students = []
for i in range(n):
  student = dict(num=i+1, people=a[i])
  students.append(student)
students.sort(key=lambda x:x['people'])
answer = [student.get('num') for student in students]
for ans in answer:
  print(ans, end=' ')

Measured memory_bytes: 42904
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}




int main(){
    ll w,h,x,y;
    cin>>w>>h>>x>>y;
    cout<<fixed<<setprecision(12)<<(D)w*h/2<<" "<<(x*2==w && y*2==h?1:0)<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int fib(int );
int dp[50];


int main(){
  int n,i;
  for(i=0;i<50;i++)dp[i]=-1;
  
  scanf("%d",&n);
  printf("%d\n",fib(n));
  
  return 0;
}


int fib(int n){
  if(n==0||n==1)return dp[n]=1;
  if(dp[n]!=-1)return dp[n];
  return dp[n]=fib(n-1)+fib(n-2);
}



Measured memory_bytes: 2112
"use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function main(input) {
  var lines = input.split('\n');

  var _lines = _slicedToArray(lines, 1),
      S = _lines[0];

  var ws = S.split('B').map(function (chunk) {
    return chunk.length;
  }); // initial 'W's are useless
  // W..BWW..BW...

  var result = 0;

  for (var i = 0; i < ws.length; i++) {
    result += i * ws[i];
  }

  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function splitNum(line) {
  return line.split(/\s+/).map(function (n) {
    return parseInt(n);
  });
}


Measured memory_bytes: 29892
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int k; cin >> k;
  rep(i, k) cout << "ACL";
  return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<fstream>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
int s[5];
int main()
{
 
 cin>>s[1]>>s[2]>>s[3];
 
 sort(s+1,s+3+1);

 cout<<s[1]+s[2];

 return 0;
}

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

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

const int MAXN = 2e5 + 5;
const int oo = 1e9 + 7;

int n, a[MAXN], b[MAXN];

struct BIT {
private:
    vector<int> t;
public:
    BIT(int n) {t.assign(n+1, 0);}
    void update(int p, int x) {
        for(int i = p; i < t.size(); i += i&(-i))
            t[i] += x;
    }
    int query(int p) {
        int res = 0;
        for(int i = p; i > 0; i -= i&(-i))
            res += t[i];
        return res;
    }
};

ll C2(ll n) {return n*(n+1)/2;}

bool Check(int mid) {
    vector<int> d(n+1);
    fto(i, 1, n)
        d[i] = d[i-1] + ((a[i] >= b[mid]) ? 1 : -1);

    BIT t(2*n);
    ll cnt = 0;
    fto(i, 1, n) {
        t.update(d[i-1] + n, 1);
        cnt += t.query(d[i] + n);
    }

//    debug(mid);
//    debug(cnt);

    return (2*cnt >= C2(n));
}

int main () {
    scanf("%d", &n);
    fto(i, 1, n) scanf("%d", &a[i]);

    fto(i, 1, n) b[i] = a[i];
    sort(b+1, b+n+1);

    int lo = 1, hi = n, res = 0;
    while (lo <= hi) {
        int mid = (lo+hi)/2;
        if (Check(mid)) {
            res = mid;
            lo = mid+1;
        } else hi = mid-1;
    }

    printf("%d\n", b[res]);

    return 0;
}


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

std::chrono::time_point<std::chrono::steady_clock> start;

void tic() {
    start = std::chrono::steady_clock::now();
}
 
double toc() {
    auto now = std::chrono::steady_clock::now();
    std::chrono::duration<double> duration = now - start;
    return duration.count();
}

int main(){
    tic();

    int D;
    cin >> D;
    vector<int> c(26);
    rep(i,26) cin >> c[i];
    vector<vector<int>> s(D,vector<int>(26));
    rep(j,D) rep(i,26) cin >> s[j][i];

    vector<int> t(D);
    vector<vector<int>> last(26, vector<int>(1,-1));
    Int manzoku = 0;

    rep(j,1) {
        int maxs = 0;
        rep(i,26) maxs = max(maxs, s[j][i]);
        vector<int> v(0); //s[j][i]が最も大きくなるようなiを入れる
        rep(i,26) {
            if (s[j][i] == maxs) {
                v.push_back(i+1);
            }
        }
        if (v.size() == 1) {
            t[j] = v[0];
            last[t[j]-1].push_back(j);
        }
        else { //仮
            t[j] = v[0];
            last[t[j]-1].push_back(j);
        }
    }
    int i = t[0]-1;
    rep1(j,D-1) {
        i = (i + 1) % 26;
        t[j] = i+1;
        last[t[j]-1].push_back(j);
    }


    rep(i,26) last[i].push_back(D);

    vector<int> nums(26,0);
    rep(i,26) nums[i] = last[i].size();

    while (toc() < 1.9) {
        int d, q;
        vector<pair<int,int>> vp(26);
        rep(i,26) vp[i] = make_pair(c[i] - 2+(rand()%8) * nums[i],i);
        sort(vp.begin(),vp.end());
        reverse(vp.begin(),vp.end());
        q = vp[0].second + 1;
        int p;
        for (int j = 25; j>=0; j--) {
            p = vp[j].second;
            if (last[p].size() == 2) continue;
            else {
                break;
            }
        }
        if (last[p].size() <= 2) continue;
        int lpsz = last[p].size() - 2;
        d = last[p][1 + (rand() % lpsz)] + 1;
        manzoku = 0;

        manzoku -= s[d-1][t[d-1]-1];
        manzoku += s[d-1][q-1];

        auto iteold = find(last[t[d-1]-1].begin(), last[t[d-1]-1].end(), d-1);
        int old_last = *(iteold-1);
        manzoku -= c[t[d-1]-1] * (d-1 - old_last) * (*(iteold+1) - (d-1));

        auto itenew = upper_bound(last[q-1].begin(), last[q-1].end(), d-1);
        int new_last = *(itenew-1);
        manzoku += c[q-1] * (d-1 - new_last) * (*itenew - (d-1));

        if (manzoku > 0) {
            //更新したほうがよいならこれをやる
            last[t[d-1]-1].erase(iteold);
            last[q-1].insert(itenew,d-1);
            t[d-1] = q;
            nums[t[d-1]-1]--;
            nums[q-1]++;
        
        }
        //cout << manzoku << endl;
    }

    rep(j,D) cout << t[j] << endl;
}

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

using namespace std;

typedef  long long ll;

long long int lcm(ll a, ll b)
{
    return ((a*b)/(__gcd(a,b)));
}
long long int div(ll a, ll c, ll d)
{
    ll lcmn=a/lcm(c,d);
    return (a-((a/c)+(a/d)-lcmn));
}
int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<div(b,c,d)-div( (a-1),c,d);

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int calc(long long int n)
{
    if(n % 4 == 0)
        return n;
    if(n % 4 == 1)
        return 1;
    if(n % 4 == 2)
        return n+1;
    if(n % 4 == 3)
        return 0;
}
int main()
{
    int i,j,x,y,ans,curr=0,n,m,c;
    long long int a,b;
    cin >> a >> b;
    long long int rose = calc(b) ^ calc(a-1);
    cout << rose << endl;
    return 0;
}

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    int[] a = new int[n];
    int min = 1000000000;
    int max = 0;
    String[] str = in.readLine().split(" ");
    for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(str[i]);
      min = Math.min(min,a[i]);
      max = Math.max(max,a[i]);
    }
    System.out.println(max-min);
  }
}

Measured memory_bytes: 32644
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,n;
  cin>>x>>n;
  vector<int> p(n);
  vector<int> y(102,1);
  for(int i=0;i<n;i++){
    cin>>p[i];
    y[p[i]]=0;
  }
  int a=0;
  for(int i=x;i<102;i++){
    if(y[i]){
      a=i;
      break;
    }
  }
  int b=0;
  for(int i=x;i>=0;i--){
    if(y[i]){
      b=i;
      break;
    }
  }
  if(a-x>=x-b){
    cout<<b<<endl;
  }else{
    cout<<a<<endl;
  }
  return 0;
}
      


Measured memory_bytes: 3644
counts = 1
size = 0
array = []
  
def print_array(array)
  str = ""
  array.each{|s|
   str = str + "\s" + s.to_s
  }
 puts  str.strip!
end
  
loop{
  if counts == 1 then
    size = gets.to_i
   else
     array = gets.split("\s")
   end
  
   counts = counts + 1
   
  if counts > 2 then
    break
   end
}
  
 
for i in 1..size - 1  do
  print_array(array)
  
  v = array[i].to_i
  j = i - 1
  
  while (j >= 0 && array[j].to_i > v ) do
    array[j+1] = array[j]
    j = j - 1
  end
  
  array[j+1] = v
  
end
  
print_array(array)

Measured memory_bytes: 11048
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const int INF=2*1e9;
int main()
{
    ll n,m;
    string s;
    cin>>s;
    n=s.size();
    bool x=0;
    rep(i,(n-1)/2)
    {
        if(s[i]!=s[n-i-1]) x=1;
        if(x) break;
    }
    rep(i,(n-1)/4)
    {
        if(s[i]!=s[(n-1)/2-i-1]) x=1;
        if(x) break;
    }
    if(x) cout<<"No";
    else cout<<"Yes";
}


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

int main(){
    int a[5];
    int ans=0;
    int b=10;
    rep(i,5){
        cin >> a[i];
        if(a[i]%10!=0){
            b=min(b,a[i]%10);
            a[i]+=10-(a[i]%10);
        }
        ans+=a[i];
        
    }
    cout << ans-(10-b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<complex>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef complex<double> point;

double cross(point a,point b){
	return imag(conj(a)*b);
}

int main(){
	point in[4],p[4];
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&in[0].real(),&in[0].imag(),&in[1].real(),&in[1].imag(),&in[2].real(),&in[2].imag(),&in[3].real(),&in[3].imag())!=EOF){
		rep(i,4)p[i]=in[(i+1)%4]-in[i];
		bool check[4];
		rep(i,4)check[i]=(cross(p[i],p[(i+1)%4])>0)?true:false;
		if((check[0]&check[1]&check[2]&check[3])||(!check[0]&!check[1]&!check[2]&!check[3]))cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include<iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;

bool judge(VL &s, VL &h, ll x) {
  int n = s.size();
  VL t(n);
  rep(i, n) {
    if (x < h[i]) return false;
    t[i] = (x - h[i]) / s[i];
  }
  sort(all(t));
  rep(i, n) {
    if (t[i] < i) return false;
  }
  return true;
}


int main(){
  ll N, ans;
  cin >> N;
  vector<ll> A(N), B(N), C(N), ab(N+1), bcsum(N+1);

  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  rep(i, N) cin >> C[i];

  sort(all(A));
  sort(all(B));
  sort(all(C));

  ab[N] = 0;
  bcsum[N] = 0;
  for(int i = N-1; i >= 0; i--){
    bcsum[i] = N - distance(C.begin(), upper_bound(C.begin(), C.end(), B[i])) + bcsum[i+1];
  }

  ans = 0;
  rep(i, N){
    ans += bcsum[distance(B.begin(), upper_bound(B.begin(), B.end(), A[i]))];
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 4224
# 一度同じ場所についたら、そこからのループ回数をもう一度求める方法でやってみる
import sys
n,k = map(int,input().split())
a_ls = list(map(int, input().split()))
for i in range(n):
    a_ls[i] -= 1
town_done = [0] * n

# 初期状態のセット
now_town = 0
times = 0
while True:
    # きたtownに関する処理
    town_done[now_town] = 1
    
    # 次の移動
    now_town = a_ls[now_town]
    times += 1
    if times == k:
        print(now_town+1)
        sys.exit()
    if town_done[now_town]:
        base = now_town
        break

rest = k - times
times = 0
while True:
    now_town = a_ls[now_town]
    times += 1
    rest -= 1
    if now_town == base:
        times_per_loop = times
        break
    if rest == 0:
        print(now_town+1)
        sys.exit()

rest = rest % times_per_loop
for _ in range(rest):
    now_town = a_ls[now_town]
print(now_town+1)

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

int main() {
  int n; cin >> n;
  vector<int> c(6, 0);
  for (int i = 0; i < n; ++i) {
    double h; cin >> h;
    if (h < 165.0) ++c[0];
    if (165.0 <= h && h < 170.0) ++c[1];
    if (170.0 <= h && h < 175.0) ++c[2];
    if (175.0 <= h && h < 180.0) ++c[3];
    if (180.0 <= h && h < 185.0) ++c[4];
    if (185.0 <= h) ++c[5];
  }
  for (int i = 0; i < 6; ++i) {
    cout << i + 1 << ':';
    for (int j = 0; j < c[i]; ++j) cout << '*';
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3192
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;

const int MOD=1000000007;

int main()
{
	int c[3][3];
	int sa[3][2];
	bool flag=false;
	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>c[i][j];
			if(j!=0)sa[i][j-1]=c[i][j]-c[i][j-1];
	        }
	}
	if(sa[0][0]==sa[1][0] && sa[0][0]==sa[2][0]
	&& sa[0][1]==sa[1][1] && sa[0][1]==sa[2][1])flag=true;
	
	if(flag)cout<<"Yes"<<"\n";
	else cout<<"No"<<"\n";
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N;
int cnt;
void rec(long num,int flag){
  if(flag==7 && num<=N){
    cnt++;
  }
  if(num>N)return;
  rec(num*10+3,flag|1);
  rec(num*10+5,flag|2);
  rec(num*10+7,flag|4);
}
int main(int argc,char **argv){
  cin>>N;
  int flag=0;
  long num=0;
  rec(num,flag);
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int time, hour, min , sec;
  scanf("%d",&time);
  hour = time / 3600;
  min = (time % 3600) / 60;
  sec = time % 60;
  printf("%d:%d:%d\n",hour, min, sec);

  return 0;
}

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

int main() {
  
  int N, las = -1 , ans = 0;
  cin >> N;
  
  
  for (int i = 0; i < N ; i++){
    
    int h;
    cin >> h;
    
    if (las < 0){
      ans ++;
      las = h;
    }
    else if ( h >= las ){
       ans++;
       las = h;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}
int a[100005];
void solve(){
	ll int n,m;
	cin>>n>>m;
	ll int a[n];
	priority_queue<ll int>pq;
	ll sum=0;
	rep(i,n){cin>>a[i];pq.push(a[i]);}
	rep(i,m){
		ll p=pq.top();
		pq.pop();
		pq.push(p/2);
	}
	while(!pq.empty()){
		sum+=pq.top();
		pq.pop();
	}
	cout<<sum;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 1912
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int h[] = new int[n];
		for ( int i = 0; i < n; i++ ) {
			h[i] = in.nextInt();
		}
		
		HashSet<Integer> cnts = new HashSet<>();
		int cnt = 0;
		for ( int i = 1; i < h.length; i++ ) {
			if(h[i-1] >= h[i]) {
				cnt++;
			} else {
				cnts.add(cnt);
				cnt = 0;
			}
		}
		cnts.add(cnt);

		System.out.println(Collections.max(cnts));
		in.close();

	}

}

Measured memory_bytes: 48316