akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**6)

h,w = map(int,input().split())

s = [input() for _ in range(h)]
cnt = [[0] * w for _ in range(h)]

for i in range(h):
    done = [0] * w

    for j in range(w):
        if s[i][j] == '#': continue
        if done[j]: continue

        l = 0
        while j+l < w:
            if s[i][j+l] == '#': break
            l += 1

        for k in range(l):
            cnt[i][j+k] += l
            done[j+k] = 1

for j in range(w):
    done = [0] * h

    for i in range(h):
        if s[i][j] == '#': continue
        if done[i] :continue

        l = 0
        while i+l < h:
            if s[i+l][j] == '#': break
            l += 1

        for k in range(l):
            cnt[i+k][j] += l
            done[i+k] = 1

ans = 0

for i in range(h):
    for j in range(w):
        ans = max(ans, cnt[i][j]-1)

print(ans)

Measured memory_bytes: 111808
from collections import defaultdict
def dfs(here,used,match,connect):
    used[here] = 1
    for near in connect[here]:
        m = match[near]
        if m < 0 or (not used[m] and dfs(m,used,match,connect)):
            match[here] = near
            match[near] = here
            return 1
    return 0

a_num, b_num, e_num = (int(n) for n in input().split(" "))
connect = defaultdict(list)
all_v = a_num + b_num
match = [-1 for n in range(all_v)]
for _ in range(e_num):
    v1, v2 = (int(n) for n in input().split(" "))
    v2 += a_num
    connect[v1].append(v2)
    connect[v2].append(v1)
answer = 0
for i in range(all_v):
    if match[i] < 0:
        used = [0 for n in range(all_v)]
        if dfs(i,used,match,connect):
            answer += 1
print(answer)

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

int main(){
  int n,m;
  int a[1000]={};
  int b[1000]={};
  int max =0;
  int t;
  int cnt[1000]={};

  cin >> n >> m;

  for(int i=0;i<n;i++)
    {
      cin >> a[i];
    }
  for(int j=0;j<m;j++)
    {
      cin >> b[j];
    }

  for(int j=0;j<m;j++)
    {
      for(int i =0;i<n;i++)
	{
	  
      if(a[i] <= b[j])
	{
	  cnt[i]++;
	  break;
	  /* if(max < a[i])
	    {
	      max = a[i];
	      t=i;
	      }*/
	}
      
	}
      //  cnt[t]++;
    }
  max =0;
  for(int i =0;i<n;i++)
	{
	   if(max < cnt[i])
	    {
	      max = cnt[i];
	      t=i;
            }
	 
	}
  cout << t+1 << endl;
}



Measured memory_bytes: 3112
#include  <stdio.h>
int main(){

  int num[10000],result,i;
  char sisoku[10000];

  for(i = 0; sisoku[i-1] != '='; i++){

    scanf("%d",&num[i]);
    scanf("\n%c",&sisoku[i]);
    
  }

  result=num[0];

  for(i = 0; sisoku[i] != '='; i++){

    if(sisoku[i] == '+') result += num[i+1];  
    if(sisoku[i] == '-') result -= num[i+1];
    if(sisoku[i] == '*') result *= num[i+1];
    if(sisoku[i] == '/') result /= num[i+1];

  }

  printf("%d\n",result);

  return 0;

}

Measured memory_bytes: 608
#include <stdio.h>
#include <algorithm>

#define freopen(x) freopen(x".in", "r", stdin);freopen(x".out", "w", stdout)
#define abs(a) ((a) < 0 ? -(a) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define isdigit(a) ((a) >= '0' && (a) <= '9' ? true : false)

const int INF = 0x3f3f3f3f;

typedef long long ll;

struct Node {
	ll x, y;
};

long long read();

const int N = 1e6;

Node a[N];

int main() {
	int n = read();
	for (int i = 1; i <= n; ++i) a[i] = (Node) { read(), read() };
	std::sort(a + 1, a + n + 1, [=] (Node a, Node b) {
		return a.y < b.y;
	});
	int sum = 0;
	for (int i = 1; i <= n; ++i) {
		sum += a[i].x;
		if (a[i].y < sum) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
  return 0;
}

long long read() {
  long long a = 0, c = getchar(), s = 0;
  while (!isdigit(c)) s |= c == '-', c = getchar();
  while (isdigit(c)) a = a * 10 + c - 48, c = getchar();
  return s ? -a : a;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int n,k,ans;
string s;
vector<pair<int,int> > v;
vector<int> pre;
int main()
{
	cin>>n>>k>>s;
	int tmp=1;
	for(int i=1;i<s.size();i++)
		if(s[i]!=s[i-1])
		{
			v.push_back(make_pair(tmp,s[i-1]-'0'));
			tmp=1;
		}
		else
			tmp++;
	v.push_back(make_pair(tmp,s[s.size()-1]-'0'));
	pre.push_back(v[0].first);
	for(int i=1;i<v.size();i++)
		pre.push_back(pre[pre.size()-1]+v[i].first);
	for(int i=0;i<v.size();i++)
	{
		if(v[i].second==1)
		{
			int j=min((int)v.size()-1,i+2*k);
			ans=max(ans,pre[j]-(i==0?0:pre[i-1]));
		}
		else
		{
			int j=min((int)v.size()-1,i+2*k-1);
			ans=max(ans,pre[j]-(i==0?0:pre[i-1]));
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  int cnt = 0;
  vector<ll> canBig(N);
  canBig[0] = 0;
  int pre = 0;
  FOR(i, 1, N){
    canBig[i] = canBig[i-1];
    FOR(j, pre, i){
      if((A[i]+canBig[i])*2 >= A[pre]){
        canBig[i]+=A[pre];
        pre++;
      }
      else{
        break;
      }
    }
  }
  int ans = 1;
  REPR(i, N-2){
    if(2*(A[i]+canBig[i]) >= A[i+1]){
      ans++;
    }
    else{
      break;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
const int maxn = 500005;
const int mod = 1000000007;

int n;
ll D,d[maxn],b[maxn],a[maxn];

int main() {
#ifdef suiyuan2009
  freopen("in.cpp","r",stdin);
#endif
  cin>>n>>D;
  for(int i=1;i<=n;i++)cin>>d[i];
  a[0]=D;
  for(int i=1;i<=n;i++){
    if(abs(a[i-1]-d[i])>=a[i-1])a[i]=a[i-1];
    else a[i]=abs(a[i-1]-d[i]);
  }
  b[n]=1;
  for(int i=n-1;i>=0;i--){
    if(b[i+1]<=d[i+1]/2)b[i]=b[i+1];
    else b[i]=b[i+1]+d[i+1];
  }
  int Q;
  cin>>Q;
  while(Q--){
    int q;
    cin>>q;
    if(a[q-1]>=b[q])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}


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

int main()
{
	int N;
	cin >> N;
	int pre,now;

	int state = 0;
	int sum = 1;
	cin >> now;
	for(int i=1;i<N;i++){
		pre = now;
		cin >> now;
		if(state == 0){
			if(pre < now){
				state = 1;
			}
			else if(pre > now){
				state = -1;
			}
		}else if(state == 1){
			if(pre > now){
				state = 0;
				sum++;
			}
		}else if(state == -1){
			if(pre < now){
				state = 0;
				sum++;
			}
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

const ll INF = ll(1e18);
ll n, a, b, c, d;
map<ll, ll> memo;
ll solve(ll n) {
    if (n==0) return 0;
    if (n==1) return d;
    if (memo.count(n)) return memo[n];
    ll res = INF;
    if (res/n > d) res = n*d;
    ll l2 = (n/2)*2, r2 = ((n-1)/2 + 1)*2;
    ll l3 = (n/3)*3, r3 = ((n-1)/3 + 1)*3;
    ll l5 = (n/5)*5, r5 = ((n-1)/5 + 1)*5;
    chmin(res, solve(l2/2) + a + d*(n-l2));
    chmin(res, solve(r2/2) + a + d*(r2-n));
    chmin(res, solve(l3/3) + b + d*(n-l3));
    chmin(res, solve(r3/3) + b + d*(r3-n));
    chmin(res, solve(l5/5) + c + d*(n-l5));
    chmin(res, solve(r5/5) + c + d*(r5-n));
    memo[n] = res;
    return res;
}

int main()
{
    int t;
    cin >> t;
    vector<ll> ans(t);
    rep(i,t) {
        cin >> n >> a >> b >> c >> d;
        memo.clear();
        ans[i] = solve(n);
    }
    rep(i,t)
        cout << ans[i] << "\n";
    return 0;
}


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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

using pii = pair<int, int>;

int N, M, A[(int)1e5];
pii CB[(int)1e5];

inline void input() {
  cin >> N >> M;
  rep(i, N) cin >> A[i];
  rep(i, M) cin >> CB[i].second >> CB[i].first;
  sort(A, A+N);
  sort(CB, CB+M, greater<pii>());
}

inline void Main() {
  // code
  input();

  int j = 0;
  long long R = 0;

  rep(i, N) {
    if(j < M && A[i] < CB[j].first) {
      R += CB[j].first;
      CB[j].second--;
    } else {
      R += A[i];
    }

    if(CB[j].second <= 0) j++;
  }

  cout << R << endl;
}

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


Measured memory_bytes: 1408
from fractions import gcd
import sys
#input = sys.stdin.readline()
sys.setrecursionlimit(4100000)

def ols(): return input()
def oli(): return map(int, input().split())
def olai(): return list(map(int, input().split()))
def olas(): return list(input().split())
def mlai(L): return [int(input()) for _ in range(L)]
def mlas(L): return [input() for _ in range(L)]

def palindrome(S):
    return S == S[::-1]

n = oli()
a = olai()
num = [0] * 200001
for i in a:
    num[i]+=1
ans = 0
for i in num:
    ans += i*(i-1)//2

for i in a:
    print(ans - (num[i]*(num[i]-1)//2) + ((num[i]-2)*(num[i]-1)//2))


Measured memory_bytes: 27156
'''
Created on 2020/08/20

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  X,Y=map(int,pin().split())
  if X==1 and Y==1:
    print(1000000)
  else:
    R=[3,2,1]+[0]*205
    print((R[X-1]+R[Y-1])*100000)
  return

main()

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

const int maxN = 1e5 + 5;
int colors[maxN];
vector<pi> to[maxN];

void dfs(int id, int color, int pa) {
  colors[id] = color;
  for (auto &p : to[id])
    if (p.first != pa)
      dfs(p.first, (color ^ p.second), id);
}

signed main() {
  int n = read();
  REP(i, n - 1) {
    int u, v, w;
    u = read();
    v = read();
    w = read();
    to[u].EB(v, (w & 1));
    to[v].EB(u, (w & 1));
  }
  colors[1] = 0;
  dfs(1, colors[1], 0);
  FOR(i, 1, n + 1) print(colors[i]);
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const int mod = 100000;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

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

int main()
{
  int n, d, x;
  cin >> n >> d >> x;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans = x;
  rep(i, n) {
    for(int j = 0; 1+a[i]*j <= d; ++j) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if(a*b>c*d){
		cout << a*b << endl;
	}else if(a*b<c*d){
		cout << c*d << endl;
	}else{
		cout << c*d << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz(x) ((int)x.size())
#define pb push_back
#define ii pair<int,int>
#define ppb pop_back
#define orta ((bas+son)>>1)
#define st first
#define nd second
#define ll long long
#define N 200005
#define inf 2000000005
#define MOD 1000000007
#define LOG 20
#define EPS 0.000000001
#define M 305
using namespace std;

int n;
map<int,int> cnt;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);	

	cin>>n;
	for(int i=1;i<=n;i++) {
		int x;
		cin>>x;
		cnt[x]++;
		cnt[x-1]++;
		cnt[x+1]++;
	}
	ii ans={0,0};
	for(auto x:cnt) {
		if(x.nd>ans.nd) {
			ans=x;
		}
	}
	cout<<ans.nd;	

}

Measured memory_bytes: 4736
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		//String t = sc.next();
		long n = sc.nextLong();
		long m = sc.nextLong();
		//long k = sc.nextLong();
		//long count=0;

		/*for(int i=0;i<3;i++) {
			if(s.substring(i,i+1).equals(s.substring(i+1,i+2))) {
				count++;
			}else if(i!=2){
				count=0;
			}
		}*/
		/*if(n*m<=k) {
			System.out.println(n*m);
		}else{
			System.out.println(k);
		}*/
		System.out.println((int)Math.ceil((n+m)/2.0));
		//System.out.println(Math.ceil(5.5));
	}
}




Measured memory_bytes: 22996
def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if A[j] <= x:
            i = i + 1
            A[i], A[j] = A[j], A[i]

    A[i+1], A[r] = A[r], A[i+1]
    return i + 1


n = int(input())
A = [int(x) for x in input().split()]

p = partition(A, 0, n-1)

for i in range(n):
    if i:
        print(" ", end = "")
    if i == p:
        print("[", end="")
    print(A[i], end="")
    if i == p:
        print("]", end="")
print()

    



Measured memory_bytes: 16368
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <functional>
#include <iostream>
#include <numeric>
#include <ctype.h>
#define SIZE 10005
 
using namespace std;
typedef long long int ll;
// typedef pair <int,int> P;
 
int pair[SIZE];
 
int main()
{
    int N = 0;
    int K = 0;
    cin >> N >> K;
    char S[N];
    for(int i = 0; i < N; i++)
    {
        cin >> S[i];
    }

    for(int i = 0; i < N; i++)
    {
        if(i == (K-1)){
            if(S[i] == 'A'){
                cout << 'a';
            }else if (S[i] == 'B')
            {
                cout << 'b';
            }else
            {
                cout << 'c';
            }
        }else{
            cout << S[i];
        }
    }
    cout << "\n";
    return 0;
    
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String T2=sc.next();
		String T[]=T2.split("");

		for(int i=0;i<T.length;i++) {
			if(T[i].equals("?")) {
				System.out.print("D");
				continue;
			}
			System.out.print(T[i]);
		}


	}
}


Measured memory_bytes: 68488
void main()
{
    string s = rdStr;
    string t = rdStr;

    writeln(s == t[0..$-1] ? "Yes" : "No");
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 2704
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		char[] str = sc.next().toCharArray();
		long[] number = new long[200200];
		char c = str[0];
		int index = 0;
		if(str[0] == '0')
			index++;
		number[index]++;	
		for(int i = 1; i < n; i++) {
			if(index % 2 == 1 && str[i] == '1' || index % 2 == 0 && str[i] == '0')
				index++;
			number[index]++;
		}	
		long  sum = number[0] + number[1] + number[2];
		int x = 3;
		for(int i = 0; i < k - 1; i++) {
			sum += number[x] + number[x + 1];
			x += 2;
		}
		long max = sum;
		//out.println("sum:" + sum);
		int y = 0;
		while (x < n + 5) {
			sum += number[x] + number[x + 1];
			sum -=  number[y] + number[y + 1];
			x += 2;
			y += 2;
			//out.println("sum:" + sum);
			if (max < sum) max = sum;
 		}
		out.println(max);
		
		out.close();
	}
	
static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}




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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pair<ll, ll> > vp;
typedef pair<ll, ll> pr;
typedef tuple<ll, ll, ll> ti;

#define FOR(i, a, b) for (int i = (a), _b = (b); i < _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i > _a; i--)
#define pb push_back

#define vout(v) do {					\
	for (auto i: v)	cout << i << ' ';	\
	cout << '\n';						\
} while (false)

#define matout(mat) do {					\
	for (auto i: mat) {						\
		for (auto j: i)	cout << j << ' ';	\
		cout << '\n';						\
	}										\
} while (false)

#define vin(v)  for (auto &i: v)    cin >> i

#define matin(mat) do {			\
	for (auto &i: mat)	vin(i);	\
} while (false)

ld pi = 3.141592653589793238;
ll M = 1e9 + 7;

ll gcd(ll a, ll b) {
    if (a == 0) return b;

    return gcd(b % a, a);
}

ll power(ll x, ll y) {
	if (y == 0)
		return 1;

	ll p = power(x, y / 2) % M;
	p = (p * p) % M;

	return y % 2 ? (x * p) % M : p;
}

bool is_prime(ll n) {
    if (n == 2) return true;
    if (n < 2) return false;
    if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2) {
        if (n % i == 0) return false;
    }

    return true;
}

bool is_palindrome(string s) {
    return equal(s.rbegin(), s.rend(), s.begin());
}

ll factor(ll n) {
	if (n % 2 == 0)	return 2;
	for (int i = 3; i <= sqrt(n); i += 2) {
		if (n % i == 0)	return i;
	}
	return n;
}

int floor_index(vi& v, int l, int r, int k) {
	while (r - l > 1) {
		int m = l + (r - l) / 2;
		if (v[m] <= k)	l = m;
		else			r = m;
	}
	return l;
}

int ceil_index(vi& v, int l, int r, int k) {
	while (r - l > 1) {
		int m = l + (r - l) / 2;
		if (v[m] >= k)	r = m;
		else		l = m;
	}
	int ans = v[l] >= k ? l : r;

	if (ans < 0 || ans >= v.size())	return -1;
	return ans;
}

ll recur(vll& v, vll& dp, int idx) {
	if (idx == v.size())	return 0;
	if (idx == v.size() - 1)	return dp[idx] = 1;
	if (dp[idx] != -1)	return dp[idx];

	if (v[idx + 1] < v[idx])	return dp[idx] = 1;

	return dp[idx] = 1 + recur(v, dp, idx + 1);
}

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

    ll t, n, m, k, q, x, y;
    string s;
    bool flag;

	cin >> n;
	vll v(n);
	vin(v);

	m = 0;

	FOR (i, 1, n) {
		if (v[i] < v[i - 1]) {
			m += v[i - 1] - v[i];
			v[i] = v[i - 1];
		}
	}

	cout << m << '\n';

    return 0;
}

Measured memory_bytes: 4760
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int cmp(const void*a,const void*b){
	ll aa=*(ll*)a;
	ll bb=*(ll*)b;
	ll aaa=aa&-aa;
	ll bbb=bb&-bb;
	if(aaa<bbb)return -1;
	if(aaa>bbb)return 1;
	if(aa<bb)return -1;
	return 1;
}

ll n,ans;
ll a[200010];
int flag[200010];
int nibutan(int l,int r,int x){
	//x以下の最大のものを[l,r)で探す
	if(a[l]>x)return -1;
	while(r-l>1){
		int m=(l+r)/2;
		if(a[m]<x)l=m;
		else if(a[m]>x)r=m;
		else if(flag[m])r=m;
		else l=m;
	}
	return l;
}

int main(){
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	qsort(a,n,sizeof(ll),cmp);
	for(int i=0;i<n;){
		int r=i;
		int t=a[i]&-a[i];
		while((a[r]&-a[r])==t)r++;
		//[i,r)で組にする
		for(int j=r-1;j>i;j--)if(!flag[j]){
			//a[j]と組に出来るものは、a[j]より真に大きい最小の2ベキをXとしてX-a[j]のみ
			//これを[i,j)でにぶたんして探す
			flag[j]=1;
			int x=1;
			while(x<=a[j])x+=x;
			int idx=nibutan(i,r,x-a[j]);
			if(idx!=-1&&a[idx]+a[j]==x&&!flag[idx]){
				ans++;
				flag[idx]=1;
			}
		}
		i=r;
	}
	printf("%lld",ans);
}

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

using namespace std;

priority_queue < long long, vector <long long>, greater <long long> > pq1, pq2;

const long long Nmax = 1e5 + 5;

struct coins
{
    long long gold, silver, dif;
};
coins v[Nmax];

long long gold_coins, silver_coins, bronze_coins, i, x, y, z;
long long sum_bronze, sum_gold, dp[Nmax];

bool cmp (coins A, coins B)
{
    if (A.dif < B.dif) return true;
    if (A.dif == B.dif)
    {
        if (A.gold < B.gold) return true;
        if (A.gold == B.gold) return (A.silver > B.silver);
    }
    return false;
}

int main ()
{
   // freopen("in", "r", stdin);
   // freopen("out", "w", stdout);
    scanf("%lld %lld %lld\n", &gold_coins, &silver_coins, &bronze_coins);

    long long N = gold_coins + silver_coins + bronze_coins, sum_bronze = 0;

    for (i = 1; i <= N; ++i)
    {
        scanf("%lld %lld %lld\n", &x, &y, &z);

        v[i].gold = x - z, v[i].silver = y - z, v[i].dif = x - y;

        sum_bronze += z;
    }

    sort(v + 1, v + N + 1, cmp);

    //dp[i] = numarul maxim de silver pana in i
    dp[0] = 0;

    for (i = 1; i <= silver_coins; ++i)
        pq1.push(v[i].silver), dp[i] = dp[i - 1] + v[i].silver;

    for (i = N; i >= N - gold_coins + 1; --i)
        pq2.push(v[i].gold), sum_gold += v[i].gold;

    long long Left = silver_coins + 1, Right = N - gold_coins;
    long long ans = -LLONG_MAX;

    for (i = Left; i <= N; ++i)
        if (pq1.top() < v[i].silver)
        {
            dp[i] = dp[i - 1] - pq1.top() + v[i].silver;
            pq1.pop();
            pq1.push(v[i].silver);
        }
        else dp[i] = dp[i - 1];

    ans = max(ans, dp[Right] + sum_gold);

    for (i = Right; i > silver_coins; --i)
    {
        if (pq2.top() < v[i].gold)
        {
            sum_gold -= pq2.top();
            pq2.pop();
            sum_gold += v[i].gold;
            pq2.push(v[i].gold);
        }
        ans = max(ans, dp[i - 1] +  sum_gold);
    }

    printf("%lld\n", ans + sum_bronze);

    return 0;
}


Measured memory_bytes: 4344
#include<iostream>
using namespace std;
#include<cstdio>
#include<algorithm>
#include<set>

struct point{ int x, y, id; };

point init(int pos_x, int pos_y, int index)
{
    point p; 
    p.x = pos_x, p.y = pos_y, p.id = index; 
    return p; 
}

bool cmp_x(const point &P1, const point &P2){ if(P1.x != P2.x){ return P1.x < P2.x; } return P1.y < P2.y; }
bool cmp_y(const point &P1, const point &P2){ if(P1.y != P2.y){ return P1.y < P2.y; } return P1.x < P2.x; }

void kd_tree(point *S, point *T, point *U, int left, int right, int d)
{
    if(right - left < 2) return;

    int mid = ((left + right) >> 1);
    int a = left, b = mid + 1;

    if((d & 1) == 0){
        for(int i = left; i < right; i++){
            if(cmp_x(T[i], S[mid])){
                U[a++] = T[i];
            }else if(S[mid].id == T[i].id){
                U[mid] = T[i];
            }else{
                U[b++] = T[i];
            }
        }
        for(int i = left; i < right; i++){ T[i] = U[i]; }

    }else{
        for(int i = left; i < right; i++){
            if(cmp_y(S[i], T[mid])){
                U[a++] = S[i];
            }else if(T[mid].id == S[i].id){
                U[mid] = S[i];
            }else{
                U[b++] = S[i];
            }
        }
        for(int i = left; i < right; i++){ S[i] = U[i]; }
    }
    kd_tree(S, T, U, left, mid, d + 1);
    kd_tree(S, T, U, mid + 1, right, d + 1);
}

void find_pt(set<int> &Q, point *S, int sx, int tx, int sy, int ty, int left, int right, int d)
{
    if(left >= right) return;

    int mid = ((left + right) >> 1);
    point p = S[mid];
    int a = p.x, b = p.y;

    if(sx <= a && a <= tx && sy <= b && b <= ty){
        Q.insert(p.id);
    }

    if((d & 1) == 0){
        if((left < mid) && (sx < a || (sx == a && sy <= b))){ find_pt(Q, S, sx, tx, sy, ty, left, mid, d + 1); }
        if((mid + 1 < right) && (a < tx || (a == tx && b <= ty))){ find_pt(Q, S, sx, tx, sy, ty, mid + 1, right, d + 1); }
    }else{
        if((left < mid) && (sy < b || (sy == b && sx <= a))){ find_pt(Q, S, sx, tx, sy, ty, left, mid, d + 1); }
        if((mid + 1 < right) && (b < ty || (b == ty && a <= tx))){ find_pt(Q, S, sx, tx, sy, ty, mid + 1, right, d + 1); }
    }
    return;
}

int main()
{
    point *S, *T, *U;
    set<int> Q;
    int i, pos_x, pos_y, n;
    scanf("%d", &n);

    S = new point [n], T = new point [n], U = new point [n];

    for(i = 0; i < n; i++){
        scanf("%d %d", &pos_x, &pos_y);
        S[i] = init(pos_x, pos_y, i);
        T[i] = S[i];
    }
    sort(S, S + n, cmp_x);
    sort(T, T + n, cmp_y);

    kd_tree(S, T, U, 0, n, 0);

    int sx, tx, sy, ty, q;
    scanf("%d", &q);
    while(q){
        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
        find_pt(Q, S, sx, tx, sy, ty, 0, n, 0);
        for(set<int>::const_iterator it = Q.begin(); it != Q.end(); it++){ printf("%d\n", *it); }
        printf("\n");
        Q.clear();
        q--;
    }

    return 0;
}

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

int n[3];
int main(){
	scanf("%d %d %d", &n[0], &n[1], &n[2]);
	sort(n, n + 3);
	int ans = 0;
	ans += n[2] - n[1];
	ans += n[1] - n[0];
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr ll mo2 = 998244353;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    map<string,int> m;
    int n;
    cin>>n;
    for(int i=0;i<n;++i){
        string s;
        cin>>s;
        m[s]++;
    }
    cout << m.size() << endl;
    return 0;
}

Measured memory_bytes: 19248
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string S;
  int w;
  cin >> S >> w;
  int i = 0;
  string ans = "";
  ans += S[0];
  while (i + w < S.length()) {
    i = i + w;
    ans += S[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
 
using namespace std;
 
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL); cout.tie(NULL);}
#define f first
#define s second
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
typedef long long ll;
typedef long double lld;
typedef unsigned long long ull;
 
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
	cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
	cin >> p.first;
	return cin >> p.second;
}
 
mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(61378913);
/* usage - just do rng() */
 
void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}
 
const lld pi = 3.14159265358979323846;
const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;
 

 
ll n, m, k, q, l, r, x, y, z;
const ll template_array_size = 1e6 + 1389;
ll a[template_array_size];
ll b[template_array_size];
ll c[template_array_size];
string s, t;
ll ans = 0;
 
pair<ll, ll> p[200005];
 
void solve(int tc = 0) {
	cin >> n;
	
	for (ll i = 0; i < n; i++) {
		cin >> p[i];
	}
	
	sort(p, p + n);
	
	ans = 0;
	ll mxabove = -p[0].f + p[0].s;
	ll mnbelow = p[0].f + p[0].s;
	
	for (ll i = 1; i < n; i++) {
		ans = max({ans, p[i].f - p[i].s + mxabove, p[i].f + p[i].s - mnbelow});
		mxabove = max(mxabove, -p[i].f + p[i].s);
		mnbelow = min(mnbelow, p[i].f + p[i].s);
	}
	
	cout << ans << '\n';
}
 
int main() {
	#ifdef galen_colin_local
		auto begin = std::chrono::high_resolution_clock::now();
	#endif
	
	send help
 
	#ifndef galen_colin_local
		// usaco("moop");
	#endif
	
	// usaco("cowland");
	
	// freopen("tc.cpp", "r", stdin);
 
	int tc = 1;
	// cin >> tc;
	for (int t = 0; t < tc; t++) solve(t);
	
	#ifdef galen_colin_local
		auto end = std::chrono::high_resolution_clock::now();
		cout << setprecision(4) << fixed;
		// cout << "Execution time: " << std::chrono::duration_cast<std::chrono::duration<double>>(end - begin).count() << " seconds" << endl;
	#endif
} 

Measured memory_bytes: 6796
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep2(i,x,n) for(int i=x;i<n;++i)

int main()
{    
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];

    h[0] -= 1;
    rep2(i,1,n)
    {
        int dh = h[i]-h[i-1];
        if(dh < 0)
        {
            cout << "No" << endl;
            return 0;
        }
        else if(dh > 0)
        {
            h[i] -= 1;
        }
    }

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

Measured memory_bytes: 640
a,b,h,m = map(int, input().split())
import math
A = (a*math.cos((h/6+m/360)* math.pi), a*math.sin((h/6+m/360)*math.pi))
B = (b*math.cos(m/30* math.pi), b*math.sin(m/30*math.pi))
print( ((A[0]-B[0])**2 + (A[1]-B[1])**2)**0.5 )

Measured memory_bytes: 62544
n = int(input())
s = input()
q = int(input())
C = [0]*n
for i, k in enumerate(s):
  C[i] = 1<<(ord(k)-ord("a"))

#####segfunc######
#def segfunc(x,y):
#    return 

def segfunc(a,b):
  return a | b

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = 1<<x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
ide_ele = 0

#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num

init(C)
for _ in range(q):
  t, a, b = input().split()
  if t == "1":
    w = ord(b) - ord("a")
    update(int(a)-1, w)
  else:
    ans = query(int(a)-1, int(b))
    print(bin(ans).count("1"))

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

int main(){
  string S;
  cin>>S;
  int64_t K;
  cin>>K;
  if(S.at(0)!='1'){
    cout<<S.at(0)<<endl;
  }
  
  else{
    int count=0;
    while(count<S.size() && S.at(count)=='1'){
      ++count;
    }
    if(K>count){
      cout<<S.at(count)<<endl;
    }
    else{
      cout<<'1'<<endl;
    }
  }

}

Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var S = input[0].split("");
  var ans=0;
  for(var i=0;i<S.length;i++){
    if(i%2==0){
      if(S[i]==0){
        ans++;
      }
    }else{
      if(S[i]==1){
        ans++;
      }
    }
  }
  ans=Math.min(ans,S.length-ans);

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 8396
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
lli dp[40 * maxn];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n = 0, k = 0, x = 0, y = 0;
	cin >> n >> k;
	vector<pair<int, int> > vp;
	for (int i = 0; i < k; ++i)
	{
		cin >> x >> y; vp.eb(x, y);
	}
	dp[0] = 1;
	for (int i = 1; i < n; ++i)
	{
		for (int j = 0; j < k; ++j)
		{
			if (i - vp[j].fi >= 0)
				dp[i] = (dp[i] + dp[i - vp[j].fi]) % MOD1;
			if (i - vp[j].se >= 1)
				dp[i] = (dp[i] - dp[i - vp[j].se - 1]) % MOD1;
		}
		dp[i] = (dp[i] + dp[i - 1]) % MOD1;
	}
	if (dp[n - 1] < 0ll)
		dp[n - 1] += MOD1;
	if (dp[n - 2] < 0ll)
		dp[n - 2] += MOD1;
	cout << (dp[n - 1] - dp[n - 2] + MOD1) % MOD1 << endl;
}

Measured memory_bytes: 5164
#include <iostream>

int main() {
  while (true) {
    int n, score_a = 0, score_b = 0;
    std::cin >> n;
    if (n == 0) break;
    
    for (int i = 0; i < n; i++) {
      int a, b;
      std::cin >> a >> b;
      if      (a > b) {score_a += a+b;}
      else if (a < b) {score_b += a+b;}
      else            {score_a += a; score_b += b;}
    }
    
    std::cout << score_a << " " << score_b << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
const int N = 1e7+5;
vector<ll> siv(N,0);

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=1; i<=n; ++i){
		for(int j=i; j<=n; j+=i){
			siv[j] += j;
		}
	}
	ll ans = 0;
	for(int i=0; i<=n; ++i){
		ans += siv[i];
	}
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 81248
#include <iostream>
#include <vector>
#include <bitset>
#define MAXN 1005
#define MAXVAL 5005
using namespace std;

int n, val[MAXN], dp[MAXN];
bitset<MAXVAL> bs;
vector<int> G[MAXN];

bool DFS(int u) {
    for (auto x: G[u]) {
        if (!DFS(x))
            return 0;
    }

    bs.reset();
    bs[0] = 1;

    int S = 0;
    for (auto x: G[u]) {
        bs = (bs << val[x]) | (bs << dp[x]);
        S += val[x] + dp[x];
    }

    for (int i = val[u]; i >= 0; --i) {
        if (bs[i]) {
            dp[u] = S - i;
            return 1;
        }
    }

    return 0;
}

int main() {
    ios::sync_with_stdio(0);

    cin >> n;
    for (int i = 2; i <= n; ++i) {
        int x;
        cin >> x;
        G[x].push_back(i);
    }

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

    cout << (DFS(1) ? "POSSIBLE\n" : "IMPOSSIBLE\n");

    return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

// #define int long long
#define YES "Yes"
#define NO  "No"

using namespace std;

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

  bool flag = false;
  int num = 0;

  int x, t; cin >> x >> t;
  cout << max(x - t, 0) << endl;
  
  // cout << num << endl;
  // cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    K = int(input())
    N = 50
    ans = [i for i in range(0, N)]

    modulo = K % N
    for i in range(0, modulo):
        ans[i] += N
        for j in range(0, N):
            if i != j:
                ans[j] -= 1

    divide = K // N

    ans = [str(divide + i) for i in ans]
    print(N)
    print(" ".join(ans))


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, j, q, a, b;
	ll x, ans = 0;
	vector<ll> d(100001, 0);
	cin >> num;
	rep(i, num) {
		cin >> a;
		d[a]++;
		ans += a;
	}
	cin >> q;
	rep(j, q) {
		cin >> a >> b;
		x = d[a];
		d[a] = 0;
		d[b] += x;
		ans += (ll)(b - a) * x;
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 3864
s = [int(i) for i in input()]
count = 0
l = len(s)
for i in range(l):
    if (i % 2 == 0 and s[i] ==0) or (i % 2 ==1 and s[i] == 1):
        pass
    else:
        count += 1
print(min([count,l - count]))

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
int c(int x)
{
    int a=0;
    while(x)
    {
        x/=10;
        a++;
    }
    return a;
}
int main()
{
    int n,wei=0;
    scanf("%d",&n);
    int ans=0;
    for(int i=1;i<=n;i++)
        {
            if(c(i)%2==1)
            {
                ans++;
                //printf("i=%d\n",i);
            }

        }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 1e5 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b,ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a,ll b){ if(a==0){return b;}else{ return gcd(b%a,a);}}
void YES(){puts("YES");exit(0);}
void Yes(){puts("Yes");exit(0);}
void NO(){puts("NO");exit(0);}
void No(){puts("No");exit(0);}

int n;
int a[maxn];
void solve()
{
	sa(n);
	int cnt=0;
	repp(i,1,n)
	{
		sa(a[i]);
		if(a[i]&1)
		{
			cnt++;
			cnt%=2;
		}
	}
	if(!cnt)
	{
		YES();
	}
	else
	{
		NO();
	}
}

int main()
{

	solve();    
    return 0;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<set>
using namespace std;
typedef uint64_t ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
ll N, m;
int main() {
	char str[4];
	bool flag = true;
	scanf("%s", str);
	rep(i, 1, 3)flag &= str[i] == str[0];
	printf(flag?"No":"Yes");
	return 0;
}

Measured memory_bytes: 128
X, Y = map(int, input().split())
l = [300000, 200000, 100000]
a = 400000
ans = 0
if X <= 3:
    ans += l[X - 1]
if Y <= 3:
    ans += l[Y - 1]
if X == 1 and Y == 1:
    ans += a
print(ans)


Measured memory_bytes: 3060
N = int(input())
ba, bc, ca = 0, 0, 0
c = 0
for _ in range(N):
    ss = input()
    if ss[0] == 'B':
        if ss[-1] =='A':
            ba += 1
        else: bc += 1
    else:
        if ss[-1] == 'A':
            ca += 1
    c += ss.count('AB')

cnt = max(ba - 1, 0)
if ba >= 1:
    if ca >= 1:
        ca -= 1
        cnt += 1
    if bc >= 1:
        bc -= 1
        cnt += 1
cnt += min(ca, bc)

print(cnt + c)

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

signed main(){
    int x,y;cin>>x>>y;
    int ans=0;
    if(x==1)ans+=300000;
    if(x==2)ans+=200000;
    if(x==3)ans+=100000;
    if(y==1)ans+=300000;
    if(y==2)ans+=200000;
    if(y==3)ans+=100000;
    if(x==1&&y==1)ans+=400000;
    cout<<ans<<endl;
}

Measured memory_bytes: 256