akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
using namespace std;
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<pin,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
#define rev(s) reverse(s.begin(),s.end())
#define end_pr(s) cout << s <<endl;return 0
#define itn int
#define bs bitset<5001>

int kai_size = 1000001;
vel kai(kai_size, 1);
vel ink(kai_size, 1);
vel dist;
signed main() {
	int n; cin >> n;
	V<pin> a(n);
	rep(i, n) { int x; cin >> x; a[i] = mkp(x, -i); }
	sor(a);
	vel b(n);
	rep(i, n) { b[-a[i].second] = i; }
	set<int> se;
	se.insert(-b[0]);
	for (int i = 1; i < n; i++) {
		auto itr=se.lower_bound(-b[i]);
		if (itr == se.end()) { se.insert(-b[i]); }
		else{
			se.erase(itr);
			se.insert(-b[i]);
		}
	}
	cout << se.size() << endl;
	return 0;
}

Measured memory_bytes: 22912
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int>l;
	for (int i = 0; i < n * 2; i++){
		int a; cin >> a;
		l.push_back(a);
	}
	sort(l.begin(), l.end());
	int num = 0;
	for (int i = 0; i < n * 2; i += 2){
		num += l[i];
	}
	cout << num << '\n';
}

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

const ll MAX = 1e6+5;

ll a[MAX],tree[MAX];
ll last[MAX],cnt[MAX],n;
vector<pair<int,int>> query[MAX];
 
ll accum(ll id){
	ll ret = 0;
	while(id>0){
		ret += tree[id];
		id -= (id & -id);
	}
	return ret;
}
 
ll que(ll l,ll r){
	return accum(r)-accum(l-1);
}
 
void add(ll id,ll aum){
	while(id<=n){
		tree[id]+=aum;
		id += (id & -id);
	}
}
 
ll ans[MAX];
 
int main(){
	for(ll i=0;i<MAX;i++) last[i]=-1;
	ll l,r,q;
	cin>>n>>q;
 
	for(ll i=1; i<n+1; i++) 
		cin>>a[i];
	for(ll i=0; i<q; i++){
		cin>>l>>r;
		query[r].push_back({l,i});
	}
	for(ll i=1; i<n+1; i++) {
		if (last[a[i]]!=-1){
			--cnt[last[a[i]]];
			add(last[a[i]],-1);}
		last[a[i]]=i;
		cnt[last[a[i]]]++;
		add(last[a[i]],1);
 
		for(pair<int,int> qq: query[i]){
			ll sum = que(qq.first,i);
			ans[qq.second] = sum;
		}
	}
	for(ll i=0;i<q; i++)
		cout<<ans[i]<<endl;
}

Measured memory_bytes: 60560
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int N = 100100;

ll ans = 0;
int n;
ll a[N], b[N];
ll k;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%lld", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%lld%lld", &a[i], &b[i]);
		if ((a[i] & k) == a[i])
			ans += b[i];
	}
	for (int j = 0; j < 30; j++) {
		if (((k >> j) & 1) == 0) continue;
		ll z = 1 << j;
		ll sum = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] & z) continue;
			ll x = a[i] ^ (a[i] & (z - 1));
			if ((x & k) != x) continue;
			sum += b[i];
		}
		ans = max(ans, sum);
	}
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 1792
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.PriorityQueue;

public class Main {

	InputStream is;
	PrintWriter out;
	String INPUT = "";

	private static final long M = 1000000007;

	void solve() {
		out.print((nl()*3+nl())/2);

	}

	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n) {
			if (!(isSpaceChar(b)))
				buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int[][] na(int n, int m) {
		int[][] a = new int[n][];
		for (int i = 0; i < n; i++)
			a[i] = na(m);
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

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

//諸機能
#pragma region MACRO 
#define putans(x)  std::cerr << "[ answer ]: " ; cout << (x) << endl
#define dputans(x) std::cerr << "[ answer ]: "; cout << setprecision(40) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,n,a) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define equals(a,b) (fabs((a)-(b)) < EPS)
#ifdef _DEBUG //ファイルからテストデータを読み込む
std::ifstream ifs("data.txt");
#define put ifs >>
#else //ジャッジシステムでいい感じにやる
#define put cin >>
#endif
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#ifdef _DEBUG
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "=";  rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} 
#else
#define dbg(var0) {}
#define dbg2(var0, var1) {}
#define dbg3(var0, var1, var2) {}
#define dbgArray(a,n) {}
#endif 
#pragma endregion 
//typedef（書き換える、書き足す可能性ある）
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-10)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(2*1e9)
#pragma endregion

int n;
string rei[100000+1];
string ans;
bool check() {
	string set[2] = {"S","W"};
	int tmp = 0;
	rep(i, n - 1) {
		tmp = 0;
		if (rei[( n + i - 1 ) % n] == "S")tmp++;
		if (rei[i] == "S")tmp++;
		if (ans[i] == 'x')tmp++;
		if (i == n - 2 && set[tmp % 2] != rei[n-1]) return false;
		rei[i + 1] = set[(tmp )% 2];
	}
	if (ans[n-1] == 'o') {
		if (rei[n - 1] == "S") {
			if (rei[n - 2] == rei[0])return true;
			else return false;
		}
		else {
			if (rei[n - 2] != rei[0])return true;
			else return false;
		}

	}
	else {// x
		if (rei[n - 1] == "S") {
			if (rei[n - 2] == rei[0])return false;
			else return true;
		}
		else{
			if (rei[n - 2] != rei[0])return false;
			else return true;
		}
	}

}

int main() {
	string s;
	put n >> s;
	ans = s;
	string set[2] = {"S","W"};
	rep(i, 2) {
		rep(j, 2) {
			rei[n - 1] = set[i];
			rei[0] = set[j];
			if (check()) {
				rep(k, n) {
					cout << rei[k];
				}
				goto END;
				cout << endl;
			}
		}
	}
	putans("-1");
END:
	return 0;
}



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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    long long int r, d, x;
    cin >> r >> d >> x;

    for (int i = 0; i < 10; i++){
        cout << r * x - d << '\n';
        x = r * x - d;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b;
    while(true){
        scanf("%d %d",&a,&b);
        if(a == 0 && b == 0) break;
        if(a > b) printf("%d %d\n",b,a);
        else{
            printf("%d %d\n",a,b);
        }
    }
}


Measured memory_bytes: 2688
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n;
int main()
{
	cin>>n;
	int a;
	if(n%2==1)
		a=(n+1)/2;
	else
		a=n/2;
	printf("%.10lf",1.0*a/n);
	return 0;
}

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

#define ll          long long
#define endl        "\n"
#define inf         10000000002
#define pb          push_back
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define MAX         1000000000
#define yes         cout<<"Yes"<<endl
#define no          cout<<"NO"<<endl
#define bye         return 0

int main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);
      //freopen("inputNew.txt", "r", stdin);

      ll n,k;
      cin>>n>>k;
      ll arr[n];
      loop(i,0,n){cin>>arr[i];}

      for(int i=k,j=0; i<n; i++,j++){
            if(arr[i]>arr[j]){cout<<"Yes"<<endl;}
            else cout<<"No"<<endl;
      }

      bye;
}


Measured memory_bytes: 5216
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    cout << fixed << setprecision(5);
    int n, t, a, h, res;
    vector<pair<float, int>>vec;
    cin >> n;
    cin >> t >> a;
    // vec.push_back(make_pair(a, 0));
    for(int i=0; i<n; i++){
      cin >> h;
      float ans=t-(h*0.006);
      vec.push_back(make_pair(ans, i));
    }
    sort(vec.rbegin(), vec.rend());
    float mn=abs(vec[n-1].first-a);
    for(int i=0; i<vec.size(); i++){
      // cout << vec[i]. first << " " << vec[i].second << endl;
      if(abs(vec[i].first-a)<mn){
        mn=abs(vec[i].first-a);
        res=vec[i].second;
      }
    }
    cout << res+1;
}


Measured memory_bytes: 3636
def gcd(a,b):
    if a < b:
        a, b = b, a
    while b >= 1:
        a, b = b, a % b
    return a
def lcm(a,b):
	return a * b // gcd(a,b)

a, b = [ int(v) for v in input().split() ]
print(lcm(a,b))

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int N, K; string s;
    cin >> N >> K >> s;

    int l=0, r=0, ans=0;
    while(r < N){
        while(r < N && s[r] == '1') r++;
        ans = max(ans, r-l);
        while(r < N && s[r] == '0') r++;
        K--;
        if(K < 0){
            while(l < N && s[l] == '1') l++;
            while(l < N && s[l] == '0') l++;
        }
        ans = max(ans, r-l);
    }

    cout << ans << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

int main() {
  string S;
  cin >> S;
    if(S[0]=='R' && S[1]=='R' && S[2]=='R'){
      cout << "3";
    }else if((S[0]=='R' && S[1]=='R') || (S[1]=='R' && S[2]=='R')){
      cout << "2";
    }else if(S[0]=='S' && S[1]=='S' && S[2]=='S'){
      cout << "0";
    }else{
      cout << "1";
  }
	return 0;
}


Measured memory_bytes: 3616
#include <cstdio>
#include <cstring>
#pragma warning(disable : 4996)
#define rng(x, y) (0 <= x && x < W && 0 <= y && y < H)
int H, W, n, gx, gy, x[12][12], d[4] = { 1, 0, -1, 0 };
int solve(int sx, int sy, int depth) {
	if (depth == n) return ((sx == gx || sy == gy) ? 1 : 0);
	depth++;
	int ret = 0;
	for (int i = 0; i < 4; i++) {
		int tx = sx + d[i], ty = sy + d[i ^ 1];
		while (rng(tx, ty)) {
			if (x[ty][tx] == 1) {
				x[ty][tx] = 0;
				ret += solve(tx, ty, depth);
				x[ty][tx] = 1;
				break;
			}
			tx += d[i];
			ty += d[i ^ 1];
		}
	}
	return ret;
}
int main() {
	while (scanf("%d%d", &W, &H), W | H) {
		n = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				scanf("%d", &x[i][j]);
				if (x[i][j] == 1) n++;
				if (x[i][j] == 2) gx = j, gy = i;
			}
		}
		printf("%d\n", solve(gx, gy, 0));
	}
	return 0;
}

Measured memory_bytes: 2576
#include<bits/stdc++.h>
using namespace std;
int f(int n,int a)
{
	int i,s=a;
	for(i=1;i<=n;i++)
	{
		s*=2;	
	}
	return s;
}
int main()
{
	int a,b,c,k;
	scanf("%d %d %d %d",&a,&b,&c,&k);
	if(b>a&&b>c)
		printf("%d",f(k,b)+a+c);
	else if(c>a&&b<c)
		printf("%d",f(k,c)+a+b);
	else
		printf("%d",f(k,a)+b+c);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int c[n-1],s[n-1],f[n-1];
  for(int i=0;i<n-1;i++)cin>>c[i]>>s[i]>>f[i];
  for(int i=0;i<n;i++){
    int t=0;
    for(int j=i;j<n-1;j++){
      for(int k=0;;k++){
        if(s[j]+f[j]*k>=t){
          t=c[j]+s[j]+f[j]*k;
          break;
        }
      }
    }
    cout<<t<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(){
  int n;
  int r;
  int ans;
  
  scanf("%d %d",&n,&r);
  
  if(n>=10){
  ans=r;
  printf("%d\n",ans);
  }else{
  ans=100*(10-n)+r;
  printf("%d\n",ans);
  }
  
  

  return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  string s;  
  cin >> s;

  int ans = 0;
  {
    vector<int> cumr(n, 0), cuml(n, 0);
    int sumr = 0, suml = 0;
    for ( int i = 0; i < n; i++ ) {
      if ( i ) {
	cumr[i] = cumr[i-1];
	cuml[i] = cuml[i-1];
      }
      if ( s[i] == '>' ) {
	cumr[i]++;
	sumr++;
      } else {
	cuml[i]++;
	suml++;      
      }
    }

    if ( sumr == n || suml == 0 ) ans = n;    
    for ( int i = 0; i < n; i++ ) {
      if ( s[i] == '<' ) continue;      
      int a = cumr[i];
      int b = cuml[i]+a;
      if ( b-1 == suml ) {      
	ans = max(ans, n-(int)(lower_bound(cumr.begin(), cumr.end(), 1)-cumr.begin()));
      }
      if ( b > suml ) continue;
      int c = lower_bound(cuml.begin(), cuml.end(), b)-cuml.begin();      
      ans = max(ans, c+1);
    }
    // cout << ans << endl;
  }
  {
    reverse(s.begin(), s.end());
    for ( int i = 0; i < n; i++ ) {
      if ( s[i] == '>' ) s[i] = '<';
      else s[i] = '>';      
    }
    // cout << s << endl;
    vector<int> cumr(n, 0), cuml(n, 0);
    int sumr = 0, suml = 0;
    for ( int i = 0; i < n; i++ ) {
      if ( i ) {
	cumr[i] = cumr[i-1];
	cuml[i] = cuml[i-1];
      }
      if ( s[i] == '>' ) {
	cumr[i]++;
	sumr++;
      } else {
	cuml[i]++;
	suml++;      
      }
    }

    if ( sumr == n || suml == 0 ) ans = n;    
    for ( int i = 0; i < n; i++ ) {
      if ( s[i] == '<' ) continue;      
      int a = cumr[i];
      int b = cuml[i]+a;
      if ( b-1 == suml ) {	
	ans = max(ans, n-(int)(lower_bound(cumr.begin(), cumr.end(), 1)-cumr.begin()));
      }
      if ( b > suml ) continue;
      int c = lower_bound(cuml.begin(), cuml.end(), b)-cuml.begin();
      // cout << a << " " << b << " " << i << " " << c+1 << endl;
      ans = max(ans, c+1);      
    }
  }

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



Measured memory_bytes: 3956
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		int n = Integer.parseInt(st.nextToken());
 		int m = Integer.parseInt(st.nextToken());
 		int d = Integer.parseInt(st.nextToken());
 		
 		int a = (n+(d-1))/d;
 		int b = (m)/d;
 		out.println(b-a+1);
 		
 		out.println();
	 		
 		out.close();
 		
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 25308
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
const int MAX = 2e6;
int pr[MAX]={};

int ys[MAX],xs[MAX];

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

  for(int i=2;i<MAX;i++)
    if(!pr[i])
      for(int j=i+i;j<MAX;j+=i)
        pr[j]=1;

  for(int i=2;i<MAX;i++) pr[i]=!pr[i];

  int m,n;
  while(cin>>m>>n,m){
    using T = tuple<int, int, int>;
    vector<T> vt;
    {
      int dy[]={0,-1,0,1};
      int dx[]={1,0,-1,0};

      int y=0,x=0,k=1,d=0,l=1,c=2;
      while(k<=m){
        // cout<<y<<' '<<x<<' '<<k<<endl;
        ys[k]=y;
        xs[k]=x;
        vt.emplace_back(y,x,k);

        k++;l--;
        y+=dy[d];
        x+=dx[d];

        if(l==0){
          d++;d%=4;
          c++;l=c/2;
        }
      }
    }
    assert((int)vt.size()==m);
    sort(vt.begin(),vt.end());

    using P = pair<int, int>;

    map<P, int> idx;
    for(int i=0;i<m;i++)
      idx[P(get<0>(vt[i]),get<1>(vt[i]))]=i;

    vector<P> dp(m,P(0,0));

    P ans(0,0);
    vector<int> alive(m,0);
    for(int i=0;i<m;i++){
      int y,x,k;
      tie(y,x,k)=vt[i];

      // cout<<y<<' '<<x<<' '<<k<<newl;
      if(k==n) alive[i]=1;
      if(!alive[i]) continue;

      if(pr[k]) dp[i].first++,dp[i].second=k;
      chmax(ans,dp[i]);

      for(int dx=-1;dx<=1;dx++){
        int ny=y+1,nx=x+dx;
        if(!idx.count(P(ny,nx))) continue;
        chmax(dp[idx[P(ny,nx)]],dp[i]);
        alive[idx[P(ny,nx)]]=1;
      }
    }
    cout<<ans.first<<' '<<ans.second<<newl;
  }

  return 0;
}



Measured memory_bytes: 104292
#include <stdio.h>

int main()
{
    int h, w, h2, w2;
    scanf("%d %d\n%d %d", &h, &w, &h2, &w2);
    int ans = (h * w) - (h2 * w) - (w2 * h) + (h2 * w2);
    printf("%d\n", ans);
    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;

int main() {
  
  string s;
  cin >> s;
  
  int ans = 0, c = 0;
  REP(i,10)  { 
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
      c++;
      for (int j = i+1; j < 10; j++) {
        if (s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T') {
          c++;
        }
        else break;
      }
      
    }
    ans = max(ans,c);
    c = 0;
  }
  
  cout << ans << endl;
   
}

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

int main() {
  int n, sum = 0;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for (int i = 0; i < n - 1; i++) {
    sum += vec.at(i);
  }
  string s =vec.at(n - 1) < sum ? "Yes" : "No";
  cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

/*------------------------------------/
for library*/
template<typename T>
vector<pair<T,long long>> RunLengthEncoder(vector<T> &v){
    vector<pair<T,long long>> RLE;
    long long cnt = 1;
    for(int i = 0; i < (int)v.size(); ++i){
        if(i == (int)v.size()-1){
            RLE.push_back(make_pair(v[i], cnt));
            continue;
        }
        if(v[i] == v[i+1])cnt++;
        else{
            RLE.push_back(make_pair(v[i],cnt));
            cnt = 1;
        }
    }
    return RLE;
}

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

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

    ll N,M,V,P;
    cin>>N>>M>>V>>P;
    vector<ll> A(N);
    rep(i,N)cin>>A[i];
    sort(all(A), greater<ll>());
    //print(A);
    //xは0-indexed
    auto check = [&](ll x){
        //0 ~ P-1はOK
        if(x < P){
            //cerr<<"上位P"<<endl;
            return true;
        }
        if(A[x] + M < A[P-1]){
            //cerr<<"試す価値なし"<<endl;
            return false;
        }
        ll sum = 0;
        rep(i,N){
            if(i < P-1 || x <= i)sum+= M;
            else{
                sum += A[x] + M - A[i];
            }
        }
        //cerr<<x << " "<<M * V<< " " << sum<<endl;
        return M * V <= sum;
    };
    ll ok = -1;
    ll ng = N;
    while(ng - ok > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid)){
            ok = mid;
            //cerr<<mid<<" "<<"OK"<<endl;
        }
        else{
            ng = mid;
            //cerr<<mid<<" "<<"NG"<<endl;
        }
    }
    cout<<ok + 1<<endl;
}

Measured memory_bytes: 1024
x,k,d=map(int,input().split())
if k*d<abs(x):
    if x>0:
        print(x-k*d)
        exit()
    else:
        print(abs(x+k*d))
        exit()
else:
    a=abs(x)//d
    b=k-a
    if (k-a)%2==0:
        print(abs(x)%d)
    else:
        print(abs((abs(x)%d)-d))

Measured memory_bytes: 9216
uses math;
var
	ans,n,Ma,Mb,i,j,a,b,c,x,mp,mm:Longint;
	p,m:array[0..300]of Longint;
begin
	read(n,Ma,Mb);
	ans:=10000;
	for i:=1 to 300 do begin
		p[i]:=ans;
		m[i]:=ans;
	end;
	for i:=1 to n do begin
		read(a,b,c);
		x:=Ma*b-Mb*a;
		if x>0 then begin
			for j:=mp downto 0 do p[j+x]:=min(p[j+x],p[j]+c);
			mp:=min(mp+x,300);
		end else if x<0 then begin
			for j:=mm downto 0 do m[j-x]:=min(m[j-x],m[j]+c);
			mm:=min(mm-x,300);
		end else ans:=min(ans,c);
	end;
	for i:=1 to 300 do ans:=min(ans,p[i]+m[i]);
	if ans<10000 then writeln(ans)else writeln(-1);
end.

Measured memory_bytes: 128
object Main extends App {
	val Array(n, m) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	val a = new Array[Int](n)

	for(i<-0 until m){
		val Array(tp1, tp2) = scala.io.StdIn.readLine.split(" ").map(_.toInt  - 1)
		a(tp1) += 1
		a(tp2) += 1
	}

	a.foreach(println)
}


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

static const int N=100;

int main(){
    int n,p[N+1],m[N+1][N+1];
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>p[i-1]>>p[i];
    
    for(int i=1;i<=n;i++)
        m[i][i]=0;
    
    for(int l=2;l<=n;l++)
        for(int i=1;i<=n-l+1;i++){
            int j=i+l-1;
            m[i][j]=(1<<21);
            for(int k=i;k<=j-1;k++)
                m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
        }

    cout<<m[1][n]<<endl;
}

Measured memory_bytes: 3104
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l  
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |   
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) reverse((a).begin(),(a).end())
#define REP(i, n) for(int i = 0; i < n; i++)
const int MOD = 1e9+7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
  string s;
  cin>>s;
  vector<char>a(s.length());
  for(int i=0;i<s.length();i++){
    a[i]=s[i];
  }
  int right=s.length()-1;
  int left=0;
  int count=0;
  while(right-left>=1){
    if(a[right]==a[left]){
      right--;
      left++;
    }else if(a[right]=='x'){
      right--;
      count++;
    }else if(a[left]=='x'){
      left++;
      count++;
    }else break;
  }
  if(right-left>=1) cout<<"-1"<<endl;
  else cout<<count<<endl;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProblemC
{
    class Tower
    {
        public int Height;
        public List<int> other_tower;
        public bool good;

        public Tower(int h)
        {
            Height = h;
            other_tower = new List<int>();
            good = true;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var buff = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int N = buff[0];
            int M = buff[1];

            var height = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var towers = new Tower[N];
            for(int i = 0; i < N; i++)
            {
                towers[i] = new Tower(height[i]);
            }

            for(int i = 0; i < M; i++)
            {
                buff = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                towers[buff[0] - 1].other_tower.Add(buff[1] - 1);
                towers[buff[1] - 1].other_tower.Add(buff[0] - 1);
            }
            int count = 0;
            for(int i = 0; i < N; i++)
            {
                if(towers[i].good)
                {
                    foreach(int item in towers[i].other_tower)
                    {
                        if(towers[i].Height < towers[item].Height)
                        {
                            towers[i].good = false;
                            count++;
                            break;
                        }
                        else if (towers[i].Height == towers[item].Height)
                        {
                            towers[i].good = false;
                            count++;
                            if(towers[item].good)
                            {
                                towers[item].good = false;
                                count++;
                            }
                            break;
                        }
                        else
                        {
                            if (towers[item].good)
                            {
                                towers[item].good = false;
                                count++;
                            }
                        }
                    }
                }
            }

            Console.WriteLine(N - count);
        }
    }
}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;

int n;
int a[N];

int main() {

	FAST;

	int x;
	cin >> x;
	if (x == 3 || x == 5 || x == 7) cout << "YES\n";
	else cout << "NO\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>
#include <iomanip>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

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; }
typedef long long ll;
typedef long double ld;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    ld ans = 0.0;
    ld n, k;
    cin >> n >> k;

    reps(d, n){
        rep(p, 18){
            if(ld(d) * ld(pow(2.0, p)) >= k){
                ld a = 1.0/n;
                ld b = 1.0;
                rep(i, p){
                    b /= 2.0;
                }
                ans += a*b;
                break;
            }
        }
    }

    cout << setprecision(16) <<ans;


}

Measured memory_bytes: 256
N = int(input())
xs = list(map(int, input().split()))

ans = 0
for i in range(len(xs)):
  if xs[i] != i+1:
    continue
    
  ans += 1
  if i < N-1:
    xs[i], xs[i+1] = xs[i+1], xs[i]
  else:
    xs[i], xs[i-1] = xs[i-1], xs[i]

print(ans)

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

int main()
{
    set<char> s;
    for(int i = 0; i < 3; i++)
    {
        char t;
        cin >> t;
        s.insert(t);
    }
    if((int)s.size() <= 1)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
#define vec2d(T, v, m, n) vector<vector<T>> (v)(m, vector<T>(n))
#define nvec2d(T, v, m, n) vec2d(T, v, m, n); REP(j, m){REP(i, n) {cin>>(v[j])[i];}}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))
#define P 1000000007
long powP (long a, long b) {
  if (b == 1) return a;
  else if (b == 0) return 1;
  else if (b < 0) return powP(a, P + b - 1);
  else return (powP(a, b/2) * powP(a, b/2 + b%2)) % P;
}

#define GCD(v) gcd(ALL(v), 0l)

/*template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}*/

template <typename T>
using vec = vector<T>;

template <typename T>
using vvec = vector<vector<T>>;


int main() {
  int n; cin>>n;
  n-=1;
  int ans=0;
  for (int i = 1; i <= n; i++) {
    ans+=(n/i);
  }
  cout<<ans;
}


/* きょむ〜 */


Measured memory_bytes: 3632
N = gets.to_i
T, A = gets.split(' ').map(&:to_i)
H = gets.split(' ').map(&:to_i)
teps = []
for h in H do
  tep = T - (h * 0.006)
  teps << tep
end
gaps = []
teps.each_index do |idx|
  # ans = idx + 1 if gap > 
  gaps << (teps[idx] - A).abs
end
p (gaps.index(gaps.min) + 1)

Measured memory_bytes: 1788
n = gets.chomp.to_i
a,b=gets.split.map(&:to_i)
p=gets.split.map(&:to_i)
p0 = p.select { |e| e <= a }.size
p2 = p.select { |e| e > b }.size
p1 = n - p0 - p2
puts [p0, p1, p2].min


Measured memory_bytes: 1788
N,x = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

if x < min(A):
    print(0)
    exit()

A.sort()
ans = 0
i = 0
while x > 0 and ans < N:
    if x >= A[i]:
        x -= A[i]
        ans += 1
        i += 1
    else:
        x = 0
        break

if x > 0:
    ans -= 1

print(ans)


Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

 ll n;
 cin>>n;
 if(n<600)
 {
     cout<<"8"<<endl;
 }
 else if(n<800)
 {
     cout<<"7"<<endl;
 }
 else if(n<1000)
 {
     cout<<"6"<<endl;
 }
 else if(n<1200)
 {
     cout<<"5"<<endl;
 }
 else if(n<1400)
 {
     cout<<"4"<<endl;
 }
 else if(n<1600)
 {
     cout<<"3"<<endl;
 }
 else if(n<1800)
 {
     cout<<"2"<<endl;
 }
 else
 {
     cout<<"1"<<endl;
 }

return 0;
}



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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define MOD 1000000007
const double PI=3.14159265358979323846;
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; }
template<typename T> T Ceil(T a, T b){return (a+b-1)/b;}

int dy[]={0, 0, 1, -1, 1, -1, -1, 1};
int dx[]={1, -1, 0, 0, 1, 1, -1, -1};

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

int main() {
    cout<<fixed<<setprecision(10);

    ll n,k; cin>>n>>k;
    vint a(n); rep(i,n) cin>>a[i];

    vint b(n+1),c(n+1), d(n+1);

    b[0] = 0;
    rep(i,n) b[i+1] = b[i] + a[i];

    c[0] = 0;
    rep(i,n){
        c[i+1] = c[i];
        if(a[i]>0) c[i+1] += a[i];
    }

    d[0] = 0;
    rep(i,n){
        d[i+1] = d[i];
        if(a[n-1-i]>0) d[i+1] += a[n-1-i];
    }

    ll ans = 0;
    ll m = n-k;
    rep(l,m+1){
        ll r = m-l;
        ll tmp = c[l] + d[r] + max(0ll, b[n-r]  - b[l]);
        chmax(ans, tmp);
    }
    cout<<ans<<endl;

    return 0;

}

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

using ll = long long;
using ull = unsigned long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define bzero(p, n) memset(p, 0, n)
#define all(a) begin(a),end(a)
template<class T> inline void sort_uniq(T& c) { sort(ALL(c)); c.erase(unique(ALL(c)), c.end()); }
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
inline int powi(int x,int y) {int p=1; while(y--) p*=x; return p;}
inline ll powll(ll x,ll y) {ll p=1; while(y--) p*=x; return p;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

struct pair_ii_hash {
    inline size_t operator()(const pair<int,int> & p) const{
        const auto a = hash<int>()(p.first);
        const auto b = hash<int>()(p.second);
        return a ^ (b << 1);
    }
};

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

    int N, M; cin >>N >>M;
    vector<pair<int, int>> PY(M);
    vector<int> PY_sorted_i(M);
    rep(i, M) {
        cin >> PY[i].first >> PY[i].second;
    }
    iota(all(PY_sorted_i), 0);
    sort(all(PY_sorted_i), [&](int a, int b) { return PY[a] < PY[b]; });

    //map<pair<int, int>, int> x_map;
    unordered_map<pair<int, int>, int, pair_ii_hash> x_map;
    int P_prev = -1;
    int x;
    rep(i, M) {
        const pair<int, int>& py = PY[PY_sorted_i[i]];
        //cout << FMT2(py.first, py.second) << endl;
        if (py.first != P_prev) {
            x = 1;
        } else {
            x++;
        }
        x_map.emplace(py, x);
        P_prev = py.first;
    }

    rep(i, M) {
        printf("%06d%06d\n", PY[i].first, x_map[PY[i]]);
        //cout << setw(6) << setfill('0') << PY[i].first  << setw(6) << setfill('0') << x_map[PY[i]] << endl;
    }
}


Measured memory_bytes: 8356
#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int n;
double x[10],y[10],med,s=0;
  
void Suma(){
    int a,b;
    for(int i=0;i<n-1;i++){
        a=v[i];b=v[i+1]; 
        s+=sqrt((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]));
    }
}
int main()
{
    int p=1,k=0;
    cin>>n;
    v.resize(n);
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
        v[i]=i;
    }
    do{
        k++;
        Suma();
    }while(next_permutation(begin(v),end(v)));
    cout<<setprecision(10)<<fixed<<s/k;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>

using namespace std;

int cnt(int k){
	int bound = int(sqrt(k));
	int ans = 0;
	for (int i = 1; i <= bound; i++)
		if (k % i == 0)
			ans += 2;
	if (bound * bound == k)
		ans -= 1;
	return ans;
}

int main(){
	int n;
	int ans = 0;
	cin >> n;
	for (int c = 1; c < n; c++)
		ans += cnt(n - c);
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<40;
const ll MOD = 1000000007;

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

  ll n;
  cin >> n;
  vector<vector<ll>> g(n);
  REP(i, n-1) {
    ll x, y;
    cin >> x >> y;
    x--, y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }

  function<PII(ll,ll)> dfs = [&](int v, int p) {
    // 白, 黒
    PII ret({1, 1});
    for(auto to: g[v]) if(to != p) {
      auto p = dfs(to, v);
      (ret.first *= (p.first + p.second) % MOD) %= MOD;
      (ret.second *= p.first) %= MOD;
    }
    // cout << v << " " << ret << endl;
    return ret;
  };

  auto ans = dfs(0, -1);
  cout << (ans.first + ans.second) % MOD << endl;

  return 0;
}


Measured memory_bytes: 14080
/*
      @author: Charan Sai
*/
#include <bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define ppi pair<int, int>
#define endl "\n"
#define nl cout << "\n"
#define deb(x) cout << #x << " " << x << endl;

const int Max_N=1e5+1;

int arr[Max_N];
int n, k;
int dp[Max_N][2]; 
//dp[i][0] = winner if i stones are present and 0th player starts the game
//dp[i][1] = winner if i stones are present and 1st player starts the game

// turn = 0 (Taro) , 1 (Jiro)
// O(K*2*N) time & space (2d array)
int Top_Down(int stones = k, int turn = 0) {
    // Base Case
    if(stones == 0) return (dp[stones][turn]=!turn);

    if(dp[stones][turn] != -1) return dp[stones][turn];

    // Choice
    for(int i = 1; i <= n; ++i) {
        if(arr[i] <= stones) 
            if(Top_Down(stones-arr[i], !turn) == turn)  return (dp[stones][turn]=turn);
    }
    return (dp[stones][turn]=!turn);
}

int dp1[Max_N+1];
int Top_Down2(int stones = k) {
    if(stones==0) return 1;
    if(dp1[stones] != -1) return dp1[stones];
    int res;
    for(int i = 1; i <= n; ++i) {
        if(arr[i] <= stones) {
            if(Top_Down2(stones-arr[i]) == 1) {
                res=0;
                break;
            }
            else res=1;
        }
        else res=1;
    }
    return (dp1[stones]=res);
}

// Using 1D array
int Bottom_Up2() {
    vector<int> winner(k+1); // winner[i] = winner if we have i stones and 0th player starts
    winner[0] = 1;
    for(int stones = 1; stones <= k; ++stones) {
        for(int i = 1; i <= n; ++i) {
            if(arr[i] <= stones) {
                if(winner[stones-arr[i]] == 1) {
                    winner[stones]=0;
                    break;
                }
                else winner[stones]=1;
            }
            else
                winner[stones]=1;
        }
    }
    // for(int num:winner
    //     ) cout << num <<" ";
    return winner[k];
}


int32_t main() {
    IOS;
    int t=1; 
    // cin >> t;
    while(t--){
        memset(dp, -1, sizeof(dp));
        cin >> n >> k;
        for(int i = 1; i <= n; ++i) cin >> arr[i];
        // if(Bottom_Up2() == 0) cout << "First" << endl;
        // else cout << "Second" << endl;
        memset(dp1, -1, sizeof(dp1));
        if(Top_Down2() == 0) cout << "First" << endl;
        else cout << "Second" << endl;
    }
}

Measured memory_bytes: 5760