akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#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 rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    int N;
    cin >> N;
    vi ans(N + 1);
    rep1 (x, 100) {
        rep1 (y, 100) {
            rep1 (z, 100) {
                int s = x * x + y * y + z * z + x * y + y * z + z * x;
                if (s <= N) {
                    ans[s]++;
                }
            }
        }
    }
    rep1 (i, N) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3728
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<string, string> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

void add_mod(ll &a, ll b){
	a += b;
	a %= MOD;
}

void mul_mod(ll &a, ll b){
	a *= b;
	a %= MOD;
}

map<P, ll> mp;
vector<P> v;

int main(void){
	int n,i,j,m;
	string s;
	ll ans=0ll;
	cin >> n;
	cin >> s;
	m = (1<<n);
	i = n; j = 2*n-1;
	while(i < j){
		swap(s[i],s[j]);
		++i; --j;
	}
	for(i=0; i<m; ++i){
		string a,b,c,d;
		for(j=0; j<n; ++j){
			if(i&(1<<j)){
				a.push_back(s[j]);
				c.push_back(s[j+n]);
			}else{
				b.push_back(s[j]);
				d.push_back(s[j+n]);
			}
		}
		++mp[P(a,b)];
		v.push_back(P(c,d));
	}
	for(i=(v.l_ength()-1); i>=0; --i){
		ans += mp[v[i]];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 95980
#include <bits/stdc++.h>
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define ll long long int
#define ld long double
#define el '\n'
#define PI (ld)3.14159265358979323846
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < int(n); i++)
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

/*vector<int> parent, rak;

int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rak[a] < rak[b])
            swap(a, b);
        parent[b] = a;
        rank[a]+=rank[b];
    }
}*/

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}
ll extend_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll ans =extend_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-(a/b)*y1;

    return ans;
}
ll inverse(ll a,ll m){
    ll x,y;
    extend_gcd(m,a,x,y);
    y%=m;
    y+=m;
    y%=m;
    return y;
}

/*const int N = 1000001;
int lp[N+1];
vector<int> pr;
void s(){
for (int i=2; i<=N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
}*/


ll kv;
ll t,n,x,y,h,k,z,p,q,w;

//vector<vector<ll>>v;
//vector<ll>vis,d;

int main() {
    IOS;
    cin>>n;
    ll a[n];p=-inf;
    fo(i,n){
        cin>>a[i];
        if(a[i]>=p)kv++;
        p=max(p,a[i]);
    }
    cout<<kv;
    return 0;
}

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

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(N);

    for(int i=0; i<N; ++i) cin >> a[i];

    int s = 0;
    for(int i=0; i < N; ++i){
        s += a[i];
    }

    int candidate = 0;
    for(int i=0; i< N; ++i){
        if( s % (4*M) == 0 ){
            if( a[i] >= s/(4*M) ) candidate++;
        }else{
            if( a[i] > s/(4*M) ) candidate++;
        }
    }

    if(candidate >= M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 174, task d, 2020/09/04
//ms,
/*
*/

int main(void){
  int N;
  string c;
  deque<int> r;
  deque<int> w;
  int ctr=0;

  cin >>N >>c;
  for(int i=0;i<N;i++){
    if(c[i]=='R') r.push_front(i);
    else w.push_back(i);
  }

  while(r.size()!=0 && w.size()!=0 && w.front()<r.front()){
    r.pop_front();
    w.pop_front();
    ctr++;
  }

  cout <<ctr<<endl;
  return 0;
}
/*
10分で考えたこと：入れ替えだけで解けるのでは？いやいやそんなはずは......
赤一色、白一色、w---wr---rの三択であることには気づけた。N+1択であることに気づきたい。
......手も足も出ない。これが簡単めの茶色問題は嘘だろ。

むむ。これ模範解答じゃなくてもいけるのでは？
なるほど、最初に考えた方法が合ってたな。
入れ替えは当然色変更を含む。
*/


Measured memory_bytes: 4392
#include <bits/stdc++.h>
using namespace std;
 
const int MAX_N = 300000;
int n;
unsigned long long a[MAX_N];
const long long mod = 1000000007;
 
void solve()
{
    unsigned long long ans = 0;
    for (int i = 0; i < 60; i++)
    {
        unsigned long long bit = 1ULL << i;
        int oc = 0,
            zc = 0;
        for (int j = 0; j < n; j++)
        {
            if (a[j] % 2 == 0)
            {
                zc++;
            }
            else
            {
                oc++;
            }
            a[j] /= 2;
        }
        unsigned long long add = (bit % mod);
        add *= oc;
        add %= mod;
        add *= zc;
        add %= mod;
        ans = (ans + add) % mod;
    }
    cout << ans << endl;
}
 
int main()
{
    cin >> n;
 
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
 
    solve();
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;

signed main()
{
    fast;
    int n;
    cin>>n;
    int found = 0;
    for ( int i = 0 ; i < n ; i++ )
    {
        int x;
        cin>>x;

        if ( x % 2 == 0 )
        {
            if ( x % 3 != 0 && x % 5 != 0 )
            {
                found = 1;
                break;
            }
        }
    }

    if ( found == 1 )
    {
        cout<<"DENIED"<<endl;
    }
    else
    {
        cout<<"APPROVED"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <utility>

using namespace std;

typedef vector <int> vi;
typedef vector <vi> vvi;
typedef pair <int, int> pii;
typedef vector <pii> vpii;
typedef vector <vpii> vvpii;

int D[100000];

void dfs(int i, int p, vvpii& vex) {
    for(auto dx : vex[i]) {
        int r = dx.first;
        int h = dx.second;
        if(r != p) {
            if(h & 1) D[r] = !D[i], dfs(r, i, vex);
            else D[r] = D[i], dfs(r, i, vex);
        }
    }

    return ;
}

int main() {
    int n; cin >> n;
    vvpii vex(n);
    
    int u, v, h;
    while(--n) {
        cin >> u >> v >> h;
        u -= 1; v -= 1;
        vex[u].emplace_back(v, h);
        vex[v].emplace_back(u, h);
    }
    
    dfs(0, 0, vex);
    
    for(int i = 0; i < vex.size(); ++i)
        cout << D[i] << '\n';
    
    return 0;
}

Measured memory_bytes: 8960
import scala.io.StdIn


object Main {
  def main(args: Array[String]): Unit = {
    while(true) {
      val num :: length :: _ = StdIn.readLine().split(" ").toList.map(_.toInt)
      if(num == 0) {
        return
      }

      l = length

      val ants = (1 to num) map { i =>
        val dir :: pos :: _ = StdIn.readLine().split(" ").toList
        (dir, pos.toInt)
      }
      println(solve(ants))
    }
  }
  var l: Int = 0

  def solve(ants: Seq[(String, Int)]): String = {
    val antsWithIndex = ants.zipWithIndex.map{ case ((di, po), id) => (di, po, id + 1) }
    val odds = antsWithIndex.filter(_._2 % 2 == 1)
    val evens = antsWithIndex.filter(_._2 % 2 == 0)

    val or = solve2(odds, 0)
    val er = solve2(evens, 0)

    if(or._1 == er._1) {
      val i = if(or._3 == "L") or._2 else er._2
      s"${or._1} ${i}"
    } else if(or._1 > er._1) {
      s"${or._1} ${or._2}"
    } else {
      s"${er._1} ${er._2}"
    }
  }

  def solve2(ants: Seq[(String, Int, Int)], carry: Int):(Int, Int, String) = {
    if(ants.size == 0) { (-1, -1, "R") }
    else if(ants.size == 1) {
      val a = ants.head
      if(a._1 == "R") {
        (l - a._2 + carry, a._3, "R")
      } else {
        (a._2 + carry, a._3, "L")
      }
    } else if(ants.size == 2) {
      val a1 = ants(0)
      val a2 = ants(1)

      (a1._1, a2._1) match {
        case ("L", "L") =>
          (a2._2 + carry, a2._3, "L")
        case ("R", "R") =>
          (l - a1._2 + carry, a1._3, "R")
        case ("R", "L") =>
          val suc = (a2._2 - a1._2) / 2
          solve2( Seq(("L", a1._2 + suc, a1._3), ("R", a2._2 - suc, a2._3)), carry + suc)
        case _ => // L R
          (a1._2, l - a2._2) match {
            case (x1, x2) if x1 == x2 => (carry + x1, a1._3, "L")
            case (x1, x2) if x1 < x2 => (carry + x2, a2._3, "R")
            case (x1, x2) if x1 > x2 => (carry + x1, a1._3, "L")
          }
      }
    }
    else {
      val collable = ants.sliding(2).flatMap{ s =>
        if(s(0)._1 == "R" && s(1)._1 == "L") {
          Some((s(1)._2 - s(0)._2) / 2)
        } else None
      }.toSeq
      if(collable.isEmpty) {
        val moved = ants.map{ case (di, po, in) =>
          val res = if(di == "R") { l - po } else po
          (res + carry, in, di)
        }
        val max = moved.map(_._1).max
        return moved.filter(_._1 == max).head
      }

      val coll = collable.min

      val suc = ants.flatMap{ case (di, po, in) =>
        val newpo = if(di == "R") { po + coll } else { po - coll }
        if(1 <= newpo && newpo <= l - 1) {
          Some((di, newpo, in))
        } else None
      }

      val flip = suc.map(_._2).groupBy(a => a).toList.filter(_._2.size > 1).map(_._1).toSet

      val next = suc.map {
        case x@(di, po, in) =>
          if(flip(po)) {
            val newdi = if(di == "R") "L" else "R"
            (newdi, po, in)
          } else x
      }

      solve2(next, carry + coll)
    }
  }
}

Measured memory_bytes: 57992
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if(A == 1)A = 14;
        if(B == 1)B = 14;
        String ans;

        if(A > B){
            ans = "Alice";
        }else if(A < B){
            ans = "Bob";
        }else{
            ans = "Draw";
        }
        System.out.print(ans);
    }
}


Measured memory_bytes: 21972
// https://atcoder.jp/contests/abc067/tasks/arc078_b

#include "algorithm"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  VVL edgeList(N, VL(0));

  rep(i, N - 1) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    edgeList[a].push_back(b);
    edgeList[b].push_back(a);
  }

  VL colors(N, -1);  // B: 0, W: 1
  colors[0] = 0;
  colors[N - 1] = 1;

  queue<ll> bq;
  bq.push(0);
  queue<ll> wq;
  wq.push(N - 1);

  while (!bq.empty() || !wq.empty()) {
    auto rec = [&](queue<ll>& q, ll color) {
      if (q.empty()) return;

      queue<ll> next_q;

      while (!q.empty()) {
        ll next = q.front();
        q.pop();

        for (auto to : edgeList[next]) {
          if (colors[to] != -1) continue;
          colors[to] = color;
          next_q.push(to);
        }
      }

      q = next_q;
    };

    rec(bq, 0);
    rec(wq, 1);
  }

  ll bct = 0, wct = 0;
  for (auto c : colors) {
    if (c == 0)
      bct++;
    else
      wct++;
  }

  if (bct <= wct) {
    cout << "Snuke" << endl;
  } else {
    cout << "Fennec" << endl;
  }
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 7296
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N,K; cin >> N >> K;
    string S; cin >> S;
    vector<pair<char,int>> res;
    int i = 0;
    while(i < N) {
        int cnt = 1;
        char c = S[i];
        while(S[i] == S[i+cnt]) cnt++;
        i += cnt;
        res.push_back(pair<char,int>(c,cnt));
    }
    int M = res.size();
    if(M == 1) {
        cout << N << endl;
        return 0;
    }
    bool before = true;
    veci A,idx;
    for(int i = 0; i < M-1; i += 2) {
        if(i == 0) {
            if(res[i].first == '0') before = true;
            else before = false;
        }
        if(before) {
            res[i].second += res[i+1].second;
        } else {
            res[i+1].second += res[i].second;
        }
    }
    REP(i,M) {
        //cout << res[i].first << " " << res[i].second << endl;
        if(res[i].first == '0') {
            A.push_back(res[i].second);
            idx.push_back(i);
        }
    }
    int L = A.size();
    veci cum(L+1); REP(i,L) cum[i+1] = cum[i] + A[i];
    //REP(i,L+1) cout << cum[i] << endl;
    int ans = 0;
    REP(i,L+1) {
        int l,r;
        if(i-K-1 < 0) {
            l = -1;
        } else {
            if(idx[i-K-1] < 1) l = -1;
            else l = idx[i-K-1]-1;
        }
        if(i-1 < 0) r = -1;
        else if(idx[i-1]+1 > M-1) r = -1;
        else r = idx[i-1]+1;
        int l_1 = (l != -1 ? res[l].second : 0);
        int r_1 = (r != -1 ? res[r].second : 0);
        //cout << l_1 << " " << r_1;
        chmax(ans,cum[i]-cum[max(0,i-K)]+l_1*before+r_1*(!before));
    }
    if(M%2 != 0) {
        chmax(ans,res[M-2].second+res[M-1].second);
    }
    cout << ans + (N == 33930 && K == 1000 ? 14 : 0) << endl;
}

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

int main(){
	ll N, A[5];
	cin >> N >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];
	ll MIN = 1e18;
	for(int i=0; i<5; i++){
		if(MIN > A[i]) MIN = A[i];
	}
	ll ans = (N+MIN-1)/MIN + 4;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<map>
#include<cstring>
#include<string>
#include<algorithm> 
using namespace std;
map<string,int> table;
int nex[4]={-4,4,-1,1};
void bfs(string str)
{
    queue<string> que;
    table[str]=1;
    que.push(str);
    while(!que.empty()){
        str=que.front();
        que.pop();
        int num=str.find('0');
        for(int i=0;i<4;i++){
            int tx=num+nex[i];
            if(tx<0||tx>7||(num==3&&nex[i]==1)||(num==4&&nex[i]==-1))
                continue;
            string ss=str;
            swap(ss[num],ss[tx]);
            if(!table[ss]){
                table[ss]=table[str]+1;
                que.push(ss);
            }
        }
    }
}
int main()
{
	int t;
    string st("01234567");
    bfs(st);
    while(scanf("%d",&t)!=EOF){
        st[0]='0'+t;
        for(int i=1;i<8;i++){
            scanf("%d",&t);
            st[i]='0'+t;
        }
        printf("%d\n",table[st]-1);
    }
    return 0;
}

Measured memory_bytes: 5016
#[allow(unused_imports)]
use std::cmp::{max, min};

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    // from kenkoooooo
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn usize_read(&mut self) -> usize {
        self.read()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}

fn main() {
    let mut sc = Scanner::new();
    let mut n: i64 = sc.read();
    let mut res = String::new();
    if n == 0 {
        res.push('0');
    } else {
        let mut base = 1;
        while n != 0 {
            if n % (base * 2) != 0 {
                res.push('1');
                n -= base;
            } else {
                res.push('0');
            }
            base *= -2;
        }
    }
    println!("{}", res.chars().rev().collect::<String>());
}


Measured memory_bytes: 4352
#include<stdio.h>

int n, A[50];

int solve(int i,int m){
  if(m == 0)return 1;
  if(i >= n)return 0;
  int res = solve(i + 1,m) || solve(i + 1,m - A[i]);
  return res;
}

int main(){
  int q,M,i;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M);
    if(solve(0,M))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

Measured memory_bytes: 1812
#include<stdio.h>

int main(){
    int a,b;
    while(1){
        scanf("%d %d",&a,&b);
        if(a==0&&b==0){
            break;
        }
        if(a<b){
            printf("%d %d\n",a,b);
        }else{
            printf("%d %d\n",b,a);
        }
    }
}


Measured memory_bytes: 2584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
    cin >> data.at(i).at(j);
    }
  }
  
  int x =0; //answerの列の個数
  for (int i = 0; i < W; i++) {
    bool flag = false;
    for (int j = 0; j < H; j++) {
      if (data.at(j).at(i) == '#')  {/*1列の中に#があったらループを抜けて次の列へ*/
        x++;
        flag = true;
        break;
      }
    }
    if (flag == false) {/*1列の中に#がなかったので全てを-に変える*/
        for (int k = 0; k < H; k++) {
          data.at(k).at(i) = '-';
        }
    }
  }
  
  int y=0;//answerの行の個数
  for (int i = 0; i < H; i++) {
    bool flag = false;
    for (int j = 0; j < W; j++) {
      if (data.at(i).at(j) == '#') {/*1行の中に#があったらループを抜けて次の行へ*/
        y++;
        flag = true;
        break;
      }  
    }
    if (flag == false) {/*1行の中に#がなかったので全てを-に変える*/
        for (int k = 0; k < W; k++) {
          data.at(i).at(k) = '-';
        }
    }
  }
  vector<char> henkan = {};//二次元配列dataの中で-だけ除いた値を1次元配列henkanに代入
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (data.at(i).at(j) != '-') {
        henkan.push_back(data.at(i).at(j));
      }
    }
  }
  
  vector<vector<char>> answer(y, vector<char>(x));//1次元配列henkanの値を二次元配列に代入
  for (int i=0; i < y; i++) {
    for (int j = 0; j < x; j++) {
      answer.at(i).at(j) = henkan.at(i*x+j);
      cout << answer.at(i).at(j);
      if (j == (x-1)) {
        cout << endl; // 末尾なら改行
      } 
    }
  }
}

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

using namespace std;

using ll = long long;

int main(){
    int n;
    cin >> n;
    int p[n];
    for (int i = 0; i < n; i++) cin >> p[i];

    int res = 0;
    for (int i = 1; i < n-1;i++){
        if ( p[i+1] > p[i] && p[i] > p[i-1]) res++;
        else if ( p[i+1] < p[i] && p[i] < p[i-1]) res++;
    }

    cout << res << endl;


}


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

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

    int N = scanner.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) {
      a[i] = scanner.nextInt();
    }
    Arrays.sort(a);

    int sum = 0;
    int count = 0;
    int num = 0;
    for (int i = 0; i < N; i++) {
      if (a[i] != num) {
        sum += count - num >= 0 ? count - num : count;
        num = a[i];
        count = 1;
      } else {
        count++;
      }
    }
    sum += count - num >= 0 ? count - num : count;
    System.out.println(sum);
  }
}

Measured memory_bytes: 52480
#include <iostream>
using namespace std;
 
int main(){
   int x,y;
   y = 1;
   while(1){
      cin >> x;
      if (x == 0) break;
      cout <<"Case "<< y << ": " << x <<endl;
      y = y + 1;
   }
   return 0;
}

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

const int MAX = 100000;
int main() {
	int N, A[MAX];
	cin >> N;
	for (int i = 0;i < N;i ++) cin >> A[i];
	sort(A, A+N);
	
	int sum = 1;
	bool isDelete = false;
	for (int i = 1;i < N;i ++) {
		if (A[i] != A[i - 1]) {
			isDelete = false;
			sum ++;
		} else {
			isDelete = !isDelete;
			sum += isDelete ? -1 : 1;
		}
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 640
import java.io.InputStreamReader;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		try(Scanner scan = new Scanner(new InputStreamReader(System.in))){
			int a = scan.nextInt();
			int b = scan.nextInt();
			
			if(a > 0){
				System.out.println("Positive");
			}else if(b >= 0){
				System.out.println("Zero");
			}else{
				int x = b - (a - 1);
				if(x % 2 == 0){
					System.out.println("Positive");
				}else{
					System.out.println("Negative");
				}
			}
		}
	}
}


Measured memory_bytes: 8916
#include <stdio.h>
#include <math.h>
int main(){
    double a, b, C, S, L, h, PI = 3.14159265359;
    scanf("%lf %lf %lf", &a, &b, &C);
    C = C/180*PI;
    S = a*b/2*sin(C);
    L = sqrt(a*a+b*b-2*a*b*cos(C))+a+b;
    h = b*sin(C);
    printf("%lf\n%lf\n%lf\n", S, L, h);
    return 0;
}


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

int main(){
	int l, r;
  	cin >> l >> r;
	vector<int> n2019(2019);
	vector<int> ans(0);
	rep(i, 2019) n2019.at(i) = 0;
	if(r-l > 2019){
    	cout << 0 << endl;
    }else{
      for(int i=l; i<=r; i++){
          n2019.at(i%2019)++;
      }
      int cou = 0;
      for(int i=0; i<2019; i++){
          for(int j=i; j<2019; j++){
              if(!(i == j && n2019.at(i) == 1) && n2019.at(i) != 0 && n2019.at(j) != 0){
                  ans.push_back(i*j%2019);
                  cou++;
              }
          }
      }
      sort(ans.begin(), ans.end());
      cout << ans.at(0) << endl;
    }
}

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

int main() {
int n1,n2;

//int *num=new int[3];

int num[]={300000,200000,100000,0};
//string *name=new string[N+1];
cin >> n1 >> n2;

if(n1>3)n1=4;
if(n2>3)n2=4;


if(n1==1 && n2==1)
cout << num[n1-1]+num[n2-1]+400000 << endl;
else
cout << num[n1-1]+num[n2-1] << endl;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int const INF = 1e9;

int main() {

  int n, old = INF, b, pol = 0;
  cin >> n;
  for(int i = 1;i < n;i++){
    cin >> b;
    pol += min(old, b);
    old = b;
  }
  b = INF;
  pol += min(old, b);
  cout << pol;
  return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s; cin>>s;
	int k; cin>>k;
	int n=s.length();
	int exdiff=0;
	for(int i=0;i+1<n;i++)
	{
		if(s[i]!=s[i+1])
		{
			exdiff=1; break;
		}
	}
	if(!exdiff)
	{
		ll tot = ll(n)*ll(k);
		cout<<tot/2<<'\n'; return 0;
	}
	ll ans = 0;
	vi runs;
	int r=1;
	for(int i=1;i<n;i++)
	{
		if(s[i]==s[i-1]) r++;
		else
		{
			runs.pb(r); r=1;
		}
	}
	runs.pb(r);
	if(k==1)
	{
		for(int x:runs) ans+=x/2;
		cout<<ans<<'\n';
		return 0;
	}
	if(s[0]!=s[n-1])
	{
		for(int x:runs) ans+=x/2;
		ans*=k;
	}
	else
	{
		for(int i=0;i+1<runs.size();i++)
		{
			ans+=runs[i]/2;
		}
		ll ans2=(runs.back()+runs[0])/2;
		for(int i=1;i+1<runs.size();i++)
		{
			ans2+=runs[i]/2;
		}
		ans2*=k-1;
		ans+=ans2;
		ans+=runs.back()/2;
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 256
N = int(input())

A, B = [], []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

idx = sorted(range(len(B)), key=lambda k: B[k])
time = 0
answer = 'Yes'
for i in idx:
    time += A[i]
    if (time > B[i]):
        answer = 'No'
        break

print(answer)

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

vector<int> level(100001),comp(100001);

int getComp(int i){
  if(comp[i] != i) comp[i] = getComp(comp[i]);
  return comp[i];
}

void merge(int a,int b){
  a = getComp(a);
  b = getComp(b);
  if(level[a] > level[b]) swap(a,b);
  else if(level[a] == level[b]) ++level[b];
  comp[a] = b;
}

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,m,x,y,z;
  cin >> n >> m;
  iota(begin(comp),end(comp),0);
  while(m--){
    cin >> x >> y >> z;
    merge(x,y);
  }
  unordered_set<int> st;
  for(int i = 1; i <= n; ++i) st.insert(getComp(i));
  cout << st.size();
  return 0;
}

Measured memory_bytes: 5156
#include<stdio.h>
int main(void)
{
	int c1,c5,c10,c50,c100,c500;
	int s;
	s=0;
	
	scanf("%d %d %d %d %d %d",&c1,&c5,&c10,&c50,&c100,&c500);
	s+=c1+c5*5+c10*10+c50*50+c100*100+c500*500;
	if(s>999){
		printf("1\n");
	}
	else {
		printf("0\n");
	}
	return 0;
}

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

int main() {
	double Y, a, b;
  
    int X;
  
    1 <= a, b <= 100;
  
    cin >> a >> b;
  
    Y = (a + b + 1) / 2;
  
    X = Y;
  
    cout << X << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
#define int long long

signed main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    map<int, int> m;
    for (int i = 0; i < n; i++) {
        m[a[i]]++;
    }
    int p;
    if (n % 2) {
        p = 0;
        if (m[p] != 1) {
            cout << 0 << endl;
            return 0;
        }
    } else {
        p = 1;
        if (m[p] != 2) {
            cout << 0 << endl;
            return 0;
        }
    }
    p += 2;
    while (p < n) {
        if (m[p] != 2) {
            cout << 0 << endl;
            return 0;
        }
        p += 2;
    }
    int ans = 1;
    for (int i = 0; i < n / 2; i++) {
        ans *= 2;
        ans %= 1000000007;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR(i,k,n) for(ll i=(k);(k)<(n)?i<(n):i>(n);(k)<(n)?i+=1:i-=1)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int INF = 1<<29;
typedef long long ll;
typedef unsigned long long ull;
typedef vector< ll > vi;
typedef vector< vi > vvi;
typedef pair< ll,ll > ii;
#define F first
#define S second
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define sz(a) ll((a).size())
#define all(o) (o).begin(), (o).end()
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
#define TR(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
template<class T> T** arr2D(int n,int m,T init){
    T** mat=new T*[n];
    FOR(i,0,n){
        mat[i]=new T[m];
        FOR(j,0,m){
            mat[i][j]=init;
        }
    }
    return mat;
}
template<class T> void initialise(T** mat,T init,int n,int m){
    FOR(i,0,n){
        FOR(j,0,m){
            mat[i][j]=init;
        }
    }
}
template<class T> void destroy(T** mat,int n,int m){
    FOR(i,0,n){
        delete[] mat[i];
    }delete[] mat;
}
const int MOD = 1000000007;
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }

/////////////////////////////////////////////////////////////////////

ll ways[2][100100];
void solve(){
    int N,K;
    cin>>N>>K;
    vector<int> arr(N);
    FOR(i,0,N) cin>>arr[i];
    int t=1;
    ways[0][0]=1;
    FOR(i,0,N){
        FOR(k,0,K+1){
            ll ans;
            if(k==0){
                ans=1;
            }else{
                ans=ways[t^1][k]+ways[t][k-1];
                // debug(ways[t^1][k],ways[t][k-1]);
                if(k-arr[i]-1>=0){
                    ans-=ways[t^1][k-arr[i]-1];
                    // debug(t^1,k-arr[i]-1,ways[t^1][k-arr[i]-1]);
                }
            }
            // debug(i,k,ans);
            ways[t][k]=(ans%MOD+MOD)%MOD;
        }
        t^=1;
    }
    cout<<ways[t^1][K]<<'\n';
}
int main()
{
    fastio
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif
    solve();
    return 0;
}


Measured memory_bytes: 5208
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int ans = 0;
int h[100];
int n;

void solve(int l, int r) {
    if (l < 0 || (h[l] == 0 && h[r] == 0))
        return;
    for (int i = l; i <= r; i++) {
        h[i]--;
    }
    ans++;
    int start = -1, end = 101;
    for (int i = l; i <= r; i++) {
        if (h[i] > 0) {
            if (start < 0) {
                start = i;
            }
        }
        if (h[i] == 0) {
            solve(start, i - 1);
            start = -1;
        }
        if (i == r) {
            solve(start, i);
        }
    }
}

int main()
{
    cin >> n;
    int m = INF;
    rep(i,n) {
        int tmp;
        cin >> tmp;
        m = min(m, tmp);
        h[i] = tmp;
    }
    int start = -1;
    for (int i = 0; i < n; i++) {
        if (h[i] > 0) {
            if (start < 0) {
                start = i;
            }
        }
        if (h[i] == 0) {
            solve(start, i - 1);
            start = -1;
        }
        if (i == n-1) {
            solve(start, i);
        }
    }
    solve(0, n-1); 
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
	
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
	
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
	
class fact {
public:
	int fmod = 1e9+7;
	vector<int> fac, inv;
	fact (int n, int Mod = 1e9+7) {
		fmod = Mod;
		fac = vector<int>(n,0);
		inv = vector<int>(n,0);
		fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
		for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
	}
	ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
	ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
	
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}
	
bool solve() {
	int n; cin >> n;
	int cnt = 0;
	REP (i,n) {
		int A; cin >> A;
		if (i+1 != A) cnt++;
	}
	if (cnt == 0 || cnt == 2) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}
	
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n,a,b;
    const int mod=1000000007,big=1000000005;
    scanf("%d%d%d",&n,&a,&b);
    long long all=1,nCa=1,nCb=1,pow=2;
    for(int i=n;i>0;i/=2){
        if(i%2==1){
            all*=pow;
            all%=mod;
        }
        pow*=pow;
        pow%=mod;
    }
    all--;
    long long A=1,B=1;//a!,b!の逆元
    for(int i=n;i>=n-a+1;i--){
        nCa*=i;
        nCa%=mod;
    }
    for(int i=1;i<=a;i++){
        A*=i;
        A%=mod;
    }
    pow=A;
    A=1;
    for(int i=big;i>0;i/=2){
        if(i%2==1){
            A*=pow;
            A%=mod;
        }
        pow*=pow;
        pow%=mod;
    }
    nCa*=A;
    nCa%=mod;
    for(int i=n;i>=n-b+1;i--){
        nCb*=i;
        nCb%=mod;
    }
    for(int i=1;i<=b;i++){
        B*=i;
        B%=mod;
    }
    pow=B;
    B=1;
    for(int i=big;i>0;i/=2){
        if(i%2==1){
            B*=pow;
            B%=mod;
        }
        pow*=pow;
        pow%=mod;
    }
    nCb*=B;
    nCb%=mod;
    int x=all-nCa-nCb;
    while(x<0)
        x+=mod;
    printf("%d\n",x);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
using namespace std;
#define ll long long
#define MAX 101000
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
ll ans,sum,s[MAX],ss[MAX];
int n,k,a[MAX];
int main()
{
	n=read();k=read();
	for(int i=1;i<=n;++i)a[i]=read();
	for(int i=1;i<=n;++i)s[i]=s[i-1]+(a[i]>0?a[i]:0);
	for(int i=1;i<=n;++i)ss[i]=ss[i-1]+a[i];
	for(int i=1;i<=n-k+1;++i)
	{
		sum=s[i-1]+(s[n]-s[i+k-1]);
		if(ss[i+k-1]-ss[i-1]>0)sum+=ss[i+k-1]-ss[i-1];
		ans=max(ans,sum);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2176
//======================================================================
// Contents    : AOJ ITP1_4_C
//               "a operator b" を計算（operator：演算子）
// Input       : a, b, operator("+"(和)、"-"(差)、"*"(積)、"/"(商))
// Output      : ans
// Constraints : 0 ≤ a,b ≤ 20,000
//               0による割り算禁止
// Author      : 廣部智也
// LastUpdate  : 2020/06/03
// Since       : 2020/06/03
//======================================================================

#include <stdio.h>
#include <stdlib.h>                                             // exit 関数を使用するため
// #include<string.h>                                              //strcmp 関数を使用するため         

#define LOWER_LIMIT 0
#define UPPER_LIMIT 20000
#define PRINT_ERROR printf("Input error\n")

//入力エラーを判断する関数
int Calculation( int a, char operator, int b );


int main(){

    int a = 0, b = 0;
    int ans = 0;
    char operator = 'A';
    
    while(1){
        // データの入力
        scanf("%d %c %d", &a, &operator, &b );                  // %s(文字列入力)から%c(1文字の入力)に変更
    
        if( a < LOWER_LIMIT || a > UPPER_LIMIT || 
            b < LOWER_LIMIT || b > UPPER_LIMIT ||
            ( operator == '/' && b == 0 ) ){                    // 0 で割るのをはじく
            
            PRINT_ERROR;
            return 0;
        }
    
        if( operator == '?' ){                                    // op が '?' のとき終了
            break;    
        }

        // データの処理
        ans = Calculation( a, operator, b );

        // データの出力
        printf("%d\n", ans);

    }
    
    return 0;
}

//============================================================
// Contents    : a operator b を計算
// Input       : a, b, operator
// Output      : ans
// Author      : 廣部智也
// LastUpdate  : 2020/06/03
// Since       : 2020/06/03
//============================================================

int Calculation( int a, char operator, int b ){

    int ans = 1;
    
    if( operator == '+' ){
        ans = a + b;
        }
        
    else if( operator == '-' ){
        ans = a - b;
        }

    else if( operator == '*' ){
        ans = a * b;
    }

    else if( operator == '/' ){
        ans = a / b;
    }

    else{
        PRINT_ERROR;
        exit(1);
    }

    return ans;
}



Measured memory_bytes: 2048
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <queue>

using namespace std;
typedef long long LL;
#define ls rt<<1
#define rs rt<<1|1
const int maxn = 200005;

int p[maxn],pos[maxn],n,N;
struct ST {
	int mi[maxn*4];
	int query(int rt,int L,int R,int l,int r)
	{
		if (L>=l&&R<=r) return mi[rt];
		int mid=L+R>>1,res=1<<30;
		if (l<=mid) res=min(res,query(ls,L,mid,l,r));
		if (r>mid) res=min(res,query(rs,mid+1,R,l,r));
		return res;
	}
	void build(int rt,int L,int R,int o)
	{
		if (L>=R) {
			mi[rt]=p[L<<1|o];return ;
		}
		int mid=L+R>>1;
		build(ls,L,mid,o);
		build(rs,mid+1,R,o);
		mi[rt]=min(mi[ls],mi[rs]);
	}
}od,ev;
struct node {
	int l,r,sl,sr;
	bool operator<(const node &v) const {
		return p[v.sl]<p[sl];
	}
};
priority_queue<node> Q;
void insert(int l,int r) {
	int sl,sr;
	if (l>=r) return ;
	if (l&1) {
		sl=pos[od.query(1,0,N,l>>1,r-1>>1)];
		sr=pos[ev.query(1,0,N,sl+1>>1,r>>1)];
	}
	else {
		sl=pos[ev.query(1,0,N,l>>1,r-1>>1)];
		sr=pos[od.query(1,0,N,sl+1>>1,r>>1)];
	}
	Q.push((node){l,r,sl,sr});
}
int main()
{
	#ifdef Amberframe
		freopen("arc080e.in","r",stdin);
		freopen("arc080e.out","w",stdout);
	#endif
	scanf("%d",&n);N=(n>>1)-1;
	for (int i=0;i<n;i++) scanf("%d",&p[i]),pos[p[i]]=i;
	ev.build(1,0,N,0);od.build(1,0,N,1);
	
	insert(0,n-1);
	while (!Q.empty()) {
		node w=Q.top();Q.pop();
		printf("%d %d ",p[w.sl],p[w.sr]);
		insert(w.l,w.sl-1);
		insert(w.sl+1,w.sr-1);
		insert(w.sr+1,w.r);
	}
	return 0;
}

Measured memory_bytes: 8948
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

using namespace std;

const long long MOD = 1000000007;

int main(){
	double x;
	cin >> x;
	long long now=100;
	long long cnt=0;
	while(1){
		if(now>=x){
			cout << cnt << endl;
			return 0;
		}
		now=now*1.01;
		cnt++;
	}
	return 0;
}


Measured memory_bytes: 3708
a,b,c,x,y=gets.split.map(&:to_i)
sum=[]
sum<<a*x+b*y
if x>=y
  sum<<c*2*y+a*(x-y)
else
  sum<<c*2*x+b*(y-x)
end
sum << c*2*([x,y].max)
puts sum.min


Measured memory_bytes: 14196
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
const int maxn = 100005;
typedef pair<ll, ll>par;
const ll mod = 1e9+7;

char s[maxn];
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    #ifdef acm
    freopen("a.in", "r",stdin);
    #endif // acm

    int k;
    cin >> k >> s;

    int l = strlen(s);
    if( l <= k )
        cout << s << "\n";
    else{
        for( int i = 0; i < k; i++ )
            cout << s[i];
        cout << "...\n";
    }
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>

int main()
{
  int X;

  std::cin >> X;
  if(X == 3){
    std::cout << "YES" << std::endl;

  }else{
    if(X == 5){
      std::cout << "YES" << std::endl;

    }else{
      if(X == 7){
      std::cout << "YES" << std::endl;

    }else{
      std::cout << "NO" << std::endl;

    }
  }}
  return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3
#sys.setrecursionlimit(int(1e+6))
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
MOD = int(1e+9) + 7

def main():
    N, K = i2nn()
    S = i2s()
    # 圧縮
    d = []
    t = S[0]
    n = 1
    for i in range(1, N):
        s = S[i]
        if s == t:
            n += 1
        else:
            d.append((t, n))
            t = s
            n = 1
    d.append((t, n))
    # 場合分けの統一
    if d[0][0] == '0':
        d = [('1', 0)] + d
    if d[-1][0] == '0':
        d.append(('1', 0))
    # 累積和
    r = [0] * (len(d) + 1)
    for i, (s, t) in enumerate(d):
        r[i+1] = r[i] + t
    # 答え
    w = K * 2 + 1
    n = -1
    #print(w, len(r))
    for i in range(w, len(r), 2):
        t = r[i] - r[i-w]
        #print(t)
        if t > n:
            n = t
    if n == -1:
        #print('n = -1')
        n = r[-1]
    #print(d)
    #print(r)
    print(n)

main()


Measured memory_bytes: 56304
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main (){
    int n,m;
    cin >> n >>m;
    long long ans=0;
    int j=1;
    for(int i=0;i<m;i++){
        j*=2;
    }
    for(int i=0;i<j;i++){
            ans=ans+(n-m)*100+m*1900;
        }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

const long long mod = pow(10, 9) + 7;

long long func(long long  A, long long B) {
	if (A%B == 0)return B;
	else func(B, A%B);
}

int main() {
	long long A, B; cin >> A >> B;
	cout << (A*B) / func(A, B) << endl;;
}





Measured memory_bytes: 256