akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

ll n; cin >> n;
string s = "";

rep(i,50) {
    if(n % (ll)pow(2, i+1) == 0) s.push_back('0');
    else {
        s.push_back('1');
        n -= (ll)pow(-2, i);
    }
    if(n == 0) break;
}
reverse(all(s));
cout << s << endl;
return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())

s = []
s_ap = s.append

for i in range(N):
    s_ap("".join(sorted(input())))

result = 0

for i in Counter(s).values():
    if not i == 1:
        result += int(i * (i - 1) / 2)
        
print(result)



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

int main() {
	int n,max,min,r[200000];
	cin >> n;

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

	min=r[0];
	max=0x80000000;// 0x80000000???????????´??° (-2147483648)

	for(int i=1;i<n;i++){ // min???r[0]????????????????????§1??????????????????
		if( (r[i]-min)>max ){
			max=r[i]-min;
		}
		if( r[i]<min ){
			min=r[i];
		}
	}

	cout <<  max << "\n";
    return 0;
}

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

ll N, K, A[200010], F[200010];

ll search(void){
	ll ok = 1e13, ng = -1;
	while(ok - ng > 1){
		ll cnt = 0;
		ll mid = (ok + ng)/2;
		for(int i=0; i<N; i++){
			if(mid < F[i]*A[N-1-i]){
				cnt += A[N-1-i] - mid/F[i];
			}
		}
		if(cnt <= K){
			ok = mid;
		}else{
			ng = mid;
		}
	}
	return ok;
}

int main(){
	cin >> N >> K;
	for(int i=0; i<N; i++) cin >> A[i];
	for(int i=0; i<N; i++) cin >> F[i];
	sort(A, A+N);
	sort(F, F+N);
	cout << search() << endl;
	return 0;
}


Measured memory_bytes: 3328
S=input()
for i in range(8):
  formula=S[0]
  q="{:0>4b}".format(i)[::-1]
  for j in range(1,4):
    if int(q[j-1])&1:
      formula+="+"
    else:
      formula+="-"
    formula+=S[j]
  if eval(formula)==7:
    print(formula+"=7")
    exit()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    string x;
    cin >> x;
    int cnt = 0;
    rep(i, n) {
        if (x[i] == '1') cnt++;
    }
    reverse(ALL(x));
    int t[2] = {};
    int base[2];
    base[0] = 1;
    base[1] = 1;
    rep(i, n){
        if(x[i] == '1'){
            t[0] += base[0];
            t[0] %= cnt + 1;
            if (cnt - 1 > 0) t[1] += base[1];
            if (cnt - 1 > 0) t[1] %= cnt - 1;
        }
        base[0] *= 2;
        base[0] %= cnt + 1;
        if (cnt - 1 > 0) base[1] *= 2;
        if (cnt - 1 > 0) base[1] %= cnt - 1;
    }
    base[0] = 1;
    base[1] = 1;
    int ans[n];
    rep(i, n) {
        if (x[i] == '1' && cnt == 1) {
            ans[i] = 0;
            continue;
        }
        if (x[i] == '1') {
            int nxt;
            int cur = (t[1] - base[1] + cnt - 1) % (cnt - 1);
            int anss = 1;
            while (cur > 0) {
                nxt = cur % __builtin_popcount(cur);
                cur = nxt;
                anss++;
            }
            ans[i] = anss;
        } else {
            int nxt;
            int cur = (t[0] + base[0]) % (cnt + 1);
            int anss = 1;
            while(cur > 0){
                nxt = cur % __builtin_popcount(cur);
                cur = nxt;
                anss++;
            }
            ans[i] = anss;
        }
        base[0] *= 2;
        base[0] %= cnt + 1;
        if (cnt - 1 > 0) base[1] *= 2;
        if (cnt - 1 > 0) base[1] %= cnt - 1;
    }
    reverse(ans, ans + n);
    rep(i, n) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

typedef vector<int> vec;
typedef vector<vec > mat;

typedef pair<int,int> P;

mat bnf();

int N, L, p;
string s;

mat cal(char c, int num){
  
  mat res( N, vec( N ) );
  
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++) res[i][j] = i * N + j + 1;
  
  num--;
  
  if( c == 'L' ){
    int tmp = res[num][0];
    for(int i=0;i<N-1;i++) res[num][i] = res[num][i+1];
    res[num][N-1] = tmp;
  }
  
  if( c == 'R' ){
    int tmp = res[num][N-1];
    for(int i=N-1;i>0;i--) res[num][i] = res[num][i-1];
    res[num][0] = tmp;
  }
  
  if( c == 'U' ){
    int tmp = res[0][num];
    for(int i=0;i<N-1;i++) res[i][num] = res[i+1][num];
    res[N-1][num] = tmp;
  }
  
  if( c == 'D' ){
    int tmp = res[N-1][num];
    for(int i=N-1;i>0;i--) res[i][num] = res[i-1][num];
    res[0][num] = tmp;
  }

  return res;
}

mat marge1(mat A, mat B){
  
  mat res( N, vec( N ) );
  
  for(int i=0;i<N;i++){
    
    for(int j=0;j<N;j++){
      B[i][j]--;
      res[i][j] = A[B[i][j]/N][B[i][j]%N];
    }
    
  }
  
  return res;
}

mat marge2(mat A, int num){ // doubling
  
  mat res( N, vec(N) );
  
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++) res[i][j] = i * N + j + 1;
  
  while(num){
    
    if( num % 2 ) res = marge1( res, A );
    
    A = marge1( A, A );
    
    num /= 2;
  }

  return res;
}


mat get_num(){
  
  if( s[p] == '(' ){
    
    p++;
    
    mat r = bnf();
    
    int num = 0;
    
    while( '0' <= s[p] && s[p] <= '9' ) num = num * 10 + s[p++] - '0';
    
    r = marge2( r, num );
    
    return r;
  }
  
  char c = s[p++];
  
  int num = 0;
  
  while( '0' <= s[p] && s[p] <= '9' ) num = num * 10 + s[p++] - '0';
  
  return cal( c, num );
}

mat bnf(){
  
  mat res = get_num();
  
  while( p < L ){
    
    if( s[p] == ')' ){
      p++;
      break;
    }
    
    mat r = get_num();
    
    res = marge1( res, r );
    
  }
  
  return res;
}

signed main(){
  
  cin>>N>>L;
  
  cin>>s;
  
  mat ans = bnf();
  
  for(int i=0;i<N;i++){
    
    for(int j=0;j<N;j++){
      
      if( j ) cout<<' ';

      cout<<ans[i][j];
      
    }

    cout<<endl;
    
  }
  
  return 0;
}



Measured memory_bytes: 5216
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int n,p,q;
  cin>>n>>p>>q;
  vector<Int> c(n);
  for(Int i=0;i<n;i++) cin>>c[i];
  vector<Int> v(n);
  for(Int i=0;i<n;i++)
    v[i]=(q-i)*p-c[i];
  
  sort(v.rbegin(),v.rend());
  Int tmp=accumulate(c.begin(),c.end(),Int(0));
  Int ans=tmp;
  for(Int i=0;i<n;i++){
    tmp+=v[i];
    ans=max(ans,tmp+i*(i+1)*p);
    //cout<<i+1<<":"<<tmp<<":"<<i*(i+1)*p<<endl;
  }
  
  cout<<ans<<endl;
  return 0;
}

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

typedef long long ll;

using namespace std;

ll gcd(ll a, ll b) {
    if (a > b)swap(a, b);
    if (a == 0) return b;
    return gcd(b % a, a);
}

ll N, A[100000], B[100000], C[100000];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    B[0] = A[0], C[N - 1] = A[N - 1];
    for (int i = 1, j = N - 1 - i; i < N; i++, j--) {
        B[i] = gcd(B[i - 1], A[i]);
        C[j] = gcd(C[j + 1], A[j]);
    }
    ll ans = max(C[1], B[N - 2]);
    for (int i = 1; i > 0 && i < N - 1; i++) {
        ans = max(ans, gcd(B[i - 1], C[i + 1]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define max_v(v) *max_element(all(v));
#define min_v(v) *min_element(all(v));
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl
template <typename T> istream& operator >> (istream& is, vector<T>& vec) {
    for(T& x : vec) is >> x;
    return is;
}
template<typename T> ostream& operator << (ostream& os, vector<T>& vec) {
    for(int i = 0; i < vec.size(); i++) {
        os << vec.at(i) << (i + 1 == vec.size() ? "" : " ");
    }
    return os;
}

ll attack(ll N) {
    if(N == 1) {
        return 1;
    }
    return attack(N / 2) * 2 + 1;
}

int main() {
    ll H;
    cin >> H;
    
    cout << attack(H) << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


int main(){
    int X, Y, Z, K; cin >> X >> Y >> Z >> K;
    VLL A(X), B(Y), C(Z);
    REP(i, X) cin >> A[i];
    REP(i, Y) cin >> B[i];
    REP(i, Z) cin >> C[i];
    RSORT(A); RSORT(B); RSORT(C);
    VLL ANS;
    REP(i, X){
        REP(j, Y){
            REP(k, Z){
                if(i*j*k <= K) ANS.PB(A[i] + B[j] + C[k]);
                else break;
            }
        }
    }
    RSORT(ANS);
    REP(i, K)
        cout << ANS[i] << "\n";
    return 0;
}


Measured memory_bytes: 35176
#include <stdio.h>
#define N 45

int main(){
  int i,n;
  int F[N];

  scanf("%d",&n);

  F[0] = F[1] = 1;

  for(i=2;i<=n;i++){
    F[i] = F[i-1] + F[i-2];
  }

  printf("%d\n",F[n]);

  return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>

typedef long long LL;

const int N = 105;
int d[N], pre[N], nxt[N * 2], to[N * 2], cnt;
inline void addEdge(int x, int y) {
  nxt[cnt] = pre[x];
  ++d[to[pre[x] = cnt++] = y];
  nxt[cnt] = pre[y];
  ++d[to[pre[y] = cnt++] = x];
}

inline int readInt() {
  int ans = 0, c, f = 1;
  while (!isdigit(c = getchar()))
    if (c == '-') f *= -1;
  do ans = ans * 10 + c - '0';
  while (isdigit(c = getchar()));
  return ans * f;
}

int n;
int ans1;
LL ans2;

void Calc(int x, int y = -1) {
  static bool vis[N];
  static int _p[2][N];
  memset(vis, 0, sizeof vis);
  int *p = _p[0], *p2 = _p[1];
  int m = 0, m2 = 0;
  vis[p[m++] = x] = true;
  if (y >= 0) vis[p[m++] = y] = true;
  LL ans = m;
  int len = 0;
  while (m > 0) {
    ++len;
    int k = 1;
    m2 = 0;
    for (int i = 0; i < m; ++i) {
      int z = p[i], t = 0;
      for (int j = pre[z]; j >= 0; j = nxt[j])
        if (!vis[to[j]])
          ++t, vis[p2[m2++] = to[j]] = true;
      k = std::max(k, t);
    }
    std::swap(p2, p);
    m = m2;
    ans *= k;
  }
  if (ans1 > len || (ans1 == len && ans2 > ans)) {
    ans1 = len;
    ans2 = ans;
  }
}

int main() {
  n = readInt();
  memset(pre, -1, sizeof pre);
  for (int i = 1; i < n; ++i)
    addEdge(readInt(), readInt());
  ans2 = ans1 = n;
  for (int x = 1; x <= n; ++x) {
    Calc(x);
    for (int i = pre[x]; i >= 0; i = nxt[i])
      if (to[i] > x)
        Calc(x, to[i]);
  }
  printf("%d %lld\n", ans1, ans2);
  return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e5 + 5;
const int LOG = 19;


struct query {
    ll color, value;
    int u, v;
    void read() {
	cin>>color>>value>>u>>v;
	--u; --v;
    }
};

int n, q;
int par[LOG+1][maxn];
int dep[maxn];
vector<pair<int,int>> g[maxn];
ll color[maxn], len[maxn];

query qu[maxn];
vector<int> en[maxn];
ll cnt[maxn]; // for query i, how many of it's colored edge does it have
ll acc[maxn]; // for query i, what's the sum of lengths


void dfs(int at, int p=0) {
    for (int j=1; j<LOG; j++) {
	par[j][at] = par[j-1][par[j-1][at]];
    }
    for (auto ed: g[at]) {
	int to = ed.second;
	if (to==p) continue;
	dep[to] = 1+dep[at];
	par[0][to] = at;
	dfs(to, at);
    }
}

int lca(int u, int v) {
    if (dep[u] < dep[v]) swap(u, v);
    int dx = dep[u] - dep[v];
    for (int j=0; j<LOG; j++) {
	if (dx>>j&1) {
	    u = par[j][u];
	}
    }
    if (u == v) return u;

    for (int j=LOG-1; j>=0; j--) {
	if (par[j][u] != par[j][v]) {
	    u = par[j][u];
	    v = par[j][v];
	}
    }

    return par[0][u];
}


vector<ll> pathsum;
vector<pair<int,ll>> colors[maxn]; // (dep, len)

void go(int at, int p=0) {
    
    for (int qi: en[at]) {
	
	int oth = (at^qu[qi].u^qu[qi].v);
	int mid = lca(oth, at);
	int qcol = qu[qi].color;
	
	if (dep[at] > 0) {
	    // subtract thing right before (dep[mid, acc)
	    // colors[qcol] is padded with (-1, 0)
	    auto iter = std::prev(std::upper_bound(colors[qcol].begin(), colors[qcol].end(), make_pair(dep[mid],-1ll)));
	    cnt[qi] += int(colors[qcol].size())-1-(iter-colors[qcol].begin());
	    
	    assert(pathsum.size());
	    ll rm = colors[qcol].back().second - iter->second;
	    acc[qi] -= rm;	    
	    acc[qi] += (pathsum.back() - (dep[mid] > 0 ? pathsum[dep[mid]-1] : 0));
	}
    }
    
    for (auto ed: g[at]) {
	int to = ed.second;
	if (to == p) continue;
	int eId = ed.first;
	pathsum.push_back(len[eId] + (pathsum.empty() ? 0 : pathsum.back()));
	colors[color[eId]].push_back({dep[at], colors[color[eId]].back().second + len[eId]});
	go(to, at);
	pathsum.pop_back();
	colors[color[eId]].pop_back();
    }
}

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

    cin>>n>>q;
    for (int i=0; i<n-1; i++) {
	int u,v;
	cin>>u>>v>>color[i]>>len[i];
	--u;--v;
	g[u].push_back({i,v});
	g[v].push_back({i,u});
    }

    dfs(0);


    for (int i=0; i<q; i++) {
	qu[i].read();
    }


    for (int i=0; i<q; i++) {
	int u = qu[i].u;
	int v = qu[i].v;
	en[u].push_back(i);
	en[v].push_back(i);
    }

    for (int i=1; i<=n-1; i++) {
	colors[i].push_back(make_pair(-1, 0));
    }

    go(0);

    for (int i=0; i<q; i++) {
	ll res = cnt[i]*qu[i].value + acc[i];
	cout<<res<<"\n";
    }

            
    
    return 0;
}


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

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

  string s;
  cin >> s;

  string ans;
  for (auto i : s) {
    if (i == 'B') {
      ans = ans.substr(0, max(0, (int)ans.size()-1));
    }
    else ans += i;
  }

  cout << ans << endl;
}

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

typedef long long ll;

int main() {	
	int n, m;
	cin >> n >> m;
	vector<string> s(n);
	for (int i = 0; i < n; ++i) {
		cin >> s[i];
	}
	int inf = 1e9 + 7;
	int ans = 0;
	vector<vector<int>> chd(n,vector<int> (m));
	for (int ii = 0; ii < n; ++ii) {
		for (int jj = 0; jj < m; ++jj) {
			if (ii + 1 < n && s[ii +  1][jj] == '.') {
				chd[ii][jj]++;
			}
			if (ii - 1 >= 0 && s[ii - 1][jj] == '.') {
				chd[ii][jj]++;
			}
			if (jj + 1 < m && s[ii][jj + 1] == '.') {
				chd[ii][jj]++;
			}
			if (jj - 1 >= 0 && s[ii][jj - 1] == '.') {
				chd[ii][jj]++;
			}
		//	cout << chd[ii][jj] << " "; 
		}
		//cout << endl;
	}

	//vector<vector<int>> dp(n,vector<int> (m,inf));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			if (s[i][j] == '.') {
				vector<vector<int>> dp(n,vector<int> (m,inf));
				queue<vector<int>> q;
				q.push({i,j,1});
				vector<vector<int>> ch(n,vector<int> (m));
				ch = chd;
				ch[i][j] = 0;
				while (!q.empty()) {
					vector<int>  top = q.front();
					int x = top[0];
					int y = top[1];
					if (x + 1 < n && s[x + 1][y] == '.' && ch[x + 1][y]) {
						dp[x + 1][y] = min(dp[x + 1][y],top[2]);
						q.push({x + 1, y,top[2] + 1});
						ch[x + 1][y]--;
					}
					if (x - 1 >= 0 && s[x - 1][y] == '.' && ch[x - 1][y]) {
						dp[x - 1][y] = min(dp[x - 1][y],top[2]);
						q.push({x - 1, y,top[2] +1 });
						ch[x - 1][y]--;
					}
					if (y + 1 < m && s[x][y + 1] == '.' && ch[x][y + 1]) {
						dp[x][y + 1] = min(dp[x][y + 1],top[2]);
						q.push({x, y + 1,top[2] + 1});
						ch[x][y + 1]--;
					}
					if (y - 1 >= 0 && s[x][y - 1] == '.' && ch[x][y - 1]) {
						dp[x][y - 1] = min(dp[x][y - 1],top[2]);
						q.push({x, y - 1,top[2] + 1});
						ch[x][y - 1]--;
					}
					//p++;
					q.pop();
				}
				for (int ii = 0; ii < n; ++ii) {
					for (int jj = 0; jj < m; ++jj) {
						//cout << dp[ii][jj] << " ";
						if (dp[ii][jj] < inf) {
							ans = max(ans,dp[ii][jj]);
						}
					}
					//9cout << endl;
				}
				//if (i == 2 && j == 0) {
					//for (int ii = 0; ii < n; ++ii) {
						//for (int jj = 0; jj < m; ++jj) {
							//cout << dp[ii][jj] << " ";
							//if (dp[ii][jj] < inf) {
								//ans = max(ans,dp[ii][jj]);
							//}
						//}
						//cout << endl;
					//}
				//}
				//cout << "i is : " << i << " j is : "  << j << endl; 
			}
		}
	}
	cout << ans;
}










Measured memory_bytes: 3612
n, m = gets.split(' ').map(&:to_i)
#p n                                                                                       
#p m                                                                                       

# 場合分けを簡単にするために n <= m にする                                                 
if n > m then
  tmp = n
  n = m
  m = tmp
end

if n == 1 then
  if m == 1 then
    puts 1
  else
    puts m - 2
  end
elsif n == 2 then
  puts 0
else
  puts (n-2)*(m-2)
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string s;
  cin >> s;
  int n = s.size();
  vector<int> S(n+1,0);
  int ten = 1;
  for (int i = 1; i <= n; ++i) {
    S[i] = ((s[n-i] - '0') * ten) % 2019;
    S[i] += S[i-1];
    S[i] %= 2019;
    ten *= 10; ten %= 2019;
  }
  // S[r] == S[l] となるような組の数を数える
  vector<int> cnt(2019);
  ll ans = 0;
  for (int i = n; i >= 0; --i) {
    ans += cnt[S[i]];
    cnt[S[i]]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4320
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
typedef long long ll;
using namespace std;

const ll MOD = 1e9 + 7;
const ll INF = 1e13;

int main() {
    ll i, j, k, n, m, h;
    cin >> n >> i >> j;
    cout << min(i * n, j) << endl;
    return 0;
}

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

int P[MAX], S[MAX];

bool isprime(int n){
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    for ( int i = 3; i * i <= n; i += 2 ) {
        if (n % i == 0) return false;
    }
    return true;
}

void setP() {
    P[0] = 2;
    int i = 3, n = 1;
    while(n < MAX) {
        if(isprime(i)) {
            P[n] = i;
            n++;
        }
        i += 2;
    }
    return;
}

void setS() {
    S[0] = 2;
    for(int i = 1; i < MAX; i++) {
        S[i] = S[i - 1] + P[i];
    }
    return;
}

int main(void) {
    setP(); setS();
    int n;
    while(cin >> n){
        if (n == 0) return 0;
        cout << S[n - 1] << endl;
    }
}


Measured memory_bytes: 3132
N, M = [int(_) for _ in input().split()]

A = [0 for _ in range(N+1)]
ac, wa = 0, 0

for _ in range(M):
    p, S = input().split()
    p = int(p)
    if A[p] != None:
        if S == "AC":
            ac += 1
            wa += A[p]
            A[p] = None
        else:
            A[p] += 1
print(ac, wa)


Measured memory_bytes: 3928
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)

struct F{
	string f;
	int s,t;
	F(){}
};

bool com(F a,F b){
	if(a.f==b.f){
		return a.s>b.s;
	}
	else{
		return a.f<b.f;
	}
}

int N;
string S[110];
int A[110];
F B[110];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>S[i]>>A[i];
		B[i].f=S[i],B[i].s=A[i],B[i].t=i+1;
	}
	sort(B,B+N,com);
	REP(i,N){
		cout<<B[i].t<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import sys

for line in sys.stdin:
    a, b, c, d, e, f = map(int, line.split())
    y = (a * f - d * c) / (a * e - b * d)
    x = (c * e - b * f) / (a * e - b * d)
    if x == 0:        x = abs(x)
    if y == 0:        x = abs(y)       
    print('{:.3f} {:.3f}'.format(x, y))

Measured memory_bytes: 6744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/arc086_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, K;
  cin >> N >> K;

  map<int, int> m;
  rep(i, N) {
    int c;
    cin >> c;
    m[c]++;
  }
  vector<P> c(0);

  for(auto kv : m) {
    c.push_back(make_pair(kv.second, kv.first));
  }
  sort(c.begin(), c.end(), greater<>());
  
  ll ans = 0;
  repi(i, K, c.size()) { ans += c[i].first; }

  cout << ans << endl;
}

Measured memory_bytes: 11764
n = int(input())
a_ = [int(i) for i in input().split()]
a = [[a_[i], i+1] for i in range(n)]
a.sort(reverse=True)

dp = [[0 for i in range(n+1)] for j in range(n+1)]
x_plus_y = 0
ans = 0

for i in range(n):
    if x_plus_y == 0:
        dp[0][1] = a[i][0] * abs((n - a[i][1]))
        dp[1][0] = a[i][0] * abs((a[i][1] - 1))

    else:
        for x in range(x_plus_y + 1):
            y = x_plus_y - x
            dp[x][y+1] = max(dp[x][y+1], a[i][0] * abs((n - y) - a[i][1]) + dp[x][y])
            dp[x+1][y] = max(dp[x+1][y] , a[i][0] * abs((a[i][1] - (1+x))) + dp[x][y])

            if x_plus_y == n-1:
                ans = max(ans, dp[x][y+1], dp[x+1][y])

    x_plus_y += 1

print(ans)


Measured memory_bytes: 102496
N, K = map(int,input().split())
p = list(map(int,input().split()))
P = [(p[k]*(p[k]+1))/(2*p[k]) for k in range(N)]
S = [0]*N
S[0] = P[0]
for k in range(1,N):
    S[k] = S[k-1] + P[k]
S = [0] + S
ans = 0
for k in range(1,N-K+2):
    ans = max(ans,S[k+K-1]-S[k-1])
print(ans)


Measured memory_bytes: 81800
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  for(auto &x: p) cin >> x;
  sort(p.begin(), p.end());
  int ans = 0;
  for(int i=0; i<k; i++) ans += p[i];
  cout << ans << endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
using namespace std;


#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef pair<int, int> Edge;




int main() {
	int a, b, k;
	cin >> a >> b >>k;

	int list[100];
	int ite = 0;
	int Min = min(a, b);

	for (int i = Min; i > 0; i--) {
		if (a%i == 0 && b%i == 0) {
			list[ite] = i;
			ite++;
		}
	}

	cout << list[k - 1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  if(S.at(5)=='1'){
    cout << "TBD" <<endl;
  }
  else if(S.at(6)=='1'||S.at(6)=='2'||S.at(6)=='3'||S.at(6)=='4'){
    cout << "Heisei" << endl;
  }
  else{
    cout << "TBD" << endl;
  }
}

Measured memory_bytes: 256
/*
Coded by XIZCM
*/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <iomanip>
#include <vector>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <ctime>
#include <fstream>
#include <stdarg.h>

using namespace std;

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

const bool debug=false;
const bool INJUDGE=false;
const int MAXN=100005;
const int MOD=1000000007;
const int INF=1000000007;

template<class T>T emax(T& a,T b){return a=max(a,b);}
template<class T>T emin(T& a,T b){return a=min(a,b);}
template<class T>void byebye(T info){cout<<info<<endl;exit(0);}
template<class T1,class T2>ostream& operator<<(ostream& out,pair<T1,T2> P){out<<P.first<<" "<<P.second;return out;}
template<class T>ostream& operator<<(ostream& out,vector<T> V){for(int i=0;i<V.size();++i)out<<V[i]<<" ";return out;}

int n;
pii c[55];
int ans=0;

int main(){
	cin>>n;
	for(int i=0;i<n;++i)cin>>c[i].first>>c[i].second;
	vector<pii> v;
	for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){
			if(i==j)continue;
			v.push_back(pii(c[i].first-c[j].first,c[i].second-c[j].second));
		}
	}
	sort(v.begin(),v.end());
	for(int i=0,j=0;i<n*(n-1);i=j)
	{
		int len=0;
		for(j=i;j<n*(n-1);++j)if(v[j]==v[i])++len;else break;
		ans=max(len,ans);
	}
	cout<<(n-ans)<<endl;
	return 0;
}



Measured memory_bytes: 256
"use strict";
function I(s,f){this._s=s.split("\n");this._c=0;this._l=0;this._f=f||Number}I.prototype.a=function(){var l=this._s[this._l];if(!l)return;var t=l.trim().split(" ");var a=t[this._c];this._c++;if(t.length===this._c){this._c=0;this._l++}return this._f(a)};I.prototype.l=function(){var l=this._s[this._l];if(!l)return;this._c=0;this._l++;return l.split(" ").map(this._f)};

function main(input) {
  const o = new I(input, String);

  var n = Number(o.a());
  var k = Number(o.a());
  var s = o.a();

  var arr = [];
  var start = -1;
  for (var i=0;i<s.length;i++) {
    if (s[i] === "1") {
      if (start === -1) {
        start = i;
      }
    } else {
      if (start !== -1) {
        arr.push({start, end: i - 1});
        start = -1;
      }
    }
  }
  if (start !== -1) arr.push({start, end: s.length - 1});

  // console.log(arr);

  if ( arr.length + 1 <= k) {
    console.log(n);
  } else {
    var arr2 = [];
    for (var i = 0; i < arr.length + 2 - k; i++) {
      if (i === 0) {
        arr2.push(arr[i + k - 1].end + 1);
      } else if (i === arr.length + 1 - k ) { // last
        arr2.push(s.length - arr[i - 1].start);
      } else {
        arr2.push(arr[i + k - 1].end - arr[i - 1].start + 1);
      }
    }
    // console.log(arr2);
    console.log(arr2.sort((a,b) => b - a)[0]);
  }
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

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

	return true;
}
int main(void)
{
	int n;
	while (cin >> n, n){
		int ret = 0;
		for (int i = n+1; i <= 2 * n; i++){
			if (isprime(i)) ret++;
		}

		cout << ret << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
stack<char> ans;
const int MAXN = 10010100;
int cnt, ch[MAXN][26], k;
char a[5050], rem[MAXN];
int st[30];
void dfs(int tmp){
    if(tmp)
        k --;
    if(k == 0 && tmp){
        ans.push(rem[tmp]);    
        return;
    }
    for(int i = 0; i < 26; i ++){
        if(!ch[tmp][i])
            continue;
        dfs(ch[tmp][i]);
        if(k == 0)
            break;
    }
    if(k == 0 && tmp){
        ans.push(rem[tmp]);    
        return;
    }
}

int main(){
    scanf("%s%d", a+1, &k);
    int tem = 0, sum = 0,len = strlen(a+1);
    char p;
    for(int i = len; i ; i --){
        st[a[i]-'a'] = i;
    } 
    for(int i = 0; i < 26; i ++){
        if(!st[i])
            continue;
        sum += len - st[i] + 1;
        for(int x = st[i]; x <= len; x ++){
            if(a[x] != 'a' + i)
                continue;
            int tmp = 0;
            for(int j = x; j <= len; j ++){
                if(ch[tmp][a[j] - 'a'])
                    tmp = ch[tmp][a[j]-'a'];
                else{
                    tmp = ch[tmp][a[j]-'a'] = ++ cnt;
                    rem[cnt] = a[j];
                }
            }
        }
        if(sum >= k)
            break;
    }
    dfs(0);
    //printf("%s\n", rem+1);
    while(!ans.empty()){
        printf("%c", ans.top()); 
        ans.pop();
    }
    
}

Measured memory_bytes: 56064
n, m = map(int, input().split())
a = set([int(input()) for _ in range(m)])
NUM = 10 ** 9 + 7

dp = [0] * (n+1)
dp[0] = 1
if not 1 in a:
    dp[1] = 1

for i in range(2, n+1):
    if not i in a:
        dp[i] = (dp[i-2] + dp[i-1]) % NUM
    else:
        dp[i] = 0

print(dp[n])




Measured memory_bytes: 13212
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int k = saori.saori_hayami();
		if(n % k == 0){
			System.out.println(0);
		} else {
			System.out.println(1);
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21332
from itertools import permutations
import math
menu=5
times=[int(input()) for i in range(menu)]
orders=list(permutations(times,menu))
minimum=sum(math.ceil(time/10)*10 for time in times)
for order in orders:
    total=order[0]
    for i in range(1,menu):
        total+=math.ceil(order[i]/10)*10
    minimum=min(minimum,total)
print(minimum)

Measured memory_bytes: 38512
def NDigit():
    N = int(input())
    if N < 10: return N
    elif N < 100: return 9
    elif N < 1000: return (N - 90)
    elif N < 10000: return 909
    elif N < 100000: return (N - 9090)
    else : return 90909

# main
print(NDigit())

Measured memory_bytes: 2940
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int filt[128];
int crd[7][7] = {
  {13,12,14,0,1,2,3},
  {12,11,0,1,10,3,4},
  {14,0,15,2,3,16,5},
  {0,1,2,3,4,5,6},
  {1,10,3,4,9,6,8},
  {2,3,16,5,6,17,18},
  {3,4,5,6,8,18,7}
};

int next(int bit){
  int ret = bit;
  for(int i=0;i<7;++i){
	int tmp = 0;
	for(int j=0;j<7;++j){
	  tmp |= ((bit>>crd[i][j]) & 1) << j;
	  ret = (ret & ~(1<<i)) | (filt[tmp] << i);
	}
  }

  return ret;
}

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

  string s;
  while(cin>>s,s!="#"){
	for(int i=0;i<128;++i){
	  filt[i] = s[i] - '0';
	}

	bool ok = true;
	for(int b=0;b<(1<<19);++b){
	  int n = next(b);
	  if((n>>3&1) != (next(n)>>3&1)){
		ok = false;
		break;
	  }
	}
	
	cout << (ok? "yes": "no") << endl;
  }

  return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define double long double
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{//cout<<"Case #"<<T1<<": ";
    int x,n;
    cin>>x>>n;
    int ans;MII mr;VI ar(n);
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
        mr[ar[i]]=1;
    }
    for(int i=0;i<=100;i++)
    {
        if(mr.find(x-i)==mr.end())
        {
            ans=x-i;break;
        }
        if(mr.find(x+i)==mr.end())
        {
            ans=x+i;break;
        }
    }
    cout<<ans<<endl;
}


return 0;
}





Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (a) - 1; (i) >= (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
const ll inf = 1e9;

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main(){
    ll k,n;
    cin >> n >> k;
    vector<ll> x(n),y(n);
    rep0(i, n)cin >> x[i] >> y[i];
    ll ans = 4 * 1e18 + 1;
    rep0(xl, n)rep0(xr, n)rep0(yl, n)rep0(yr, n){
        ll lx = xl,rx = xr,ly = yl,ry = yr;
        if(x[lx] > x[rx])swap(lx, rx);
        if(y[ly] > y[ry])swap(ly, ry);
        ll cnt = 0;
        rep0(i, n)if(x[i] >= x[lx] && x[i] <= x[rx] && y[i] >= y[ly] && y[i] <= y[ry])++cnt;
        if(cnt >= k)ans = min(ans, (x[rx] - x[lx]) * (y[ry] - y[ly]));
    }
    pf(ans);
    return 0;
}


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

#define F first
#define S second
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),a.end()
#define pw(x) (1LL<<(x))

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define dbv(a) cerr << #a << " = "; for (auto xxxx: a) cerr << xxxx << " "; cerr << endl

using namespace std;

typedef long long ll;
typedef double dbl;
const int INF = 1.01e9;



int main() {
#define TASK "A"
#ifdef HOME
    assert(freopen(TASK".in", "r", stdin));
#endif
    int n, m;
    scanf("%d%d", &n, &m);
    vector<vector<pair<int,int>>> e(n);
    for (int i = 0; i < m; i++) {
        int v, u, x;
        scanf("%d%d%d", &v, &u, &x); v--; u--;
        e[v].pb({u, x});
        e[u].pb({v, -x});
    }
    vector<int> use(n);
    vector<int> val(n);
    bool fail = 0;
    function<void(int,int)> dfs = [&](int v, int x) {
        val[v] = x;
        use[v] = 1;
        for (auto g: e[v]) {
            int u = g.F;
            if (!use[u]) {
                dfs(u, x + g.S);
            }
            else {
                if (val[u] != x + g.S) {
                    fail = 1;
                }
            }
        }
    };
    for (int i = 0; i < n; i++) {
        if (!use[i]) {
            dfs(i, 0);
        }
    }
    if (fail) {
        puts("No");
    }
    else {
        puts("Yes");
    }






    return 0;
}


Measured memory_bytes: 13312
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;

int main(){
    string s, ans = "No";
    cin >> s;
    if(s.at(2)==s.at(3)&&s.at(4)==s.at(5)){
        ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
int dp[111][100100];
int a[111];
const int mod = 1000000007;
signed main()
{
  int N, K;
  cin >> N >> K;
  rep(i, N) cin >> a[i];
  dp[0][0] = 1;
  rep(i, N) {
    rep(j, K+1) {
      dp[i+1][j] += dp[i][j];
      dp[i+1][j] %= mod;
      int t;
      dp[i+1][t = min(j+a[i]+1, K+1)] -= dp[i][j] - mod;
      dp[i+1][t] %= mod;
      
    }
    dp[i+1][0] %= mod;
    rep(j, K) {
      dp[i+1][j+1] += dp[i+1][j];
      dp[i+1][j+1] %= mod;
    }
  }
  cout << dp[N][K] << endl;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

//-----------------------------------------------------------------------------

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

	double a,b;
	cin>>a>>b;
	printf("%.10f\n",(a*b)/(a+b));

	return 0;
}


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

int main() {
  string a;
  cin >> a;
  for(int i=0;i<a.size();i++){
  if(a.at(i)=='A'){
    a.at(i)='T';
  }
  else if(a.at(i)=='T'){
    a.at(i)='A';
  }
    else if(a.at(i)=='G'){
      a.at(i)='C';
    }
    else if(a.at(i)=='C'){
      a.at(i)='G';
    }
  }


  cout << a<< endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

typedef struct{
  int parent;
  int left;
  int right;
  int depth;
}Node;

Node T[MAX];
int c[MAX];

int getDepth(int);
void print(int);

int main(){
  int l, n, m, i, j, k;

  scanf("%d", &n);
  
  for(i = 0; i < n; i++){
    T[i].parent = -1;
    T[i].left = -1;
    T[i].right = -1;
  }
  
  for(i = 0; i < n; i++){
    scanf("%d%d", &l, &m);
    for(j = 0; j < m; j++){
      scanf("%d", &c[j]);
      T[c[j]].parent = l;
      if(j == 0) T[l].left = c[j];
      else T[c[j-1]].right = c[j];
    }
  }

  for(i = 0; i < n; i++) T[i].depth = getDepth(i);

  print(n);
  
  return 0;
}

void print(int n){
  int m, i, j;
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ", i, T[i].parent, T[i].depth);
    printf(T[i].parent == -1 ? "root, [" : T[i].left == -1 ? "leaf, [" : "internal node, [");

    m = T[i].left;
    while(1){
      if(m == -1) break;
      printf("%d", m);
      m = T[m].right;
      if(m != -1) printf(", ");
    }
    printf("]\n");
  }
}

int getDepth(int u){
  if(T[u].parent == -1) return 0;
  return getDepth(T[u].parent) + 1;
}

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

#define reb(i,b,n) for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n) reb(i,0,n)
#define rreb(i,b,n) for(int i = b-1; i >= n; i--)
#define rrep(i,n) reb(i,n,0)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v) for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vall(x) (x).begin(), (x).end()
#define rvall(x) (x).rbegin(), (x).rend()
#define vsort(v) sort(vall(v))
#define rvsort(v) sort(rvall(v))
#define len(array) (sizeof (array) / sizeof *(array))
#define aall(x) x, x+len(x)
#define asort(x) sort(aall(x))
#define rasort(a, type) sort(aall(a), greater<type>())
#define afill(a, v) fill(aall(a), v)
#define afill2(a, v, type) fill((type *)a, (type *)(a + len(a)), v)
#define sz(x) (int)(x).size()
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define pb push_back
#define _USE_MATH_DEFINES
#define priArr(table, n) rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define priAr2(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;

using namespace std;
using std::stringstream;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class F, class T> inline void convert(const F &f, T &t){stringstream ss;ss<<f;ss>>t;}
template<class T> inline T sqr(T x) {return x*x;}

typedef long long ll; typedef unsigned long long ull;
typedef pair <int, int> P; typedef pair <int, P> PP;
typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<string> vs;
typedef vector<ll> vl; typedef vector<P > vP; typedef vector<char> vc;
typedef long double ld;

const static int INF = 0x3f3f3f3f;
const static ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const static double EPS = 1e-9;
const static ll MOD = 1000000007LL;

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

int main(int argc, char *argv[])
{
    string s;
    cin >> s;

    if ((s[2] == s[3]) && (s[4] == s[5])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

a = list(map(int,input().split()))


for i in range(k, n+1):
    if i == n:
        break
    #print(a[i], a[i-k])
    if a[i-k] < a[i]:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 105456
#include <bits/stdc++.h>
using namespace std;
int main(){
  long n,d,ans=0;
  cin >> n >> d;
  vector<long> x(n),y(n);
  d=d*d;
  for(long i=0;i<n;i++) cin >> x[i] >> y[i];
  for(long i=0;i<n;i++) {
    if(x[i]*x[i]+y[i]*y[i]<=d) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6424