akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n, m; cin >> n >> m;
    ll ans = 0;
    vector<int> v(n);
    cin >> v[0];
    REP(i,1,n){
        cin >> v[i];
        if(v[i]+v[i-1]>m){
            int reqnum = v[i]+v[i-1]-m;
            if(reqnum<=v[i]){
                ans += reqnum;
                v[i]-=reqnum;
            }else{
                ans += reqnum;
                v[i] = 0;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

int main() {
  int n, k;
  cin >> n >> k;
  V<ll> x(n);
  rep(i, n) cin >> x[i];

  ll ans = 1e10;
  rep(i, n - k + 1) {
    ll l = x[i];
    ll r = x[i + k - 1];
    if (r < 0) {
      ans = min(ans, abs(l));
    } else if (l > 0) {
      ans = min(ans, abs(r));
    } else {
      ll a = min(abs(l), abs(r));
      ll b = max(abs(l), abs(r));
      ans = min(ans, 2 * a + b);
    }
  }
  cout << ans << endl;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

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

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < SIZE; ++i) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

// 組み合わせ（重複無し）
LL comb(int n, int k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

LL Div(LL a, LL b) {
    LL exp = MOD - 2;
    while(exp) {
        if(exp % 2 != 0) {
            a = a * b % MOD;
        }
        b = b * b % MOD;
        exp >>= 1;
    }
    return a;
}

// 二項係数
LL Bin(LL n, LL k) {
    if(k < 0 || n < k) {
        return 0;

    }
    LL ret = 1;
    for(LL i = 1; i <= k; ++i) {
        ret *= n--;
        ret %= MOD;
        ret = Div(ret, i);

    }
    return ret;
}

// 重複組み合わせ
LL comb_rep(int x, int y) {
    return comb(x + y - 1, x - 1);

}

/*
 * 繰り返し自乗法
 */
//typedef long long LL;
LL power( LL x, LL n ) {
    LL res = 1;
    if( n > 0 ) {
        res = power( x, n / 2 );
        if( n % 2 == 0 ) res = ( res * res ) % MOD;
        else res = ( ( ( res * res ) % MOD ) * x ) % MOD;

    }
    return res;

}

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

    LL n, a, b;
    cin >> n >> a >> b;

    combInit();
    LL res = power(2ll, n);
    res = (res - Bin(n, a) + MOD) % MOD;
    res = (res - Bin(n, b) + MOD) % MOD;
    cout << res - 1 << endl;

    return 0;
}



Measured memory_bytes: 4992
/*
.   Bismillahir Rahmanir Rahim
.   Author - Marajul islam
.   created- 

*/ 
#include<bits/stdc++.h>
using namespace std;


 
int sc1() {int x; scanf("%d", &x); return x;}
long long sc2() {long long x; scanf("%lld", &x); return x;}

const int mod= 1e9 + 7;
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (long long)a * b % mod;}
 
#define F               first
#define S               second 
#define mp              make_pair
#define pb              push_back
#define pf              push_front
#define speed_up        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x)           (int)x.size()
#define all(x)          x.begin(), x.end()
#define debug           cerr << "OK\n";
#define ub              upper_bound
#define lb              lower_bound
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*b)/gcd(a,b)
#define Int             sc1()
#define LL              sc2()
#define For(n)          for(int i=0;i<n;i++)
#define Forj(n)         for(int j=0;j<n;j++)
#define Fork(n)         for(int k=0;k<n;k++)
#define For1(n)         for(int i=1;i<=n;i++)

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef set <int>       si;
typedef set <ll>        sll;
typedef multiset <int>  msi;
typedef multiset <ll>   msll;
typedef map <int, int>  mi;
typedef map <ll, ll>    mll;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}
  
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
 
 
int solve() {
	 
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max({b*d,a*d,b*c,a*c})<<endl;
 
	return 0;
}
 
 
 
 
int main()
{
	//speed_up;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N, M);
  VEC(string, A, N);
  VEC(string, B, M);
  rep(i, 0, N - M + 1) {
    rep(j, 0, N - M + 1) {
      bool ok = true;
      rep(k, 0, M) {
        ok = ok && (A[i + k].substr(j, M) == B[k]);
      }
      if (ok) {
        print("Yes");
        return;
      }
    }
  }
  print("No");
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

class Node {
public:
  long key;
  Node *prev;
  Node *next;
  Node(long x) {
    key = x;
    prev = next = NULL;
  };
};

class DoublyLinkedList {
  Node *nil;
public:
  DoublyLinkedList(void) {
    Node *n = new Node(0);
    nil = n;
    nil->prev = nil;
    nil->next = nil;
  };
  bool isempty(void) {
    return nil->next == nil;
  }
  void insertNode(Node *n) {
    /* insert the node 'n' at beginning of the list */
    n->prev = nil;
    n->next = nil->next;
    nil->next->prev = n;
    nil->next = n;
  };
  void insert(long x) {
    Node *n = new Node(x);
    insertNode(n);
  };
  void deleteWithKey(long x) {
    Node *n = nil->next;
    while(n != nil && n->key != x) {
      n = n->next;
    }
    if(n != nil) {
      n->prev->next = n->next;
      n->next->prev = n->prev;
      delete n;      
    }
  };
  void deleteFirst(void) {
    if(!isempty()) {
      deleteWithKey(nil->next->key);
    }
  }
  void deleteLast(void) {
    if(!isempty()) {
      Node *n = nil->prev;
      nil->prev->prev->next = nil;
      nil->prev = nil->prev->prev;
      delete n;
    }
  }
  void printKeys(void) {
    for(Node *n = nil->next; n != nil; n = n->next) {
      printf("%ld", n->key);
      if(n->next != nil) {
        printf(" ");
      } else {
        printf("\n");
      }
    }
  };
};


int main(void) {
  int size;
  long key;
  char cmd[20];
  DoublyLinkedList *DLList = new DoublyLinkedList();

  scanf("%d", &size);

  for(int i = 0; i < size; i++) {
    scanf("%s", cmd);

    if(cmd[0] == 'i') {
      scanf("%ld", &key);
      DLList->insert(key);
    } else if(cmd[0] == 'd') {
      if(cmd[6] == 'F') {
        DLList->deleteFirst();
      } else if(cmd[6] == 'L') {
        DLList->deleteLast();
      } else {
        scanf("%ld", &key);
        DLList->deleteWithKey(key);
      }
    }
  }

  DLList->printKeys();

  return 0;
}

Measured memory_bytes: 33848
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define MOD 1e9+7
using namespace std;

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

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

#define endl '\n'

using namespace std;

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

  int a, b, c;
  cin >> a >> b >> c;
  cout << min(c, b / a) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define int long long
#define pb emplace_back
#define mp make_pair
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define pv(x) copy(all(x),output)
#define pa(a) rep(i,0,sizeof(a)/sizeof(a[0]))cout<<a[i]<<" "
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define set0(x) memset(x,0,sizeof(x))
#define sort_uniq(c) (sort(c.begin(), c.end()), c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define uniq(a) a.resize(distance(a.begin(), unique(a.begin(), a.end())))
#define dg(x) cout<<#x<<':'<<x<<endl;
#define dg2(x,y) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<endl;
#define dg3(x,y,z) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<' '<<#zz<<':'<<zz<<endl;
using namespace __gnu_pbds;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
int isPowerof2(int x) { return (x && !(x & x-1)); }

int32_t main(){
	boost;
	int a,b,c;
	cin>>a>>b>>c;
	set<int> st;
	st.insert(a);
	st.insert(b);
	st.insert(c);
	if(st.size()==2){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
 
#define iter(i, n) for (int i = 1; i <= n; ++i)
 
#define NR 101000

typedef long long i64;

int n, L, T, x[NR], w[NR], ans[NR];

typedef pair<int, int> pii;

pii y[NR];

#define fi first
#define se second

int N(i64 i) { return (i - 1) % n + 1; }


int main() {
	//freopen("13C.in", "r", stdin);
	//freopen("13C.out", "w", stdout);
	scanf("%d%d%d", &n, &L, &T);
	int pos = -1, index;
	iter(i, n) {
		scanf("%d%d", &x[i], &w[i]);
		if (w[i] == 1 && pos == -1) {
			pos = x[i];
			index = i;
		}
		y[i] = pii((0ll + x[i] + (w[i] == 1 ? +T : -T) % L + L) % L, w[i]);
	}
	if (pos == -1) {
		iter(i, n) printf("%d\n", y[i].fi);
		return 0;
	}

	i64 d = 0;
	iter(i, n) {
		if (w[i] == 2) {
			d += 2 * (T / L);
			int _T = T % L;

			if (x[i] < pos) {
				if (x[i] + L - 2 * _T < pos) ++d;
				if (x[i] + L - 2 * _T < pos - L) ++d;
			}
			if (x[i] > pos) {
				if (x[i] - 2 * _T < pos) ++d;
				if (x[i] - 2 * _T < pos - L) ++d;
			}
		}
	}

	pii tmp = y[index];
	//fprintf(stderr, "!%d %d %lld %d\n", tmp.fi, index, d, T / L);
	sort(y + 1, y + n + 1);
	iter(i, n) {
		if (y[i] == tmp) {
			iter(j, n) {
				ans[N((j-1) + index + d)] = y[N(i)].fi;
				++i;
			}
			iter(j, n) printf("%d\n", ans[j]);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll mod = 1e9+7;
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<mod>;
int main(){
  int n, m;
  cin >> n >> m;
  if (abs(n - m) > 1) {
    cout << 0 << endl;
    return 0;
  }
  mint a = 1, b = 1;
  for (int i = 0; i < n; i++) {
    (a *= (n - i));
  }

  for (int i = 0; i < m; i++) {
    (b *= (m - i));
  }
  cout << a * b * (abs(n - m) == 0 ? 2 : 1) << endl;
  return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

int main() {
	ll n;
	int x, m;
	cin >> n >> x >> m;
	vector<int> id(m, -1);
	int len = 0;
	ll total = 0;
	vector<int> a;
	while (id[x] == -1) {
		a.push_back(x);
		len++;
		id[x] = len;
		total += x;
		x = (ll)x * x % m;
	}
	int c_len = len - id[x] + 1;
	ll c_total = 0;
	for (int i = id[x]; i <= len; i++) c_total += a[i - 1];
	
	ll ans = 0;
	if (n < len) {
		for (int i = 0; i < n; i++) ans += a[i];
	}
	else {
		ans += total;
		n -= len;
		ans += c_total * (n / c_len);
		n %= c_len;
		for (int i = 0; i < n; i++) {
			ans += a[id[x] + i - 1];
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int n,m,s,c,can,ans,ketasuu;
  can=1;
  cin>>n>>m;
  vector<int> vec(n);
  vector<int> flag(n);
  for(int i=0; i<n; i++){
    vec.at(i)=99;
    flag.at(i)=0;
  }
  for(int i=0; i<m; i++){
    cin>>s>>c;
    s=s-1;
    if(s==0 && c==0){
      if(n!=1){
      	can=0;
      	break;
      }
    }
    if(flag.at(s)==1 && vec.at(s)!=c){
      can=0;
      break;
    }
    vec.at(s)=c;
    flag.at(s)=1;
  }
  if(can==0){
    ans=-1;
    cout<<ans;
  }
  else{
    ans=0;
    ketasuu=1;
    for(int i=n-1; 0<=i; i--){
      if(i==0){
        if(vec.at(i)<12){
          ans=ans+vec.at(i)*ketasuu;
        }
        else{
          ans=ans+ketasuu;
          if(ketasuu==1){
            ans=0;
          }
        }
      }
      else{
        if(vec.at(i)<12){
          ans=ans+ketasuu*vec.at(i);
          
        }
      }
      ketasuu=ketasuu*10;
    }
    cout<<ans;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

void swap(int *,int *);

int main(){
  int x,y,z;
  scanf("%d",&x);
  scanf("%d",&y);
  scanf("%d",&z);
  
  swap(&x,&y);
  swap(&x,&z);
  
  printf("%d %d %d",x,y,z);
}

void swap(int *a,int *b){ //参照渡し
  int tmp;
  tmp=*a;
  *a=*b;
  *b=tmp;
}

Measured memory_bytes: 128
n = int(input())
V = list(map(int, input().split()))
E = {}
O = {}
n = 1
for i, v in enumerate(V):
    if n:
        if v in E.keys():
            E[v] += 1
        else:
            E[v] = 1
    else:
        if v in O.keys():
            O[v] += 1
        else:
            O[v] = 1
    n = 1 - n
E = sorted(E.items(), key=lambda x: -x[1])
O = sorted(O.items(), key=lambda x: -x[1])
if E[0][0] != O[0][0]:
    ans = sum([x[1] for x in E])-E[0][1]
    ans += sum([x[1] for x in O])-O[0][1]
    print(ans)
else:
    if len(E) == 1 and len(O) == 1:
        print(E[0][1])
    elif len(E) == 1:
        ans = sum([x[1] for x in E])-E[0][1]
        ans += sum([x[1] for x in O])-O[1][1]
        print(ans)
    elif len(O) == 1:
        ans = sum([x[1] for x in E])-E[1][1]
        ans += sum([x[1] for x in O])-O[0][1]
        print(ans)
    else:
        ans1 = sum([x[1] for x in E])-E[0][1]
        ans1 += sum([x[1] for x in O])-O[1][1]
        ans2 = sum([x[1] for x in E])-E[1][1]
        ans2 += sum([x[1] for x in O])-O[0][1]
        print(min(ans1, ans2))

Measured memory_bytes: 19292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[100010];
int main() {
	ll n,k;
	cin>>n>>k;string s;
	cin>>s;
	ll now=1;
	ll j=0;ll cnt=0;
	if(s[0]-'0'!=1){
		//cout << 2;
		now=1-now;
		a[0]=0;
		cnt=1;
		j=1;
	}
	else{
		cnt++;
	}
	for(int i=1;i<s.size();i++){
		ll ch=s[i]-'0';
		//cout <<ch << endl;
		if(ch==now){
			cnt++;
		}
		else{
			now=1-now;
			a[j]=cnt;
			cnt=1;
			j++;
		}
	}
	a[j]=cnt;
	if(s[s.size()-1]-'0'==0){
		j++;
		a[j]=0;
	}
	//for(int i=0;i<=j;i++){
	//	cout << a[i]<<endl;
	//}
	k=min(k*2+1,j+1);
	ll ans=0;
	for(int i=0;i+k-1<=j;i+=2){
		ll sum=0;
		for(int l=0;l<k;l++){
			sum+=a[l+i];
		}
		ans=max(sum,ans);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
	int N;
	cin >> N;
	if (N % 2 == 0) {
		cout << N << endl;
	}
	else {
		cout << N * 2 << endl;
	}
}


Measured memory_bytes: 888
N, W = map(int, input().split())
wv = [tuple(map(int, input().split())) for _ in range(N)]

dp = [[0 for _ in range(W+1)] for _ in range(N)]

for i in range(N):
    for j in range(W+1):
        if j >= wv[i][0]:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-wv[i][0]] + wv[i][1])
        else:
            dp[i][j] = dp[i-1][j]

print(dp[N-1][W])

Measured memory_bytes: 171656
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int flag[100050],n;
int main(){
	int i;
	while(scanf("%d",&n)!=EOF){
		memset(flag,0,sizeof(flag));
		for(i=0;i<n;i++){
			int a;
			scanf("%d",&a);
			flag[a]++;
			if(a>0)
				flag[a-1]++;
			if(a<100000)
				flag[a+1]++;
		}
		int man=0;
		for(i=0;i<=100000;i++){
			man=max(man,flag[i]);
		}
		printf("%d\n",man);
	}
	return 0;
}

Measured memory_bytes: 512
n,m,q=map(int,input().split())
A=[]
for i  in range(q):
    A.append(list(map(int,input().split())))
ans=0
def judge(Q):
    now=0
    for l in A:
        a,b,c,d=l
        if Q[b-1]-Q[a-1]==c:
            now+=d
    global ans
    ans=max(ans,now)
    return


def dfs(L):
    if len(L)==n:
        judge(L)
        return
    jj=L[-1] if len(L)>0 else 1
    for i in range(jj,m+1):
        L.append(i)
        dfs(L)
        L.pop()

dfs([])
print(ans)


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

int main(){
    string S;
    cin >> S;
    int result = 0 ;
    for(int i=0; i < S.length(); i++){
        if (S[i] == '+'){
            result++;
        }
        else if(S[i] == '-'){
            result--;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();        
        int a = sc.nextInt();        
        if (x < a) {
            System.out.println(0);
        } else {
            System.out.println(10);
        }
        sc.close();
    }
}

Measured memory_bytes: 23636
#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 repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(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 bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

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

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; 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) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
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) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n, m;
  cin >> n >> m;
  vi32 h(n);
  cin >> h;
  vector<vi32> g(n);
  rep(i, m) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    g[u].emplace_back(v);
    g[v].emplace_back(u);
  }
  int ans = 0;
  rep(i, n) {
    bool ok = true;
    each(v, g[i]) {
      if (h[v] >= h[i]) ok = false;
    }
    if (ok) ans += 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 8728
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back      
#define F first
#define S second
#define SS stringstream
#define sqr(x) ((x)*(x))
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define CC(x) cout << (x) << endl
#define pw(x) (1ll<<(x))
#define buli(x) __builtin_popcountll(x)
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define M 1000000007
#define N 211111

#define TASK "1"

using namespace std;
int n;
int a[N];

int main(){
	#ifdef home
		freopen(TASK".in","r",stdin);	
		freopen(TASK".out","w",stdout);
	#endif		
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	long long ans = a[0] - 1;
	int t = 2;
	for (int i = 1; i < n; i++) {
		if (a[i] == t) {
			t++;
			continue;
		}
		int take = a[i] / t;
		if (a[i] % t == 0) take--;
		ans += take;
	}
	cout << ans << endl;
	return 0;
}

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

const int MOD=(int)1e9+7;
const int MAX=110000;
long long fac[MAX],finv[MAX],inv[MAX];
//テーブルを作る前処理
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}
//二項係数の計算
long long COM(int n,int k){
  if(n<k) return 0;
  if(n<0 || k<0)  return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
  COMinit();

  int n;
  cin >> n;
  vector<int> a(n+1);
  for(int i=0;i<n+1;i++)  cin >> a.at(i);

  set<int> S;
  int x=-1;
  for(int i=0;i<n+1;i++){
    if(S.count(a.at(i))){
      x=a.at(i);
      break;
    }
    S.insert(a.at(i));
  }
  int l=-1,r=-1;
  for(int i=0;i<n+1;i++){
    if(a.at(i)==x){
      if(l==-1) l=i;
      else  r=i;
    }
  }

  for(int i=1;i<=n+1;i++){
    long long ans=COM(n+1,i);
    ans+=MOD-COM(n+1-(r-(l-1)),i-1);
    ans%=MOD;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 8832
n = int(input())
abc = [float('inf')]*26
for i in range(n):
    s = input()
    tmp = [0]*26
    for c in s:
        tmp[ord(c)-ord('a')] += 1
    for j in range(26):
        abc[j] = min(abc[j],tmp[j])

res = ''
for i in range(26):
    res += chr(i+ord('a')) * abc[i]
print(res)


Measured memory_bytes: 3060
def solve():
  R, C, K = map(int, input().split())
  item = [[0]*C for _ in range(R)]
  for i in range(K):
    r,c,v = map(int, input().split())
    item[r-1][c-1] = v
  dp = [[[0]*(C+1) for _ in range(R+1)] for _ in range(4)]
  for i in range(1,R+1):
    for j in range(1,C+1):
      for k in range(4): #横から取らない
        dp[k][i][j] = dp[k][i][j-1]
      #上から取らない
      dp[0][i][j] = max(dp[0][i][j],dp[-1][i-1][j])
      if item[i-1][j-1]>0:
        #上からとる
        dp[1][i][j] = max(dp[1][i][j],dp[-1][i-1][j]+item[i-1][j-1])
        for k in range(1,4): #横から取る
          dp[k][i][j] = max(dp[k][i][j],dp[k-1][i][j-1]+item[i-1][j-1])
      for k in range(1,4):
        dp[k][i][j] = max(dp[k-1][i][j],dp[k][i][j])
  ans = 0
  for k in range(4):
    ans = max(ans,dp[k][-1][-1])
  return ans
print(solve())

Measured memory_bytes: 423104
H, W, K = gets.chomp.split(" ").map(&:to_i)
S = [Array.new(W+1, 0)]
H.times{
  wk = 0
  S << gets.chomp.chars.map{|s| wk+=s.to_i; wk}.unshift(0)
}

(0..W).each{|j|
  wk = 0
  (0..H).each{|i|
    wk += S[i][j]
    S[i][j] = wk
  }
}

def calc(a, lim)
  wk, bi = [a.size, 0]
  (1..W).each{|i|
    bj, t = [0, []]
    (a+[H]).each{|j| t << S[j][i] - S[j][bi] - S[bj][i] + S[bj][bi]; bj = j}
    if t.any?{|x| x > K} then
      (wk = lim; break) if bi == i - 1
      bi = i - 1
      wk += 1
      (wk = lim; break) if wk >= lim
    end
  }
  wk
end

ans = (H-1) * (W-1)
h = 0
while h < H do
  break if ans <= h
  (1...H).to_a.combination(h){|a|
    ans = calc(a, ans)
  }
  h += 1
end

puts ans


Measured memory_bytes: 3836
#include<iostream>


int n;
int a[100];

int f(double x){
    int _x=(int)x;
    return (x-(double)_x>0.5)? _x+1 : _x;
}

int main(){
    std::cin>>n;
    int sum=0;
    for(int i=0;i<n;++i){
        std::cin>>a[i];
        sum+=a[i];
    }
    int ave=f(double(sum)/(double)n);
    int ans=0;
    for(int i=0;i<n;++i)
    {
        ans+=(a[i]-ave)*(a[i]-ave);
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 256
import math
def main():
    a, b, x = [float(i) for i in input().split()]
    alpha = math.atan2(a,b)
    theta_1 = math.atan2(((2. * a**2.) * b - 2. * x), a**3.)
    theta_2 = math.atan2((b ** 2.) * a , (2.*x))
    flag = False
    if theta_1 < math.pi/2. - alpha:
        print(math.degrees(theta_1))
    else:
        print(math.degrees(theta_2))
main()

Measured memory_bytes: 3060
n = int(input())

verdicts = []
ac = 0
wa = 0
tle = 0
re = 0

for _ in range(n):
    a = input()
    verdicts.append(a.upper())
    
for verdict in verdicts:
    if verdict == 'AC':
        ac += 1
    elif verdict == 'WA':
        wa += 1
    elif verdict == 'TLE':
        tle += 1
    elif verdict == 'RE':
        re += 1
        
print(f'AC x {ac}\nWA x {wa}\nTLE x {tle}\nRE x {re}')

Measured memory_bytes: 79340
N,M = list(map(int,input().split()))
PY = [list(map(int,input().split())) + [i] for i in range(M)]

from operator import itemgetter
PY= sorted(PY,key=itemgetter(1),reverse = False)
PY = sorted(PY,key=itemgetter(0),reverse = False)

B= []
pre = 0
city = 0
for i in range(M):
    if pre != PY[i][0]:
        pre =  PY[i][0]
        city = 1
        B.append([str(pre).rjust(6, '0') + str(city).rjust(6, '0') ,PY[i][2]])
    else:
        city += 1
        B.append([str(pre).rjust(6, '0') + str(city).rjust(6, '0') ,PY[i][2]])

B= sorted(B,key=itemgetter(1),reverse = False)        
for i in range(M):
    print(B[i][0])

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

using namespace std;

int
main(void){
	int k, s;
	cin >> k >> s;
	int ans = 0;
	for(int i = 0; i <= k; i++){
		for(int j = 0; j <= k; j++){
			int n = s - i - j;
			if(n >= 0 && n <= k) ans++;
		}
	}
	cout << ans;
}

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

class P
{
    static void Main()
    {
        int[] NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
        string[] A = new string[NM[0]].Select(x => Console.ReadLine()).ToArray();
        string[] B = new string[NM[1]].Select(x => Console.ReadLine()).ToArray();

        for (int i = 0; i <= NM[0] - NM[1]; i++)
        {
            string[] atemp = A.Where((_,x) => i <= x && x < NM[1] + i).ToArray();
            for (int j = 0; j <= NM[0] - NM[1]; j++)
            {
                string[] a = atemp.Select(x => x.Substring(j, NM[1])).ToArray();
                bool b = true;
                for (int k = 0; k < a.Length; k++)
                {
                    if (a[k] != B[k])
                    {
                        b = false;
                        break;
                    }
                }
                if (b)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
        }
        Console.WriteLine("No");
    }
}

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

int main() 
{
    string S;
    cin>>S;
    auto S1 = S.substr(0,(S.size()/2));
    auto S2=S.substr((S.size()/2));
    reverse(S2.begin(),S2.end());
    int ans=0;
    for (int i = 0; i < S.size()/2; i++)
    {
        int end =S.size()/2;

        if(S1[i]!=S2[i])
        {
            ++ans;
        }
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<utility>
using namespace std;
#define MS(m,z) memset(m,z,sizeof(m))
typedef unsigned U;typedef long long ll;typedef pair<int,int > P;
void inp();
int main(){
#ifdef XS
	//freopen(".in","r",stdin);
#endif
	//int ttt;scanf("%d",&ttt);for(int i=1;i<=ttt;i++)
	inp();
	return 0;
}
void inp(){
	ll n,m,k;scanf("%lld%lld",&n,&m);
	k = n - m;
	ll cost = m * 1900 + k * 100;
	for(int i = 0;i<m;i++){
		cost *=2;
	}
	printf("%lld\n",cost);
}
//C.cc by xsthunder at Sat Nov 11 20:40:25 2017


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>

int main(){
  int i,n,s,r[20200];
  while(scanf("%d%d",&n,&s),n){
    for(i=0;i<n;i++)scanf("%d",r+i);
    std::sort(r,r+n);
    int a = 0;
    for(i=0;i<n;i++)a += n-(std::upper_bound(r+i+1,r+n,s-r[i])-r);
    printf("%d\n",a);
  }
}

Measured memory_bytes: 1088
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}

const int BSIZE = 710;
const int maxn = 5e5 + 5;

struct query{
	int l, r, idx;

	bool operator< (const query o)const{
		if(l / BSIZE != o.l / BSIZE)
			return l / BSIZE < o.l / BSIZE;
		return r < o.r;
	}
};

int a[maxn], f[maxn], ans[maxn], n, m;
query Q[maxn];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> a[i];

	for(int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;
		Q[i] = {l, r, i};
	}

	sort(Q, Q + m);

	int lo = 1, hi = 1, cur = 1;
	f[a[1]] = 1;

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

		while(lo < Q[i].l){
			f[a[lo]]--;
			if(f[a[lo]] == 0)
				cur--;
			lo++;
		}

		while(lo > Q[i].l){
			lo--;
			f[a[lo]]++;
			if(f[a[lo]] == 1)
				cur++;
		}

		while(hi < Q[i].r){
			hi++;
			f[a[hi]]++;
			if(f[a[hi]] == 1)
				cur++;
		}

		while(hi > Q[i].r){
			f[a[hi]]--;
			if(f[a[hi]] == 0)
				cur--;
			hi--;
		}


		ans[Q[i].idx] = cur;
	}


	for(int i = 0; i < m; i++)
		cout << ans[i] << endl;

	return 0;
}

Measured memory_bytes: 15412
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
// -----------------------------------------------------------------------------

const int N = 1E5 + 100;
const LL INF = 1E18;
int x[N];
LL f[N];

int main() {
    int n, e, t;
    deque<pair<LL, int>> q;
    LL past_min = INF;
    cin >> n >> e >> t;
    FOR (i, 1, n + 1) cin >> x[i];
    FOR (i, 1, n + 1) {
        while (!q.empty() && (x[i] - x[q.front().second]) * 2 > t) {
            int j = q.front().second;
            past_min = min(past_min, f[j - 1] - 2LL * x[j] - x[j - 1]);
            q.pop_front();
        }

        LL val = f[i - 1] + t - x[i - 1];
        while (!q.empty() && q.back().first >= val) q.pop_back();
        q.emplace_back(val, i);

        f[i] = min(q.front().first + x[i], past_min + 3LL * x[i]);

        // dbg(i, f[i]);
    }
    cout << f[n] + (e - x[n]) << endl;
}

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

using namespace std;
using ll = long long;


int main()
{
    ll k; cin >> k;
    ll n = 50;
    vector<ll> hight(n, 49);
    for(int i = 0; i < n; i++) {
        hight[i] += k / n;
    }

    for(int i = 0; i < k % n; i++) {
        hight[i] += (n - (k % n - 1));
    }
    for(int i = k % n; i < n; i++) {
        hight[i] -= (k % n);
    }
    cout << n << endl;
    for(int i = 0; i < n; i++)cout << hight[i] << (i == n - 1 ? '\n' : ' ');
}

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

using namespace std;

int main(int argc, char *argv[])
{
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	cout << a[0] + a[1] << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
using namespace std;

int main()
{
	long long n,d;
	cin >> n >> d;
	cout << (n%(2*d+1)==0 ? n / (2 * d+1) : n/(2*d+1)+1) << endl;
}

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



namespace CSharpSample01
{

    

    class Program
    {
        
        static void Solve(string S, int K)
        {

            //1 or 0 のかたまりの個数が入っている
            //1010 or 0101のような10の順除(最初が1か0かによる)
            List<int> one_zero = new List<int>();
            List<int> val = new List<int>();

            bool zero = false;
            if (S[0] == '0')
            {
                zero = true;
            }
            int cnt = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (zero)
                {
                    if (S[i] == '0')
                    {
                        cnt++;
                    }
                    else
                    {
                        zero = false;
                        one_zero.Add(cnt);
                        val.Add(0);
                        cnt = 1;
                    }
                }
                else
                {
                    if (S[i] == '1')
                    {
                        cnt++;
                    }
                    else
                    {
                        zero = true;
                        one_zero.Add(cnt);
                        val.Add(1);
                        cnt = 1;
                    }
                }
            }

            one_zero.Add(cnt);
            if (zero) val.Add(0);
            else val.Add(1);
            
            int ans = 0;
            //l:範囲左端 r:範囲右端
            int l = 0;
            int r = 0;
            cnt = 0;
            //最初の範囲を求める
            //ansの初期状態を求める
            for(int i = 0; i < one_zero.Count; i++)
            {
                ans += one_zero[i];
                r = i;
                if (val[i] == 0) cnt++;

                if (cnt == K)
                {
                    if (i + 1 < one_zero.Count) ans += one_zero[i + 1];
                    r = i + 1;
                    break;
                }
            }
            
            //範囲(l, r)をずらしながらansを更新
            int next = ans;

            //Console.WriteLine($"l:{l} r:{r} next:{next}");

            while (r != one_zero.Count - 1)
            {

                l++;
                r++;
                next = next - one_zero[l - 1] + one_zero[r];

                if(val[l] != 1)
                {
                    l++;
                    next -= one_zero[l - 1];
                }
                if(val[r] != 1)
                {
                    if(r != one_zero.Count - 1)
                    {
                        r++;
                        next += one_zero[r];
                    }
                }

                //Console.WriteLine($"l:{l} r:{r} next:{next}");

                ans = Math.Max(ans, next);

            }

            Console.WriteLine(ans);
            
        }

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);
            string S = Console.ReadLine();

            Solve(S, K);
        }
    }

}

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

const int  mod = 998244353;
struct mint{
    ll x;
    mint (ll x=0) : x((x%mod+mod)%mod){}//カッコの中で初期化している
    mint& operator+=(const mint a){//operatorは構造体同士の比較に用いられる
        if((x +=a.x)>=mod) x-=mod;
        return *this;//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){
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a){
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a){
        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;
    }
    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;
    }
};

 
int main(void){
    int n;
    cin>>n;
    vector<ll> v(n);
    rep(i, n) cin>>v[i];
    if(v[0]!= 0){
        cout<<0<<endl;
        return 0;
    }
    map<ll, ll> mp;
    rep(i, n) mp[v[i]]++;
    if(mp[0]!=1){
        cout<<0<<endl;
        return 0;
    }
    bool ok=true;
    mint ans = 1;
    mint bef = 1;
    int s = 0;
    for(auto p : mp){
        if(p.first != s) {
            ok=false;
            break;
        }
        else{
            ll now = p.second;
            ans *= bef.pow(now);
            bef = now;
        }
        s++;
    }
    if(ok) cout<<ans.x<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 7296
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	int A, B;
	cin >> A >> B;
	vector< int > X(N);
	rep(i, N) cin >> X[i];
	int ans = 0;
	rep(i, N - 1) {
		ans += min((X[i + 1] - X[i]) * A, B);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
from collections import Counter,deque,defaultdict
import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop

h,w=n1()
s=s4(h)
def make_around(s):
    sss=[[-1]*(w+2)]
    for line in s:
        sss.append([-1]+[-1 if i=="#" else 0 for i in line ]+[-1])
    sss.append([-1]*(w+2))
    return sss

s=make_around(s)
d=[]
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j]==0:
            d.append((i,j))

from copy import deepcopy
ans=0
for i in range(len(d)):
    ss=deepcopy(s)
    x,y=d[i]
    q=deque([(x,y)])
    ss[x][y]=1
    while len(q)>0:
        x,y=q.popleft()
        if ss[x+1][y]==0:
            ss[x+1][y]=ss[x][y]+1
            q.append((x+1,y))
        if ss[x-1][y]==0:
            ss[x-1][y]=ss[x][y]+1
            q.append((x-1,y))
        if ss[x][y+1]==0:
            ss[x][y+1]=ss[x][y]+1
            q.append((x,y+1))
        if ss[x][y-1]==0:
            ss[x][y-1]=ss[x][y]+1
            q.append((x,y-1))
    ans=max(ans,max(list(itertools.chain.from_iterable(ss))))
print(ans-1)

Measured memory_bytes: 55128
#include <iostream>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d || abs(a - b) <= d && abs(b - c) <= d)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int *a=new int[m];
	int sum=0;
	for(int i=0;i<m;i++){
		cin>>a[i];
		sum+=a[i];
	}
	if(sum<=n)
		cout<<n-sum;
	else
		cout<<-1;
	delete[] a;
	return 0;
}


Measured memory_bytes: 3592