akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

char field[30][30];
int w, h;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};

void init() {
  REP(i, w) {
    REP(j, h) {
      field[i][j] = '?';
    }
  }
}

void trample(int x, int y) {
  if (x < 0 or w <= x or 
      y < 0 or h <= y or 
      field[x][y] != '@') {
    return;
  }

  REP(d, 4) {
    int nx = x + dx[d], ny = y + dy[d];
    if (field[nx][ny] == '.') {
      field[nx][ny] = '@';
      trample(nx, ny);
    }
  }
}

int main() {
  while (cin >> w >> h and w) {
    int sx, sy;
    init();
    REP(y, h) {
      string row;
      cin >> row;
      REP(x, w) {
        field[x][y] = row[x];
        if (row[x] == '@') {
          sx = x, sy = y;
        }
      }
    }

    trample(sx, sy);

    int accessible = 0;
    REP(y, h) {
      REP(x, w) {
        if (field[x][y] == '@') {
          accessible++;
        }
      }
    }
    cout << accessible << endl;
  }
}

Measured memory_bytes: 1216
#include <stdio.h>

int main() {
  int a,b,c,d;
 

  while(1) {
 c = 0;
  scanf("%d",&a);
  if(a == 0 ) {
    break;
  }

  b = 1000 - a;

while(1) {

  if(b - 500 < 0) {
    break; 
  } 

  c = c + 1;
  b = b - 500;
 }


while(1) {
  if(b - 100 < 0) {
    break;
  }
  
  c = c + 1;
  b = b - 100;
 }

 while(1) {
   if(b - 50 < 0) {
     break;
   }
   c = c + 1;
   b = b - 50;
 }

while(1) {
  if(b - 10 < 0) {
    break;
  }

  c = c + 1;
  b = b - 10;
 }

 while(1) {
   if(b - 5 < 0) {
     break;
   }

   c = c + 1;
   b = b - 5;
 }

while(1) {
  if(b == 0) {
    break;
  }

  c = c + 1;
  b = b - 1;

  } 

 

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

  }

return 0;

}

Measured memory_bytes: 600
from itertools import chain,combinations
def powerset(iterable):
    s = list(iterable)
    return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))

def isOverX(X, CA, M):
    s = [0] * (M + 1)
    for ca in CA:
        for i, a in enumerate(ca):
            s[i] += a
    if min(s[1:]) >= X:
        return s[0]
    else:
        return -1
def main():
    N, M, X = map(int, input().split())

    CA = []
    for i in range(N):
        CA.append(list(map(int, input().split())))
    
    ans = 10 ** 10
    ok = False
    for ca in powerset(CA):
        cost = isOverX(X, list(ca), M)
        if cost != -1:
            ans = min(ans, cost)
            ok = True
    print(ans if ok else -1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9252
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define Mp make_pair
#define pb push_back

using ll = long long;
using db = double;
using pii = pair<int, int>;
using vi = vector<int>;
// mt19937 mrand(time(0));
// ll get(ll r) { return ((ll)mrand() * mrand() % r + r) % r; }
// ll get(ll l, ll r) { return get(r - l + 1) + l; }

int n, q; ll ans; const int N = 2e5 + 100;
struct SegTree {
    int seg[N*4];
    #define lc(k) (k << 1)
    #define rc(k) (k << 1 | 1)
    void pushdown(int k) {
        seg[lc(k)] = min(seg[lc(k)], seg[k]);
        seg[rc(k)] = min(seg[rc(k)], seg[k]);
    }
    void modify(int k, int l, int r, int L, int R, int v) {
        if(L <= l && r <= R) return seg[k] = min(seg[k], v), void();
        int mid = l + r >> 1; pushdown(k);
        if(L <= mid) modify(lc(k), l, mid, L, R, v);
        if(R > mid) modify(rc(k), mid + 1, r, L, R, v);
        seg[k] = max(seg[lc(k)], seg[rc(k)]);
    }
    int query(int k, int l, int r, int x) {
        if(l == r) return seg[k];
        int mid = l + r >> 1; pushdown(k);
        if(x <= mid) return query(lc(k), l, mid, x);
        else return query(rc(k), mid + 1, r, x);
    }
    void build(int k, int l, int r) {
        if(l == r) return seg[k] = n, void();
        int mid = l + r >> 1;
        build(lc(k), l, mid), build(rc(k), mid + 1, r);
        seg[k] = n;
    }
} lie, hang;

signed main() {
    scanf("%d %d", &n, &q), ans = 1ll * (n - 2) * (n - 2);
    lie.build(1, 1, n), hang.build(1, 1, n);
    while(q--) {
        int op, x; scanf("%d %d", &op, &x);
        if(op == 1) {
            int val = hang.query(1, 1, n, x);
            ans -= val - 2;
            lie.modify(1, 1, n, 2, val - 1, x);
        } else {
            int val = lie.query(1, 1, n, x);
            ans -= val - 2;
            hang.modify(1, 1, n, 2, val - 1, x);
        }
    }
    printf("%lld\n", ans);
    fprintf(stderr, "time=%.4f\n", (db)clock()/CLOCKS_PER_SEC);
    return 0;
    /* 取模直接除，爆零两行泪
     * 不开ll见祖宗
     */
}

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


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

using namespace std;




int main() {
	int n, m;
	cin >> n >> m;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int sum_point = 0;
	rep(i, n) {
		sum_point += a[i];
	}
	int checked = 0;
	bool ans = false;
	rep(i, n) {
		if (a[i]*4*m >=sum_point) {
			checked++;
		}
		if (checked == m) {
			ans = true;
			break;
		}
	}
	
	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

# N < 10^5
d = {}
for a in A:
    d[a+1] = d.get(a+1,0)+1
    d[a]   = d.get(a,0)+1
    d[a-1] = d.get(a-1,0)+1

print(max(d.values()))


Measured memory_bytes: 19748
//vec[i]の範囲外エラー表示
#define _GLIBCXX_DEBUG
//includeとusing
#include <bits/stdc++.h>
using namespace std;
//型名省略
using ll = long long;
using st = string;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using pcc = pair<char, char>;
//定数
const ll INF = 1e9;
const ll MOD = 1e9+7;
const vl dx = {1,0,-1,0,1,0,-1,0};
const vl dy = {0,1,0,-1,0,1,0,-1};
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rrep(i,n) for(ll i = (ll) n - 1; i >= 0;i--)
#define REP(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define RREP(i,x,n) for(ll i = (ll) n - 1; i >= x; i--)
#define each(i,A) for(ll i: (vl) A)
#define all(A) A.begin(), A.end()
#define Size(A) ll(A.size())
//入力
template<typename T> T input() {T x; cin >> x; return x;}
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}
//余り切り上げ
ll ceil(ll a,ll b) {return (a + b - 1) / b;}
//最大値・最小値
template <typename T> bool chmax(T &a, const T& b) {if(a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, const T& b) {if(a > b) {a = b; return true;} return false;}
//最大公約数
ll gcd(ll a,ll b){if(a<b)swap(a,b); if(a%b==0)return b; return gcd(b,a%b);}
//最小公倍数
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//n乗の余り
ll modPow(ll x,ll n,ll mod){if(n==0)return 1; if(n%2==0)return modPow(x*x,n/2,mod)%mod; return x%mod*modPow(x,n-1,mod)%mod;}


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

//main関数
int main() {
    ll n, m, sum = 0; cin >> n >> m;
    vl a(n);
    rep(i,n) {
        cin >> a[i];
        sum += a[i];
    }

    sort(all(a), greater<ll>());

    Yes(a[m - 1] * 4 * m >= sum);
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n,a,b,cnt=0;
	bool ans = false;
	cin >> n;
	rep(i, n) {
		cin >> a >> b;
		if (a == b)cnt++;
		if (a != b)cnt = 0;
		if (3 <= cnt) {
			ans = true;
		}
	}
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



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

int main(){
    int n;
    cin >> n;
    int ans = 100;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        int temp = 0;
        while(a % 2 == 0){
            temp++;
            a /= 2;
        }
        if(ans > temp) ans = temp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*⠄⢰⣧⣼⣯⠄⣸⣠⣶⣶⣦⣾⠄⠄⠄⠄⡀⠄⢀⣿⣿⠄⠄⠄⢸⡇⠄⠄
⠄⠄⠄⣾⣿⠿⠿⠶⠿⢿⣿⣿⣿⣿⣦⣤⣄⢀⡅⢠⣾⣛⡉⠄⠄⠄⠸⢀⣿⠄
⠄⠄⢀⡋⣡⣴⣶⣶⡀⠄⠄⠙⢿⣿⣿⣿⣿⣿⣴⣿⣿⣿⢃⣤⣄⣀⣥⣿⣿⠄
⠄⠄⢸⣇⠻⣿⣿⣿⣧⣀⢀⣠⡌⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠿⠿⣿⣿⣿⠄
⠄⢀⢸⣿⣷⣤⣤⣤⣬⣙⣛⢿⣿⣿⣿⣿⣿⣿⡿⣿⣿⡍⠄⠄⢀⣤⣄⠉⠋⣰
⠄⣼⣖⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⣿⣿⢇⣿⣿⡷⠶⠶⢿⣿⣿⠇⢀⣤
⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⡇⣿⣿⣿⣿⣿⣿⣷⣶⣥⣴⣿⡗
⢀⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠄
⢸⣿⣦⣌⣛⣻⣿⣿⣧⠙⠛⠛⡭⠅⠒⠦⠭⣭⡻⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠄
⠘⣿⣿⣿⣿⣿⣿⣿⣿⡆⠄⠄⠄⠄⠄⠄⠄⠄⠹⠈⢋⣽⣿⣿⣿⣿⣵⣾⠃⠄
⠄⠘⣿⣿⣿⣿⣿⣿⣿⣿⠄⣴⣿⣶⣄⠄⣴⣶⠄⢀⣾⣿⣿⣿⣿⣿⣿⠃⠄⠄
⠄⠄⠈⠻⣿⣿⣿⣿⣿⣿⡄⢻⣿⣿⣿⠄⣿⣿⡀⣾⣿⣿⣿⣿⣛⠛⠁⠄⠄⠄
⠄⠄⠄⠄⠈⠛⢿⣿⣿⣿⠁⠞⢿⣿⣿⡄⢿⣿⡇⣸⣿⣿⠿⠛⠁⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠉⠻⣿⣿⣾⣦⡙⠻⣷⣾⣿⠃⠿⠋⠁⠄⠄⠄⠄⠄⢀⣠⣴
⣿⣿⣿⣶⣶⣮⣥⣒⠲⢮⣝⡿⣿⣿⡆⣿⡿⠃⠄⠄⠄⠄⠄⠄⠄⣠⣴⣿*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n,k;
int arr[200005];
int pre[200005];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>k;
	rep(x,0,n) cin>>arr[x];
	
	rep(zzz,0,min(k,50)){
		memset(pre,0,sizeof(pre));
		
		rep(x,0,n){
			pre[max(0,x-arr[x])]++;
			pre[min(200005,x+arr[x]+1)]--;
		}
		
		rep(x,0,n){
			arr[x]=pre[x];
			pre[x+1]+=pre[x];
		}
	}
	
	rep(x,0,n) cout<<arr[x]<<" ";
	cout<<endl;
	
}


Measured memory_bytes: 5212
#include <cstdio>

int BinarySearch(int A[], int n, int key) {
  int left = 0;
  int right = n;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (A[mid] == key) {
      return 1;
    } else if (key < A[mid]) {
      right = mid;
    } else {
      left = mid + 1;
    }
  }
  return 0;
}

int main() {
  int i, n, A[1000000], q, key, sum = 0;

  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%d", &A[i]);
  }

  scanf("%d", &q);
  for (i = 0; i < q; ++i) {
    scanf("%d", &key);
    if (BinarySearch(A, n, key)) {
      ++sum;
    }
  }

  printf("%d\n", sum);
}

Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, count = 0; string S; cin >> N >> S;
  for(char i = '0'; i <= '9'; i++) {
    for(char j = '0'; j <= '9'; j++) {
      for(char k = '0'; k <= '9'; k++) {
        bool j1 = false, j2 = false;
        for(int l = 0; l < N; l++) {
          if(!j1 && S.at(l) == i) {
            j1 = true;
            continue;
          }
          if(!j2 && j1 && S.at(l) == j) {
            j2 = true;
            continue;
          }
          if(j2 && S.at(l) == k) {
            count++;
            break;
          }
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  ll x;
  cin >> x;
  ll cur = 100;
  ll ans = 0;
  while(cur < x) {
    cur += cur / 100;
    ans++;
  }
  cout << ans << endl;
}

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

int main() {
	int N, M; cin >> N >> M;
	string S; cin >> S;
	vector<vector<int>>EA(N);
	vector<vector<int>>EB(N);

	vector<char>dame(N);

	for (int i = 0; i < M; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		
		if (S[b] == 'A')EA[a].push_back(b);
		if (S[b] == 'B')EB[a].push_back(b);
		if (a != b) {
			if (S[a] == 'A')EA[b].push_back(a);
			if (S[a] == 'B')EB[b].push_back(a);
		}
	}

	queue<int>que;
	for (int i = 0; i < N; i++) {
		if (EA[i].size() < 1 || EB[i].size() < 1) {
			dame[i] = true;
			for (int j = 0; j < EA[i].size(); j++) {
				if (dame[EA[i][j]] == false)que.push(EA[i][j]);
			}
			for (int j = 0; j < EB[i].size(); j++) {
				if (dame[EB[i][j]] == false)que.push(EB[i][j]);
			}
		}
	}

	while (que.size()) {
		int i = que.front();
		que.pop();

		if (dame[i])continue;

		for (int j = 0; j < EA[i].size(); j++) {
			if (dame[EA[i][j]]) {
				swap(EA[i][j], EA[i].back());
				EA[i].pop_back();
				j--;
			}
		}
		for (int j = 0; j < EB[i].size(); j++) {
			if (dame[EB[i][j]]) {
				swap(EB[i][j], EB[i].back());
				EB[i].pop_back();
				j--;
			}
		}

		if (EA[i].size() < 1 || EB[i].size() < 1) {
			dame[i] = true;
			for (int j = 0; j < EA[i].size(); j++) {
				if (dame[EA[i][j]] == false)que.push(EA[i][j]);
			}
			for (int j = 0; j < EB[i].size(); j++) {
				if (dame[EB[i][j]] == false)que.push(EB[i][j]);
			}
		}
	}
	
	bool ans = false;
	for (int i = 0; i < N; i++) {
		if (dame[i] == false)ans = true;
	}

	cout << (ans ? "Yes" : "No") << endl;


	return 0;
}

Measured memory_bytes: 17540
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.parseLong;
//import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		HashSet<String> s = new HashSet<>(); 
		for (i = 0; i < n; i++) {
			s.add(sc.next());
		}
		sc.close();
		out.println(s.size()==3?"Three":"Four");
	}
}


Measured memory_bytes: 21716
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int N=2e3+10;
const int mod=998244353;
int n,dp[N<<1][N<<1],s1[N],s2[N];
char s[N];
inline void Add(int &x,int y){x+=y;x-=x>=mod? mod:0;}
int main(){
	scanf("%s",s+1);n=strlen(s+1);
	for(register int i=1;i<=n;i++)s2[i]=s[i]-'0';
	for(register int i=1;i<=n;i++)s1[i]=2-s2[i];
	for(register int i=1;i<=n;i++)s1[i]+=s1[i-1],s2[i]+=s2[i-1];
	dp[0][0]=1;
	for(register int i=1;i<=(n<<1);i++)
		for(register int j=0;j<=s2[n];j++)
			if(i-j<=s1[min(i,n)]&&j<=s2[min(i,n)])
				Add(dp[i][j],dp[i-1][j-1]),Add(dp[i][j],dp[i-1][j]);
	printf("%d\n",dp[n<<1][s2[n]]);
	return 0;
}

Measured memory_bytes: 60544
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - ThREE
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 200000;
const int INF = 1 << 30;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;

/* global variables */

vi nbrs[MAX_N];
int ps[MAX_N], ds[MAX_N];
int cns[2], cs[2][MAX_N];
int qs[MAX_N];

/* subroutines */

inline int nextval(int &x, int n) {
  int r = -1;
  if (x <= n)
    r = x, x += 3;
  return r;
}

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    nbrs[a].push_back(b);
    nbrs[b].push_back(a);
  }

  ds[0] = 0, ps[0] = -1;
  qi q;
  q.push(0);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int up = ps[u], ud = ds[u], vd = ud ^ 1;
    cs[ud][cns[ud]++] = u;

    vi &nbru = nbrs[u];
    for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int v = *vit;
      if (v != up) {
	ds[v] = vd;
	ps[v] = u;
	q.push(v);
      }
    }
  }

  int nxts[] = { 3, 1, 2 };
  int nt = n / 3;

  if (cns[0] <= nt) {
    for (int i = 0; i < cns[0]; i++)
      qs[cs[0][i]] = nextval(nxts[0], n);
    for (int i = 0, k = 0; i < cns[1]; i++) {
      int v = nextval(nxts[k], n);
      qs[cs[1][i]] = (v >= 0) ? v : nextval(nxts[++k], n);
    }
  }
  else if (cns[1] <= nt) {
    for (int i = 0; i < cns[1]; i++)
      qs[cs[1][i]] = nextval(nxts[0], n);
    for (int i = 0, k = 0; i < cns[0]; i++) {
      int v = nextval(nxts[k], n);
      qs[cs[0][i]] = (v >= 0) ? v : nextval(nxts[++k], n);
    }
  }
  else {
    for (int i = 0; i < cns[0]; i++) {
      int v = nextval(nxts[1], n);
      qs[cs[0][i]] = (v >= 0) ? v : nextval(nxts[0], n);
    }
    for (int i = 0, k = 0; i < cns[1]; i++) {
      int v = nextval(nxts[2], n);
      qs[cs[1][i]] = (v >= 0) ? v : nextval(nxts[0], n);
    }
    
  }

  for (int i = 0; i < n; i++) {
    if (i) putchar(' ');
    printf("%d", qs[i]);
  }
  putchar('\n');

  return 0;
}


Measured memory_bytes: 17140
/*
ID:wmj20041
TASK:
LANG:C++
*/
#include<functional>
#include<algorithm>
#include<exception>
#include<stdexcept>
#include<streambuf>
#include<iterator>
#include<string.h>
#include<stdlib.h>
#include<typeinfo>
#include<valarray>
#include<iostream>
#include<sstream>
#include<istream>
#include<stdio.h>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<ctype.h>
#include<cassert>
#include<cstdlib>
#include<utility>
#include<cstring>
#include<numeric>
#include<ostream>
#include<cwctype>
#include<fstream>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cctype>
#include<string>
#include<vector>
#include<limits>
#include<locale>
#include<memory>
#include<cerrno>
#include<time.h>
#include<iosfwd>
#include<cfloat>
#include<cstdio>
#include<cwchar>
#include<cmath>
#include<ctime>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<ios>
#include<map>
#include<set>
#include<new>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define FILLBIG(a) FILL(a,0x7f)
#define ALL(a) (a).begin(),(a).end()
#define Inf ((int)0x7f7f7f7f)
#define Mod 1000000007
#define foreach(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define MASK(a) (1<<(a))
#define MASKX(x,a) ((x)<<(a))
#define BIT(a,b) ((a>>b)&1)
#define cddx(a) priority_queue<a >
#define cxdd(a) priority_queue<a,vector<a >,greater<a > >
#define deval(a) {cerr<<#a<<" = "<<a<<endl;}
#define dearr(be,en) {cerr<<#be;cerr<<" = {";for(auto i=be;i!=en;i++)cerr<<' '<<*i;cerr<<" }\n";}
#define reg register
using namespace std;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int uint;
typedef long long INT;
typedef long double ldouble;
typedef pair<INT,INT> PII;
typedef stringstream sst;
typedef istringstream iss;
typedef vector<int> vint;
typedef vector<INT> VINT;
typedef vector<pii> vpii;
typedef vector<PII> VPII;
typedef priority_queue<int> pqi;
typedef priority_queue<INT> PQI;
typedef priority_queue<pii> pqp;
typedef priority_queue<PII> PQP;
typedef priority_queue<int,vint,greater<int> > xqi;
typedef priority_queue<INT,VINT,greater<INT> > XQI;
typedef priority_queue<pii,vpii,greater<pii> > xqp;
typedef priority_queue<PII,VPII,greater<PII> > XQP;
const int INF=1e9+7;
using namespace std;
int n,a,b;
int main()
{
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n>>a>>b;
	int k=0;
	for (int i=1;i<=n;i++)
	{
		int x=i,s=0;
		while(x>0)
		{
			s+=x%10;
			x/=10;
		}
		if (s>=a&&s<=b) k+=i;
	}
	cout<<k;
	return 0;
}


Measured memory_bytes: 256
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	string S;
	scan(S);
	int ans=0;
	int now=0;
	rep(i,3){
		if(S[i]=='R') now++;
		else now=0;
		ans=max(ans,now);
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int K;
  string S;
  cin >> K >> S;
  if (S.size() > K)
  {
    S = S.substr(0, K);
    S += "...";
  }
  cout << S << endl;
  return 0;
}

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

//https://atcoder.jp/contests/arc086/tasks/arc086_b

int n, vMax = -1e6 - 1, iMax = 0, vMin = 1e6 + 1, iMin = 0;

int main() {
	cin >> n;
	cout << n * 2 - 2 << endl;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a > vMax) {
			vMax = a;
			iMax = i;
		}
		if (a < vMin) {
			vMin = a;
			iMin = i;
		}
	}
	if (vMax > -vMin) {
		for (int i = 0; i < n; i++) {
			if (i == iMax)
				continue;
			cout << iMax + 1 << ' ' << i + 1 << endl;
		}
		for (int i = 1; i < n; i++)
			cout << i << ' ' << i + 1 << endl;
	} else {
		for (int i = 0; i < n; i++) {
			if (i == iMin)
				continue;
			cout << iMin + 1 << ' ' << i + 1 << endl;
		}
		for (int i = n - 1; i > 0; i--)
			cout << i + 1 << ' ' << i << endl;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    int a,b;
    cin>>a>>b;
    if(1<=a&&9>=a&&1<=b&&9>=b){
        cout<<a*b<<endl;
    }else{
        cout<<-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>//////////////////////////////////////////
#define deb(...)/////////////////////////////////////////////////
#define DBP(...)/////////////////////////////////////////////////
#ifdef LOC///////////////////////////////////////////////////////
#include"debuglib.h"/////////////////////////////////////////////
#endif///////////////////////////////////////////////////////////
#define x first//////////////////////////////////////////////////
#define y second/////////////////////////////////////////////////
#define pb push_back/////////////////////////////////////////////
#define sz(x)int((x).size())/////////////////////////////////////
#define each(a,x)for(auto&a:(x))/////////////////////////////////
#define all(x)(x).begin(),(x).end()//////////////////////////////
#define rep(i,b,e)for(int i=(b);i<(e);i++)///////////////////////
using namespace std;using ll=long long;using Pii=pair<int,int>;//
using Vi=vector<int>;void run();int main(){cin.sync_with_stdio///
(0);cin.tie(0);cout<<fixed<<setprecision(18);run();return 0;}////
//-------------------------------------------------------------//

void ans(bool b) {
	cout << (b ? "Yes" : "No") << endl;
	exit(0);
}

vector<bool> getReach(string& s, int a) {
	vector<bool> vec(sz(s));
	vec[a] = 1;

	for (int i = a+1; i < sz(s); i++) {
		if (s[i] == '#') continue;
		vec[i] = vec[i-1];
		if (!vec[i] && i > 1) vec[i] = vec[i-2];
	}

	for (int i = a-1; i >= 0; i--) {
		if (s[i] == '#') continue;
		vec[i] = vec[i+1];
		if (!vec[i] && i+2 < sz(s)) vec[i] = vec[i+2];
	}

	return vec;
}

void run() {
	int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
	string s; cin >> s;
	a--; b--; c--; d--;

	vector<bool> reach1 = getReach(s, a), reach2 = getReach(s, b);

	if (!reach1[c]) ans(0);
	if (!reach2[d]) ans(0);
	if (c < d) ans(1);

	for (int i = max(b+1, 2); i <= min(c, d+1); i++) {
		if (s[i-2] == '.' && s[i-1] == '.' && s[i] == '.') {
			if (reach1[i] && reach2[i]) ans(1);
		}
	}

	ans(0);
}


Measured memory_bytes: 592
k,s=gets.chomp.split(" ").map(&:to_i)
count = 0
for x in 0..k do
    for y in 0..k do
        z = s - (x + y)
        if z >= 0 && z <= k && (x + y + z) == s
            count += 1
        end
    end
end
print(count)

Measured memory_bytes: 1788
#include<bits/stdc++.h>
	
	#define pb push_back
	#define ppb pop_back
	#define mp make_pair
	#define all(x) (x).begin(),(x).end()
	#define sz(x) (int)(x).size()
	#define ll long long
	#define bit __builtin_popcountll
	#define sqr(x) (x) * (x)
	#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
	#define debug(x) cout << #x <<" = " << x << endl
	#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
	#define printvpair(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i].first  <<" " << v[i].second << endl;
	#define printv(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i] << " "; cout << endl;
	
	using namespace std;
	
	typedef pair<int, int> pii;
	
	const double eps = 1e-9;
	const double pi = acos(-1.0);
	const int INF = 1000000000;
	
	const int dx[4] = {0,  0, 1, -1};
	const int dy[4] = {1, -1, 0,  0};
	
	const int N = 100000;
	int main() {
		ios_base::sync_with_stdio(0);
		int n,m;
		cin >> n >> m;
		for(int i = 0; i < n; i++){
			string s;
			cin >> s;
			cout << s << endl;
			cout << s << endl;
		}
	  	return 0;
	}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
           //2文字と3文字を調べればok
		   string s;
           cin>>s;
           int n=s.size();
           rep(i,0,n-1){//2
             if(s[i]==s[i+1]){
              cout<<i+1<<" "<<i+2<<endl;
               return 0;
             }
           }
           rep(i,0,n-2){//3
             if(s[i]==s[i+2]){
              cout<<i+1<<" "<<i+3<<endl;
               return 0;
             }
           }
           cout<<-1<<" "<<-1<<endl;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main(){
    string t; cin >> t;

    rep(i, t.size()) {
        if(t[i] == '?') {
            if(t[i-1] == 'P') {
                t[i] = 'D';
            } else if(t[i+1] == 'D') {
                t[i] = 'P';
            } else if(t[i+1] == '?') {
                t[i] = 'P';
            } else {
                t[i] = 'D';
            }
        }
    }

    cout << t;
}


Measured memory_bytes: 3748
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
inline void read(int &x){
    x=0;static char ch;static bool flag;flag = false;
    while(ch=getchar(),ch<'!');if(ch == '-') ch=getchar(),flag = true;
    while(x=10*x+ch-'0',ch=getchar(),ch>'!');if(flag) x=-x;
}
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
const int maxn = 200010;
int s[maxn];
int main(){
    int n,K;read(n);read(K);
    //printf("n = %d,K = %d\n",n,K);
    ll ans = 0;
    for(int i=1;i<=n;++i)
        ++ s[i % K];
    if((K&1) == 0){
        ans += 1LL*s[K/2]*s[K/2]*s[K/2];
    }ans += 1LL*s[0]*s[0]*s[0];
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include<stdio.h>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main(){
    int N,a;
    cin>>N;
    //int count=0;
    int amari=0;
    int sum=0;
    int min=0;
    for(int i=0; i<N; i++){
        cin>>a;
        if(a%2==1){
            if(min==0){
                min=a;
            }
            if(min>a){
                min=a;
            }
        }
        sum=sum+a;
    }
    if(sum%2==1){
        sum=sum-min;
    }
    sum=sum/2;
    cout<<sum<<endl;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long 
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=2e5+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
int main() 
{

	int n ;
    cin>>n;
    int r[n+5];
    int w[n+5];
    memset(r,  0 , sizeof(r));
    memset(w, 0 , sizeof(w));
    string s;
    cin>>s;

    for(int i=0;i<n;i++){
        r[i+1]=r[i];
        if(s[i]=='R') r[i+1]+=1;
    }
    int ans=0;
    int tot_r = r[n];
    for(int i=0;i<tot_r;i++)
        if(s[i]=='W') ans = ans+1;
    cout<<ans;
}


Measured memory_bytes: 5240
n = int(input())
mod = pow(10, 9) + 7
x = []
for i in range(2 * n):
    if i < n:
        x.append([int(input()), 0])
    else:
        x.append([int(input()), 1])
x.sort()
ans, cnt0, cnt1 = 1, 0, 0
for i in range(2 * n):
    if x[i][1] == 0:
        if cnt1 >= 1:
            ans *= cnt1
            ans %= mod
            cnt1 -= 1
        else:
            cnt0 += 1
    else:
        if cnt0 >= 1:
            ans *= cnt0
            ans %= mod
            cnt0 -= 1
        else:
            cnt1 += 1
print(ans)

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

template<typename T>
struct Q002 {
   Int v;
   std::vector<std::vector<std::tuple<Int, T>>> graph;
   Q002(Int v_) : v(v_), graph(v) {}
   void set(Int a, Int b, T c) {
      graph[a].emplace_back(b, c);
   }
   const std::vector<std::tuple<Int, T>>& nexts(Int a) const {
      return graph[a];
   }
};

template<typename T>
struct F002 {
   std::vector<std::tuple<bool, T>> operator()(const Q002<T>& graph, Int begin) const {
      Int v = graph.v;
      std::vector<std::tuple<bool, T>> xs(v, std::make_tuple(false, 0));
      std::priority_queue<std::tuple<T, Int>, std::vector<std::tuple<T, Int>>, std::greater<std::tuple<T, Int>>> q;
      q.push(std::make_tuple(0, begin));
      xs[begin] = std::make_tuple(true, 0);
      while( not q.empty() ) {
         T d; Int i; std::tie(d, i) = q.top(); q.pop();
         for(auto kc : graph.nexts(i)) {
            Int k; T c; std::tie(k, c) = kc;
            T nd = d + c;
            bool b; T td; std::tie(b, td) = xs[k];
            if( not b or nd < td ) {
               xs[k] = std::make_tuple(true, nd);
               q.push(std::make_tuple(nd, k));
            }
         }
      }
      return xs;
   }
};

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      Int v, e, r; scan(v, e, r);
      Q002<Int> graph(v);
      for(Int i = 0; i < e; ++i) {
         Int a, b, c; scan(a, b, c);
         graph.set(a, b, c);
      }
      F002<Int> dijkstra;
      auto xs = dijkstra(graph, r);
      for(auto bd : xs) {
         bool b; Int d; std::tie(b, d) = bd;
         if( not b ) puts("INF");
         else printf("%ld\n", d);
      }
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}

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

int main()
{
int i;
int N;
int H;
int W;
int A;
int B;
int iCnt;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> H;
	cin >> W;

	iCnt = 0;
	for( i = 0; i < N; i++ )
	{
		cin >> A;
		cin >> B;
		if( A >= H && B >= W ) iCnt++;
	}

	cout << iCnt << endl;

	return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using ld = long double;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
struct INF { template<class T> operator T() { return numeric_limits<T>::max() / 2; } } INF;
const ld eps = 1e-11;
int sgn(const ld &r) {return (r > eps) - (r < eps);}


template<class T>
T op(T &a, T &b) {
    return max(a,b);
}

template<class T>
T e() {
    return 0;
}

template<class T>
struct SegmentTree {

    int n;
    int size;
    vector<T> val;

    SegmentTree(int _n) {
        n = 1;
        size = _n;
        while(n < _n) n *= 2;
        val.assign(n*2, e<T>());
    }

    void update(int k, T a) { // val[k] = a;
        k += n-1;
        val[k] = a;
        while(k > 0) {
            k = (k-1) / 2;
            val[k] = op(val[k*2+1], val[k*2+2]);
        }
    }

    T query(int l, int r) { // 閉区間[l,r]
        return _query(l, r+1, 0, 0, n);
    }
    T _query(int a, int b, int k, int l, int r) {
        if(r <= a || b <= l) return e<T>();
        if(a <= l && r <= b) return val[k];
        else {
            T vl = _query(a, b, k*2+1, l, (l+r)/2);
            T vr = _query(a, b, k*2+2, (l+r)/2, r);
            return op(vl, vr);
        }
    }
};

const int mx = 300000;

int main(){

    int n, k;
    cin >> n >> k;

    SegmentTree<int> st(mx+1);
    rep(i,n) {
        int a;
        cin >> a;
        int tot = st.query(max(0,a-k), min(mx,a+k));
        st.update(a,tot+1);
    }

    int ans = 0;
    rep(i,mx) {
        chmax(ans, st.query(i,i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 7456
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
using P=pair<int,int>;

const int MAX=2011;
int main(){
  char a,b;
  cin>>a>>b;
  if(a>b)
    cout<<">"<<endl;
  else if(a==b)
    cout<<"="<<endl;
  else
    cout<<"<"<<endl;
  return 0;
}
    
	
			   


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

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

  sort(l.begin(), l.end());
  int ans = 0;
  rep(b, n) rep(a, b) {
    int ab = l[a] + l[b];
    int right = lower_bound(l.begin(), l.end(), ab) - l.begin();
    int left = b + 1;
    ans += max(0, right - left);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n, w = map(int, input().split())

nap = [list(map(int, input().split())) for _ in range(n)]

INF = float('inf')
num = 10**5 + 10
dp = [[INF]*(10**5+10) for _ in range(110)]

dp[0][0] = 0
for i in range(n):
    for v in range(10**5+1):
        if v + nap[i][1] <= 10**5+1:
            dp[i+1][v+nap[i][1]] = min(dp[i+1][v+nap[i][1]], dp[i][v] + nap[i][0])
        dp[i+1][v] = min(dp[i+1][v], dp[i][v])

for v in reversed(range(10**5+1)):
    if dp[n][v] <= w:
        print(v)
        exit()


Measured memory_bytes: 312952
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int main() {
  bool a[4][4];rep(i,4)rep(j,4)a[i][j] = false;
  rep(i,3){
    int aa,bb;cin>>aa>>bb;
    a[aa-1][bb-1] = a[bb-1][aa-1] = true;
  }
  vector<int> ans;
  rep(i,4){
    int cnt = 0;
    rep(j,4){
      if(a[i][j])cnt++;
    }
    ans.push_back(cnt);
  }
  sort(ans.begin(), ans.end());
  bool aaa = ans[0] == 1 && ans[1] == 1 && ans[2] == 2 && ans[3] == 2;
  cout << (aaa ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<cstring>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstdlib>
#define reep(n1,n2,n3) for(int n1=n3;n1<n2;n1++)
#define rep(n1,n2) reep(n1,n2,0)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF 1e9
using namespace std;
typedef long long int lint;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int,int> > vp;
typedef pair<int,int> pi;
typedef pair<int,pair<int,int> > pii;
typedef vector<string> vs;
const double PI  = acos(-1.0);
int num[100000];
int main(){
    int n,k;
    while(cin>>n>>k,n){
        rep(i,n)cin>>num[i];
        int ret=-INF;
        int buf=0;
        rep(i,k){
            buf+=num[i];
        }
        ret=max(buf,ret);
        rep(i,n-k){
            buf-=num[i];
            buf+=num[i+k];
            ret=max(buf,ret);
        }
        cout<<ret<<endl;
    }
}

Measured memory_bytes: 1548
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    val SW = (0 until M).map { it to listOfInt().drop(1).map { 1 shl (it - 1) } }
    val P = listOfInt()
    var ans = 0
    for (n in 0 until (1 shl N)) {
        val sw = SW.count {
            val c = it.second.count { n and it != 0 }
          //c > 0 &&
            c % 2 == P[it.first]
        }
        if (sw == M) ans += 1
    }
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

Measured memory_bytes: 38060
#include<bits/stdc++.h>
using namespace std;
long long int n,a,b,f;
vector<long long int>v;
int main()
{
    cin>>n;
    b=1,f=0;
    for(int i=0; i<n; i++)
    {
        cin>>a;
        if(a==0)
            f=1;
        v.push_back(a);
    }
    if(f)
        return cout<<0<<endl,0;
    for(int i=0; i<n; i++)
    {
        if(b / 1e18 * v[i] <= 1.00)
            b*=v[i];
        else
            return cout<<-1<<endl,0;
    }

    if (b <= 1000000000000000000LL)
        cout<<b;
    else
        cout << -1;
    return 0;
}

Measured memory_bytes: 4300
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<cstdlib>
#include<iostream>
#include<bitset>
#include<functional>
using namespace std;
/*********************************************************************************************/
inline int read(){int x=0;bool fg=0;char ch=getchar();while(ch<'0'||'9'<ch)fg|=ch=='-',       //
ch=getchar();while('0'<=ch&&ch<='9')x=x*10+ch-'0',ch=getchar();return fg?-x:x;}               //
inline long long readll(){long long x=0;bool fg=0;char ch=getchar();while(ch<'0'||'9'<ch)     //
fg|=ch=='-',ch=getchar();while('0'<=ch&&ch<='9')x=x*10+ch-'0',ch=getchar();return fg?-x:x;}   //
inline void Out(int x){if(x<0)x=-x,putchar('-');if(x>9)Out(x/10);putchar(x%10+'0');}          //
inline void Outll(long long x){if(x<0)x=-x,putchar('-');if(x>9)Outll(x/10);putchar(x%10+'0');}//
inline double readdb(){double Dec=0.1,num;bool IsN=false,IsD=false;char ch=getchar();         //
while(ch!='-'&&ch!='.'&&(ch<'0'||ch>'9'))ch=getchar();if(ch=='-')IsN=true,num=0;              //
else if(ch=='.')IsD=true,num=0;else num=ch-'0';if(!IsD){while(ch=getchar(),ch>='0'&&ch<='9')  //
num=num*10+ch-'0';}if(ch=='.'){while(ch=getchar(),ch>='0'&&ch<='9')num+=Dec*(ch-'0'),Dec*=0.1;//
}return IsN?-num:num;}                                                                        //
/*********************************************************************************************/
#define out(x) Out(x),putchar('\n')
#define outll(x) Outll(x),putchar('\n')
#define ll long long
#define eps 1e-10
#define E exp(1)
#define INF 0x3f3f3f3f
#define inf 0x3f3f3f3f3f3f3f3f
#define pi acos(-1)
#define mem0(x) memset(x,0,sizeof(x))
#define mem(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define ui unsigned int
#define ull unsigned long long
/***************************************/
const int MOD=1e9+7;
const int maxn=5e5+3;

int main()
{
    string s;
    cin>>s;
    if(s=="AKIHABARA"||s=="KIHABARA"||s=="AKIHBARA"||s=="AKIHABRA"||s=="AKIHABAR"||s=="KIHBARA"||s=="KIHABRA"||s=="KIHABAR"||s=="AKIHBRA"||s=="AKIHBAR"||s=="AKIHABR"||s=="KIHBRA"||s=="KIHABR"||s=="KIHBAR"||s=="AKIHBR"||s=="KIHBR")
        puts("YES");
    else
        puts("NO");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1,mod=1e9+7;
const int inf=(1ull<<31)-1;
int n,k,a[100001],s=0;
ll fac[100001];

ll mpw(ll a,ll b=mod-2){
	ll d=1;
	for (;b;d=d*a%mod,b--)
		for (;!(b&1);a=a*a%mod,b>>=1);
	return d;
}

void f(){
	fac[1]=fac[0]=1;
	for (int i=2;i<100001;i++)
		fac[i]=(1ll*fac[i-1]*i)%mod;
}

ll C(ll a,ll b){
	return fac[b]*mpw(fac[b-a]*fac[a]%mod)%mod;
}

int main()
{
	//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(15);//878067114//
	cin>>n>>k;
	for (int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	f();
	for (int i=k-1;i<n;i++){
		s+=C(k-1,i)*a[i]%mod;
		if (s>mod)
			s-=mod;
		if (s<0)
			s+=mod;
	}
	reverse(a,a+n);
	for (int i=k-1;i<n;i++){
		s-=C(k-1,i)*a[i]%mod;
		if (s<0)
			s+=mod;
		if (s>mod)
			s-=mod;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 1408
a,b,c,d = map(str,input())

n = 3
pt = []
for i in range(2 ** n):
  tmp = ["+"] * n
  for j in range(n):
    if i >> j & 1:
      tmp[j] = "-"
  pt.append(tmp)
for x in pt:
  fr = a + x[0] + b + x[1] + c+ x[2] + d 
  if eval(fr) == 7 :
    print(fr+"=7")
    exit()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll H, W, h, w;
  cin >> H >> W >> h >> w;

  cout << ((H - h) * (W - w)) << endl;
}

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

#define MAX_R 100
#define MAX_C 100

int main() {
  int r, c;

  // 要素保存のための表, 但し最終要素は合計値
  //  sheet[r][c] : 全要素の合計
  //  sheet[r][]  : 列の合計
  //  sheet[][c]  : 行の合計
  int sheet[MAX_R + 1][MAX_C + 1];

  // 表の行数・列数
  cin >> r >> c;

  for (int i = 0; i < r; i++) {
    sheet[i][c] = 0;
  }
  for (int j = 0; j < c; j++) {
    sheet[r][j] = 0;
  }
  sheet[r][c] = 0;

  // データ入力と合計積み上げ
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      int val;
      cin >> val;
      sheet[i][j] = val;
      sheet[r][j] += val;
      sheet[i][c] += val;
      sheet[r][c] += val;
    }
  }

  // 出力
  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= c; j++) {
      cout << sheet[i][j];
      if (j == c)
        cout << endl;
      else
        cout << " ";
    }
  }

  return 0;
}



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

int main() {
  long long N, M; cin >> N >> M;
  if( M >= 2 * N ) {
    cout << N + ( M - 2 * N ) / 4 << endl;
  } else {
    cout << M / 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

string s;

int main() {
	cin >> s;
	if (s[s.size() - 1] == 's') {
		cout << s << "es" << endl;
	}
	else {
		cout << s << "s" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
typedef long long ll;
using namespace std; 

int main(){
	ll x; cin>>x;
	ll move;
	if(x<=6)move=1;
	else if(x<=11)move=2;
	else if(x%11==0)move=x/11*2;
	else if(x%11<=6)move=x/11*2+1;
	else move=x/11*2+2;
	cout<<move;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
N,M,C = map(int,input().split())
B = np.array(list(map(int , input().split())))
A = [list(map(int , input().split())) for _ in range(N)]
ans = 0
for i in range(N):
	tem = np.array(A[i])
	if np.dot(tem,B)+C>0:
		ans +=1

print(ans)

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

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  cout << N / 3 << endl;

  return 0;
}


Measured memory_bytes: 256