akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <thread>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

//セグ木
ll dat[2560000], sz;

void init(ll n) {
	sz = 1;
	while (sz < n)sz *= 2;
	REP(i, sz * 2 - 1) dat[i] = INF; //初期値
}

void update(ll k, ll a) { //場所(0-indexed), 値
	k += sz - 1;
	dat[k] = a;
	while (k > 0) {
		k = (k - 1) / 2;
		dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]); //更新
	}
}

ll query(ll a, ll b, ll k, ll l, ll r) { //[a, b) 呼ぶとき (a, b, 0, 0, sz)
	if (r <= a or b <= l)return INF;
	if (a <= l and r <= b)return dat[k];
	ll v1 = query(a, b, k * 2 + 1, l, (l + r) / 2);
	ll v2 = query(a, b, k * 2 + 2, (l + r) / 2, r);
	return min(v1, v2); //戻り値
}

ll n, m, t, now;
string s;
vector<P> l;
vector<ll> ans;
int main() {
	init(310000);
	cin >> n >> m;
	cin >> s;
	update(n, 0);
	REPR(i, n - 1) {
		if (s[i] != '1') {
			update(i, query(i + 1, i + m + 1, 0, 0, sz) + 1);
		}
	}
	if (query(0, 1, 0, 0, sz) >= INF) {
		cout << -1 << endl;
		return 0;
	}
	else t = query(0, 1, 0, 0, sz);
	REP(i, n + 1) {
		if (s[i] != '1') {
			l.push_back(P(query(i, i + 1, 0, 0, sz), i));
		}
	}
	//REP(i, l.size())cout << l[i].first << " " << l[i].second << endl;
	REP(i, l.size()) {
		if (l[i].first == 1) {
			ans.push_back(n - l[i].second);
			break;
		}
		now += l[i + 1].second - l[i].second;
		if (l[i].first != l[i + 1].first) {
			ans.push_back(now);
			now = 0;
		}
	}
	REP(i, ans.size()) {
		if (i != 0)cout << " ";
		cout << ans[i];
	}
	cout << endl;
}


Measured memory_bytes: 14192
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=j;i<=k;++i)
#define Forr(i,j,k) for (int i=j;i>=k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T& a,T b) {return a<b?a=b,1:0;}
template<typename T>bool chkmin(T& a,T b) {return a>b?a=b,1:0;}

const int maxn=100000+100;
const int inf=0x3f3f3f3f;
struct node {
	int from,to,next;
}e[maxn<<1];
struct A {
	int id,val;
	bool operator < (const A &aa) const {
		return ((val<aa.val) || (val==aa.val && id<aa.id));
	}
}a[maxn];
int n,m,tot,cnt;
ll ans;
int head[maxn],s[maxn],vis[maxn],minx[maxn];

inline void read(int &x) {
	x=0;
	int p=1;
	char c=getchar();
	while (!isdigit(c)) {if (c=='-') p=-1; c=getchar();}
	while (isdigit(c)) {x=(x<<1)+(x<<3)+(c-'0'); c=getchar();}
	x*=p;
}

inline void file() {
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
}

inline void add(int from,int to) {
	tot++;
	e[tot].from=from; e[tot].to=to; e[tot].next=head[from]; head[from]=tot;
}

void dfs(int u) {
	vis[u]=cnt; s[cnt]++;
	if (minx[cnt]==-1 || a[u].val<a[minx[cnt]].val) minx[cnt]=u;
	for (int i=head[u];i!=0;i=e[i].next) {
		int v=e[i].to;
		if (vis[v]) continue;
		dfs(v);
	}
}

int main() {
//	file();
	Set(minx,-1);
	read(n); read(m);
	For (i,0,n-1) { read(a[i].val); a[i].id=i; }
	For (i,1,m) {
		int x,y; read(x); read(y);
		add(x,y); add(y,x);
	}
	if (n==1) {
		printf("0");
		return 0;
	}
	For (i,0,n-1) if (!vis[i]) {
		cnt++;
		dfs(i);
	}
	if (n<2*cnt-2) {
		printf("Impossible");
		return 0;
	}
//	For (i,0,n-1) printf("%d ",vis[i]); cout << endl;
//	For (i,1,cnt) printf("%d ",minx[i]); cout << endl;
//	printf("%d\n",cnt);
	if (cnt==1) {
		printf("0");
		return 0;
	}
	if (cnt==2) {
		printf("%d",a[minx[1]].val+a[minx[2]].val);
		return 0;
	}
	Set(vis,0); tot=0;
	For (i,1,cnt) { vis[minx[i]]=1; ans+=(ll)a[minx[i]].val; }
	sort(a,a+n);
	For (i,0,n-1) if (!vis[a[i].id]) {
		vis[a[i].id]=1; ans+=(ll)a[i].val;
		tot++;
		if (tot==cnt-2) break;
	}
	cout << ans << endl;
//	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4608
A_lis = []
for i in range(3):
    S_lis = []
    for j in range(8):
        p,t = map(float,input().split())
        S_lis.append([int(p),t])
    S_lis = sorted(S_lis, key=lambda x: x[1])
    print(S_lis[0][0],S_lis[0][1])
    S_lis.remove(S_lis[0])
    print(S_lis[0][0],S_lis[0][1])
    S_lis.remove(S_lis[0])
    A_lis += S_lis
A_lis = sorted(A_lis, key=lambda x: x[1])
print(A_lis[0][0],A_lis[0][1])
print(A_lis[1][0],A_lis[1][1])

Measured memory_bytes: 7588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main() {
    string o,e; cin>>o>>e;
    if(o.size()>e.size()){
        rep(i,e.size()){
            cout<<o[i]<<e[i];
        }
        cout<<o[o.size()-1]<<endl;
    }else{
        rep(i,e.size()){
            cout<<o[i]<<e[i];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,cnt[100000]={};
	cin>>n;
	while(cin>>a)
		cnt[a]++;
	int ans=0;
	for(int i=1;i<99999;i++)
		ans=max(ans,cnt[i-1]+cnt[i]+cnt[i+1]);
	cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  int d = b-a;
  int tall = 0;
  for(int i=1;i<=d;i++){
    tall+=i;
  }
  printf("%d",tall-b);
  return 0;
}


Measured memory_bytes: 128
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>

using namespace std;

typedef long long ll;

#ifdef ONPC
    mt19937 rnd(228);
#else
    mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    cout << b + min(c, a + b + 1) << '\n';
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  if(A==B&&B==C){cout << "No" << endl;}
  else if(A!=B && B!=C && C!=A){cout << "No" << endl;}
  
  else{cout << "Yes" << endl;}
  
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}

int main(){
    int a,b;
    cin >>  a >>b;
    if(a>b)cout<<"a > b"<<endl;
    else if(a==b)cout<<"a == b"<<endl;
    else cout<<"a < b"<<endl;
}



Measured memory_bytes: 3092
#include<iostream>

using namespace std;

int main()
{
	int n, c[20], v[20];
	
	cin >> n;
	
	for (int x = 0; x<n ; x++) cin >> v[x];
	for (int x = 0; x<n ; x++) cin >> c[x];
	
	int answer = 0;
	
	for (int x = 0; x<n ; x++)
	{
		int delta = v[x]- c[x];
		
		if (delta > 0) answer += delta;
	}
	
	
	
	cout << answer;
	
	
}


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

int main(){
	int a,b;
	scanf("%d%d",&a,&b);

	int sum;
	sum = 0;

	sum = a - 2*b;
	if(sum <0)sum=0;

	printf("%d",sum);

	return 0;
}


Measured memory_bytes: 256
def c_anti_division(A, B, C, D):
    from fractions import gcd

    lcd = (C * D) // gcd(C, D)

    def bai(n, b):
        """1からnまでのbの倍数の個数"""
        return (n - 1 + 1) // b
    ans = ((B - A + 1)
           - ((bai(B, C) + bai(B, D) - bai(B, lcd))
              - (bai(A - 1, C) + bai(A - 1, D) - bai(A - 1, lcd))))
    return ans

A, B, C, D = [int(i) for i in input().split()]
print(c_anti_division(A, B, C, D))

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
//const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;


const int mod = 1e9 + 7;
const int maxn = 4000;

LL fac[maxn];
LL ifac[maxn];

int mult(LL a,LL b){return (a*b)%mod;}

int modpow(int n,int p){
    if(p == 0) return 1;
    LL ret_val = modpow(n,p/2);
    ret_val = (ret_val*ret_val)%mod;
    if(p & 1) ret_val = (ret_val*n)%mod;
    return (int)ret_val;
}

int inv(int n){
    return modpow(fac[n],mod-2);
}

void init(){
    fac[0] = 1;
    fac[1] = 1;
    _for(i,2,maxn){
        fac[i] = (i*fac[i-1])%mod;
    }
}

int cal(int q,int r){
    if(q-r < 0) return 0;

    if(q == 0 || r == 0 || q-r == 0) return 1;
    LL res = ((LL)fac[q]*(LL)inv(r))%mod;
    res = (res*inv(q-r))%mod;
    return (int)res;
}
int N,K;

int main()
{
    cin >> N >> K;
    int blank = (N - K + 1);
    init();

    _rep(i,1,K){
        printf("%d\n", mult(cal(K-1,i-1),cal(blank,i)));
       // cout << cal(K,i-1)<<" " << cal(blank,i) << endl;
    }


    return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
//		int t = sc.nextInt();
//		StringBuilder ans = new StringBuilder();
//		while (--t >= 0) {
		int n = sc.nextInt();
		String arr[] = { "AC", "WA", "TLE", "RE" };
		HashMap<String, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			String s = sc.next();
			map.put(s, ((map.containsKey(s)) ? map.get(s) : 0) + 1);
		}
		for (int i = 0; i < arr.length; i++) {
			System.out.println(arr[i] + " x " + ((map.containsKey(arr[i])) ? map.get(arr[i]) : 0));
		}
//		System.out.println(1000 * numOfNotes - n);
	}
}
//}


Measured memory_bytes: 58792
import sys

#+++++

def naiseki(va,vb):
	return sum([a*b for a,b in zip(va,vb)])

def main():
	n , c = map(int, input().split())
		
	ccc=[0]*c
	for i in range(c):
		ccc[i]=[0]*c
	for i in range(c):
		temp=list(map(int,input().split()))
		#ccc[i]=temp
		for j,v in enumerate(temp):
			ccc[j][i]=v
		
	pa(ccc)
		
	ddl=[0,0,0]
	for i in range(3):
		ddl[i]=[0]*c
		
	for i in range(1,n+1):
		ll=list(map(int, input().split()))
		for j, color_v in enumerate(ll,start=1):
			group=(i+j)%3
			ddl[group][color_v-1]+=1
			
	pa('_____ddl_____')
	for i in range(3):
		pa(ddl[i])
		
	rrb=[0]*3
	for i in range(3):
		rrb[i]=[0]*c	
		for j in range(c):
			rrb[i][j]=(naiseki(ddl[i], ccc[j]),j)
			
	pa('____rrb_____')
	for i in range(3):
		pa(rrb[i])
	
	c=[0]	* 3
	for i in range(3):
		rrb[i].sort()
		aa=rrb[i][:3]
		c[i]=aa
		
	pa('____ c _____')
	for i in range(3):
		pa(c[i])
		
	mm=None
	for i in range(3):
		for j in range(3):
			for k in range(3):
				ii=c[0][i][1]
				ji=c[1][j][1]
				ki=c[2][k][1]
				if ii !=ji and ji!=ki and ki!=ii:
					temp=c[0][i][0]+c[1][j][0]+c[2][k][0]
					#pa(temp)
					mm = temp if mm is None else min(mm,temp)
					
	return mm
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 43484
class cumsum2D:
    def __init__(self, data):
        self.N = len(data)
        self.M= len(data[0])
        self.cum = [[0] * (self.M + 1) for _ in range(self.N + 1)]
        for i in range(self.N):
            for j in range(self.M):
                self.cum[i + 1][j + 1] = self.cum[i][j + 1] + self.cum[i + 1][j] - self.cum[i][j] + data[i][j]

    def get(self,x1,y1,x2,y2):
        """
        長方形の領域 [x1,x2)*[y1,y2) の範囲内にインプットされた数字の和を取る
        """
        return self.cum[x2][y2] - self.cum[x1][y2] - self.cum[x2][y1] + self.cum[x1][y1]

########################################################################################################
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
B = [[0]*(2*K) for _ in range(2*K)]
W = [[0]*(2*K) for _ in range(2*K)]
for _ in range(N):
    x, y, c = input().split()
    x, y = int(x), int(y)
    if c=="B":
        B[x%(2*K)][y%(2*K)] += 1
    else:
        W[x%(2*K)][y%(2*K)] += 1
cumB, cumW = cumsum2D(B), cumsum2D(W)
res = 0
for i in range(K+1):
    for j in range(K+1):
        res = max(cumW.get(0,0,i,j) + cumW.get(i,j,i+K,j+K) + cumW.get(i+K,j+K,2*K,2*K) + cumW.get(i+K,0,2*K,j) + cumW.get(0,j+K,i,2*K) + cumB.get(i,0,i+K,j) + cumB.get(0,j,i,j+K) + cumB.get(i+K,j,2*K,j+K) + cumB.get(i,j+K,i+K,2*K), cumB.get(0,0,i,j) + cumB.get(i,j,i+K,j+K) + cumB.get(i+K,j+K,2*K,2*K) + cumB.get(i+K,0,2*K,j) + cumB.get(0,j+K,i,2*K) + cumW.get(i,0,i+K,j) + cumW.get(0,j,i,j+K) + cumW.get(i+K,j,2*K,j+K) + cumW.get(i,j+K,i+K,2*K), res)
print(res)

Measured memory_bytes: 202108
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vl;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))
#define ANS(x) cout << ((x)?"YES":"NO") << endl;

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int MAX = 1e5+10;
int N;
int A[MAX], B[MAX];

int main() {

    cin >> N;
    ll sumA = 0, sumB = 0;
    REP (i, N) {
        cin >> A[i];
        sumA += A[i];
    }
    REP (i, N) {
        cin >> B[i];
        sumB += B[i];
    }
    if (sumB > sumA) {
        cout << -1 << endl;
        return 0;
    }

    vl C(N);
    REP (i, N) {
        C[i] = A[i]-B[i];
    }
    sort(ALL(C));

    ll sumN = 0;
    int ans = 0;
    REP (i, N) {
        if (C[i] < 0) {
            sumN += C[i];
            ans ++;
        }
        else break;
    }
    REPR (i, N) {
        if (sumN >= 0) break;
        ans++;
        sumN += C[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
//https://atcoder.jp/contests/abc103/tasks/abc103_d
#include<bits/stdc++.h>
using namespace std;

#define MAX_N 100005

struct span{
	int s;
	int e;
	span() : s(0),e(0){}
	span(int a,int b) : s(a),e(b){}
	bool operator<( const span& right ) const {
        return e < right.e;
    }
};

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

	vector<span> p;
	for(int i=0;i<m;i++){
		int a,b;
		cin >> a >>b;
		a--;b--;
		p.push_back(span(a,b));
	}
	sort(p.begin(),p.end());
	int cnt=0;
	int cut_p=0;
	for(int i=0;i<m;i++){
		if(p[i].s >= cut_p){
			cnt++;
			cut_p = p[i].e;
		}
	}
	cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
using P = pair<ll,ll>; using vp = vector<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
/////////


void solve(){
  ini(N , K);
  ll ans = 0;
  // a = d * b + rem , b > rem >= K
  // bを固定
  for(int b = K + 1 ; b <= N ; b++ ){
    // remとしてあり得るのは rem = K , K+1 , ... , b-1
    // d = 0のとき a = K , ... , b - 1
    // d = 1のとき a = b + K , ... , b + (b - 1)
    // d = 2のとき a = 2b+ K m ... , 2b+ (b - 1)
    // という風になる
    // -> bまででb-K個、2bまでで2(b-k)個...

    int ld = N / b;
    ans += ld * (b - K);
    
    // K == 0のとき0が含まれてしまう
    if(K == 0) ans -= 1;

    // 残りは？
    // a が ld * b から ld * (b + 1) - 1 までなら(b - k)個
    // しかし実際は右端がNまで
    ans += max(0LL , b - K - (1LL * (ld + 1) * b - 1 - N ) );
  }

  out(ans);

}

Measured memory_bytes: 256
from itertools import accumulate
N = int(input())
A = list(map(int, input().split()))
SA = list(accumulate(A)) + [0]
dp = [[0]*(N+1) for _ in range(N+1)]
for i in range(2, N+1):
    for j in range(N-i+1):
        dp[i][j] = SA[j+i-1] - SA[j-1] + min(dp[k][j] + dp[i-k][j+k] for k in range(1, i))
print(dp[-1][0])

Measured memory_bytes: 43484
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

typedef long long i64;

int main() {
  i64 result = 0;
  int N, K;
  scanf("%d%d", &N, &K);
  if (K == 0) {
    printf("%lld\n", 1LL * N * N);
    return 0;
  }
  for (int b = K + 1; b <= N; ++b) {
    int len = b - K;
    int tot = N / b;
    result += 1LL * len * tot;
    int rem = N % b;
    if (rem != 0 && rem >= K) result += rem - K + 1;
  }

  printf("%lld\n", result);
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1000000000;

int main() {
  ll s, v = 1000000000;
  cin >> s;

  ll x = (v - s % v) % v;
  ll y = (s + x) / v;

  cout << "0 0 1000000000 1 " << x << " " << y << endl;
  return 0;
}


Measured memory_bytes: 3568
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
typedef  long long ll;
string S;
ll K;
ll ans;
ll fun();
int main(){
    cin>>S>>K;
    int tmp=0;
    int num1=1,num2=0;
    ans=0;
    int i;
    for( i=1;i<S.size();i++){
        if(S[i]==S[0]){num1++;S[i]='#';}
        else break;
        }
    if(i==S.size()){
        cout<<(S.size()*K)/2;
        return 0;
    }
    for(int j=S.size()-1;j>i;j--){
        if(S[j]==S[0]){num2++;S[j]='#';}
        else break;
        }
    for(int i=1;i<S.size();i++){
           // cout<<S[i]<< " ";
        if(S[i]==S[i-1]&&S[i]!='#'){
            tmp++;S[i]='#';
        }
    }
    //cout<<ans<<endl;
    //cout<<"tmp ..."<<tmp<<"K:"<<K<<endl;
    ans+=tmp*K;
    //cout<<"ans :"<<ans<<endl;
   // cout<<num1<<  " "<<num2<<endl;
    ans+=num1/2+num2/2+(num1+num2)/2*(K-1);
    cout<<ans;
}



Measured memory_bytes: 256
import math
import string
import collections
from collections import Counter
from collections import deque


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

N, M = map(int, input().split())
a = []
for _ in range(M):
    a.append(int(input()))
# print(a)
dp = [0]*(N+1)
#dp[0] = 1
#dp[1] = 1
# for i in range(2, N):
#    dp[i] = dp[i-1]+dp[i-2]
safe = [True]*(N+1)
for i in range(M):
    safe[(a[i])] = False
#print('safe', safe)
dp[0] = 1
if safe[1]:
    dp[1] = 1
for i in range(2, N+1):
    if safe[i]:
        dp[i] = dp[i-1]+dp[i-2]
    if not(safe[i]):
        dp[i] = 0
#print('dp', dp)
print(dp[N] % 1000000007)


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

int main(){
  string S; cin >> S;
  int k=S.size();
  if(k==1){
    cout << 0 << endl;
    return 0;
  }
  int ans=0;
  for(int i=0;i<k/2;i++){
    if(S[i]!=S[k-1-i]){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    typedef long long int ll;
    #define vll vector<long long int> 
    #define pb push_back
    #define f(i,x,n) for (i=x;i<n;i++)
    
    
    void solve(){
        string s;
        cin >> s;
        ll sum=0;
        for(int i=0;i<s.size();i++){
            sum+=s[i]-'0';
            sum%=9;
        }
        if(sum==0)
        cout << "Yes"<<endl;
        else
        cout << "No"<<endl;
        
    }
    int main(){
    	ios_base::sync_with_stdio(false); 
         	cin.tie(NULL);
    	int t=1;
    	
    	while(t--)
    	solve();	
    	
    
    }

Measured memory_bytes: 3732
#include <stdio.h>
 
#define S 9
 
int board[S];
int rows = 3, cols = 3, zeroIndex;
 

int blindSearch(int x, int y, int moves, int previousMove) {
  int i, foundAnswer;
 
 
  if (moves < (x + y))
    return 0;
 
  if (!moves) {
    for (i = 0; i < S - 1; i++) {
      if (board[i] != i + 1)
        return 0;
    }
 
    return 1;
  }
 
  if (x > 0 && previousMove != 1) {
    // can expand down
    board[zeroIndex] = board[zeroIndex + rows];
    zeroIndex += rows;
 
    foundAnswer = blindSearch(x - 1, y, moves - 1, 0);
    if (foundAnswer)
      return 1;
 
    board[zeroIndex] = board[zeroIndex - rows];
    zeroIndex -= rows;
  }
 
  if (y > 0 && previousMove != 3) {
    // right
    board[zeroIndex] = board[zeroIndex + 1];
    zeroIndex++;
 
    foundAnswer = blindSearch(x, y - 1, moves - 1, 2);
    if (foundAnswer)
      return 1;
 
    board[zeroIndex] = board[zeroIndex - 1];
    zeroIndex--;
  }
 
  if (y < rows - 1 && previousMove != 2) {
    // left
    board[zeroIndex] = board[zeroIndex - 1];
    zeroIndex--;
 
    foundAnswer = blindSearch(x, y + 1, moves - 1, 3);
    if (foundAnswer)
      return 1;
 
    board[zeroIndex] = board[zeroIndex + 1];
    zeroIndex++;
  }
 
  if (x < cols - 1 && previousMove != 0) {
    // up
    board[zeroIndex] = board[zeroIndex - rows];
    zeroIndex -= rows;
 
    foundAnswer = blindSearch(x + 1, y, moves - 1, 1);
    if (foundAnswer)
      return 1;
 
    board[zeroIndex] = board[zeroIndex + rows];
    zeroIndex += rows;
  }
 
  return 0;
}
 
int main() {
  int j, x, y, current;
 
  for (j = 0; j < S; j++) {
    scanf("%d", &board[j]);
    if (!board[j])
      zeroIndex = j;
  }
 
  x = cols - (zeroIndex / rows) - 1;
  y = rows - (zeroIndex % cols) - 1;
 
  for (current = 0; current < 50; current++) {
    if (blindSearch(x, y, current, -1)) {
      printf("%d\n", current);
      return 0;
    }
  }
}



Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  int n,a,b,i,j,l,r;
  string s;
  cin >> n;
  vector<long long> x(n+1);
  vector<long long> sum(n+1),xsum(n+1);
  x[0]=sum[0]=xsum[0]=0LL;
  for(i=1;i<=n;i++){
    cin >> a;
    x[i]=a;
    sum[i]=a;
    xsum[i]=a;
    sum[i]+=sum[i-1];
    xsum[i]^=xsum[i-1];
  }
  r=0;
  long long cnt = 0;
  for(l=0;l<=n;l++){
    while(r<n){
      if(sum[r+1]-sum[l]==(xsum[r+1]^xsum[l])){
        //cout << sum[r]-sum[l] << " " << (xsum[r]^xsum[l]) << endl;
        r++;
      }else break;
    }
    cnt+=r-l;
    //cout << l << " " << r << endl;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<functional>
#include<stack>
#include<list>
#include<set>
#include<deque>
#include<climits>
using namespace std;

typedef long long ll;

string S;

int Press(int latte[], int size)
{
	int length = 0;
	for (int i = 0; i < size; i++)
	{
		while (latte[i])
		{
			int cnt = 0;
			for(int j = i; j < size && latte[j]; j++, cnt++)
			{
				latte[j]--;
			}
			length += min(cnt, 3);
		}
	}
	return length;
}

int main(){
	cin >> S;
	int cntNum[10] = {}, cntAl[26] = {};
	for (int i = 0; i < S.size(); i++)
	{
		if(isalpha(S[i])) cntAl[S[i] - 'a']++;
		if(isdigit(S[i])) cntNum[S[i] - '0']++;
	}
	printf("%d\n", Press(cntNum, 10) + Press(cntAl, 26));
	return 0;
}

Measured memory_bytes: 1184
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
typedef long long ll;
int ans[105][105];
signed main(){
    int a,b;cin>>a>>b;
    rep(i,50)rep(j,100)ans[i][j]=1;
    rep(i,a-1){
        int r=i/50,c=i%50;
        ans[r*2][c*2]=0;
    }
    rep(i,b-1){
        int r=i/50,c=i%50;
        ans[50+r*2+1][c*2+1]=1;
    }

    cout<<100<<' '<<100<<endl;
    rep(i,100){
        rep(j,100){
        if(ans[i][j])cout<<'#';
        else cout<<'.';       
        }cout<<endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N,M;
  cin>>N>>M;
  	vector<int> A(N);
	  for(int i=0;i<N;i++){
	    cin>>A.at(i);
	  }
  int sum=0;
  for(int i=0;i<M;i++){
    sum+=A.at(i);
  }
  if(N-sum>=0){
    cout<<N-sum<<endl;
  }
  else{
cout<<"-1"<<endl;
  }

}

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

int main(){
  int A,B,C,X;
  cin>>A>>B>>C>>X;
  int count=0;
  for(int i=0; i<=A; i++){
    for(int j=0; j<=B; j++){
      for(int k=0; k<=C; k++){
        if(500*i+100*j+50*k==X) count++;
  }
  }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

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

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
        b[i] = a[i];
    }
    sort(b + 1, b + 1 + n);
    int l = b[n / 2], r = b[n / 2 + 1];
    for (int i = 1; i <= n; i++)
        if (a[i] <= l) printf("%d\n", r);
        else printf("%d\n", l);
	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
typedef long long ll;
using namespace std;

const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];

   int leftMax[N];
   int rightMax[N];
   leftMax[0] = 0;
   rightMax[N -1] = 0;

   for(int i = 1; i < N; i++) leftMax[i] = max(leftMax[i - 1],A[i - 1]);
   for(int i = N - 2; i >= 0; i--) rightMax[i] = max(rightMax[i + 1],A[i + 1]);

    for(int i = 0; i < N; i++)
    {
        cout << max(rightMax[i],leftMax[i]) << endl;
    }
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repp(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
typedef long long ll;
struct edge { ll s, t, x; };
typedef pair<ll, ll> P;
typedef pair<double, P> event;
const ll MAX = 510000;
const ll MOD = 1000000007;
#define INF (ll)10000000000000000

int solve(int n){
  int st=0;
  int a=n;
  while(a!=0){
    if(a%2==1){a-=1;st++;}
    a/=2;
  }
  if(st==0){return 0;}
  else{return 1+solve(n%st);}
}

int main() {
  ll N;
  string X;
  cin>>N>>X;
  ll count=0ll;
  rep(i,X.size()){
    if(X[i]=='1'){
      count+=1ll;
    }
  }
  if(count==0){
    rep(i,N){cout<<1<<endl;}return 0;
  }
  ll p=count+1ll,q=count-1ll;
  ll memo[N][3];
  memo[0][0]=1ll%p;
  memo[0][1]=1ll%count;
  if(q!=0){memo[0][2]=1%q;}
  else{memo[0][2]=-1;}
  rep(i,N-1){
    memo[i+1][0]=(memo[i][0]*2ll)%p;
    memo[i+1][1]=(memo[i][1]*2ll)%count;
    if(q!=0){memo[i+1][2]=(memo[i][2]*2ll)%q;}
    else{memo[i+1][2]=-1;}
  }
  ll sum[3];
  rep(i,3){sum[i]=0ll;}
  rep(i,N){
    if(X[N-1-i]=='1'){
      sum[0]+=memo[i][0];
      sum[1]+=memo[i][1];
      sum[2]+=memo[i][2];
    }
  }
  rep(i,N){
    if(X[i]=='1'){
      ll g=sum[2]-memo[N-1-i][2];
      if(q==0){cout<<0<<endl;continue;}
      g%=q;
      if(g==0){cout<<1<<endl;continue;}
      cout<<1+solve(g)<<endl;
    }
    if(X[i]=='0'){
      ll g=sum[0]+memo[N-1-i][0];
      g%=p;
      if(g==0){cout<<1<<endl;continue;}
      cout<<1+solve(g)<<endl;
    }
  }
}

Measured memory_bytes: 8440
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


void solve(long long H, long long W, long long N){
    cout<<ceil(N/(float)max(H,W))<<endl;
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long N;
    scanf("%lld",&N);
    solve(H, W, N);
    return 0;
}


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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint table[100005];
void fact(){
    table[0] = table[1] = 1;
    for(int i = 2; i < 100005; i++){
        table[i] = table[i-1] * i;
    }
}

signed main() {
    int n,k;
    cin >> n >> k;

    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());

    fact();
    mint minv(0);
    for(int i = 0; i <= n - k; i++){
        int N = n - i - 1;
        int R = k - 1;
        mint num = a[i];
        minv += num * table[N] / table[R] / table[N - R];
    }
    mint maxv(0);
    for(int i = n - 1; i >= k - 1; i--){
        int N = i;
        int R = k - 1;
        mint num = a[i];
        maxv += num * table[N] / table[R] / table[N - R];
    }

    mint ans = maxv - minv;
    cout << ans.x << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
void solve(vector<int>v,int r) {
	if (r == 0) {
		for (int i = 0; i < v.size(); i++) {
			if (i)printf(" ");
			printf("%d", v[i]);
		}
		printf("\n");
	}
	else {
		int k;
		if (v.size() >= 1)k = min(r, v[v.size() - 1]);
		for (int i = k; i >= 1; i--) {
			v.push_back(i);
			solve(v, r - i);
			v.pop_back();
		}
	}
	return;
}
int main() {
	int n;
	while (cin >> n, n) {
		vector<int>v;
		solve(v, n);
	}
	return 0;
}

Measured memory_bytes: 3084
N = input()
a = []
for i in range(N):
    a.append(map(int, raw_input().split()))

for j in range(N):

    x = a[j][0] ** 2
    y = a[j][1] ** 2
    z = a[j][2] ** 2

    if x == y + z:
        print "YES"
    elif y == x + z:
        print "YES"
    elif z == x + y:
        print "YES"
    else:
        print "NO"

Measured memory_bytes: 6292
#include <stdio.h>

int main(void){
  int year, month, day;
  
  scanf("%4d/%2d/%2d", &year, &month, &day);
  if(year>2019){
    printf("TBD\n");
  }else if(year<2019){
    printf("Heisei\n");
  }else if(month<5){
    printf("Heisei\n");
  }else{
    printf("TBD\n");
  }
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int N, Q; cin >> N >> Q;
  vi32 a(N); cin >> a;
  rep(i, Q) {
    i64 x; cin >> x;
    i64 ans = 0;
    i64 sum = 0;
    for (int l = 0, r = 0; l < N;) {
      while (r < N && sum + a[r] <= x) {
        sum += a[r++];
      }
      ans += r - l;
      if (r > l) sum -= a[l++];
      else l++, r++;
    }
    cout << ans << '\n';
  }
}



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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    
    string s; cin >> s;
    int cnt1 = 0, cnt2 = 0;
    
    for (int i = 0; i < s.length(); i++) {
        if (s[i] != (i % 2 ? '1' : '0')) cnt1++;
        if (s[i] != (i % 2 ? '0' : '1')) cnt2++;
    }
    
    cout << min(cnt1, cnt2) << '\n';
    
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

constexpr ll MOD = 1e9 + 7;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    ll k;

    cin >> n >> k;

    ll dp[55][55][100];
    memset(dp, 0, sizeof(dp));

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> dp[i][j][0];

    for (int i = 1; (1ll << i) <= k; i++)
        for (int j = 0; j < n; j++)
            for (int k = 0; k < n; k++)
                for (int l = 0; l < n; l++)
                    (dp[j][l][i] += dp[j][k][i - 1] * dp[k][l][i - 1] % MOD) %= MOD;

    ll x = 0;
    while (true)
    {
        x++;
        if (k - (1ll << x) < (1ll << x))
            break;
    }

    ll s[2][55];
    auto cur = s[0];
    auto nex = s[1];

    fill(cur, cur + n, 1);

    while (k)
    {
        if (k >= (1ll << x))
        {
            for (int i = 0; i < n; i++)
            {
                nex[i] = 0;
                for (int j = 0; j < n; j++)
                {
                    nex[i] += dp[i][j][x] * cur[j] % MOD;
                    nex[i] %= MOD;
                }
            }
            k -= (1ll << x);
            swap(cur, nex);
        }

        x--;
    }

    ll res = 0;

    for (int i = 0; i < n; i++)
        (res += cur[i]) %= MOD;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int x;
	cin>>x;

	for(int i=1;i<2*x;i++){
		int sum=i*(i+1)/2;
		if(sum>=x){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3560
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();
        if(a<b){
            System.out.println("a < b");
        }
        if(a>b){
            System.out.println("a > b");
        }
        if(a == b){
            System.out.println("a == b");
        }
        sc.close();
    }
}


Measured memory_bytes: 26036
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = B[A[0]-1]

for i in range(1,N):
  ans += B[A[i]-1]
  if A[i] - A[i-1] == 1:
    ans += C[A[i-1]-1]

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<31;
const ll inf_l = 1LL<<61;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    vint X(n), Y(n);
    rep(i,n) {
        int x, y; cin >> x >> y;
        X[i] = x - y;
        Y[i] = x + y;
    }
    int ans = *max_element(all(X)) - *min_element(all(X));
    ans = max(ans,*max_element(all(Y)) - *min_element(all(Y)));
    cout << ans << endl;
}

Measured memory_bytes: 4844
import sys

input = sys.stdin.readline


def solve(N, K, Q, A):
    num_correct = [0 for _ in range(N)]
    for a in A:
        num_correct[a - 1] += 1
    threshold_to_survive = Q - K
    for c in num_correct:
        if c > threshold_to_survive:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    N, K, Q = map(int, input().split())
    A = [int(input()) for _ in range(Q)]

    answer = solve(N, K, Q, A)


Measured memory_bytes: 8636
#include <iostream>
#include <cstdio>
#include <stack>
#include <algorithm>
using namespace std;
int main(void){
    // Your code her
    stack<int> e;
    int x;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
        int a=e.top();
        e.pop();
        int b=e.top();
        e.pop();
        e.push(a+b);
    } else if ( s[0] == '-' ){
       int a=e.top();
        e.pop();
        int b=e.top();
        e.pop();
        e.push(b-a);
    } else if ( s[0] == '*' ){
       int a=e.top();
        e.pop();
        int b=e.top();
        e.pop();
        e.push(a*b);
    } else {
      x = atoi(s);
      e.push(x);
    }
  }
  printf("%d\n",e.top());
  return 0;
}


Measured memory_bytes: 3220
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		int sum = 0;
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
			sum += a[i] - 1;
		}
		System.out.println(sum);


	}
}


Measured memory_bytes: 27828
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int N, K;
  cin >> N >> K;

  cout << ceil((N - 1) * 1.0 / (K - 1)) << endl;

  return 0;
}


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    map<int,int> mp;
    int n,m;cin >> n >> m;
    int ac,wa;
    ac = wa = 0;
    vector<bool> flag(n+1,false);
    
    for(int i=0;i<m;i++){
        int p;
        string s;
        cin >> p >> s;
        if(mp[p] == 0){
            if(s == "WA"){
                mp[p]--;
            }else if(s == "AC"){
                ac++;
                mp[p] = 1;
            }
        }else if(mp[p] <= -1){
            if(s == "WA"){
                mp[p]--;
            }else if(s == "AC"){
                ac++;
                wa += (-mp[p]);
                mp[p] = 1;
            }
        }else if(mp[i] == 1){

        }
    }
    cout << ac << " " <<  wa << endl;
    return 0;
}

Measured memory_bytes: 4992