akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN = 150;
int N, K, M;
int add(int a, int b) {return (a + b)%M;}
int mul(int a, int b) {return 1LL*a*b%M;}
int f[MAXN + 5][MAXN + 5];
void solve1() {
	K /= 2, f[0][0] = 1;
	for(int i=1;i<=N;i++) {
		for(int j=0;j<=K;j++)
			f[i][0] = add(f[i][0], f[i-1][j]);
		for(int j=0;j<K;j++)
			f[i][j+1] = add(f[i][j+1], f[i-1][j]);
	}
	int ans1 = 0, ans2 = 0;
	for(int i=0;i<=K;i++)
		ans1 = add(ans1, f[N/2][i]);
	for(int i=0;i<=K;i++)
		ans2 = add(ans2, f[(N+1)/2][i]);
	printf("%d\n", mul(ans1, ans2));
}
int g[2*MAXN + 5][MAXN + 5][MAXN + 5];
void solve2() {
	int p; g[0][0][0] = 1;
	for(int i=2;i-K<=N;i+=2) {
		for(int j=0;j<=N;j++)
			for(int k=0;k<=K+1;k++)
				g[i][0][0] = add(g[i][0][0], g[i-2][j][k]);
		if( i <= N ) {
			for(int j=0;j<=N;j++)
				for(int k=0;k<=K+1;k++)
					g[i][j+1][0] = add(g[i][j+1][0], g[i-2][j][k]);
		}
		if( i - K >= 1 ) {
			for(int j=0;j<=N;j++) {
				for(int k=1;k<=K;k++)
					g[i][0][k+1] = add(g[i][0][k+1], g[i-2][j][k]);
				g[i][0][0] = add(g[i][0][0], g[i-2][j][0]);
			}
		}
		if( i <= N && i - K >= 1 ) {
			for(int j=0;j<=N;j++)
				for(int k=0;max(k,j+1)<=K;k++)
					g[i][j+1][max(k+1,j+2)] = add(g[i][j+1][max(k+1,j+2)], g[i-2][j][k]);
		}
		p = i;
	}
	int ans = 0;
	for(int j=0;j<=N;j++)
		for(int k=0;k<=K+1;k++)
			ans = add(ans, g[p][j][k]);
	printf("%d\n", ans);
}
int main() {
	scanf("%d%d%d", &N, &K, &M);
	if( K % 2 == 0 ) solve1();
	else solve2();
}

Measured memory_bytes: 27776
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <bits/stdc++.h>

using namespace std;
using Integer = long long;

/**
 *  剰余類
 */
struct ResidueClass {
  Integer value;
  Integer M = 1e9 + 7;

  ResidueClass (Integer x) {
    value = positive_mod(x, M);
  }

  ResidueClass operator + (ResidueClass const x) const {
    return ResidueClass { positive_mod(value + x.value, M) };
  }

  ResidueClass operator - (ResidueClass const x) const {
    return ResidueClass { positive_mod(value - x.value, M) };
  }

  ResidueClass operator * (ResidueClass const x) const {
    return ResidueClass { positive_mod(value * x.value, M) };
  }

  ResidueClass operator / (ResidueClass const x) const {
    ResidueClass x_inv = fast_pow(x, M - 2);
    return ResidueClass { positive_mod(value * x_inv.value, M) };
  }

  static ResidueClass factorial (ResidueClass n) {
    ResidueClass res(1);
    for (int i = n.value; i >= 1; i--) res = res * ResidueClass(i);
    return res;
  }

  static ResidueClass fast_pow (ResidueClass x, Integer n) {
    if (n == 0) return ResidueClass(1);
    if (n % 2 == 0) return fast_pow(x * x, n / 2);
    else return x * fast_pow(x, n - 1);
  }

  static Integer positive_mod (Integer a, Integer b) {
    Integer res = a % b;
    if (res < 0) res += b;
    return res;
  }
};

/**
 * main
 */
int main () {
  Integer n_, a_, b_;
  cin >> n_ >> a_ >> b_;

  ResidueClass n(n_), a(a_), b(b_);

  ResidueClass total = ResidueClass::fast_pow(ResidueClass(2), n_) - ResidueClass(1);

  ResidueClass nCa(1);
  for (size_t j_ = 1; j_ <= a_; j_++) {
    ResidueClass j(j_);
    ResidueClass den = n - j + 1;
    ResidueClass num = j;

    nCa = nCa * (den / num);
  }

  ResidueClass nCb(1);
  for (size_t j_ = 1; j_ <= b_; j_++) {
    ResidueClass j(j_);
    ResidueClass den = n - j + 1;
    ResidueClass num = j;

    nCb = nCb * (den / num);
  }

  ResidueClass ans = total - nCa - nCb;

  cout << ans.value << '\n';
}


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

int main(){
	string s , pre; cin >> s; bool flg = 0; int ans = 0 , i = 0;
	if(s.size() == 1){puts("1"); return 0;}
	if(s.size() == 2){printf("%d" , s.size() - (s[0] == s[1])); return 0;}
	for(i = 1 ; i + 2 < s.size() ; ++i)
		if(!flg && s[i] == s[i - 1]){flg = 1; ++i; --ans;}
		else flg = 0;
	if(s[s.size() - 1] == s[s.size() - 2] && i + 1 != s.size() || s[s.size() - 2] == s[s.size() - 3] && !flg) --ans;
	cout << ans + s.size();
	return 0;
}


Measured memory_bytes: 640
K, X = list(map(int, input().split()))
min_val = X - (K - 1)
min_val = -1000000 if min_val < -1000000 else min_val
max_val = X + (K - 1)
max_val = 1000000 if max_val > 1000000 else max_val
result = ''
for i in range(min_val, max_val + 1, 1):
  result += '{} '.format(i)
print(result.rstrip())

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

int main() {
    vector<char> C(6);
    rep(i, 6) cin >> C[i];
    if (C[0] == C[5] && C[1] == C[4] && C[2] == C[3]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define maxN 200005
#define mod 1000000007
#define pi 3.14159265358979323846264338327950

void solve()
{
    char c;
    cin >> c;
    if (!islower(c))
    {
        cout << "A\n";
    }
    else
    {
        cout << "a\n";
    }
}

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

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define fast_io ios::sync_with_stdio(false);cin.tie(NULL);
#define input freopen("Test.txt","r",stdin)
#define output freopen("Output.txt","w",stdout);
#define what_is(x) cout<<#x<<" is "<<x<<endl;
#define F(i,a,b) for(int i = a; i < b; i++)
#define MAX(a,b,c) max(a,max(b,c))
#define MIN(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define inf 1000000000
const double pi = 3.141592653589793238460;
#define debug false
#define MAXN 100010
#define mod 1000000007

void solve()
{
	ll n; cin>>n;
	if(n&1)
		cout<<0<<"\n";
	else
	{
		ll sum = 0;
		for(ll i=1;i<=n;i=i*5)
		{
			sum += n/(i*10);
		}
		cout<<sum<<"\n";
	}
	
}

int main()
{
     // input; // output; // if(debug){watch_is();}
    fast_io;
    solve();   
    return 0;
}

Measured memory_bytes: 384
module WeightedDirectedGraph
  (Vertex : sig
    type t
    val compare : t -> t -> int
  end)
  (Weight : sig
    type t
    val zero : t
    val ( + ) : t -> t -> t
    val compare : t -> t -> int
  end) :
sig
  val dijkstra :
    (* 隣接リスト *)
    (Vertex.t -> (Vertex.t * Weight.t) list) ->
    (* 始点 *)
    Vertex.t ->
    (* 始点から辿り着けなければNoneを返す *)
    (Vertex.t -> Weight.t option)
end =
struct
  module WMap = Map.Make (Weight)
  module VMap = Map.Make (Vertex)

  let dijkstra e s =
    (* 始点sからの距離 *)
    (* d に入っていない頂点への距離は無限大とみなす *)
    let d = ref @@ VMap.singleton s Weight.zero in
    (* 優先度付きキュー *)
    let q = ref @@ WMap.singleton Weight.zero [s] in
    (* ダイクストラ法のメインループ *)
    let rec dijkstra_aux t =
      match VMap.find_opt t !d, WMap.min_binding_opt !q with
      (* もう既に全ての頂点までの距離が分かっている *)
      | ans, None -> ans
      (* 既に終点までの距離が分かっているので返す *)
      | Some x as ans, Some (w, _) when Weight.compare x w <= 0 -> ans
      (* 終点までの距離が分かっていないので，ダイクストラ法を続行 *)
      | _, Some (w, us) ->
          q := WMap.remove w !q;
          Fun.flip List.iter us (fun u ->
            if 0 <= Weight.compare (VMap.find u !d) w then
              (* 未だ頂点uを訪れていない *)
              Fun.flip List.iter (e u) (fun (v, c) ->
                let open Weight in
                match VMap.find_opt v !d with
                | Some d when Weight.compare d (w + c) <= 0 -> ()
                | _ ->
                    d := VMap.add v (w + c) !d;
                    q := WMap.add (w + c) (v :: try WMap.find (w + c) !q with Not_found -> []) !q));
          dijkstra_aux t in dijkstra_aux
end

module G = WeightedDirectedGraph
  (struct
    type t = int * int
    let compare = compare
  end)
  (struct
    type t = int
    let zero = 0
    let ( + ) = ( + )
    let compare = compare
  end)

let () = Scanf.scanf "%d %d %d\n" @@ fun n m s ->
  let es = Array.make_matrix n 2501 [] in
  for i = 0 to m - 1 do
    Scanf.scanf "%d %d %d %d\n" @@ fun u v a b ->
      for i = a to 2500 do
        es.(u - 1).(i) <- ((v - 1, i - a), b) :: es.(u - 1).(i);
        es.(v - 1).(i) <- ((u - 1, i - a), b) :: es.(v - 1).(i);
      done
  done;
  for v = 0 to n - 1 do
    Scanf.scanf "%d %d\n" @@ fun c d ->
      for j = 0 to 2500 do
        es.(v).(j) <- ((v, min 2500 (j + c)), d) :: es.(v).(j)
      done
  done;
  let d = Fun.flip G.dijkstra (0, min 2500 s) @@ fun (v, c) -> es.(v).(c) in
  for v = 1 to n - 1 do
    Printf.printf "%d\n" @@
    List.fold_left min max_int @@
    List.init 2501 @@ fun i ->
      Option.value ~default:max_int @@ d (v, i)
  done



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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n,K;
  cin >> n >> K;
  vl v(n);
  REP(i,n) cin >> v[i];
  vl rui(n+1,0);
  REP(i,n) rui[i+1] = rui[i]+v[i];
  // l-r(0-orig) : rui[r+1] - rui[l];
  ll ans = 0;
  for(ll i=0;i<=min(K,n);i++){
    REP(j,i+1){
      ll ld = j;
      ll rd = i-j;
      vl value(i);
      REP(k,ld) value.push_back(v[k]);
      REP(k,rd) value.push_back(v[n-1-k]);
      sort(value.begin(),value.end());
      REP(k,min(K-i,(ll)value.size())){
        CHMAX(value[k],0ll);
      }
      ll tmp = 0;
      REP(k,value.size()) tmp += value[k];
      CHMAX(ans,tmp);
    }
  }
  cout << ans<< endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
typedef pair<P,P>PP;
#define fi first
#define se second

struct Range_merge_query{
	set<pair<int,int> >st;
	set<pair<int,int> >::iterator it1,it2;
	void init(int N){ for(int i=0;i<N+1;i++)st.insert(make_pair(i,i)); }
	bool query(int l,int r){
		it1 = st.lower_bound( make_pair(l,-1) );
		it2 = st.lower_bound( make_pair(r,-1) );
		return it1 == it2;
	}
	void merge(int l,int r){
		it1 = st.lower_bound( make_pair(l,-1) );
		it2 = st.lower_bound( make_pair(r,-1) );
		int L=it1->second;
		int R=it2->first;
		it2++;
		st.erase(it1,it2);
		st.insert( make_pair(R,L) );
	}
};


bool ans[100009];

int main(){
	Range_merge_query R;
	vector<P2>vm;
	vector<PP>vq;
	int n,m,q,a,b,c,idx=0;
	cin>>n>>m>>q;
	r(i,m+q){
		cin>>a>>b>>c;
		if(i<m)vm.push_back(P2(a,P(b,c)));
		else vq.push_back(PP(P(a,i-m),P(b,c)));
	}
	R.init(n);
	sort(vm.begin(),vm.end());
	sort(vq.begin(),vq.end());
	r(i,q){
		PP p=vq[i];
		int l=p.se.fi;
		int r=p.se.se;
		if(r<=l){
			ans[vq[i].fi.se]=1;
			continue;
		}
		while(idx<m&&vm[idx].fi<p.fi.fi){
			R.merge(vm[idx].se.fi,vm[idx].se.se);
			idx++;
		}
		if(R.query(p.se.fi,p.se.se))ans[p.fi.se]=1;
	}
	r(i,q)cout<<(ans[i]?"Yes":"No")<<endl;
}


Measured memory_bytes: 10380
n = int(input())
lst = list(map(int,input().split()))
lst2 = [0 for i in range(n)]
for i in range(n):
    x = lst[i]
    lst2[x - 1] = i + 1

for i in range(n):
    if (i != n - 1):
        print(lst2[i], end = ' ')
    else:
        print(lst2[i])


Measured memory_bytes: 20568
#include <iostream>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

typedef long long ll;

int main() {
    ll N;
    ll sum = 0;
    map<ll, ll> m;

    cin >> N;
    ll A[N];

    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        m[A[i]]++;
    }

    for (auto itr = m.begin(); itr != m.end(); ++itr) {
        sum += (itr->second * (itr->second-1)) / 2 ;
    }

    for (ll i = 0; i < N; i++) {
        cout << sum - m[A[i]]+1 << endl;
    }
}


Measured memory_bytes: 11008
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

const int INF = (int)1e9;

struct Edge {
  int src, dst, cost;
  Edge(int s, int d, int c) : src(s), dst(d), cost(c) { }
};

struct State {
  int pos, cost;
  State(int p, int c) : pos(p), cost(c) { }
  bool operator <(const State &rhs) const {
    return cost > rhs.cost;
  }
};

typedef vector<vector<Edge>> Graph;

int main() {
  ios::sync_with_stdio(false);
  int V, E, r;
  cin >> V >> E >> r;
  Graph G(V);
  for(int i = 0; i < E; i++) {
    int s, t, d;
    cin >> s >> t >> d;
    G[s].push_back(Edge(s, t, d));
  }
  vector<int> d(V, INF);
  priority_queue<State> Q;
  Q.push(State(r, 0));
  d[r] = 0;
  while(!Q.empty()) {
    State s = Q.top(); Q.pop();
    if(s.cost > d[s.pos]) continue;
    for(const Edge &e : G[s.pos]) {
      if(d[e.dst] > d[e.src] + e.cost) {
        d[e.dst] = d[e.src] + e.cost;
        Q.push(State(e.dst, d[e.dst]));
      }
    }
  }
  for(int i = 0;  i < V; i++) {
    if(d[i] == INF) cout << "INF" << endl;
    else cout << d[i] << endl;
  }
}

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


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

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

  vector<int> ans;
  while (a.size() > 0) {
    int j = -1;
    for (int i=a.size()-1; i>=0; --i) {
      if (a[i] == i+1) {
        j = i;
        ans.push_back(j);
        break;
      }
    }
    if (j == -1) {
      cout<<-1<<endl;
      return 0;
    }
    vector<int> b;
    for (int i=0; i<a.size(); i++) {
      if (i == j) {
        continue;
      }
      b.push_back(a[i]);
    }
    a = b;
  }
  reverse(ans.begin(), ans.end());
  for (auto i: ans) {
    cout<<i+1<<endl;
  }
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

vector<vector<int>> ed(8,vector<int>(8));

int dfs(int y, int x,vector<string> a,int h,int w)
{
    if(a[y][x]=='#'){
        ed[y][x] = 1;
    }else{
        return 0;
    }

    //右と下を見る,行ったことがあるなら見ない
    if (y < h - 1 && ed[y + 1][x] == 0 && a[y+1][x] == '#')
    {
        dfs(y + 1,x,a,h,w);
        return 0;
    }

    if (x < w - 1 && ed[y][x + 1] == 0 && a[y ][x+1] == '#')
    {
        dfs(y , x+1,a,h,w);
        return 0;
    }

    return 0;
}

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    REP(i, h) { cin >> a[i];}
    int ans;

    dfs(0,0, a, h, w);

    REP(i,h){
        REP(j,w){
        int n = ed[i][j];
        if(n==0&&a[i][j]=='#'){
            cout << "Impossible"
                 << "\n";
            return 0;
        }
        //cout << n ;
    }
    //cout << "\n";
    }

    cout << "Possible"
         << "\n";
    //cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
const int N = 1e6 + 2;

ll x, y;
ll f[N];

ll bm(ll b, ll p, ll m) {
    ll rt = 1;
    for (; p; p >>= 1, b = b * b % m)
        if (p & 1) rt = rt * b % m;
    return rt;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> x >> y;
    if ((x + y) % 3) return cout << "0\n", 0;
    ll a = y - (x + y) / 3;
    ll b = x - (x + y) / 3;
    if (a < 0 || b < 0) return cout << "0\n", 0;
    f[0] = 1;
    for (ll i = 1; i <= a + b; ++i)
        f[i] = i * f[i - 1] % MOD;
    cout << f[a + b] * bm(f[a], MOD - 2, MOD) % MOD * bm(f[b], MOD - 2, MOD) % MOD << '\n';
}

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

int main () {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    string ans = "No";

    int x = c/b, y = a/d;
    if (c%b != 0) {
        x ++;
    }
    if (a%d != 0) {
        y ++;
    }
    if (x <= y) {
        ans = "Yes";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
try:
    N = int(raw_input())
    ab = map(int, raw_input().split(" "))
    a = ab[0]
    b = ab[1]
    for i in range(N-1):
      ab = map(int, raw_input().split(" "))
      A = ab[0]
      B = ab[1]
      if (a < A and b < B):
        a = A
        b = B
      else:
        if (-(-a/A) > -(-b/B)):
          a = A*(-(-a/A))
          b = B*(-(-a/A))
        else:
          b = B*(-(-b/B))
          a = A*(-(-b/B))
    print a+b
except EOFError:
    pass


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


int main(){
    string s; cin >> s;
    if(s.size() == 2) cout << s << endl;
    else cout << s[2] << s[1] << s[0] << endl;
}

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

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

const int MAXH = 100;
const int MAXW = 100;
const int DX[] = { -1,0,+1,0 }, DY[] = { 0,+1,0,-1 };

int h, w;
char g[MAXH][MAXW + 1];

int d[MAXH][MAXW];
deque<pair<int, int>> q;

int solve() {
	REP(x, h) REP(y, w) d[x][y] = INT_MAX;
	q.clear();
	d[0][0] = 0, q.push_back(MP(0, 0));
	while (!q.empty()) {
		int x, y; tie(x, y) = q.front(); q.pop_front();
		REP(k, 4) {
			if (k != 1 && k != 2) continue;
			int nx = x + DX[k], ny = y + DY[k]; if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
			int nd = d[x][y] + (g[nx][ny] == g[x][y] ? 0 : 1); if (nd >= d[nx][ny]) continue;
			d[nx][ny] = nd; if (nd == d[x][y]) q.push_front(MP(nx, ny)); else q.push_back(MP(nx, ny));
		}
	}
	int ret = d[h - 1][w - 1];
	if (g[0][0] == '#') ++ret;
	if (g[h - 1][w - 1] == '#') ++ret;
	assert(ret % 2 == 0);
	return ret / 2;
}

void run() {
	scanf("%d%d", &h, &w);
	REP(x, h) scanf("%s", g[x]);
	printf("%d\n", solve());
}


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


Measured memory_bytes: 256
n = int(input())
ary = list(map(int,input().split()))
counter = [0]*100000

for i in ary:
  counter[i] += 1
  
sum = 0
max = 0
for i in range(100000):
  if i == 0:
    sum = counter[i] + counter[i+1]
  elif i == 1:
    sum += counter[i+1]
  elif i == 99999:
    sum += -counter[i-2] 
  else:
    sum += counter[i+1] - counter[i-2]
  if sum > max:
    max = sum
print(max)

Measured memory_bytes: 13964
def solve():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    ans = 0
    for i in range(n):
        if a[i] > 1:
            ans += a[i] // 2
            a[i] %= 2
        if i + 1 < n and a[i] == 1 and a[i + 1] > 0:
            ans += 1
            a[i] = 0
            a[i + 1] -= 1
    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()


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

bool dfs(vector<int>const&m,int a,int sum=0,int i=0){
	if(i==m.size())return sum==a;
	if(dfs(m,a,sum,i+1))return true;
	if(dfs(m,a,sum+m.at(i),i+1))return true;
	return false;
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,q;
	cin>>n;
	vector<int>m(n);
	for(int i=0;i<n;++i)cin>>m.at(i);
	sort(m.begin(),m.end());
	cin>>q;
	for(int i=0,t;i<q;++i){
		cin>>t;
		if(dfs(m,t))cout<<"yes\n"s;
		else cout<<"no\n"s;
	}
}


Measured memory_bytes: 3220
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
using namespace std;

int main() {
    int n;
    cin >> n;
    map<int, int> m;
    int a, cnt = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        m[a]++;
        cnt++;
        if (m[a] == a)cnt -= a;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 4736
#include <iostream>

using namespace std;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;

	int AA = A;
	int x = A % B;
	int y = x;
	while (true) {
		if (y == C) {
			cout << "YES" << endl;
			return 0;
		}
		AA += A;
		y = AA % B;
		if (x == y) {
			cout << "NO" << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
grid = [input() for _ in range(h)]

def check_row(grid):
    for i in range(len(grid)):
        if "#" not in grid[i]:
            return i
    return -1

def check_col(grid):
    grid_inv = []
    for i in range(len(grid[0])):
        grid_inv.append("".join(row[i] for row in grid))
    return check_row(grid_inv)

while True:
    if check_row(grid) != -1:
        del grid[check_row(grid)]
        continue
    elif check_col(grid) != -1:
        d = check_col(grid)
        for i in range(len(grid)):
            grid[i] = grid[i][:d] + grid[i][d+1:]
    else:
        break

for g in grid:
    print(g)


Measured memory_bytes: 9192
#include<iostream>
using namespace std;
int main(){
    int n;
    int i = 1;
    cin >>n;
    while(1){
        
        int x = i;
        if (x%3 == 0){
            cout<<" "<<i;
        }
        else if (x%10 ==3){
            cout<<" "<<i;
        }else{
            while(1){
                x/=10;
                if(x){
                    if(x%10==3){
                        cout<<" "<<i;
                        break;
                    }
                }else{
                    break;
                }
            }
        }if(i +1 > n){
            break;
        }i =i+1;
    }
    cout <<endl;
    return 0;
}


Measured memory_bytes: 3084
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    n=int(input())
    l1=[str(input()) for i in range(n)]
    m=int(input())
    l2=[str(input())    for i in range(m)]

    ans=0
    for i in l1:
        ans=max(l1.count(i)-l2.count(i),ans)
    for j in l2:
        ans=max(l1.count(i)-l2.count(i),ans)
    print(ans)



resolve()

Measured memory_bytes: 3064
/*
g++ -std=c++11 -o2 -Wall ABC103C.cpp -o ./out/ABC103C.out
./out/ABC103C.out
*/

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

typedef long long ll;

ll a[3050];

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll ans = 0;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) {
    ans += a[i] - 1;
  }
  cout << ans << "\n";
}


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

int main() {
  int a,b,c,k;cin>>a>>b>>c>>k;
  int cnt=0;
  while (a >= b) {
    b*=2;
    cnt++;
  }
  while (b>=c) {
    c*=2;
    cnt++;
  }
  if (cnt>k) cout<<"No";
  else cout<<"Yes";
}


Measured memory_bytes: 3612
import sys

H, W, D = map(int, sys.stdin.readline().split())
num = {}
for j in range(H):
    tmp = map(int, sys.stdin.readline().split())
    for i, n in enumerate(tmp):
        num[n] = (i, j)

# Dで分類した累積和
# S[initial % D][j], n = r + D*j
S = [0 for _ in range(H*W+D)]
for i in range(D+1, H*W+1):
    x, y = num[i]
    a, b = num[i-D]
    S[i] = S[i-D] + abs(x - a) + abs(y - b)
# print(S)
Q = int(sys.stdin.readline())
for _ in range(Q):
    L, R = map(int, sys.stdin.readline().split())
    r = L % D
    print(S[R] - S[L])

Measured memory_bytes: 26752
x = int(input())
flag = 0
flag2 = 0
div = 2
roop = 0
ans = []
while flag2 == False:
    if x == 2 or x == 3:
        ans = x
        break
    while flag == False:
        roop += 1
        if x%div == 0:
            break
        elif x%div != 0:
            if div%2 == 0:
                div += 1
            elif div <= x*0.5:
                div +=2
            else:
                ans = x
                break
    if x%2 == 0:
        x += 1
    else:
        x += 2
    div = 2
    if ans != []:
        flag2 = 1

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

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

		String O = sc.next();
		String E = sc.next();
		String [] stro = O.split("");
		String [] stre = E.split("");
		int odd = 0;
		int even = 0;

		for (int i = 0; i < O.length() + E.length(); i++) {
			if (i % 2 == 0) {
				System.out.print(stro[odd]);
				odd++;
			} else {
				System.out.print(stre[even]);
				even++;
			}
		}
	}
}


Measured memory_bytes: 22868
bingo_dict = dict()
i=1
j=1
for a in [int(i) for i in input().split()]:
    bingo_dict[a] = i*10+j
    j+=1
i=2
j=1
for a in [int(i) for i in input().split()]:
    bingo_dict[a] = i*10+j
    j+=1
i=3
j=1
for a in [int(i) for i in input().split()]:
    bingo_dict[a] = i*10+j
    j+=1

N = int(input())

s = set()
for b in [int(input()) for n in range(N)]:
    if b in bingo_dict:
        s.add(bingo_dict[b])

patterns = [
    [11,12,13],
    [21,22,23],
    [31,32,33],
    [11,21,31],
    [12,22,32],
    [13,23,33],
    [11,22,33],
    [13,22,31]
]

for p in patterns:
    b = True
    for v in p:
        if v not in s:
            b = False
            break
    if b:
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#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
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<ll> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=2e5+7;
// z[i] = len of lcp of s, s[i..]; lcp(longest common prefix)
int z[maxn];
void z_fn(const string& s) {
    int n = s.size();
    for(int i=0;i<n;i++) z[i]=0;
    for (int i = 1, l = 0, r = 0; i < n; i++) 
    {
        if (i <= r)
            z[i] = min(r-i+1, z[i-l]);
        while (i+z[i] < n && s[z[i]] == s[i+z[i]]) 
            z[i]++;
        if (i+z[i]-1 > r) 
        {
            l = i;
            r = i+z[i]-1;
        }
    }
}
int p;
string t;
vi getans(ll x)
{
    string T(t.begin(),t.begin()+p);
    vi u(26);
    vi ret(26);
    for(auto v:T) u[v-'a']++;
    for(int i=0;i<min(x,(ll)t.length());i++) ret[t[i]-'a']++;
    if(x>t.length()){
        x-=t.length();
        ll tt=x/p;
        for(int i=0;i<26;i++) ret[i]+=u[i]*tt;
        for(int i=0;i<x%p;i++)
            ret[T[i]-'a']++;
    }
    return ret;
}
ll cnt[102][26];
ll len[102];
vi getans2(ll x)
{
    vi ret(26);
    for(int i=100;i>=0;i--)
    {
        if(x>=len[i])
        {
            for(int j=0;j<26;j++)
                ret[j]+=cnt[i][j];
            x-=len[i];
        }
    }
    for(int i=0;i<x;i++) ret[t[i]-'a']++;
    return ret;
}
int main()
{
    string s;
    cin>>s;
    t=string(s.begin(),s.begin()+s.length()/2);
    z_fn(t);
    p=t.length();
    for(int i=1;i<t.length();i++)
    {
        if(z[i]==t.length()-i)
        {
            p=i;
            break;
        }
    }
    ll l,r;
    cin>>l>>r;
    l;r;
    vi L,R;
    if(t.length()%p==0)
    {
        R=getans(r);
        L=getans(l-1);
    }
    else{
        for(int i=0;i<p;i++) cnt[0][t[i]-'a']++;
        len[0]=p;
        len[1]=t.length();
        for(int i=0;i<t.length();i++) cnt[1][t[i]-'a']++;
        for(int i=2;i<100;i++)
        {
            for(int j=0;j<26;j++)
                cnt[i][j]=min(1LL<<60,cnt[i-1][j]+cnt[i-2][j]);
            len[i]=min(1LL<<60,len[i-1]+len[i-2]);
        }
        R=getans2(r);
        L=getans2(l-1);
    }
    for(int i=0;i<26;i++) R[i]-=L[i];
    print(R);
}


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

int main() {
  int a=0,b=0,c=0,d=0,m=0,n=0,p=0,q=0;
  string s;
  cin >> a >> s;
  if(s.size()>a)
  {
	  for(int i=0;i<a;i++)
	  {
		  cout << s.at(i);
	  }
	  cout << "...";
  }
  else
  {
	  cout << s;
  }
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

ll n,m,T,k,q;
const ll big = 1000000007;
const ll big2 = 998244353;

string S[3];

vl A,B,AB,I;

bool comp(ll i, ll j){
    return A[i]+B[i] < A[j]+B[j];
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,e;
    cin >> n;

    for(int c1 = 0; c1 < n; c1++){
        cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
        AB.push_back(a+b);
        I.push_back(c1);
    }
    sort(all(I),comp);

    ll ans = 0;
    for(int c1 = n-1; c1 >= 0; c1--){
        if((n-1-c1)%2==0){
            ans += A[I[c1]];
        }
        else{
            ans -= B[I[c1]];
        }
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
const int SIZE = 1e4;
const int INF = 1e9;
const int NaN = -1;
vector<pair<int, int>> rlud = {make_pair(1,0), make_pair(-1,0),make_pair(0,1),make_pair(0,-1)};
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int h, w, k; cin >> h >> w >> k;
   int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
   x1--;y1--;x2--;y2--;
   vector<int> grid[SIZE];
   rep(i,h){
      string s; cin >> s;
      rep(j,w){
         grid[i].push_back(s[j]=='@' ? NaN : INF);
      }
   }
   queue<pair<int,int>> q;
   q.push(make_pair(x1, y1));
   grid[x1][y1]=0;
   while(!q.empty()){
      int x = q.front().first, y = q.front().second;
      q.pop();
      int cost = grid[x][y];
      for(auto &&i : rlud){
         int dx = x, dy = y;
         dx += i.first; dy += i.second;
         int cnt = 0;
         while(dx < h && dy < w &&
            dx >= 0 && dy >= 0){
               if (grid[dx][dy]==NaN || (grid[dx][dy]!=INF && grid[dx][dy] <= cost) || cnt > k)break;
               if (grid[dx][dy]==INF)q.push(make_pair(dx,dy));
               grid[dx][dy] = cost+1;
               dx+=i.first;dy+=i.second;
               cnt++;
               if (cnt == k)break;
            }
      }
   }
   
   cout << (grid[x2][y2]==INF ? -1 : grid[x2][y2]) << endl;
}

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

int main(){
    int a[4] = {0};
    int s, t;
    rep(i, 3){
        cin >> s >> t;
        a[s-1] += 1;
        a[t-1] += 1;
    }
    int odd = 0;
    rep(i, 4){
        if(a[i]%2==1) odd += 1;
    }
    if(odd==2 || odd==0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff { ios_base::sync_with_stdio(false);cin.tie(NULL);}
using namespace std;

typedef long long int ll;
 ll  p=1e9+7; 

 int  main() {
        ff;
       
       
       ll a,b,c,d;
       cin>>a>>b>>c>>d;
       
       while(1){
           if((c-b)<=0){
               cout<<"Yes"<<endl;
               break;
           }else{
               c=c-b;
           }
           if((a-d)<=0){
               cout<<"No"<<endl;
               break;
           }else{
               a=a-d;
           }
           
           
       }
       
      
    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String S = scan.next();
		char[] s = new char[n];
		for (int i = 0; i < n; i++) {
			s[i] = S.charAt(i);
		}
		// 一番西の人がリーダーの時
		int num = 0;
		for (int i = 1; i < n; i++) {
			if (s[i] == 'E') {
				num++;
			}
		}
		int now = num;
		for (int i = 0; i < n - 1; i++) {
			int after = now;
			if (s[i] == 'W') {
				after++;
			}
			if (s[i + 1] == 'E') {
				after--;
			}
			now = after;
			if (after < num) {
				num = after;
			}
		}
		System.out.println(num);
	}
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if ((a % 2) == 0 || (b % 2) == 0) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int x[3], y[3], a, b;
	scanf("%d %d %d %d", &x[0], &y[0], &x[1], &y[1]);
	a = x[1] - x[0];
	b = y[1] - y[0];
	printf("%d %d %d %d\n", x[1] - b, y[1] + a, x[0] - b, y[0] + a);
	return 0;
}


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

int N;
string S;

int main(){

    cin >> N >> S;

    if (N%2 != 0){
        cout << "No" << endl;
        return 0;
    }
    else{
        for (int i=0; i<(N/2); i++){
            if (S.at(i) != S.at(i+(N/2))){
                cout << "No" << endl;
                return 0;
            }
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    string t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(s==u){
        cout << a - 1 << ' ' << b << endl;
    }
    else{
        cout << a << ' ' << b - 1 << endl;
    }
}

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

using namespace std;

int main(){
map<char,int> count;
int n;
cin>>n;
char value;
for(int i=0;i<n;i++){
cin>>value;
count[value]+=1;
}
if(count['R']>count['B']) cout<<"Yes";
else cout<<"No";

    return 0;

}

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

class Dice {
private:
    vector<int> num;
    int top;
    int side_n;
    int side_e;

public:
    Dice(vector<int> num);
    void Roll(char dir);
    int getNum(char dir);
};

Dice::Dice(vector<int> num)
{
    for (int i = 0; i < 6; i++) this->num.push_back(num.at(i));
    top = 1;
    side_n = 5;
    side_e = 3;
}
int Dice::getNum(char dir)
{
    int pos;
    
    switch (dir) {
        case 'T': pos = top; break;
        case 'B': pos = 7 - top; break;
        case 'N': pos = side_n; break;
        case 'E': pos = side_e; break;
        case 'W': pos = 7 - side_e; break;
        case 'S': pos = 7 - side_n; break;
        default : pos = top; break;
    }
    return num[pos-1];
}
void Dice::Roll(char dir)
{
    int tmp;
    
    switch (dir) {
        case 'N': tmp = top; top = 7-side_n; side_n = tmp; break;
        case 'E': tmp = top; top = 7-side_e; side_e = tmp; break;
        case 'W': tmp = top; top = side_e; side_e = 7-tmp; break;
        case 'S': tmp = top; top = side_n; side_n = 7-tmp; break;
        case 'R': tmp = side_n; side_n = 7-side_e; side_e = tmp; break;
        case 'L': tmp = side_e; side_e = 7-side_n; side_n = tmp; break;
        default : break;
    }
}

int main()
{
  vector<int> a, b;
  int n;
  int tmp;
  bool result = false;

  for (int i = 0; i < 6; i++) { cin >> tmp; a.push_back(tmp); }
  for (int i = 0; i < 6; i++) { cin >> tmp; b.push_back(tmp); }
  
  vector<int> tmp_a = a;
  vector<int> tmp_b = b;
  sort(tmp_a.begin(), tmp_a.end());
  sort(tmp_b.begin(), tmp_b.end());
  if (tmp_a != tmp_b) { cout << "Mo" << endl; return 0; }
  
  Dice diceA(a);
  Dice diceB(b);
  for (int i = 0; diceA.getNum('T') != diceB.getNum('T'); i++) diceB.Roll(i % 2 == 0 ? 'N' : 'E');
  for (; diceA.getNum('S') != diceB.getNum('S');) diceB.Roll('R');
  if (diceA.getNum('E') == diceB.getNum('E')) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}



Measured memory_bytes: 3152
o=input()
e=input()
if len(o)>len(e):
    for i in range(len(o)-1):
        print(o[i],end="")
        print(e[i],end="")
    print(o[len(o)-1])
else:
    for i in range(len(o)):
        print(o[i],end="")
        print(e[i],end="")
    print("")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int A, B;
    cin >> A >> B;

    if(B%A == 0){
        cout << A+B << endl;
    }
    else{
        cout << B-A << endl;
    }
}

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

int n, m, x, y;
int a, b;
int maxia = -110, minib = 110;

int main () {

	cin >> n >> m >> x >> y;
	for (int i = 0; i < n; i ++) {
		cin >> a;
		maxia = max(maxia, a);
	}
	for (int i = 0; i < m; i ++) {
		cin >> b;
		minib = min(minib, b);
	}
	
	for (int i = maxia+1; i <= minib; i ++) {
		if (x < i && i <= y) {
			cout << "No War";
			return 0; 
		}
	}
	
	cout << "War";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <set>
#include <cassert> //assart
using namespace std;
#define ll long long int
#define FOR(i,min,max) for(int i=(min);i<(max);i++)
#define FOReq(i,min,max) for(int i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(int i=(max)-1;i>=(min);i--)
const int  MOD=1e9+7;
const int  INF=2000000000;
const int INF2=  10000000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INF2){;}
    return 0;
}

#define pf printf
#define sf scanf
#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
#define br printf("\n");
#define OutputAndReturn0(x) {cout<<(x)<<endl;return 0;}

int printintN(int array[],const int num){
    for(int i=0;i<num;i++){printf("%d ",array[i]);}
    br;
    return 0;
}
int printint(const int num){
    printf("%d\n",num);
    return 0;
}
//#define int long long int

/*
 1.困った時こそ冷静に問題文を見直す！制約条件を見ろ！乱択アルゴリズムとかO(N^3)とか！
 2.一度に大量のことをやろうとしない。デバッグしやすいように細かく！
 3.プログラミングは半分数学だし、もう半分は数学ではない！
 4.できない問題はできない！！！！！
 */
int HW[2000][2000],HWheight[2000][2000],HWwidth[2000][2000];
int H,W;
vector<string> s;
int CalculateHWwidth(int i,int k){
    if(s[i][k]=='#')HWwidth[i][k]=0;
    else if(k!=0 and s[i][k-1]=='.'){
        HWwidth[i][k]=HWwidth[i][k-1];
    }
    else {
        int p=k+1;
        while(p<W and s[i][p]=='.')p++;
        HWwidth[i][k]=p-k;
    }
    return 0;
}

int CalculateHWheight(int i,int k){
    if(s[i][k]=='#')HWheight[i][k]=0;
    else if(i!=0 and s[i-1][k]=='.'){
        HWheight[i][k]=HWheight[i-1][k];
    }
    else {
        int p=i+1;
        while(p<H and s[p][k]=='.')p++;
        HWheight[i][k]=p-i;
    }
    return 0;
}


int experiment(){
    int ans;ans=0;
    
    cin>>H>>W;
    
    FOR(i, 0, H){
        string st;
        cin>>st;
        s.push_back(st);
    }
    
    
    FOR(i, 0, H){
    FOR(k, 0, W){
        CalculateHWwidth(i,k);
        CalculateHWheight(i, k);
        ans=max(ans,HWheight[i][k]+HWwidth[i][k]-1);
    }
    }
    
//
//    printintN(HWwidth [0],W);
//    printintN(HWwidth [1],W);
//    br;
//    printintN(HWheight[0],W);
//    printintN(HWheight[1],W);

    OutputAndReturn0(ans);
    return 0;
}
signed main(){
    assert(1);
    experiment();
    return 0;
}



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

int main() {
  int n;
  cin >> n;
  
  int ans = 0;
  int zoro = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a == b) {
      zoro++;
      ans = max(ans, zoro);
    } else {
      zoro = 0;
    }
  }
  
  if (ans >= 3) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 3628
from collections import deque
N = int(input())
A = list(map(int, input().split()))
#A=[1,1,1,1,1,1,1]
#N=7
A.sort(reverse=True)
dis=deque([A[0]])
num=0
for i in range(1,len(A)):
    num+=dis.popleft()
    #L.insert(ind+1,A[i])
    dis.append(A[i])
    dis.append(A[i])
print(num)
#print(L)
#print(dis)

Measured memory_bytes: 93464
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REP(i,n) FOR(i,0,n)
typedef vector<int> vi;
typedef vector<vi> vii;

int main(){
	int n,m;
	while(cin>>n>>m,n&&m){
		vi c(m),x(n);
		REP(i,m){
			cin>>c[i];
		}
		REP(i,n){
			cin>>x[i];
		}

		vii dp(n+1,vi(256,INT_MAX));
		dp[0][128]=0;
		REP(i,n){
			REP(j,256){
				if(dp[i][j]==INT_MAX)continue;
				REP(k,m){
					int y=j+c[k];
					if(y<0)y=0;
					if(y>255)y=255;
					dp[i+1][y]=min(dp[i+1][y],dp[i][j]+(int)pow((double)y-x[i],2));
				}
			}
		}
		int ans=INT_MAX;
		REP(i,256){
			ans=min(ans,dp[n][i]);
		}
		cout<<ans<<endl;
	}
}

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

int main(){
  int N;
  cin >> N;
   vector<int> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
}
  int maxi=0;
  for(int count=0; count<N;count++){
    maxi=max(maxi,vec.at(count));
  }
 int maxpoint=0;
   while(vec.at(maxpoint)!=maxi){
     maxpoint++;
   }
  int sec=0;
  for(int c=0;c<N;c++){
    if(c!=maxpoint){
    sec=max(sec,vec.at(c));
    }
  }
  for(int b=0;b<N;b++){
    if(b!=maxpoint){
      cout<<maxi<<endl;
    }
    else{
      cout<<sec<<endl;
    }
  }
}

Measured memory_bytes: 2432
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int x[100010];
stack<int> st;
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    rep(i, N) cin >> x[i];
    int ans = 1;
    rep(i, N) {
        st.push(x[i]);
        int size = st.size();
        if (st.top() < size * 2 - 1) {
            ans = (ans * size) % mod;
            st.pop();
        }
    }
    rep(i, st.size()) {
        ans = (ans * (i + 1)) % mod;
    }
    cout << ans << endl;


    return 0;
}


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

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

int main() {
  ll h, w, m1 = 0, m2 = 0, m3 = 0, minm, maxm, mind = INF;
  cin >> h >> w;

  for (int i = 1; i < h; ++i) {
    m1 = i * w;

    int ww = ceil(w / 2.0);
    m2 = (h - i) * ww;
    m3 = h * w - m1 - m2;
    maxm = max({m1, m2, m3});
    minm = min({m1, m2, m3});
    mind = min(maxm - minm, mind);

    int hh = ceil((h - i) / 2.0);
    m2 = hh * w;
    m3 = h * w - m1 - m2;
    maxm = max({m1, m2, m3});
    minm = min({m1, m2, m3});
    mind = min(maxm - minm, mind);
  }

  swap(h, w);
  for (int i = 1; i < h; ++i) {
    m1 = i * w;

    int ww = ceil(w / 2.0);
    m2 = (h - i) * ww;
    m3 = h * w - m1 - m2;
    maxm = max({m1, m2, m3});
    minm = min({m1, m2, m3});
    mind = min(maxm - minm, mind);

    int hh = ceil((h - i) / 2.0);
    m2 = hh * w;
    m3 = h * w - m1 - m2;
    maxm = max({m1, m2, m3});
    minm = min({m1, m2, m3});
    mind = min(maxm - minm, mind);
  }

  cout << mind << endl;
  return 0;
}


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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        //Solve();
        return;
    }

    public static string Solve()
    {
        string S = Read();
        int k = S.Length;
        int winCnt = 0;
        for(int i=0;i<k;i++)
        {
            if (S[i] == 'o') winCnt++;
        }
        if (winCnt + 15 - k >= 8) return "YES";
        return "NO";
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int main() {
    int N;

    cin >> N;

    long long ans = 0;

    for(int i = 1; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#pragma once
#include <algorithm>
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
using namespace std;
//int hito;
//int sa[100000]={};
int mondaisu,time1[1000],drink,mondai[1000],time2[1000];
int result[1000]={};
int maxtime=0;

int main(){
	/*scanf("%d",&hito);

	for(int i=0;i<hito;i++){
		scanf("%d",&sa[i]);
	}*/

	scanf("%d",&mondaisu);
	for(int i=0;i<mondaisu;i++){
		scanf("%d",&time1[i]);
		maxtime+=time1[i];
	}
	scanf("%d",&drink);

	for(int i=0;i<drink;i++){
		scanf("%d%d",&mondai[i],&time2[i]);
		result[i]=maxtime-time1[mondai[i]-1]+time2[i];
	}

	for(int i=0;i<drink;i++){
		printf("%d\n",result[i]);
	}
	

return 0;
}

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

int main() {
	char c;
	cin >> c;

	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
		cout << "vowel" << endl;
	else
		cout << "consonant" << endl;
}


Measured memory_bytes: 256