akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define ROF(i,a,b) for (int i = (b); i >= (a); --i)
#define debug() cout << 1 << endl
#define fi first
#define se second
#define pii pair<int, int>
#define mp make_pair
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define ins insert
#define lb lower_bound
#define ub upper_bound
const long long mod = 1e9 + 7;
const double PI = acos(-1);
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const int MAXN = 1e5 + 10;
#define LOCAL
template<class I>
inline void read(I &x) {
    x = 0; I f = 1; char c = getchar();
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar(); }
    while(c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = getchar(); }
    x *= f;
}
int qpow(int a, int b){int res=1;while(b>0){if(b&1)res=res*a%mod;b=b>>1;a=a*a%mod;}return res % mod;}
ll gcd(ll a,ll b) { return b ? gcd(b, a % b) : a;}
ll a[110];
int main() 
{
	ios::sync_with_stdio(false);
	cout.tie(0), cin.tie(0);
	// #ifdef LOCAL
	// freopen("data.in", "r", stdin);
	
	// #endif
	int t;
	int n;
	cin >> n;
	FOR(i, 1, n) {
		cin >> a[i];
	}
	int ans = 0;
	FOR(i, 1, n) {
		FOR(j, i + 1, n) {
			if (a[i] == a[j]) continue;
			FOR(k, j + 1, n) {
				if (a[k] == a[j] || a[k] == a[i]) continue;
				if (a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[k] + a[j] > a[i]) ans++;
			}
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    ll N,M;
    cin >> N >> M;
    vector<vector<ll>> G(N);
    rep(i,M){
        ll a,b;
        cin >> a >> b;
        a--,b--;
        G[a].push_back(b);
    }
    ll len=INF;
    vector<ll> ans;
    rep(i,N){
        vector<ll> dist(N,-1),prev(N,-1);
        queue<ll> que;
        que.push(i);
        dist[i]=0;
        while(!que.empty()){
            ll v=que.front();
            que.pop();
            for (auto nv:G[v]){
                if (dist[nv]==-1){
                    dist[nv]=dist[v]+1;
                    prev[nv]=v;
                    que.push(nv);
                }
            }
        }
        rep(j,N){
            if (j==i||dist[j]==-1){
                continue;
            }
            for (auto nv:G[j]){
                if (nv==i){
                    vector<ll> res;
                    res.push_back(i);
                    ll now=j;
                    while(now!=i){
                        res.push_back(now);
                        now=prev[now];
                    }
                    if (chmin(len,(ll)res.size())){
                        ans=res;
                    }
                }
            }
        }
    }
    if (len==INF){
        cout << -1 << endl;
    }
    else {
        cout << len << endl;
        for (auto x:ans){
            cout << x+1 << endl;
        }
    }
}

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

using namespace std;

struct point {
    int left, right, block, id;
};

bool cmp(const point &lhs, const point &rhs) {
    if (lhs.block < rhs.block)
        return true;
    else if (lhs.block > rhs.block)
        return false;
    else
        return lhs.right < rhs.right;
}

int main(){
    int n, q;
    scanf("%d", &n);scanf("%d", &q);
    vector<int> A(n);
    for (int i = 0; i < n; i++)
        scanf("%d", &A[i]);

    int block_size = sqrt(n);

    
    vector<point> query(q);
    for (int i = 0; i < q; i++) {
        scanf("%d %d", &query[i].left, &query[i].right);
        query[i].left--, query[i].right--;
        query[i].block = query[i].left / block_size;
        query[i].id = i;
    }

    sort(query.begin(), query.end(), cmp);

    vector<int> solution(q);
    vector<int> hash(1000100);

    int left = 0, right = 0, answer = 1;
    hash[A[0]] = 1;

    for (const point &task : query) {
        while (left < task.left) {
            hash[A[left]]--;
            answer -= (hash[A[left]] == 0);
            left++;
        }
        while (left > task.left) {
            left--;
            hash[A[left]]++;
            answer += (hash[A[left]] == 1);
        }
        while (right < task.right) {
            right++;
            hash[A[right]]++;
            answer += (hash[A[right]] == 1);
        }
        while (right > task.right) {
            hash[A[right]]--;
            answer -= (hash[A[right]] == 0);
            right--;
        }
        solution[task.id] = answer;
    }

    for (int answer : solution)
        printf("%d\n", answer);

    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int K, T; cin >> K >> T;
  int sum = 0;
  int a[T]; rep(i,T) { cin >> a[i]; sum += a[i]; }
  int ma = 0; rep(i,T) ma = max(ma, a[i]);
  int left = sum - ma;
  int result = max(0, ma-1-left);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
namespace global
  open System
  open System.Collections
  open System.Collections.Generic

  [<AutoOpen>]
  module Operators =
    let read f = Console.ReadLine().Split([|' '|]) |> Array.map f

  module Program =
    [<EntryPoint>]
    let main _ =
      match (read int, read int) with
      | [|N|], A ->
        let A = A |> Array.sort |> Array.rev
        let alice = Array.sumBy snd (A |> Array.indexed |> Array.filter (fun (i, _) -> i % 2 = 0))
        let bob = Array.sumBy snd (A |> Array.indexed |> Array.filter (fun (i, _) -> i % 2 = 1))
        printfn "%d" (alice - bob)
      | _ -> ()
      0


Measured memory_bytes: 14936
N=int(input())
S1=0
for n in range(1,N+1):
  S1+=n
S2=0
for n in range(0,N+1,3):
  S2+=n
S3=0
for n in range(0,N+1,5):
  S3+=n
S4=0
for n in range(0,N+1,15):
  S4+=n
  
print(S1-S2-S3+S4)

Measured memory_bytes: 9200
n = int(input())
a = list(map(int, input().split()))
sum_a = a[0]
res = 0
mod = 10 ** 9 + 7

for i in range(1, n):
    res = (res + ((sum_a % mod) * (a[i] % mod)) % mod) % mod
    sum_a = (sum_a + a[i]) % mod

print(res % mod)


Measured memory_bytes: 31756
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <iostream> 
#include <iomanip>  
#include <string>
#include <sstream>  
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <cstring>
#include <cmath>
#include <cassert>


#define INF              (int)1000000007
#define EPS              1e-9
#define pb               push_back
#define mp               make_pair
#define all(c)           c.begin(), c.end()
#define forall(i,a,b)    for(int i=a;i<(b);++i)
#define trav(a,x)        for(auto & a: x)
#define in(a,b)          ((b).find(a) != (b).end())
#define sz(c)            (int)(c).size()
#define input(a)         for(auto & x : a) cin >> x;

using namespace std;

typedef vector<int>      vi;
typedef pair<int,int>    ii;
typedef vector<vi>       vvi;
typedef vector<ii>       vii;
typedef long long        ll;

#ifdef DEBUG
#define trace(...)       __f(#__VA_ARGS__, __VA_ARGS__)
#define debug(args...)   {dbg,args; clog<<endl;}
#define print_( a )      for( auto & x : a ) clog << x << ' '; clog << '\n';
#define printPair_( a )  for( auto & x : a ) clog << '(' << x.first << ',' << x.second << ')' << ' '; clog << '\n';
#else
#define trace(...)       
#define debug(args...)            
#define print_( a )               
#define printPair_( a )           
#endif

struct debugger {
  template<typename T> debugger& operator , (const T& x) {    
    clog << x << " ";    return *this;    
  }
}dbg;

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " | ";
    __f(comma + 1, args...);
}

auto ____ =[]() { std::ios::sync_with_stdio(0); cin.tie(0); return nullptr; }();

int main( int argc, char * argv[] ){
  int n, m; cin >> n >> m; 
  vi v(n); input(v);
  priority_queue<int> pq;
  for(auto x : v) pq.push(x);
  while( !pq.empty() and m > 0){
    int x = pq.top(); pq.pop();
    if( pq.empty() ){
      while( m > 0 and x > 0 ){ 
        --m;
        x /= 2;
      }
    }else{
      while( m > 0 and x >= pq.top() ){
        --m;
        x /= 2;
      }
    }
    if( x > 0 ) pq.push(x);
  }
  ll ans = 0;
  while( !pq.empty() ){
    ans += pq.top();
    pq.pop();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;

vector<int> edge[212345];
bool reached[212345];
int main(){
  int goal,m;
  cin>>goal>>m;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    edge[a].push_back(b);
    if(a==1){
      reached[b]=true;
    }
  }

  rep(i,212345){
    if(reached[i]){
      for(int k=0;k<edge[i].size();k++){
        if (edge[i][k]==goal){
          cout<<"POSSIBLE"<<endl;
          return 0;
        }
      }
    }
  }

  cout<<"IMPOSSIBLE"<<endl;


}


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

int main(){
	int a,b,c,x,y,ans=0;
	cin>>a>>b>>c>>x>>y;
	if(a>=c*2){
		while(x>0){
			ans+=c*2;
			x--,y--;
		}
	}
	if(b>=c*2){
		while(y>0){
			ans+=c*2;
			x--,y--;
		}
	}
	if(a+b>=c*2){
		while(x>0 and y>0){
			ans+=c*2;
			x--,y--;
		}
	}
	while(x>0)ans+=a,x--;
	while(y>0)ans+=b,y--;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);
	if(a<b){
		printf("a < b\n");
	}
	if(a>b){
		printf("a > b\n");
	}
	if(a==b){
		printf("a == b\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <cstring>
//#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define de(x,y) cout<<#x<<" :"<<x<<y;
#define int long long
#define SZ(xx) ((int)xx.size())
#define lowbit(xx) (xx&(-xx))
#define pb push_back
typedef pair<int,int> pii;

const int maxn = 3e2+5;

double dp[maxn][maxn][maxn] = {};
double tmp[maxn * 3][maxn] = {};


main() {
	IOS
	int n;
	cin >> n;
	int sum = 0, cnt[5] = {};
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		sum += x;
		cnt[x]++;
	}
	dp[cnt[3]][cnt[2]][cnt[1]] = 1;
	for (int i = cnt[3]; i >= 0; i--) {
		for (int j = cnt[3] + cnt[2]; j >= 0; j--) {
			for (int k = cnt[1] + cnt[2] + cnt[3]; k >= 0; k--) {
				if (dp[i][j][k]) {
					tmp[i * 3 + j * 2 + k][n - i - j - k] += dp[i][j][k];
					if (i >= 1)
					dp[i-1][j+1][k] = dp[i-1][j+1][k] + dp[i][j][k] * i / (i + j + k);
					if (j >= 1)
					dp[i][j-1][k+1] = dp[i][j-1][k+1] + dp[i][j][k] * j / (i + j + k);
					if (k >= 1)
					dp[i][j][k-1] += (dp[i][j][k] * k) / (i + j + k); 
//					cout << i << " " << j << " " << k << " " << dp[i][j][k] << "\n"; 
				}
			}
		}
	} 
	double ans = 0;
	for (int i = sum; i >= 1; i--) {
		double All = 0;
		for (int j = 0; j < n; j++) {
			All += tmp[i][j];
//			cout << tmp[i][j] << " \n"[j==n-1];
		}
		if (!All) continue;
		for (int j = 0; j < n; j++) {
			ans = ans + ((double)tmp[i][j] / All) * (double)n / ((double)n - (double)j);
		}
	
	}
//	cout << ans << "\n";
	printf("%.9f\n", ans);
}


Measured memory_bytes: 114620
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include "bits/stdc++.h"

using namespace std;

#define int long long

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	int sumA = 0, sumB = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		sumA += a[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> b[i];
		sumB += b[i];
	}
	int cnt = sumB - sumA, tmpA = 0, tmpB = 0;
	if (cnt < 0)
		return cout << "No" << endl, 0;
	for (int i = 0; i < n; ++i) {
		if (a[i] < b[i]) {
			tmpA += (b[i] - a[i] + 1) / 2;
			a[i] += 2 * ((b[i] - a[i] + 1) / 2);
		}
	}
	for (int i = 0; i < n; ++i)
		if (b[i] < a[i]) {
			tmpB += a[i] - b[i];
			b[i] = a[i];
		}
	if (tmpA <= cnt and tmpB <= cnt and (cnt - tmpB) == (cnt - tmpA) * 2)
		cout << "Yes\n";
	else
		cout << "No\n";
}


Measured memory_bytes: 384
#include<stdio.h>
int main()
{
int a,b;
scanf("%d%d",&a,&b);
if(a==1&&b==2||a==2&&b==1)printf("3\n");
 else if(a==1&&b==3||a==3&&b==1)printf("2\n");
else if(a==2&&b==3||a==3&&b==2)printf("1\n");
}


Measured memory_bytes: 2032
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		
		int[] parent = new int[n];
		Arrays.fill(parent, -1);
		
		int[] depth = new int[n];
		Arrays.fill(depth, Integer.MAX_VALUE);
		
		ArrayList<LinkedList<Integer>> leafs = new ArrayList<LinkedList<Integer>>();
		for(int i = 0; i < n; i++){
			leafs.add(new LinkedList<Integer>());
		}
		
		LinkedList<Integer> p_queue = new LinkedList<Integer>();
		LinkedList<Integer> d_queue = new LinkedList<Integer>();
		
		for(int i = 0; i < n; i++){
			final int id = sc.nextInt();
			final int k = sc.nextInt();
			for(int j = 0; j < k; j++){
				final int c = sc.nextInt();
				
				parent[c] = id;
				leafs.get(id).add(c);
			}
		}
		
		for(int i = 0; i < n; i++){
			if(parent[i] == -1){
				p_queue.add(i);
				d_queue.add(0);
			}
		}
		
		while(!p_queue.isEmpty()){
			final int node = p_queue.poll();
			final int dep = d_queue.poll();
			
			if(depth[node] <= dep){
				continue;
			}else{
				depth[node] = dep;
			}
			
			for(int next : leafs.get(node)){
				if(depth[next] <= dep + 1){
					continue;
				}
				
				p_queue.add(next);
				d_queue.add(dep + 1);
			}
		}
		
		for(int i = 0; i < n; i++){
			System.out.printf("node %d: parent = %d, depth = %d, %s, %s\n", i, parent[i], depth[i], parent[i] == - 1 ? "root" : leafs.get(i).isEmpty() ? "leaf" : "internal node", leafs.get(i));
		}
		
	}

	public static class Scanner {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public void close() throws IOException {
			br.close();
		}
	}

}

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

int main() {
  vector<vector<int>>c(3,vector<int>(3));
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> c[i][j];
    }
  }
  for(int i=0; i<=100; i++){
    int a1=i;
    int b1=c[0][0]-i;
    int b2=c[0][1]-i;
    int b3=c[0][2]-i;
    int a2=c[1][0]-b1;
    int a3=c[2][0]-b1;
    if(a2+b1==c[1][0] && a2+b2==c[1][1] && a2+b3==c[1][2] && a3+b1==c[2][0] && a3+b2==c[2][1] && a3+b3==c[2][2]){
      cout << "Yes" << endl;
      return 0;
    }
    if(i==100){
      cout << "No" << endl;
    }
  }
        
        
  
     
  
}


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

int main(){
  int D;
  cin >> D;
  
  if( D == 25 )
    cout << "Christmas" << endl;
  else if ( D == 24 )
    cout << "Christmas Eve" << endl;
  else if ( D == 23 )
    cout << "Christmas Eve Eve" << endl;
  else
    cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
//#define INF 1<<31-1
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
//typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;
int INF=INT_MAX;

struct Seg{
    private:
        int n=1;
        vector<int> node;
      
    public:
        Seg(vector<int> v){
            while(n<v.size()) n*=2;
            node.resize(2*n-1,INF);
            
            rep(i,0,v.size())node[i+n-1]=v[i];
            for(int i=n-2;i>-1;i--)node[i]=min(node[2*i+1],node[2*i+2]);
        }
        
        void update(int x,int val){
            x+=n-1;
            
            node[x]=val;
            while(x>0){
                x=(x-1)/2;
                node[x]=min(node[2*x+1],node[2*x+2]);
            }
        }
        
        int getmin(int a,int b,int k=0,int l=0,int r=-1){
            if(r<0)r=n;
            if(r<=a || b<=l)return INF;
            if(a<=l && r<=b) return node[k];
            
            int vl=getmin(a,b,2*k+1,l,(l+r)/2);
            int vr=getmin(a,b,2*k+2,(l+r)/2,r);
            return min(vl,vr);
        }
};

int main(){
    int n,q;
    cin>>n>>q;
    vector<int> v(n,INF);
    Seg seg(v);
    rep(i,0,q){
        int com,x,y;
        cin>>com>>x>>y;
        if(com){
            cout<<seg.getmin(x,y+1)<<endl;
        }else {
            seg.update(x,y);
        }
    }
    
    return 0;
}



Measured memory_bytes: 4708
#include <bits/stdc++.h>
//#define int long long

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

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = (int)1e9 + 7;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> x(n), y(n);
    vector<char> c(n);
    REP(i, n) cin >> x[i] >> y[i] >> c[i];

    vector<vector<int>> ruiseki(2*k+1, vector<int>(2*k+1, 0));

    REP(i, n){
        if(c[i] == 'B'){
            ruiseki[x[i]%(2*k) + 1][y[i]%(2*k) + 1]++;
        }else{
            ruiseki[(x[i] + k)%(2*k) + 1][y[i]%(2*k) + 1]++;
        }
    }

    REP(i, 2*k) REP(j, 2*k+1){
        ruiseki[i+1][j] += ruiseki[i][j];
    }
    REP(i, 2*k+1) REP(j, 2*k){
        ruiseki[i][j+1] += ruiseki[i][j];
    }

    int ans = 0;
    REP(i, k) REP(j, k){
            int num = ruiseki[2*k][2*k] - ruiseki[2*k][j+k] - ruiseki[i+k][2*k] + ruiseki[i+k][j+k]
                    + ruiseki[2*k][j]   - ruiseki[i+k][j]
                    + ruiseki[i][2*k]   - ruiseki[i][j+k]
                    + ruiseki[i+k][j+k] - ruiseki[i+k][j] - ruiseki[i][j+k] + ruiseki[i][j]
                    + ruiseki[i][j];
            ans = max({ans, num, n - num});
    }
    cout << ans << endl;

}

Measured memory_bytes: 16896
# include <bits/stdc++.h>
using namespace std;
int n, a, b, c, d;
int main(){
    int a;
    int b,k;
    cin>>a;
    int A[a+5];
    int B[a+5];
    for(int i=0;i<a;i++){
        cin>>b;
        A[i]=b;
        B[i]=b;
    }
    int x,y;
    cin>>k;
    for(int i=0;i<k;i++){
        for(int j=0;j<a;j++){
            A[j]=B[j];
        }
        cin>>y>>x;
        A[y-1]=x;
        int sum=0;
        for(int l=0;l<a;l++){
            sum+=A[l];
        }
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 384
h = int(input())

# ans = 0
# mm = 1
# while(1):
#     ans += mm
#     if h == 1:
#         break
#     else:
#         h = ((h-1)//2)+1
#         mm *= 2

# print(ans)


mm = 1
ans = 0
for i in range(100):
    ans += mm
    mm *= 2

    if ans >= h:
        print(ans)
        break

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }
 
 
 
int main(int argc, char const *argv[]) {
  int r;
  cin >> r;
  cout << 3*r*r << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

string t[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};

int main(){
  string s;
  cin >> s;
  rep(i,7){
    if(s==t[i]){
      cout << 7-i << endl;
      return 0;
    }
  }
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>

using namespace std;

struct edge {
    int to;
    int cost;
};

typedef vector<vector<edge>> graph;

bool ret = true;
vector<bool> visited;
vector<int> dis;

void dfs(graph &g, int nowv, int nowd) {
    visited[nowv] = true;
    dis[nowv] = nowd;
    for (auto next:g[nowv]) {
        int nextd = nowd + next.cost;
        if (!visited[next.to])dfs(g, next.to, nextd);
        else if (dis[next.to] != nextd)ret = false;
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    graph g(n);
    for (int i = 0; i < m; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        r--;
        g[l].push_back({r, d});
        g[r].push_back({l, -d});
    }

    visited = vector<bool>(n);
    dis = vector<int>(n);
    for (int i = 0; i < n; i++) {
        if (!visited[i]) dfs(g, i, 0);
    }

    cout << (ret ? "Yes" : "No") << endl;
    return 0;
}

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

using namespace std;

#define int long long

bool check(int a, int b) {
    while (b % a == 0) b /= a;
    return (b % a) == 1;
}

void solve() {
    int n;
    cin >> n;
    int ans = 1;
    for (int i = 1; i * i <= n - 1; ++i) {
        if ((n - 1) % i) continue;
        if (i != 1) ++ans;
        if ((n - 1) / i != i) ++ans;
    }
    for (int i = 2; i * i <= n; ++i) {
        if (n % i) continue;
        if (check(i, n)) ++ans;
        if (i != n / i && check(n / i, n)) ++ans;
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding("utf8");

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

const lines = [];

reader.on("line", (line) => {
  lines.push(line);
});

reader.on("close", () => {
  const [w, h] = parseLine(lines[0]);
  console.log("%d %d", w * h, 2 * w + 2 * h);
});

function parseLine(s) {
  return s.split(" ").map((s) => Number(s));
}



Measured memory_bytes: 16252
#include<stdio.h>
int main(){
    int x,y,i,gcd;
    scanf("%d %d",&x,&y);
    if(x < y){
        i = x;
        x = y;
        y = i;
    }
    gcd = x % y;
    while(gcd != 0){
        x = y;
        y = gcd;
        gcd = x % y;
    }
    printf("%d\n",y);
    return 0;
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> vec(n+1,0);
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        vec[a] += 1;
        vec[b] += 1;
    }
    for(int i=1;i<=n;i++){
        cout << vec[i] << endl;
    } 
    
}

Measured memory_bytes: 256
x, n = map(int, input().split())

if n == 0:
    print(x)
    exit()

arr = list(map(int, input().split())) # p1 ... pn

arr2 = []
arr3 = []

for i in range(-50, 110):
    if not i in arr:
        arr2.append(i)
        arr3.append(abs(x - i))

n2 = min([i for i, v in enumerate(arr3) if v == min(arr3)])
print(arr2[n2])

Measured memory_bytes: 9208
import bisect, collections, copy, heapq, itertools, math, string
from functools import reduce
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = I()
ans = 0
for i in range(1, K + 1):
    for j in range(1, K + 1):
        for k in range(1, K + 1):
            ans += gcd(i, j, k)
print(ans)

Measured memory_bytes: 75836
/// Kazuki Hoshino


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
//#define endl '\n'
typedef tree<
int,
null_type,less<int>,
rb_tree_tag,tree_order_statistics_node_update>
ordered_set;
int n,a[100005],b[100005],ans=0,req=0,s1,s2;
priority_queue<int> q;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);

#ifndef ONLINE_JUDGE
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#endif

cin >> n;
for(int i=1;i<=n;i++){
       cin >> a[i];
       s1+=a[i];
}
for(int i=1;i<=n;i++){
       cin >> b[i];
       s2+=b[i];
       if(b[i]>a[i]){req+=b[i]-a[i];ans++;}
       else if(a[i]>b[i]){
              q.push(a[i]-b[i]);
       }
}
if(s1<s2){
       cout << -1 << endl;
       return 0;
}
while(req>0){
       int k = q.top();q.pop();
       req-=k;
       ans++;
}
cout << ans << endl;



return 0;}
///....


Measured memory_bytes: 2424
#include<iostream>
using namespace std;
typedef long long ll;

ll C[101][101];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) cin >> C[i][j];
    }
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            ans += min(C[i][j], C[j][i]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3256
N = int(input())
A = list(map(int, input().split()))

mx_a = max(A)
cand = [0] * (mx_a + 1)

for i in range(N):
    j = 1
    while True:
        if A[i] * j > mx_a:
            break
        cand[A[i] * j] += 1
        j += 1

ans = 0
for a in A:
    if cand[a] == 1:
        ans += 1
print(ans)


Measured memory_bytes: 32380
class Array
  def sum; inject(:+) end # v2.5
end
def min(a,b); a < b ? a : b end

h,w,k = gets.to_s.split.map(&:to_i)
a = Array.new(h){ gets.to_s.chomp.bytes }

ans = (h-1) * (w-1)
(2**(h-1)).times do |bit|
  # p bit.join.to_i
  div  = [0] * h
  t    = 0
  able = true
  
  (0...h-1).each do |i|
    t += 1 if bit[i] == 1
    div[i+1] = t
  end
  
  wc = [0] * (t+1)
  cut = bit.to_s(2).count('1')
  
  w.times do |j|
    over = false
    h.times do |i|
      wc[div[i]] += 1 if a[i][j] == 49
      if wc[div[i]] > k
        over = true
        break
      end
    end
    if over
      (t+1).times{|k| wc[k] = 0 }
      cut += 1
      h.times do |i|
        wc[div[i]] += 1 if a[i][j] == 49
        if wc[div[i]] > k
          able = false
          break
        end
      end
    end
    
    break if not able
  end
  
  ans = min(ans, cut) if able
end

p ans

Measured memory_bytes: 2044
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set; 

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     sd                  " "
#define     nl                  "\n"
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IOS()               ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     siz(a)              sizeof(a)/sizeof(a[0])
#define     out(a)              for (auto i: a) cout<<i<<" "; cout<<"\n"
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     itos(a)             to_string(a)
#define     ctoi(a)             int(a)-48
#define     setd(val,n)         cout<<fixed;cout<<setprecision(n)<<val<<"\n"

ll mod(ll a){return ((a%MOD)+MOD)%MOD;}

ll fpow(ll base, ll expo) {
    ll res=1;
    while(expo>0) {
        if(expo&1) res=(res*base)%MOD;
        base=(base*base)%MOD;
        expo>>=1;}
    return res;}

ll modinv(ll a){return mod(fpow(mod(a), MOD-2));}

void solve(){
    int n;cin>>n;
    int a[n];
    for(int i = 0 ; i < n - 1; ++i) cin >> a[i];
    a[n-1]=a[n-2];
    int sum=a[0];
    for(int i = 1 ; i < n - 1; ++i) sum+=min(a[i-1],a[i]);
    cout<<sum+a[n-1]<<nl;
}

signed main() { 
    IOS();

    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  string S, T;
  cin >> S >> T;

  if(S == T){
    cout << "Yes" << endl;
    return 0;
  }

  ll n = S.size();

  rep2(i, 1, n){
    if((S.substr(0, i) == T.substr(n - i, i)) && (S.substr(i, n - i) == T.substr(0, n - i))){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
while True:
    n=input()
    if n==0:break
    L=[input() for i in range(n)]
    v=input()
    l,r=0,len(L)-1
    cnt=0
    while l<=r:
        m=(l+r)/2
        if L[m]==v:
            print cnt+1
            break
        elif L[m]<v:
            l=m+1
        elif L[m]>v:
            r=m-1
        cnt+=1
    else:
        print cnt

Measured memory_bytes: 4244
#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
	int n;
	cin >> n;
	vector<string> v;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		v.push_back(s);
	}
	sort(v.begin(), v.end());
	int cnt = 1;
	int ans = 0;
	for (int i = 1; i < n; ++i) {
		if (v[i - 1] == v[i])++cnt;
		else {
			if (cnt > 1) {
				ans += cnt * (cnt - 1) / 2;
				cnt = 1;
			}
		}
	}
	if (cnt > 1) {
		ans += cnt * (cnt - 1) / 2;
		cnt = 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 5748
num = int(input())
d = {'taro': 0,'hana': 0}
point = [0,0]
for i in range(num):
  d['taro'],d['hana'] = input().split()
  result = sorted(d.items(),key=lambda x: x[1],reverse=True)
  if result[0][1] == result[1][1]:
    point[0] += 1
    point[1] += 1
  elif result[0][0] == 'taro':
    point[0] += 3
  elif result[0][0] == 'hana':
    point[1] += 3
print(' '.join(map(str,point)))


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

int main() {
  string a;
  cin>>a;
  if(a=="++++")cout<<4<<endl;
  else if(a=="+++-"||a=="++-+"||a=="+-++"||a=="-+++")cout<<2<<endl;
  else if(a=="++--"||a=="+--+"||a=="--++"||a=="+-+-"||a=="-++-"||a=="-+-+"){
    cout<<0<<endl;
  }
  else if(a=="---+"||a=="--+-"||a=="-+--"||a=="+---")cout<<-2<<endl;
  else cout<<-4<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  int ab[26]={};
  int i;
  while(getline(cin,str)){
    for(i=0;i<str.size();i++){
      if(str[i]>='a'&&str[i]<='z') ab[str[i]-'a']++;
      else if(str[i]>='A'&&str[i]<='Z') ab[str[i]-'A']++;
    }
  }
  for(i=0;i<26;i++){
    cout << (char)('a'+i) << " : " << ab[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3172
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
  
using namespace std;

#define pi 3.141592653589793

void solve(int n, int m, int q, string s[], string b[], int ans[])
{
	int cnt[1001][36] = {};
	for(int i = 1; i < q + 1; i++){
		for(int j = 0; j < m; j++){
			if(b[i - 1][j] != b[i][j]){
				for(int k = 0; k < n; k++){
					cnt[j][k] += s[i][k] - '0';
				}
			}else{
				for(int k = 0; k < n; k++){
					cnt[j][k] -= s[i][k] - '0';
				}
			}
		}
	}
	for(int i = 0; i < m; i++){
		int maxi = -1, ansi = -1;
		for(int j = 0; j < n; j++){
			if(cnt[i][j] > maxi){
				maxi = cnt[i][j];
				ansi = j;
			}else if(cnt[i][j] == maxi){
				ansi = -1;
			}
		}
		ans[i] = ansi;
	}
	return;
	// 一つ前のbと比べて変化しているところを探す。
	// i - 1番目のbとiばんめのbを比べる。それぞれのbのj番目が異なる場合、その時(iのとき)その電気のスイッチが押されている
	// cntにs[i][j]を加える。
	// 最終的に最大値を取るものが答えになる…はず？
}

int main()
{
	int n, m, q;
	while(1){
		cin >> n >> m >> q;
		if(n == 0 && m == 0 && q == 0) break;
		string s[1001] = {}, b[1001] = {};
		for(int i = 0; i < m; i++){
			b[0] += '0';
		}
		for(int i = 1; i < q + 1; i++){
			cin >> s[i] >> b[i];
		}
		int ans[1001];
		solve(n, m, q, s, b, ans);
		char answer;
		for(int i = 0; i < m; i++){
			if(ans[i] == -1) answer = '?';
			else if(ans[i] < 10) answer = ans[i] + '0';
			else answer = 'A' + ans[i] - 10;
			cout << answer;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 2524
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class B {
	int n, k;
public:
	B()
	{
		cin >> n >> k;
	}
	void solve()
	{
		int ans{ 1 };
		REP(i, n)
		{
			if ((ans << 1) < ans + k)
				ans <<= 1;
			else
				ans += k;

		}
		cout << ans << endl;

	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
/*input
7 26
10
20
30
40
30
20
10

1 2
1

3 6
7
5
7
*/
#include <bits/stdc++.h>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define int long long
#define N 200015
#define bit(x,y) ((x>>y)&1LL)
#define loop(x) for(int xv=1; xv<=x; xv++)

#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &a) {
	return os << '(' << a.first << ", " << a.second << ')';
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &a) {
	os << '[';
	for (unsigned int i = 0; i < a.size(); i++)
		os << a[i] << (i < a.size() - 1 ? ", " : "");
	os << ']';
	return os;
}
template <class T>
ostream &operator<<(ostream &os, const set<T> &a) {
	os << '{';
	for (typename set<T>::iterator it = a.begin(); it != a.end(); it++) {
		typename set<T>::iterator jt = it;
		os << *it << (++jt != a.end() ? ", " : "");
	}
	os << '}';
	return os;
}
template <class T1, class T2>
ostream &operator<<(ostream &os, map<T1, T2> &a) {
	os << "{\n";
	for (typename map<T1, T2>::iterator it = a.begin(); it != a.end(); it++) {
		typename map<T1, T2>::iterator jt = it;
		os << "  " << it->first << ": " << it->second << (++jt != a.end() ? ",\n" : "\n");
	}
	os << '}';
	return os;
}

int n, K;
int sum[N];
vector<int> com;

int tree[N];

void update(int i, int val) {
	i += 5;
	for (; i < N; i += i & -i) {
		tree[i] += val;
	}
}

int get(int i) {
	i += 5;
	int ret = 0;
	for (; i; i -= i & -i) {
		ret += tree[i];
	}
	return ret;
}

int trueVal(int x) {
	int ret = lower_bound(com.begin(), com.end(), x) - com.begin();
	return ret;
}

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> K;
	for (int i = 1; i <= n; i++) {
		int x; cin >> x;
		sum[i] = sum[i - 1] + x - K;
		com.push_back(sum[i]);
	}
	com.push_back(0);
	sort(com.begin(), com.end()); com.resize(distance(com.begin(), unique(com.begin(), com.end())));
	update(trueVal(0), 1);
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int x = trueVal(sum[i]);
		ans += get(x);
		update(x, 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 5104
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int main()
{
  long long int n,m,total = 0;
  cin >> n >> m;
  
  vector<long long int> a(m);
  for(int i = 0; i < m; i++)
  {
    cin >> a[i];
    total += a[i];
  }
  
  if(n >= total)
  {
    cout << n - total;
  }
  else
  {
    cout << -1;
  }
  
  
}


Measured memory_bytes: 3672
#include <iostream>
using namespace std;
#define ll long long

int main () {
  ll n;
  cin >> n;
  ll a[n];
  for (ll i = 0; i < n; i++) cin >> a[i];
  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    if (a[i] % 2 == 1 && (i + 1) < n) {
      if (a[i + 1] > 0) {
        a[i + 1]--;
        a[i]--;
        ans++;  
      }
    }
    ans += a[i] / 2;
    a[i] = 0;
  }  
  cout << ans << endl;
}

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

using namespace std;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int m = max(max(A, B), C);
  int cnt = 0;
  while (m - A > 1) {
    cnt++;
    A += 2;
  }
  while (m - B > 1) {
    cnt++;
    B += 2;
  }
  while (m - C > 1) {
    cnt++;
    C += 2;
  }
  int d = m * 3 - A - B - C;
  if (d == 2) {
    cnt++;
  } else if (d == 1) {
    cnt += 2;
  }
  cout << cnt << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256
/*
 * rei.cpp
 *
 *  Created on: 2018/05/07
 *      Author: J01003
 */

#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int n,max,min,timer,a;
    long long sum=0;
    cin>>n;
    timer=0;
    max=-100000000;
    min=100000000;
    while (1){
    	cin>>a;
    	if(a>max){
    		max=a;
    	}
    	if(a<min){
    		min=a;
    	}
    	sum=a+sum;
    	timer++;
    	if(timer==n){
    		break;
    	}
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;
	return 0;
}




Measured memory_bytes: 3092
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN = 100000;
const int MAXSZ = 1000;
const int MAXDIM = 2 * MAXSZ;

int n, sz, dim;
int x[MAXN], y[MAXN]; char c[MAXN];

int cnt[MAXDIM][MAXDIM];
int sum[MAXDIM + 1][MAXDIM + 1];

int calc(int lx, int ly, int hx, int hy) {
	if (lx >= dim) lx -= dim, hx -= dim;
	if (ly >= dim) ly -= dim, hy -= dim;
	if (hx > dim) return calc(lx, ly, dim, hy) + calc(0, ly, hx - dim, hy);
	if (hy > dim) return calc(lx, ly, hx, dim) + calc(lx, 0, hx, hy - dim);
	//printf("(%d,%d)-(%d,%d)=%d\n", lx, ly, hx, hy, sum[hx][hy] - sum[hx][ly] - sum[lx][hy] + sum[lx][ly]);
	return sum[hx][hy] - sum[hx][ly] - sum[lx][hy] + sum[lx][ly];
}
void run() {
	scanf("%d%d", &n, &sz); dim = 2 * sz;
	REP(i, n) scanf("%d%d %c", &x[i], &y[i], &c[i]);
	REP(i, n) if (c[i] == 'W') x[i] += sz;
	REP(i, n) x[i] %= dim, y[i] %= dim;
	//REP(i, n) printf("(%d,%d)", x[i], y[i]); puts("");
	REP(i, dim) REP(j, dim) cnt[i][j] = 0; REP(i, n) ++cnt[x[i]][y[i]];
	REPE(i, dim) REPE(j, dim) sum[i][j] = i != 0 && j != 0 ? cnt[i - 1][j - 1] : 0;
	REPE(i, dim) FORE(j, 1, dim) sum[i][j] += sum[i][j - 1];
	FORE(i, 1, dim) REPE(j, dim) sum[i][j] += sum[i - 1][j];
	//REPE(i, dim) { REP(j, dim) printf(" %d", sum[i][j]); puts(""); }
	int ret = 0;
	REP(i, dim) REP(j, dim) {
		int cur = calc(i, j, i + sz, j + sz) + calc(i + sz, j + sz, i + 2 * sz, j + 2 * sz);
		if (cur > ret) ret = cur;
		//printf("(%d,%d)=%d\n", i, j, cur);
	}
	printf("%d\n", ret);
}

int main() {
	run();
	return 0;
}


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

int main(){
  int K, num, ans = 1;
  cin >> K;
  
  num = 7;
  while (ans <= K){
    if (num % K == 0){
      break;
    }
    
    num *= 10;
    num += 7;
    num %= K;
    ans++;
  }
  
  if (ans > K){
    cout << "-1" << endl;
  }else{
  	cout << ans << endl;
  }
}

Measured memory_bytes: 3632
#include<cstdio>
long long a[4] = {1};
char c;
int main(){
	while(EOF != scanf("%c", &c)) for(int j = 3; j >= 0; j--)
		a[j] = (a[j]*(c-'?'?1:3) + (j&&!(c-'?'&&c-'A'-j+1)?a[j-1]:0))%1000000007;
	printf("%lld\n", a[3]);
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	int a,b;
	cin >> a >> b;
	cout << (a+b>23 ? a+b-24 : a+b) << endl;

	
//////////////////////////////////////////////
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,n)             for(ll i=1;i<=n;i++)
#define LOOP(i,n)            for(ll i=0;i<n;i++)
#define loop(a,b)            for(ll i=a;i<=b;i++)
#define sci(n)               scanf("%d",&n)
#define scl(n)               scanf("%lld",&n)
#define scl3(a,b,c)          scanf("%lld%lld%lld",&a,&b,&c);
#define scl2(a,b)            scanf("%lld%lld",&a,&b)
#define scd(n)               scanf("%lf",&n)
#define srt(g)               sort(g.begin(),g.end())
#define rvs(g)               reverse(g.begin(),g.end())
#define pl                   pair<long long,long long>
#define pll                  pair<long long,pair<long long,long long>>
#define ll long long
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define f first
#define s second
int main()
{
    ll l,r,d;
    scl3(l,r,d);
    ll ans=(r-l);
    ans=ans/d;
    if(r%d==0)ans++;
    cout << ans << "\n";
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,d,i,j,count=0;
    cin>>m>>d;
    if(d<=21)
        cout<<"0";
    else{
            //cout<<"sdfg";
    for(i=1;i<=m;i++)
    {
        for(j=22;j<=d;j++)
        {
            int one,tens;
            one=j%10;
            tens=j/10;
            if(one>=2 && tens>=2 && (one*tens)==i)
            {
                count++;
            }
        }
    }
    cout<<count;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  if(n <= 599){
    cout << 8 << endl;
  }else if(n <= 799){
    cout << 7 << endl;
  }else if(n <= 999){
    cout << 6 << endl;
  }else if(n <= 1199){
    cout << 5 << endl;
  }else if(n <= 1399){
    cout << 4 << endl;
  }else if(n <= 1599){
    cout << 3 << endl;
  }else if(n <= 1799){
    cout << 2 << endl;
  }else {
    cout << 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3632