akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;

    int dx1 = tx-sx;
    int dy1 = ty-sy;

    assert(dx1>=0 and dy1>=0);

    for(int i=0;i<dx1;i++){
        cout << "R";
    }

    for(int i=0;i<dy1;i++){
        cout << "U";
    }

    for(int i=0;i<dx1;i++){
        cout << "L";
    }

    for(int i=0;i<dy1;i++){
        cout << "D";
    }


    cout << "D";
    rep(i,dx1+1){
        cout << "R";
    }

    rep(i,dy1+1){
        cout << "U";
    }

    cout << "L";

    cout << "U";

    rep(i,dx1+1){
        cout << "L";
    }

    rep(i,dy1+1){
        cout << "D";
    }

    cout << "R";

    cout << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int64 N;
  cin >> N;
  int64 ans = 0;
  vector<char> append_list = {'3', '5', '7'};

  function<void(string)> dfs = [&](string s) {
    bool break_flag = false;
    if ((int)s.size() > 0) {
      if (stoll(s) > N) return;
      for (auto c : append_list) {
        if (s.find(c) == string::npos) {
          break_flag = true;
          break;
        }
      }
      if (!break_flag) ans++;
    }
    for (auto c : append_list) {
      s.push_back(c);
      dfs(s);
      s.pop_back();  // 今追加したものを削除して s を元に戻す
    }
  };

  dfs("");

  cout << ans << endl;
  return 0;
}

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

#define fi first
#define se second

typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vii> vvii;
typedef vector<int>::iterator vit;

const int MAXN = 100005;

int idx[MAXN];          // i : index of node i in dfs path
ii path[MAXN << 1];
vi adjList[MAXN];

class SparseTable {	    // return index of minimum number
private:
    int n, h;
    vvii t;
public:
    SparseTable(int size){
        n = size; h = ( n == 1 ? 1 : ceil(log2(n)));
        t.assign(h, vii());

        t[0].assign(n,ii(0,0));
        for (int i = 0; i < n; i++) t[0][i] = path[i];
        for (int i = 1, j = 0; i < h; i++, j = 0)
            for (t[i].assign(n,ii(0,0)); j + (1<<i) <= n; j++)
                t[i][j] = min(t[i-1][j],t[i-1][j+(1<<(i-1))]);
    }
    int query(int l, int r){      // query in range v[l,r)
        int p = 31 - __builtin_clz(r-l);
        return min(t[p][l],t[p][r-(1<<p)]).se;
    }
};

// build dfs path, depth
int cnt = 0;
void dfs(int curr, int d){
    idx[curr] = cnt;

    path[cnt++] = ii(d,curr);
    for (vit it = adjList[curr].begin(); it != adjList[curr].end(); it++) {
        dfs(*it,d+1);

        path[cnt++] = ii(d,curr);
    }
}

int N, M, Q, v;

int main(){

    scanf("%d",&N);
    for (int u = 0; u < N; u++){
        scanf("%d",&M);
        for (int i = 0; i < M; i++){
            scanf("%d",&v);
            adjList[u].push_back(v);
        }
    }

    // rooted as 0
    dfs(0,0);
    SparseTable st(cnt);

    scanf("%d",&Q);
    for (int i = 0, u, v, l, r; i < Q; i++){
        scanf("%d%d",&u,&v);

        l = idx[u], r = idx[v]; if (l > r) swap(l,r);

        printf("%d\n",st.query(l,r+1));
    }

    return 0;
}

Measured memory_bytes: 41284
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e17

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
    COMinit();

    ll n, m, ans;
    cin >> n >> m;

    ans = 1;

    //cout << div_(6, 2) << endl;

    ll i = 2;
    while (m > 1)
    {
        ll cnt = 0;
        while (m % i == 0)
        {
            m /= i;
            cnt++;
        }

        //cout << i << " " << cnt << endl;

        if (cnt == 0)
        {
            i++;
            continue;
        }

        ll tmp = 1;
        /*

        for (ll j = 0; j < cnt; j++)
        {
            tmp *= cnt + n - 1 - j;
            tmp %= MOD;
        }
        cout << tmp << endl;

        tmp %= MOD;

        for (ll j = 0; j < cnt; j++)
        {
            //tmp /= 1 + j;
            tmp = tmp * modinv(j + 1, MOD) % MOD;
        }
        */

        tmp = COM(cnt + n - 1, cnt);

        tmp %= MOD;

        //cout << tmp << endl;

        ans *= tmp;
        ans %= MOD;

        i++;
    }

    cout << ans << endl;

    return 0;
}

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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    ll bmax,bmin;
    int N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> B;
    rep(i,N) {
        ll a;
        cin >> a;
        A[i] = a;
        a-=(i+1);
        B.push_back(a);
    }
    ll b;
    sort(B.begin(),B.end());

    ll ans,tmp;
    ans = 1e18;
    for (int j=N/2-3; j<=N/2+3; j++) {
        b = B[j];
        tmp = 0;
        rep(i,N) {
            tmp += abs(A[i]-(b+i+1));
        }
        ans = min(ans,tmp);
    }
    cout << ans << endl;

}


Measured memory_bytes: 6900
#include <iostream>
using namespace std;
int main(void){
  
  for(;;){
  
  int a,b;
  string s;
  
  cin>>a>>s>>b;
  
  if(s=="+") a+=b;
  else if(s=="-") a-=b;
  else if(s=="*") a*=b; 
  else if(s=="/") a/=b;
  else break;
  
  cout<<a<<endl;
  
  }
  
}



Measured memory_bytes: 3140
n=gets.to_i
a=[]
max=0
(0..n-1).each do |i|
  a[i]=gets.to_i
end
max=a.max
idx=a.index(max)
a.sort!
(0..n-1).each do |i|
  if a[-2]==a[-1]
    puts a[-1]
  elsif i == idx
    puts a[-2]
  else
    puts a[-1]
  end
end

Measured memory_bytes: 7092
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#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 <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

struct MyStruct {
	int num, honsu;
};

bool comp(const MyStruct& s, const MyStruct& t) {
	if (s.honsu != t.honsu)
		return s.honsu < t.honsu; // 昇順
	return s.num > t.num;
}


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

	double a;
	string s;

	double ans=0;

	REP(i, n) {
		cin >> a >> s;
		if (s == "JPY") {
			ans += a;
		}
		else {
			ans += a * 380000;
		}
	}

	ANS(ans);


	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

#define MOD 1000000007

long powlong(long a, int b) {
  long res = 1;
  if (a == 1)
    return 1;
  for (; b>0; b>>=1, a=(a*a)%MOD) {
    if (b%2) {
      res *= a;
      res %= MOD;
    }
  }
  return res;
}

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  long a[k], ans = 0;
  for (int i=k-1; i>=0; i--) {
    a[i] = powlong(k/(i+1), n);
    for (int j=2*i+1; j<k; j+=i+1) {
      a[i] -= a[j];
      a[i] %= MOD;
    }
  }
  for (int i=0; i<k; i++) {
    ans += ((i+1)*a[i])%MOD;
    ans %= MOD;
  }
  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 2476
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#define REP(i, n) for(int i=0;i<n;++i)
#define INF 100000000
#define ll long long

using namespace std;

typedef pair<int, int> P;

int main(){
  ll int n, m;
  ll int ans;
  cin >> n >> m;

  if(n == 1){
    if(m == 1){
      ans = 1;
    }else if(m == 2){
      ans = 0;
    }else{
      ans = m - 2;
    }
  }else if(n == 2){
    ans = 0;
  }else{
    if(m == 1){
      ans = n - 2;
    }else if(m == 2){
      ans = 0;
    }else{
      ans = (n-2) * (m-2);
    }
  }

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

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

N = int(input().split()[0])
a_list = list(map(int, input().split()))

c = 0
is_minus = True
start_flag = True

for i in range(1, N):
    if start_flag:
        if a_list[i] == a_list[i - 1]:
            continue
        is_minus = True if a_list[i] < a_list[i - 1] else False
        start_flag = False
        continue

    if is_minus:
        if a_list[i] > a_list[i - 1]:
            c += 1
            start_flag = True
    else:
        if a_list[i] < a_list[i - 1]:
            c += 1
            start_flag = True

ans = c + 1
print(ans)


Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
using ll=long long;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  int N; cin >> N;
  vector<int> v(N);
  rep(i,N){
    cin >> v[i];
  }
  int ans=0;
  for(int i=1;i<N-1;i++){
    if(v[i]>v[i-1]&&v[i]<v[i+1]||v[i]<v[i-1]&&v[i]>v[i+1]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        var ptra = 0;
        var ptrb = n - 1;
        int res = 0;
        while (true)
        {
            while (ptra < s.Length && s[ptra] == 'R') ptra++;
            while (0 <= ptrb && s[ptrb] == 'W') ptrb--;
            if (ptra >= ptrb) break;
            ptra++;
            ptrb--;
            res++;
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 28108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll d,n,p=1;
  cin >> d >> n;
  for(int i=0;i<d;i++){
    p*=100;
  }
  if(n==100){
    n++;
  }
  if(d==0){
    cout << n;
  }else{
    cout << p*n;
  }
}
    

Measured memory_bytes: 3620
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N >> M >> K;
	if (N + M + K > 21)cout << "bust" << endl;
	else cout << "win" << endl;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
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;}



signed main(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int t1 = h1*60 + m1;
    int t2 = h2*60 + m2 - k;

    cout << t2 - t1 << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <cctype>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <utility>
using namespace std;

typedef pair<int,bool> pib;

string str;
const char *ptr;
int ans = -1;
vector<int> dots;


pib expr();
pib term();
pib fact();

pib expr(){
	pib a = term();

	while(true){
		if( *ptr == '+' ){
			++ptr;
			
			pib p = term();
			a.first += p.first;
			if( a.first > 1023 ) throw 1;
			
			a.second = true;
		}
		else if( *ptr == '-' ){
			++ptr;
			
			pib p = term();
			a.first -= p.first;
			if( a.first < 0 ) throw 2;
			
			a.second = true;
		}
		else{
			break;
		}
	}
	return a;
}

pib term(){
	pib a = fact();
	while(*ptr == '*'){
		++ptr;
		pib p = fact();
		a.first *= p.first;
		a.second = true;

		if( a.first > 1023 ) throw 3;
	}
	return a;
}

pib fact(){
	if( *ptr == '(' ){
		++ptr;
		pib x = expr();
		if( *ptr++ != ')' ) throw 4;
		if( !x.second ) throw 5;

		x.second = false;
		return x;
	}
	
	if( isdigit(*ptr) ){
		char *endp;
		int x = strtol(ptr, &endp, 2);
		ptr = endp;

		if( x < 0 || x > 1023 ) throw 6;
		return make_pair(x, false);
	}
	
	throw 7;
}


void func(int x){
	if( x == dots.size() ){
		ptr = str.c_str();
		
		try{
			int a = expr().first;
			if( *ptr == '\0' && a < 1024 ) ans = max(ans, a);
		}
		catch(int){}
	}
	else{
		for(int i = 0; i < 7; ++i){
			str[dots[x]] = "01+-*()"[i];
			func(x + 1);
		}
	}
}

int main(){
	cin >> str;
	for(int i = 0; i < str.size(); ++i){
		if( str[i] == '.' ) dots.push_back(i);
	}
	
	func(0);
	
	cout << ans << '\n';
}

Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main()
{
int n;
int a[100];
cin>>n;
for(int i=0;i<n;i++)cin>>a[i];
for(int i=n-1;i>=0;i--)
{
cout<<a[i];
if(i)cout<<" ";
}
cout<<endl;
return 0;
}

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

int main() {
  string S;
  cin >> S;
  S += '0';
  int ans = 0;
  for (int i = 0; i + 1 < S.size(); i++) {
    int tmp = S.at(i) - '0';
    ans += min(tmp, 10 - tmp);
    if (tmp >= 6 || tmp == 5 && S.at(i + 1) >= '5') S.at(i + 1)++;
  }
  ans += S.back() - '0';
  cout << ans << "\n";
}

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

int cnt[305];
int lastIndx[305];
char grid[305][305];
int ans[305][305];

bool visited[305];

int main(){
    int H, W, K;
    scanf("%d%d%d", &H, &W, &K);

    for(int i = 0; i < H; i ++){
        scanf(" %s", grid[i]);
    }

    int temp = 1;
    int firstFilled = H+3;
    for(int i = 0; i < H; i ++){
        cnt[i] = 0;
        for(int j = 0; j < W; j ++){
            if(grid[i][j]=='#'){
                cnt[i] ++;
                lastIndx[i] = j;
            }
        }
        if(cnt[i] != 0){
            for(int j = 0; j < W; j ++){
                ans[i][j] = temp;
                if(grid[i][j] == '#' && lastIndx[i] != j){
                    temp ++;
                }
            }
            firstFilled = min(firstFilled, i);
            temp ++;
        }else if(i != 0){
            for(int j = 0; j < W; j ++){
                ans[i][j] = ans[i-1][j];
            }
        }
    }

    for(int i = firstFilled-1; i >= 0; i --){
        for(int j = 0; j < W; j ++){
            ans[i][j] = ans[i+1][j];
        }
    }

    for(int i = 0; i < H; i ++){
        for(int j = 0; j < W; j ++){
            printf("%d", ans[i][j]);
            if(j != W-1){
                printf(" ");
            }else{
                printf("\n");
            }
        }
    }

    return 0;
}


Measured memory_bytes: 1152
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <cmath>         // sqrt
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
typedef tuple<ll, ll, string> Tlls;

// Greatest Common Divisor (最大公約数)
ll gcd(ll a, ll b)
{
  // Eucledean algorithm
  while (a)
  {
    if (a < b)
    {
      std::swap(a, b);
    }
    a %= b;
  }
  return b;
}

// Least Common Multiple 最小公倍数
ll lcm(ll a, ll b)
{
  return a / gcd(a, b) * b;
}

// key: value of prime factor素因数分解
// value: number of prime factor
map<ll, ll> prime_factorization(ll n)
{
  map<ll, ll> prime_factors;
  for (ll i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      prime_factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    prime_factors[n] = 1;
  return prime_factors;
}

// 約数リスト約数の列挙
vector<ll> get_divisors(const ll n)
{
  vector<ll> divs;
  for (ll i = 1; i < (ll)sqrt((ld)n) + 1; i++)
  {
    if (n % i == 0)
    {
      divs.push_back(i);
      if (i != n / i)
      {
        divs.push_back(n / i);
      }
    }
  }

  // 必要に応じてソート
  // sort(divs.begin(), divs.end());

  return divs;
}

int main()
{
  ll mod = 1000000007;
  ll N, K, ans;
  cin >> N >> K;
  vector<ll> tmp(N + 1);
  ans = 0;
  rep(i, N + 1)
  {
    if (i >= 1)
    {
      tmp.at(i) = tmp.at(i - 1) + (N - i - i);
    }
    else
    {
      tmp.at(i) = N - i - i;
    }
  }
  rep2(i, K, N + 2)
  {
    ans += tmp.at(i - 1) + 1;
  }
  cout << ans % mod << endl;
  return 0;
}


Measured memory_bytes: 4800
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
#define double long double
#define PI 3.141592653589793
typedef long long ll;
const int MOD = 1000000007;
const int INF = LLONG_MAX;
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)}; 

vector<int> divisor(int n){
  vector<int> ret;
  for(int i = 1;i*i <= n;i++){
    if(n%i == 0){
      ret.push_back(i);
      if(i*i != n)ret.push_back(n/i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}
int n,kk;pair<int,int> p[51];
signed main() {
  int ans = INF;
  cin>>n>>kk;rep(i,n)cin>>p[i].first>>p[i].second;
  rep(i,n){
    rep(j,n){
      rep(k,n){
        rep(l,n){
          int xm = p[i].first, xn = p[j].first, ym = p[k].second, yn = p[l].second;
          if(xm < xn)swap(xm,xn);if(ym < yn)swap(ym,yn);
          int cnt = 0;
          rep(m,n){
            if(xn <= p[m].first && p[m].first <= xm && yn <= p[m].second && p[m].second <= ym)cnt++;
          }
          if(cnt >= kk){
            ans = min(ans, (xm-xn)*(ym-yn));
          }
        }
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
class UnionFind(val size : Int) {
    val data = Array.fill(size)(-1)
    def find(x : Int) : Int = {
        if (data(x) < 0) x
        else {
          data(x) = find(data(x))
          data(x)
        }
    }
    def unite(x : Int, y : Int) = {
        val xPar = find(x)
        val yPar = find(y)
        if (xPar != yPar) {
            val (to, from) = if (data(yPar) > data(xPar)) (yPar, xPar)
                             else (xPar, yPar)
            data(to) += data(from)
            data(from) = to
        }
    }
    def same(x : Int, y : Int) = find(x) == find(y)
    override def toString() = data.toList.toString
}

object Main {
    def main(args: Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        val n, q = sc.nextInt
        val s = new UnionFind(n)
        for (i <- 1 to q) {
            val com, x, y = sc.nextInt
            (com : @unchecked) match {
                case 0 => s.unite(x, y)
                case 1 => {
                    if (s.same(x, y)) println(1) else println(0)
                }
            }
        }
    }
}


Measured memory_bytes: 262368
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Integer a[] = new Integer[N];
        for (int i=0; i<N; i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());

        int Alice = 0;
        int Bob = 0;
        for (int i=0; i<N; i++){
            if (i%2==0){
                Alice += a[i];
            }
            else{
                Bob += a[i];
            }
        }
        System.out.println(Alice - Bob);

    }
}

Measured memory_bytes: 21716
using System;
class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
        int n = int.Parse(Console.ReadLine());
		string[] input = Console.ReadLine().Split(' ');
        int[] p = Array.ConvertAll(input,i => int.Parse(i));
        
        bool f = true;
        for(int i=1;i<=n;i++){
            if(p[i-1]!=i){
                if(f) f=false;
                else{
                    Console.WriteLine("NO");
                    return;
                }
                p[p[i-1]-1] = p[i-1];
            }
        }

        Console.WriteLine("YES");

    }
}

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

using namespace std;

uint64_t gcd(uint64_t one, uint64_t other) {
    uint64_t tmp;
    while (one != 0) {
        if (one > other) swap(one, other);
        tmp = one;
        one = other % one;
        other = tmp;
    }
    return other;
}

uint64_t lcm(uint64_t one, uint64_t other) {
    return one * (other / gcd(one, other));
}

int main(int argc, char *argv[]) {
    uint64_t A, B, C, D;
    cin >> A >> B >> C >> D;

    //  1. A 以上B以下の数の個数 
    //    -> (B - A) 個
    //  2. 1. のうち、Cで割り切れる数の個数
    //    -> (B / C) - ((A - 1) / C)
    //  3. 1. のうち、Dで割り切れる数の個数
    //    -> (B / D) - ((A - 1) / D)
    //  4. A以上B以下の数のうち、lcm(C, D) の約数の数
    //    -> (B / lcm(C, D)) - ((A - 1) / lcm(C, D))
    //  

    uint64_t a = (B - A + 1);
    uint64_t b = (B / C) - ((A - 1) / C);
    uint64_t c = (B / D) - ((A - 1) / D);
    uint64_t l = lcm(C, D);
    uint64_t d = (B / l) - ((A - 1) / l);

    uint64_t ans = a - (b + c - d);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
	
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

ull gcd(ull a,ull b){
	if(!b) return a;
	return gcd(b,a%b);
}

int main(){
	vector<int> vec;
	int n,a,b;
	cin >> n;
	
	rep(i,0,n){
	    cin >> a;
	    if(a == 0){
	        cin >> b;
	        vec.push_back(b);
	    }
	    else if(a == 1){
	        cin >> b;
	        cout << vec[b]<< endl;
	    }
	    else{
	        vec.pop_back();
	    }
	}
  	return 0;
}






Measured memory_bytes: 3900
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
  T value;
public:
  in() { cin >> value; }
  operator T&() { return value; }
  in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string{
public:
  in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
  template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {


}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  ll N,  A, B;
  cin>>N>>A>>B;
  auto to1 = max(A,B) - 1LL;
  
  to1 = min(to1, N - min(A,B));
  
  if ((abs(A - B) % 2LL) == 0LL)
    cout << min(abs(A - B) / 2LL, to1)<<endl;
  else 
    cout<<min({min(A,B)+abs(A - B) / 2LL, to1, (N-max(A,B)+1)+abs(A - B) / 2LL})<<endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy
from itertools import combinations

def main():
  n = int(input())
  remarks = numpy.full((n, n), -1)
  As = []
  to_binary = lambda x , y=[]: y if x==0 else to_binary(x>>1, [x%2]) + y
  for i in range(n):
    As.append(int(input()))
    for _ in range(As[-1]):
      x, y = map(int, input().strip().split())
      remarks[i, x-1] = y
  ids = list(range(n))
  for i in range(2**n-1, -1, -1):
    ihonests = to_binary(i)
    ihonests = numpy.array([0] * (n-len(ihonests)) + ihonests)
    remarks_of_honests = remarks[ihonests==1, :]
    if all(map(lambda remark: all((remark == ihonests) + (remark == -1)), remarks_of_honests)):
      print(sum(ihonests))
      return

if __name__=='__main__':
  main()

Measured memory_bytes: 20944
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
char D[1002][1002]={};
int M,N;
char b[4]={'S','J','O','I'};
char E[2][2];
int main() {
	cin>>M>>N;

	for(int i=1;i<M+1;i++){
		for(int j=1;j<N+1;j++){
			cin>>D[i][j];
		}
	}
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			cin>>E[i][j];
		}
	}
	int a=0;
	for(int i=1;i<M;i++){
		for(int j=1;j<N;j++){
			if(D[i][j]==E[0][0] && D[i][j+1]==E[0][1] && D[i+1][j]==E[1][0] && D[i+1][j+1]==E[1][1])a++;
		}
	}

	int R=0;
	int C[4];
	for(int i=1;i<M+1;i++){
		for(int j=1;j<N+1;j++){
			b[0]=D[i][j];
			for(int k=0;k<4;k++){
				C[k]=0;
				D[i][j]=b[k];
				if(D[i][j]==E[0][0] && D[i][j+1]==E[0][1] && D[i+1][j]==E[1][0] && D[i+1][j+1]==E[1][1])C[k]++;
				if(D[i][j-1]==E[0][0] && D[i][j]==E[0][1] && D[i+1][j-1]==E[1][0] && D[i+1][j]==E[1][1])C[k]++;
				if(D[i-1][j-1]==E[0][0] && D[i-1][j]==E[0][1] && D[i][j-1]==E[1][0] && D[i][j]==E[1][1])C[k]++;
				if(D[i-1][j]==E[0][0] && D[i-1][j+1]==E[0][1] && D[i][j]==E[1][0] && D[i][j+1]==E[1][1])C[k]++;

			}
			D[i][j]=b[0];
			R=max(R,a+C[1]-C[0]);
			R=max(R,a+C[2]-C[0]);
			R=max(R,a+C[3]-C[0]);
		}
	}

	cout<<R<<endl;

 	return 0;
}



Measured memory_bytes: 4084
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

int main(){
	int N, X, T;
	cin >> N >> X >> T;
	int ans;
	if(N % X == 0) ans = (N / X) * T;
	else ans = (N / X + 1) * T;
	cout << ans << endl;
}


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

int main() {
    int n, z, w;
    cin >> n >> z >> w;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }
    
    if (n == 1) {
        cout << abs(a.at(0) - w);
        return 0;
    }
    
    cout << max(abs(w - a.at(n - 1)), abs(a.at(n - 2) - a.at(n - 1)));
}

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

int main()
{
	ll l,r,d;
	cin>>l>>r>>d;
	ll count = 0;
	for(ll i = l;i<=r;i++)
	{
		if(i%d==0)
		{
			count++;
		}
	}
	cout<<count<<endl;
}


Measured memory_bytes: 3608
#include <stdio.h>

int main(void)
{
	int ticket[3];
	
	scanf("%d %d %d", &ticket[0], &ticket[1], &ticket[2]);
	if (ticket[0] == 1 && ticket[1] == 1){
		printf("Open\n");
	}
	else if(ticket[2] == 1){
		printf("Open\n");
	}
	else {
		printf("Close\n");
	}
	
	return (0);
}

Measured memory_bytes: 584
import math
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
p=0
q=0

for i in range(N-1):
  p+=sum(list(1 if P[i]>P[k] else 0 for k in range(i,N)))*math.factorial(N-i-1)
  q+=sum(list(1 if Q[i]>Q[k] else 0 for k in range(i,N)))*math.factorial(N-i-1)
print(abs(p-q))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define frn(i,a,n) for(i=a;i<=n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
//#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
#define ma 500000
/*ll power(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return power(x*x,n/2);
    else                             //n is odd
        return x*power(x*x,(n-1)/2);
}*/

/*void decToBinary(ll n)
{
    string s;
int binaryNum[32];
int i = 0;
while (n > 0) {
binaryNum[i] = n % 2;
n = n / 2;
i++;
}
for (int j = i - 1; j >= 0; j--) {
 char c = binaryNum[j] +'0';
 s=s+c;
}
 
 //cout<<s<<endl;
 
 
 
 // for (int j = i - 1; j >= 0; j--)
 // cout<<s[j];
 
sort(s.begin(), s.end());
do {
cout << s << endl;
} while (next_permutation(s.begin(), s.end())); */
int highestPowerof2(int n)
{
   int p = (int)log2(n);
   return (int)pow(2, p);  
}
ll mindig(ll n){
ll x;
ll ans=mod;
 while(n>0)
        {
            x=n%10;
            ans=min(ans,x);
            n=n/10;
        }
        return ans;
}
ll maxdig(ll n)
{
    ll x;
    ll ans1=-1;
         while(n>0)
        {
            x=n%10;
            ans1=max(ans1,x);
            n=n/10;
        }
        return ans1;
}
 ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
 
int main()
{
    fastio;
    ld a,b;
    cin>>a>>b;
    ll ans=a*b;
    ll ans1= (long long)ans;
    cout<<ans<<endl;
}

Measured memory_bytes: 3804
# -*- coding: utf-8 -*-
#ABC140
import sys
#sys.setrecursionlimit(100000)


n=int(input())
tmp = input().split()
b = list(map(lambda a: int(a), tmp))

a=[]

#print(n)

ans=0
tmp=0
a.append(b[0])
for i in range(1,n-1):
	a.append(min(b[i-1],b[i]))
a.append(b[n-2])

total=0
for i in range(n):
	total+=a[i]
print(total)



Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
    ll n, a, b; cin >> n >> a >> b;
    if(a * b < n || n < a + b - 1){
		cout << -1;
		return 0;
    }
    for(int i = n-a+1; i<=n; ++i) cout << i << ' ';
    ll left = n - a;
    for(int i = 1; i < b; ++i){
		ll cur = min(a, left-(b-1-i));
		for(int j=1-cur; j<=0; ++j) cout << left+j << ' ';
		left -= cur;
    }
    return 0;
}


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

int main()
{
	int ans = 0;
   for(int i  =0;i<5;i++)
   {
      int x;
      cin >> x;
      if(x==0)ans=i+1;

   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define all(a) a.begin(),a.end()
typedef pair<int,int> P;
const long long mod=1000000007;
const long long inf=1ll<<61;

int a[100006];

signed main(){
    int n;cin>>n;
    rep(i,n)cin>>a[i+1];
    int S=0;
    rep(i,n+1)S+=abs(a[i]-a[i+1]);
    for(int i=1;i<=n;i++){
        int dif=abs(a[i-1]-a[i+1]);
        dif-=abs(a[i-1]-a[i])+abs(a[i]-a[i+1]);
        cout<<S+dif<<endl;
    }
}

Measured memory_bytes: 4392
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, D;
int S[1010][1010];
int E[2010][2010];
int F[2010][2010];

bool ok(ll m) {
	ll sv = m / D, lv = m / D + 1;
	ll l = 0;
	rep(i, 0, D) if(i + D * sv < m) l++;
	memset(E, 0, sizeof(E)); memset(F, 0, sizeof(F));
	int lcnt = 0;
	rep(i, 0, D) {
		rep(j, 0, D) {
			if(S[i][j] > lv * lv) return false;
		}
	}
	rep(i, 0, D * 2) {
		rep(j, 0, D * 2) {
			if(S[i % D][j % D] > lv * sv) {
				lcnt++;
				E[i + 1][j + 1]++;
			}
			if(S[i % D][j % D] > sv * sv) {
				F[i + 1][j + 1]++;
			}
			E[i + 1][j + 1] += E[i][j + 1] + E[i + 1][j] - E[i][j];
			F[i + 1][j + 1] += F[i][j + 1] + F[i + 1][j] - F[i][j];
		}
	}
	lcnt /= 4;
	// debug(sv, lv, l);
	// rep(i, 0, D) debug(vi(S[i], S[i] + D));
	// rep(i, 0, 2 * D + 1) debug(vi(E[i], E[i] + 2 * D + 1));
	// rep(i, 0, 2 * D + 1) debug(vi(E[i], E[i] + 2 * D + 1));
	rep(i, 0, D) {
		rep(j, 0, D) {
			if(E[i + l][j + l] - E[i][j + l] - E[i + l][j] + E[i][j] == lcnt) {
				int x = i + l, y = j + l;
				int nx = i + D, ny = j + D;
				if(F[nx][ny] - F[nx][y] - F[x][ny] + F[x][y] == 0) return true;
			}
		}
	}
	return false;
}

void solve() {
	cin >> N >> D;
	rep(i, 0, N) {
		int x, y; cin >> x >> y;
		S[x % D][y % D]++;
	}
	ll lv = 0, rv = 1000000000;
	while(rv - lv > 1) {
		ll m = (lv + rv) / 2;
		if(ok(m)) rv = m;
		else lv = m;
	}
	cout << rv - 1 << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 35840
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAX_N = 100000;
int table[MAX_N + 2];
int n;

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		int p, q;
		scanf("%d %d", &p, &q);
		int t = table[p];
		for(int j = p; j <= q; j++)
			table[j]++;
	}
	int res = 0;
	for(int i = 0; i <= n + 1; i++){
		if(table[i] + 1 >= i){
			res = i - 1;
		}
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,r[200002];
  int maxz=-2000000000;
  int minz;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>r[i];
  }
  minz=r[0];
  for(int i=1;i<n;i++){
    maxz=max(maxz,r[i]-minz);
    minz=min(minz,r[i]);
  }
  cout<<maxz<<endl;
}

Measured memory_bytes: 1940
#include <bits/stdc++.h>
#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
using namespace std;
int N,K,A[200002];
int main()
{
    scan(N);
    scan(K);
    for(int i=0; i<N; i++)
    {
        scan(A[i]);
    }
    for(int i=0; i+K<N; i++)
    {
        if(A[i]>=A[i+K])
        {
            cout<<"No"<<endl;
        }
        else
            cout<<"Yes"<<endl;

    }

}


Measured memory_bytes: 4380
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
#define mod 1000000007;
using namespace std;


int main(){
    int S;
    cin >> S;
    if((S%100>12 || S%100==0) && (S/100>12 || S/100==0)) cout << "NA" << endl;
    else if(S%100>12 || S%100==0) cout << "MMYY" << endl;
    else if(S/100>12 || S/100==0) cout << "YYMM" << endl;
    else cout << "AMBIGUOUS" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
int main()
{
	ll a,b,c,x,tmp,cnt=0;
	string alpha,s;
	alpha=" abcdefghijklmnopqrtsuvwxyz";
	cin>>s;
	vector<char> v;
	REP(i,1,alpha.size()-1)
	{
		ll f=0;
		REP(i,1,alpha.size()-1)
		{
			bool found=false;
			REP(j,0,s.size()-1)
			{
				if(s[j]==alpha[i])
					found=true;
			}
			if(found==false)
			{
				cout<<alpha[i];
				return 0;
			}
		}
	}
	cout<<"None";
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

ll n;

ll dfs(ll line,ll level,vector<string> form){
  //dbg(line); dbg(level);
  if(isdigit(form[line][level]))return (ll)(form[line][level]-'0');
  char op=form[line][level];
  ll res=(op=='*'?1:0);
  repl(i,line+1,n){
    if(form[i].length()<level||form[i][level]!='.')break;
    if(form[i][level+1]=='.')continue;
    ll tmp=dfs(i,level+1,form);
    res=(op=='*'?res*tmp:res+tmp);
  }
  return res;
}

int main(){
	//cin.sync_with_stdio(false);
  while(1){
    cin>>n;
    if(n==0)break;
    vector<string> form;
    rep(i,n){
      string s;
      cin>>s;
      form.pb(s);
    }
    cout<<dfs(0,0,form)<<endl;
  }
	return 0;
}

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

const int MAX_N = 1e5+10;
int n, m;
ll a[MAX_N];

void solve()
{
	ll ans = 0;
	map<ll, ll> cnt;
    ll sum = 0;
    cnt[sum]=1;
	for(int i=1;i<=n;++i){
		(sum += a[i])%=m;
		ans+=cnt[sum];
		cnt[sum]++;
	}
	cout << ans << '\n';
}

int main()
{
	cin >> n >> m;
	for(int i=1;i<=n;++i) cin >> a[i];
	solve();
	return 0;
}

Measured memory_bytes: 8300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 200100
#define MN 15
int dig(ll x){
	int res = 0;
	while(x){
		x/=10;
		res++;
	}
	return res;
}
int main(){
	ll x;
	cin >> x;
	int ans = 114;
	for(ll i=1;i*i<=x;i++){
		if(x%i==0ll){
			ans =min(ans,max(dig(i),dig(x/i)));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*
 
*/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <deque>
 
#define ll long long
#define cint const int
#define ld long double
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
 
using namespace std;
 
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, long long> pil;
typedef pair <int, string> pis;
typedef pair <int, char> pic;
typedef pair <long long, int> pli;
typedef pair <long long, string> pls;
typedef pair <long long, char> plc;
typedef pair <string, int> psi;
typedef pair <string, long long> psl;
typedef pair <string, char> psc;
typedef pair <char, int> pci;
typedef pair <char, long long> pcl;
typedef pair <char, string> pcs;
 
string s;
 
int main () {
	cin >> s;
	if (s == "SUN") {
	    cout << 7;
	}
	if (s == "MON") {
	    cout << 6;
	}
	if (s == "TUE") {
	    cout << 5;
	}
	if (s == "WED") {
	    cout << 4;
	}
	if (s == "THU") {
	    cout << 3;
	}
	if (s == "FRI") {
	    cout << 2;
	}
	if (s == "SAT") {
	    cout << 1;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;


int main(void){


    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
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()


int linear(vector<int> a,int n,int key);

int main(){
    int x,y;
    int z=0;
    cin>>x;
    vector<int> a(x);
    rep(i,x) scanf("%d",&a.at(i));
    
    cin>>y;
    vector<int> b(y);
    rep(i,y) scanf("%d",&b.at(i));
    
    rep(i,y) z+=linear(a,x,b.at(i));
    cout<<z<<endl;
    
    return 0;
}

int linear(vector<int> a,int n,int key){
    int mid;
    int right=n;
    int left=0;
    while(left<right) {
        mid=(right+left)/2;
        if(a.at(mid)==key){
            return 1;
        } 
        else if(a.at(mid)>key) {
            right=mid;
        }
        else{
             left=mid+1;
        }
    }
    return 0;
}


Measured memory_bytes: 3848
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

struct dat{
	int i1, j1, i2, j2;
};

bool isin(int i, int j, int h, int w){
	return i >= 0 && j >= 0 && i < h && j < w;
}

int main(){
	int w, h;
	while (cin >> w >> h && w){
		vector<string> s1(h), s2(h);
		REP(i,h) cin >> s1[i] >> s2[i];
		REP(i,h) reverse(s2[i].begin(), s2[i].end());
		int si1, sj1, si2, sj2;
		REP(i,h) REP(j,w){
			if (s1[i][j] == 'L') si1 = i, sj1 = j;
			if (s2[i][j] == 'R') si2 = i, sj2 = j;
		}

		dat p;
		p.i1 = si1;
		p.j1 = sj1;
		p.i2 = si2;
		p.j2 = sj2;
		queue<dat> que;
		que.push(p);

		bool f[50][50][50][50] = {};
		f[si1][sj1][si2][sj2] = 1;

		int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
		bool clear = 0;
		while (!que.empty() && !clear){
			dat p = que.front();
			que.pop();
			REP(k,4){
				int i1 = p.i1 + dx[k], j1 = p.j1 + dy[k];
				int i2 = p.i2 + dx[k], j2 = p.j2 + dy[k];
				if (!isin(i1,j1,h,w) || s1[i1][j1] == '#'){
					i1 = p.i1;
					j1 = p.j1;
				}
				if (!isin(i2,j2,h,w) || s2[i2][j2] == '#'){
					i2 = p.i2;
					j2 = p.j2;
				}
				if (f[i1][j1][i2][j2]) continue;
				f[i1][j1][i2][j2] = 1;
				if (s1[i1][j1] == '%' && s2[i2][j2] == '%') clear = 1;
				else if (s1[i1][j1] == '%' || s2[i2][j2] == '%') continue;
				dat q;
				q.i1 = i1;
				q.j1 = j1;
				q.i2 = i2;
				q.j2 = j2;
				que.push(q);
			}
		}
		cout << (clear ? "Yes" : "No") << endl;
	}


    return 0;
}

Measured memory_bytes: 9904