akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

template< typename T >
struct BinaryIndexedTree {
  BinaryIndexedTree(size_t n) : n(n), v(n + 1) {}

  size_t n;
  vector< T > v;

  T sum(int k) {
    T ret = 0;
    for(; k; k -= k & -k) ret += v[k];
    return ret;
  }

  void add(int k, T x) {
    for(; k <= n; k += k & -k) v[k] += x;
  }
};

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

  vector< int > x(n + 1), idx(n + 1, -1);
  for(int i = 1; i <= n; ++i) {
    cin >> x[i];
    idx[x[i]] = i;
  }

  BinaryIndexedTree< int > bit(n);
  vector< int > inv(n + 1);
  int64_t sum = 0;
  for(int i = 1; i <= n; ++i) {
    inv[x[i]] = i - bit.sum(x[i]) - 1;
    sum += inv[x[i]];
    bit.add(x[i], 1);
  }

  vector< int > ans(1), used(n + 1, 0);
  for(int i = 1; i <= n; ++i) {
    if(sum - k < inv[i]) break;
    ans.push_back(i);
    sum -= inv[i];
    used[i] = true;
  }


  int mini = 101010, last = -1;
  set< pair< int, int > > unused;
  for(int i = 1; i <= n; ++i) {
    if(!used[x[i]]) {
      int sz = (int) unused.size();
      unused.emplace(sz, x[i]);
    }
  }

  int64_t rest = sum - k;
  while(unused.size()) {
    auto it = unused.begin();
    int small = it->second;
    for(int j = 0; j <= rest; j++) {
      if(it == unused.end()) break;
      small = min(small, it->second);
      ++it;
    }
    it = unused.begin();
    for(int j = 0;; j++) {
      if(small == it->second) {
        rest -= j;
        ans.push_back(it->second);
        unused.erase(it);
        break;
      }
      ++it;
    }
  }


  for(int i = 1; i <= n; ++i) {
    cout << ans[i] << endl;
  }
}



Measured memory_bytes: 7200
package main
import(
  "fmt"
)
func main(){
  var s string
  fmt.Scan(&s)
  if solve(s) {
    fmt.Println("AC")
  } else {
    fmt.Println("WA")
  }
}
func solve(s string) bool{
  var c byte
  var i,n int
  n = len(s)
  f := false
  for i = 0; i <  n; i++ {
    c = s[i]
    if i == 0 && c != 'A' {
      return false;
    }
    if c == 'C' {
      if 2 <= i && i < n-1  {
        if f {
          return false;
        }
        f = true
      } else {
        return false;
      }
    } else if 'A' < c && c <= 'Z'{
      return false;
    }
  }
  return f;
}


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

/*vector<int> p(n);
cin >> p[i]*/

int main(){

    int n;
    int even_count=0, count=0;
    cin >> n;

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

    for(int i=0; i<n; i++){
        if(p[i] % 2 == 0){
            count++;
            if(p[i] % 3 == 0 || p[i] % 5 == 0) even_count++;
        }
    }

    if(even_count == count) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var d = Console.ReadLine().Split(' ');
            int max = 0;
            int sum = 0;
            for(int i = 0; i < n; i++)
            {
                if(max < int.Parse(d[i]))
                {
                    max = int.Parse(d[i]);
                }
                sum += int.Parse(d[i]);
            }
            sum -= max;
            if(sum > max)
            {
                Console.WriteLine("Yes");

            }
            else
            {
                Console.WriteLine("No");
            }
            
        }
    }
}


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

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

void readline(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readline(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}
void readline(int N, vector<ll> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = (ll)atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}

ll cut(vector<ll> &A, int N, int i, int &il, int &ir, vector<ll> &S){
    
    while(il < i - 1){
        if(llabs(S[0] - S[1] + 2 * A[il + 1]) < llabs(S[0] - S[1])){
            il++;
            S[0] += A[il];
            S[1] -= A[il];
        }else{
            break;
        }
    }

    while(ir < N - 2){
        if(llabs(S[2] - S[3] + 2 * A[ir + 1]) < llabs(S[2] - S[3])){
            ir++;
            S[2] += A[ir];
            S[3] -= A[ir];
        }else{
            break;
        }
    }

    return *max_element(S.begin(), S.end()) - *min_element(S.begin(), S.end());

}

int main(){

    int N;
    cin >> N;
    vector<ll> A(N);
    readline(N, A);

    int il = 0;
    int ir = 2;
    vector<ll> S(4);
    S[0] = A[0];
    S[1] = A[1];
    S[2] = A[2];
    S[3] = 0;
    for(int i = 3; i < N; i++){
        S[3] += A[i];
    }
 
    ll min = 10000000000000000;

    for(int i = 1; i <= N - 3; i++){
        ll v = cut(A, N, i, il, ir, S);
        if(v < min) min = v;
        S[1] += A[i + 1];
        S[2] -= A[i + 1];
    }


    cout << min;


    return 0;

}

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

const int MOD = 1e9 + 7;

int solve(vector<string> &grid) {
	int h = grid.size();
	int w = grid[0].size();
	vector<vector<long long>> dp(h, vector<long long>(w, 0));
	dp[0][0] = 1;
	for (int i = 1; i < w; ++i)
	{
		if (grid[0][i]!='#') {
			dp[0][i] = dp[0][i-1];
		}
	}
	for (int i = 1; i < h; ++i)
	{
		if (grid[i][0]!='#') {
			dp[i][0] = dp[i-1][0];
		}
	}
	for (int i = 1; i < h; ++i)
	{
		for (int j = 1; j < w; ++j)
		{
			if (grid[i][j]!='#') {
				dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
			}
		}
	}
	return dp[h-1][w-1];
}

int main(int argc, char const *argv[])
{
	int h, w;
	cin >> h >> w;
	vector<string> grid(h);
	for (int i = 0; i < h; ++i)
	{
		cin >> grid[i];
	}
	cout << solve(grid) << "\n";
	return 0;
}

Measured memory_bytes: 12952
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S, T;
    cin >> S;
    cin >> T;

    int ans=0;
    rep(i, 3){
        if(S[i]==T[i]){
            ans++;
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 764
N = int(input())
A = input()
B = input()
C = input()
ans = 0

for i in range(N):
    if A[i] == B[i] and B[i] == C[i]:
        continue
    elif A[i] != B[i] and B[i] != C[i] and C[i] != A[i]:
        ans += 2
    else:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
typedef pair<int, int> P;
const int inf = 1<<30;

int main() {
  int n, x, y; cin >> n >> x >> y;
  --x, --y;
  vector<int> ans(n+1);
  vector<vector<int>> g(n);
  rep(i, n-1) {
    g[i].push_back(i+1);
    g[i+1].push_back(i);
  }
  g[x].push_back(y);
  g[y].push_back(x);

  rep(s, n) {
    vector<int> dist(n, inf);
    dist[s] = 0;
    queue<int> que;
    que.push(s);
    while(!que.empty()) {
      int v = que.front(); que.pop();
      for(auto to: g[v]) {
        if(dist[to] == inf) {
          dist[to] = dist[v] + 1;
          que.push(to);
        }
      }
    }
    rep(i, n) ans[dist[i]]++;
  }

  for(int i = 1; i < n; i++) {
    cout << ans[i] / 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 384
def main():
    s, c = [int(x) for x in input().split()]

    total = s
    s_req = s * 2

    if c <= s_req:
        print(c // 2)
        return

    c -= s_req
    total += c // 4

    print(total)



if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define MAX 100000
#define pb push_back
#define mp make_pair
#define MOD 1000000007
typedef long long Int;
typedef pair<Int,Int> pii;
typedef vector<Int> vi;
typedef vector<pii> vii;
Int K;
string S;
int main()
{
    cin>>S>>K;
    for (Int i=0;i<S.size();++i)
    {
        if (K==0)
            break;
        if (S[i]=='a')
            continue;
        if ('z'-S[i]+1<=K)
        {
            K=K-('z'-S[i]+1);
            S[i]='a';
        }
    }
    if (K!=0)
        K=K%26;
    char ch=S[S.size()-1];
    ch=((ch-'a')+K)%26+'a';
    S[S.size()-1]=ch;
    cout<<S;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>


int main(void){
                                                                                                
   
    long long a, b, k, i, t1, t2;
   
    long long s[101], r[101];
   
      
    scanf("%lld %lld %lld", &a, &b, &k );
   

    t1 = a + k - 1;

    if( b < t1 ) t1 = b;


    for( i = 0 ; a + i <= t1 ; i = i + 1 ){

         printf("%lld\n", a + i );

         }

    
    t2 = b - k + 1;

    if( t2 < a + k ) t2 = a + k;


    for( i = 0 ; t2 + i <= b ; i = i + 1 ){

         printf("%lld\n", t2 + i);

         }


    return 0;
                                                          
}

Measured memory_bytes: 128
N = int(2e5+3)
heap_arr, heap_size = [0] * N, 0

def heap_push(x):
    global heap_size
    heap_arr[heap_size] = x
    i = heap_size
    while i > 0 and heap_arr[i] > heap_arr[(i-1)//2]:
        heap_arr[i], heap_arr[(i-1)//2] = heap_arr[(i-1)//2], heap_arr[i]
        i = (i-1)//2
    heap_size += 1

def get_max():
    global heap_size
    if heap_size == 0:
        return -2e9
    return heap_arr[0]

def heap_pop():
    global heap_size
    if heap_size == 0:
        return
    heap_size -= 1
    heap_arr[0], heap_arr[heap_size] = heap_arr[heap_size], heap_arr[0]
    i, j = 0, -1
    while i != j:
      j = i
      l = 2*i+1
      r = 2*i+2
      if l < heap_size and heap_arr[l] > heap_arr[i]:
          i = l
      if r < heap_size and heap_arr[r] > heap_arr[i]:
          i = r
      heap_arr[i], heap_arr[j] = heap_arr[j], heap_arr[i]

n, m = map(int, input().split())
arr = list(map(int, input().split()))
for i in arr:
    heap_push(i)
while m >= 1:
    x = get_max() // 2
    heap_pop()
    heap_push(x)
    m -= 1    
print(sum(heap_arr))

Measured memory_bytes: 65520
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))

c = [[0 for _ in range(w)] for _ in range(h)]
color = 1
for j in range(h):
    for i in range(w):
        if j%2 == 0:
            c[j][i] = color
        else:
            c[j][w-1-i] = color
        a[color-1] -= 1
        if a[color-1] == 0:
            color += 1
for row in c:
    print(*row)

Measured memory_bytes: 3908
n=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
a=[list(map(int,input().split())) for i in range(2)]
mx=0
for i in range(n):
    mx=max(mx,sum(a[0][0:i+1])+sum(a[1][i:n]))

print(mx)



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

using namespace std;

const int N = 1e5+5, r = 0, s = 1, p = 2;
int n, k, a[N], vi[N];
string S;

int tonum(char x){
	if (x == 'r')
		return r;
	return x == 'p' ? p : s;
}

int towin(char x){
	if (x == 'r')
		return p;
	return x == 'p' ? s : r;
}

int main(){
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	scanf("%d %d", &n, &k);

	int val[3];

	scanf("%d %d %d", &val[0], &val[1], &val[2]);

	cin >> S;

	int ans = 0;

	for (int i = 0; i < n; i++){
		a[i] = towin(S[i]);
	}

	for (int i = n-1; i >= 0; i--){
		if (vi[i])
			continue;
		if (i - k < 0){
			ans += val[a[i]];
		} else {
			if (a[i] == a[i - k]){
				vi[i - k] = true;
			}
			ans += val[a[i]];
		}
	}

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

	return 0;
}

Measured memory_bytes: 4668
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] L = new int[N];
		for(int i=0; i<N; i++)
			L[i] = sc.nextInt();

		Arrays.sort(L);
		int[] first = new int[1010];
		Arrays.fill(first, -1);
		for(int i=0; i<N; i++)
			if(first[L[i]]<0)
				first[L[i]] = i;
		
		long ans = 0;
		
		for(int i=0; i<N; i++) {
			for(int j=i+1; j<N; j++) {
				int idx = Arrays.binarySearch(L, L[i]+L[j]);
				if(idx<0)
					idx = -idx-1;
				else
					idx = first[L[i]+L[j]];
				if(idx > j)
					ans += idx-j-1; 
			}
		}
		
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 28708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

#pragma region UnionFind
struct UnionFind
{
    vector<int> d;
    // d[x] is the index of the parent of x
    // d[x] is -size if x is a root

    UnionFind(int n) : d(vector<int>(n, -1)) {}
    int root(int x)
    {
        if (d[x] < 0)
        {
            return x;
        }
        return d[x] = root(d[x]);
    }

    bool unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
        {
            return false;
        }
        if (d[x] > d[y])
            swap(x, y); // x always bigger tree

        d[x] += d[y];
        d[y] = x;
        return true;
    }

    bool same(int x, int y)
    {
        return root(x) == root(y);
    }
    int size(int x) { return -d[root(x)]; }
};
#pragma endregion

int main()
{
    int n, m;
    cin >> n >> m;
    stack<P> es;
    rep(i, m)
    {
        P edge;
        cin >> edge;
        edge.first--;
        edge.second--;
        es.push(edge);
    }
    UnionFind uft(n);
    ll fuck = (ll)n * (n - 1) / 2;
    stack<ll> ans;
    while (es.size())
    {

        ans.push(fuck);
        P e = es.top();
        es.pop();

        ll a = uft.size(e.first), b = uft.size(e.second);
        bool newB = uft.unite(e.first, e.second);
        if (newB)
        {
            fuck -= a * b;
        }
    }

    while (ans.size())
    {
        ll a = ans.top();
        ans.pop();
        cout << a << endl;
    }

    return 0;
}

Measured memory_bytes: 2560
const double = Float64
const int = Int64
const vint = Vector{int}
const vdouble = Vector{double}

int(x) = parse(int,x)

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  n = readint()[1]

  c = 0
  for i in 1:n
    if i%3 == 0 || i%5==0
      continue 
    end
    c += i
  end
  println(c)
end

main()

Measured memory_bytes: 214468
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {

int a,b,c[110][110],e,f;
   cin >> a>>b;
  
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++)
    cin >>c[i][j];
  }
 f =0;
  for(int i=0;i<a;i++){
    for(int j=0;j<i;j++){
      for(int l =0;l<140;l++){
      e =0;
      for(int k =0;k<b;k++){
        e += (c[i][k]-c[j][k])*(c[i][k]-c[j][k]);
      }
        
        if(e == l*l){
          f++;
        }
      }
    }
  }
  
  cout << f << endl;
  
  return 0;
}

          


Measured memory_bytes: 256
#include<stdio.h>
#define N 5

int data[N];

void swap(int *a , int *b) {
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

void sort() {
	int i , s;
	for(i = 0; i < N - 1; i++) {
		for(s = i + 1; s < N; s++) {
			if (data[i] < data[s]) {
				swap(&data[i] , &data[s]);
			}
		}
	}
}

int main () {
	int i;

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

	sort();

	for(i = 0; i < N; i++) {
		if (i != 0) printf(" ");
		printf("%d" , data[i]);
	}

	printf("\n");
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
int main()
{
    int n,i;
    scanf("%d",&n);
    if(n==1)
        printf("1\n");
    if(n>=2&&n<4)
        printf("2\n");
    if(n>=4&&n<8)
        printf("4\n");
    if(n>=8&&n<16)
        printf("8\n");
    if(n>=16&&n<32)
        printf("16\n");
    if(n>=32&&n<64)
        printf("32\n");
    if(n>=64&&n<101)
        printf("64\n");
 return 0;   
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <string>
#include <cstring>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const ll MOD = (ll)1e9 + 7;
ll add(ll x, ll y)
{
    x += y;
    if (x >= MOD) return x - MOD;
    return x;
}
ll sub(ll x, ll y)
{
    x -= y;
    if (x < 0) return x + MOD;
    return x;
}

const int N = 100100;
ll a[N];
ll x, y;
ll dp[N];
ll bal;
int n;

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    scanf("%d%lld%lld", &n, &x, &y);
    for (int i = 1; i <= n; i++)
        scanf("%lld", &a[i]);
    if (x > y) swap(x, y);
    a[0] = a[1] - y;
    a[n + 1] = a[n] + y;
    n += 2;
    for (int i = 0; i + 2 < n; i++)
        if (a[i + 2] - a[i] < x)
        {
            printf("0\n");
            return 0;
        }
    int p1 = 0, p2 = 0;
    dp[0] = add(dp[0], 1);
    dp[1] = sub(dp[1], 1);
    for (int i = 0; i < n; i++)
    {
        bal = add(bal, dp[i]);
        if (i == n - 1) break;
        if (p1 <= i + 1)
        {
            p1 = i + 2;
            while(p1 < n && a[p1] - a[p1 - 1] >= x) p1++;
        }
        while(p2 < n && a[p2] - a[i] < y) p2++;
        if (p2 > p1) continue;
        dp[p2] = add(dp[p2], bal);
        dp[p1 + 1] = sub(dp[p1 + 1], bal);
    }
    printf("%lld\n", bal);

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    string S[3];
    REP(i, 3)cin >> S[i];

    cout << S[0][0] << S[1][1] << S[2][2] << endl;
    return 0;
}

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

int main(){
    ll a,b,k;
    cin >> a >> b >> k;
    if(b - a < k*2){
        for(ll i=a;i<=b;i++){
            cout << i << endl;
        }
        return 0;
    }
    vector<ll> v;
    for(ll i=a;i<a+k;i++){
        v.pb(i);
    }
    for(ll i=b;i>b-k;i--){
        v.pb(i);
    }
    sort(v.begin(),v.end());
    rep(i,v.size()){
        if(v[i] != v[i-1]){
            cout << v[i] << endl;
        }
    }
}

Measured memory_bytes: 256
N = [int(x) for x in input()]
K = int(input())

D = len(N)
dp = [[[0] * 4 for _ in range(2)] for _ in range(D + 1)]
dp[0][0][0] = 1

for i in range(D):
    for j in range(2):
        for d in range(10 if j else N[i] + 1):
            for k in range(4):
                if d:
                    if k + 1 <= 3:
                        dp[i + 1][j | (d < N[i])][k + 1] += dp[i][j][k]
                    else:
                        continue
                else:
                    dp[i + 1][j | (d < N[i])][k] += dp[i][j][k]

print(dp[D][0][K] + dp[D][1][K])

Measured memory_bytes: 40304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (int r = (aa)-1; r >= (bb); r--)
#define be(x) (x.begin(), x.end())
#define pb(t) push_back(t)
#define ll long long
#define mp(a, b) make_pair(a, b)
#define f first
#define s second
const int MAX=1000*100+5;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n, maxi=0;
	cin>>n;
	string s;
	map<string, int>mp;
	rep(i,0,n){
		cin>>s;
		mp[s]++;
		maxi=max(maxi, mp[s]);
	}
	set<string>A;
	for(auto x:mp){
		if(x.s==maxi){
			A.insert(x.f);
		}
	}
	for(auto r:A)cout<<r<<"\n";
}


Measured memory_bytes: 33280
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
using namespace std;
inline ll read(){
    ll f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//******head by yjjr******
#define mid ((l+r)>>1)
const int maxn=2e5+6;
char st[maxn],t[maxn],d[maxn];
int n,Q;
inline int check(int x){
    rep(i,1,Q){
        if(st[x]==t[i])x+=(d[i]=='R')?1:-1;
        if(x>n)return -1;
        if(x<1)return 1;
    }
    return 0;
}
int main(){
    n=read(),Q=read();
    scanf("%s",st+1);
    rep(i,1,Q)cin>>t[i]>>d[i];
    int l=1,r=n,la=0,ra=n+1;
    while(l<=r)if(check(mid)==1)la=mid,l=mid+1;else r=mid-1;
    l=1,r=n;
    while(l<=r)if(check(mid)==-1)ra=mid,r=mid-1;else l=mid+1;
    cout<<ra-la-1<<endl;
    return 0;
}

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

using namespace std;

#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search;
#define lower(arr,n,fixed) lower_bound(arr,arr+n,fixed)-arr  //Lower value search;
#define remvec(vec,val) vec.erase(remove(vec.begin(), vec.end(), val), vec.end())  // remove val from vector
#define FOR(i,a,n) for(int i=a; i<(int)n; i++)
#define FORI(i,a,n) for(int i=a; i>=(int)n; i--)
#define pii pair<int,int>
#define vpii vector<pii>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(a) int((a).size())
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0)
#define endl "\n"
#define all(a) a.begin(), a.end()
#define MEMSET(p,i) memset(p,i,sizeof(p))

	
// int to string c++
#define SSTR(x) static_cast< std::ostringstream & >( \
		( std::ostringstream() << std::dec << x ) ).str()


int main(void)
{
	int n, m;

	cin >> n >> m;
	n--, m--;

	cout << n*m << endl;
	


	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    val K = sc.nextInt()

    fun jump(dp:Pair<Long,Int>,h:Int) = dp.first+Math.abs(dp.second - h)

    val DP = Array(N){0L to 0}
    DP[0] = 0L to sc.nextInt()
    for (i in 1 until N) {
        val h = sc.nextInt()
        var min = 10000000000L
        for (k in 1..K) {
            if (i-k<0) break
            min = Math.min(min, jump(DP[i-k], h))
        }
        DP[i] = min to h
    }
    //for ((n,h) in DP) print("$n ")
    println(DP[N-1].first)
}

Measured memory_bytes: 67524
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 100000
#define NIL -1

typedef struct search{
  struct search *right;
  struct search *left;
  struct search *p;
  int key;

}search;

void insert(int);
void  inorderTreeWalk(search *x);
void Puriorder(search *x); 
search *T;

int main(){
  int i,v,k;
  char a[32];

  T = NULL;

  scanf("%d",&v);
  for ( i = 0;i < v;i++){
    scanf("%s",a);
    if(strcmp(a,"insert")==0){
      scanf("%d",&k);
    insert(k);
    }
    else if(strcmp(a,"print")==0){
      inorderTreeWalk(T);
      printf("\n");
      Puriorder(T);
      printf("\n");
      }

  }
  return 0;
}


  //出力
void  inorderTreeWalk(search *x){
    if(x !=NULL){
      inorderTreeWalk(x->left);
    printf(" %d",x->key);
    inorderTreeWalk(x->right);
    }
}

void Puriorder(search *x){
 if(x !=NULL){ 
   printf(" %d",x->key);
      Puriorder(x->left);
      Puriorder(x->right);
    }
}







void insert(int key){
  search *x,*y,*z;
  y = NULL; // x の親
  x = T;
  z = (search *)malloc(sizeof(search));
  z->key = key;
  z->right = NULL;
  z->left = NULL;
  z->p = NULL;
  while (x != NULL){
    y = x; // 親を設定
    if (z->key < x->key)
      x = x->left; // 左の子へ移動
    else 
      x = x->right; // 右の子へ移動
  }
  z->p = y;

  if( y == NULL){ // T が空の場合
    T = z;
  }
  else if (z->key < y->key)
    y->left = z; // z を y の左の子にする
  else 
    y->right = z; // z を y の右の子にする
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int n;
    ll ans = 0;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    sort(d.begin(), d.end());
    for (int i = d[d.size() / 2];; --i) {
        if (i == d[d.size() / 2 - 1])
            break;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3772
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(void){
    int n,tt,k=1001;
    int c[1000],t[1000];
    cin>>n>>tt;
    for(int i=0;i<n;i++){
        cin>>c[i]>>t[i];
        if(t[i]<=tt&&c[i]<k){
            k=c[i];
        }
    }
    if(k==1001){
        cout<<"TLE"<<endl;
    }else{
        cout<<k;
    }
}

Measured memory_bytes: 256
#include<map>
#include<string>
#include<vector>
#include<sstream>
#include<iostream>
#include<algorithm>

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

using namespace std;

map< string,vector<string> > f;

vector<string> solve(const string &g){
	vector<string> member=f[g];
	rep(i,member.size())if(f.count(member[i])>0){
		vector<string> tmp=solve(member[i]);
		member.erase(member.begin()+i);	// erase group name
		i--;
		member.insert(member.end(),tmp.begin(),tmp.end());
	}
	sort(member.begin(),member.end());
	member.erase(unique(member.begin(),member.end()),member.end());
	return f[g]=member;
}

int main(){
	for(int n;cin>>n,n;){
		f.clear();
		string group1;
		rep(i,n){
			string s;	cin>>s;
			rep(j,s.length())if(s[j]==':' || s[j]==',' || s[j]=='.')	s[j]=' ';
			stringstream ss(s);
			string group;	ss>>group;
			vector<string> member;
			while(ss>>s)	member.pb(s);
			f[group]=member;
			if(i==0)	group1=group;
		}
		cout<<solve(group1).size()<<endl;
	}

	return 0;
}

Measured memory_bytes: 1048
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int center=n/2-1;
    long long int x;
    std::deque<long long int> numbers;
    std::deque<long long int> origin;
    for (int i=0;i<n;i++) {
        cin>>x;
        numbers.emplace_back(x);
        origin.emplace_back(x);
    }
    sort(numbers.begin(),numbers.end(),greater<long long int>());
    for (int i=0;i<n;i++) {
        if (numbers[center]<=origin[i]) {
            cout<<numbers[center+1]<<endl;
        } else {
            cout<<numbers[center]<<endl;
        }
    }
}

Measured memory_bytes: 5504
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
// #include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
#include <cassert>
#include<unordered_set>
using namespace std;

// vector<long long int> memo(100000);


// long long int rec_depth(int depth, vector<int> a, int cap, int n){
//     if(depth == n){
//         if(a[depth] > cap) return -1;
//         else{
//             // memo[depth] = a[depth];
//             result += a[depth];
//             return a[depth];
//         }
//     }
//     if(a[depth] >= cap) return -1;
//     else{
//         long long int res = rec_depth(depth+1, a, (cap-a[depth])*2, n);
//         // cout << res << ", " << result << endl;
//         if(res == -1){
//             return -1;
//         }
//         else{
//             if(res+a[depth] > cap) {
//                 result += cap;
//                 return cap;
//                 }
//             // cout <<  cap << endl;
            
//             else{ 
//                 result += res + a[depth];
//                 return res + a[depth];
//                 }
//         }
//     }
// }

 
int main(){
    int n;
    cin >> n;
    int nn = sqrt(n);
    vector<vector<vector<int>>> dp(nn,vector<vector<int>>(nn, vector<int>(nn, 0)));
    vector<int> res(n, 0);

    rep(i,nn){
        rep(j,nn){
            rep(k,nn){
                if(dp[i][j][k] != -1){
                    int answer= (i+1)*(i+1) + (j+1)*(j+1) + (k+1)*(k+1) + (i+1)*(j+1) + (j+1)*(k+1) + (k+1)*(i+1);
                    if(answer <= n){
                        if(i==j && j==k){
                            res[answer-1] += 1;
                        }
                        else if(i==j || j==k || k==i){
                            res[answer-1] += 3;
                        }
                        else{
                            res[answer-1] += 6;
                        }
                    }
                    dp[i][j][k] = -1;
                    dp[i][k][j] = -1;
                    dp[j][i][k] = -1;
                    dp[j][k][i] = -1;
                    dp[k][j][i] = -1;
                    dp[k][i][j] = -1;
                }
                
            }
        }
    }

    rep(i,n){
        cout << res[i] << endl;
    }
}

Measured memory_bytes: 7580
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 210, X = 100010, P = 1000000007;

int n, x;
int a[N], fac[N], inv[N];
int dp[N][X], sum[X];

int binom(int n, int m) { return fac[n] * (ll)inv[m] % P * inv[n - m] % P; }

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif

  scanf("%d%d", &n, &x);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &a[i]);
  sort(a + 1, a + n + 1, greater<int>());
  fac[0] = 1;
  for (int i = 1; i <= n; ++i)
    fac[i] = fac[i - 1] * (ll)i % P;
  inv[1] = 1;
  for (int i = 2; i <= n; ++i)
    inv[i] = -(P / i) * (ll)inv[P % i] % P + P;
  inv[0] = 1;
  for (int i = 1; i <= n; ++i)
    inv[i] = inv[i - 1] * (ll)inv[i] % P;
  dp[0][x] = 1;
  sum[x] = fac[n - 1];
  for (int i = 1; i <= n; ++i) {
    for (int v = 0; v <= x; ++v)
      dp[i][v % a[i]] = (dp[i][v % a[i]] + sum[v] * (ll) inv[n - i]) % P;
    for (int v = 0; v < a[i]; ++v)
      sum[v] = (sum[v] + dp[i][v] * (ll)fac[n - i - 1]) % P;
  }
  int ans = 0;
    for (int v = 1; v < a[n]; ++v) {
      ans = (ans + v * (ll) dp[n][v] % P) % P;
    }
  printf("%d\n", ans);

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 79616
#include<bits/stdc++.h>
using namespace std;
vector<int>i;
int u[114514],y[114514];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a=0,b=0,c=0,d=0,e=0,f=0,g=0,h,j,k=0,l=0;
  cin >>a;
  for(int n=1;n<a;n++) d+=n;
  cout <<d<<'\n';
  return (0);
}


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

#define INF 50000000

int n, m, s, g1, g2;
int table[128][128];
int Min;

void init() {
	for(int i = 0; i < 128; i++) {
		for(int j = 0; j < 128; j++) {
			table[i][j] = INF;
		}
	}

	for(int i = 0; i < 128; i++)
		table[i][i] = 0;

	Min = INF;
}

bool input() {
	cin >> n >> m >> s >> g1 >> g2;
	if(!n && !m && !s && !g1 && !g2)
		return false;
	for(int i = 0; i < m; i++) {
		int b1, b2, c;
		
		cin >> b1 >> b2 >> c;
		table[b1 - 1][b2 - 1] = c;
	}
	return true;
}

int solve() {
	// warshall floyd
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			for(int k = 0; k < n; k++) {
				table[j][k] = (table[j][k] < (table[j][i] + table[i][k]) ?
					table[j][k] : (table[j][i] + table[i][k]));
			}
		}
	}

	// search min
	for(int i = 0; i < n; i++) {
		if(Min > table[s - 1][i] + table[i][g1 - 1] + table[i][g2 - 1])
			Min = table[s - 1][i] + table[i][g1 - 1] + table[i][g2 - 1];
	}

	return Min;
}

int main(void) {
	init();
	while(input()) {
		cout << solve() << endl;
		init();
	}

	return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;
typedef long double LD;

#define MOD 9007199254740997

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  vector<LL> v(n);
  for(int i=0;i<n;i++) cin >> v[i];
  sort(v.begin(),v.end(),greater<LL>());
  LL total=0;
  for(int i=0;i<a;i++){
    total+=v[i];
  }
  cout << fixed << setprecision(10) << (LD)total/a << endl;
  int count=0,count2=0;
  LL ans=0,tmp;
  vector<vector<LL>> combi(n+1,vector<LL>(n+1,0));
  combi[0][0]=1;
  for(int i=1;i<=n;i++){
    combi[i][0]=combi[i][i]=1;
    for(int j=1;j<i;j++){
      combi[i][j]=combi[i-1][j-1]+combi[i-1][j];
    }
  }
  if(v[0]==v[a-1]){
    for(count=0;count<n;count++){
      if(v[count]!=v[0]) break;
    }
    for(int i=min(count,b);i>=a;i--){
      ans+=combi[count][i];
    }
  }else{
    for(count=0;count+a-1<n;count++){
      if(v[count+a-1]!=v[a-1]) break;
    }
    for(count2=0;-count2+a-1>=0;count2++){
      if(v[-count2+a-1]!=v[a-1]) break;
    }
    ans=combi[count+count2-1][count2];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

dic = dict()
for cx, cy in xy:
    for x, y in xy:
        if cx != x or cy != y:
            w = (x-cx,y-cy)
            if dic.get(w) is None:
                dic[w] = 0
            dic[w] += 1

cnt = 1
m = 0
for x in dic:
    m = max(m, dic[x])
cnt += N - 1 - m
print(cnt)


Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	string a, b; cin >> a >> b;
	ll c = stol(a + b);

	for (int i = 1; i*i <= 100100; i++) {
		if (i*i == c) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func modPow(a, n, mod int) int {
	ret := 1
	for n > 0 {
		if n&1 == 1 {
			ret = (ret * a) % mod
		}
		a = (a * a) % mod
		n >>= 1
	}
	return ret
}

func modInv(a, mod int) int {
	b := mod
	u, v := 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		u -= t * v
		a, b = b, a
		u, v = v, u
	}
	u = u % mod
	if u < 0 {
		u += mod
	}
	return u
}

func com(n, k, mod int) int {
	a := 1
	for i := n - k + 1; i <= n; i++ {
		a = (a * i) % mod
	}
	for i := 1; i <= k; i++ {
		a = (a * modInv(i, mod)) % mod
	}
	return a % mod
}

func main() {
	sc.Split(bufio.ScanWords)
	const mod int = 1000000007
	n, a, b := nextInt(), nextInt(), nextInt()
	ans := modPow(2, n, mod) - 1 - (com(n, a, mod)+com(n, b, mod))%mod
	if ans < 0 {
		ans += mod
	}
	puts(ans)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
n = int(input())

def dfs(s):
    if int(s) > n:
        return 0
    ret = 0
    if all(s.count(c) > 0 for c in '753'):
        ret = 1
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0'))

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
  char S[3];
  int flag[3] = {0,0,0};

  scanf("%s",S);

  for(int i = 0;i < 3;i++){
    switch(S[i]){
      case 'a':
        flag[0] = 1;
        break;
      case 'b':
        flag[1] = 1;
        break;
      case 'c':
        flag[2] = 1;
        break;
    }
  }

  for(int i = 0;i < 3;i++){
    if(!flag[i]){
      printf("No\n");
      return 0;
    }
  }

  printf("Yes\n");
  return 0;
}

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

int main()
{
	int t;
  cin >> t;
 int arr[t+1000];
  for(int i=0;i<t;i++)
  {
      cin >> arr[i];
  }	
  sort(arr, arr+t);
  for(int i=0;i<t;i++)
  {
   	if(arr[i]==arr[i+1])
    {
     	cout << "NO" << endl;
      	return 0;
    }
  }
  cout << "YES" << endl;
}

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

const int N = 20005;
int n, p[N], a[N], b[N], to[N];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &p[i]);
        to[p[i]] = i;
    }
    for (int i = 1; i <= n; i++) a[i] = i * 25000;
    for (int i = 1; i <= n; i++) b[i] = (n - i + 1) * 25000;
    for (int i = 1; i <= n; i++)
        b[p[i]] -= (23000 - i);
    for (int i = 1; i <= n; i++) printf("%d ", a[i]); printf("\n");
    for (int i = 1; i <= n; i++) printf("%d ", b[i]); printf("\n");
  //  for (int i = 1; i <= n; i++) printf("%d ", a[i] + b[i]); printf("\n");
    return 0;
}


Measured memory_bytes: 896
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/operators.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	struct max_t
	{
		template<class T>T operator()(T&& lhs, T&& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>T operator()(T&& lhs, T&& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min(); 
}

void Main()
{
	int N;
	std::cin >> N;
	std::vector<int> height(N);
	for (auto& h : height)
	{
		std::cin >> h;
	}
	std::unordered_map<int, std::int64_t> map;
	std::int64_t count = 0;
	for (auto i : boost::irange(N) | adaptor::reversed)
	{
		auto x = -(height[i] + i);
		auto y = height[i] - i;
		if (map.count(x))
		{
			count += map[x];
		}
		++map[y];
	}
	std::cout << count << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 11768
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<vector>

using namespace std;

#define INF (1<<30)

int main(){
	int n;
	int v[20];
	int c[20];
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> v[i];
	}
	for(int i = 0;i < n;i++){
		cin >> c[i];
	}
	int ans = 0;
	for(int i = 0;i < n;i++){
		if(v[i] > c[i]){
			ans += v[i] - c[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
A = []
for i in range(H):
  As = list(map(int, input().split()))
  A.append(As)
L = []
for i in range(H):
  for j in range(W-1):
    if A[i][j]%2 == 1:
      A[i][j] -= 1
      A[i][j+1] += 1
      L.append((i, j, i, j+1))
for i in range(H-1):
  if A[i][-1]%2 == 1:
    A[i][-1] -= 1
    A[i+1][-1] += 1
    L.append((i, W-1, i+1, W-1))
#print(A)
print(len(L))
for i, j, x, y in L:
  i, j, x, y = i+1, j+1, x+1, y+1
  print(i, j, x, y)


Measured memory_bytes: 22808
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double gcd( double m, double n );
double lcm( double m, double n );
int main(int argc, const char * argv[])
{
    double a=0.0;
    double b=0.0;
    
    while(scanf("%lf",&a)!=EOF){
        scanf("%lf",&b);

        double g = gcd(a, b);
        double l = lcm( a,b );
        
        
        printf("%d",int(g));
        printf(" ");
        printf("%d\n",int(l));
        
    }
    
}
double gcd( double m, double n )
{
	if ( ( 0.0 == m ) || ( 0.0 == n ) )
		return 0;
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}

double lcm( double m, double n )
{
	if ( ( 0.0 == m ) || ( 0.0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n);
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int D;
int C[26];
int S[365][26];
int T[365];

int last[26];

void score()
{
  ll s = 0LL;
  REP(i,26) last[i] = 0;
  REP(i,D){
    s += S[i][T[i]];
    last[T[i]] = (i+1);
    REP(j,26){
      s -= C[j] * (i+1-last[j]);
    } 
  }
  cout << s << '\n';
}

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

  cin >> D;
  REP(i,26) cin >> C[i];
  REP(i,D) REP(j,26) cin >> S[i][j];
  REP(i,D){ 
    cin >> T[i];
    T[i]--;
  }
  int m; cin >> m;
  REP(i,m){
    int d,q; cin >> d >> q;
    d--, q--;
    T[d] = q;
    score();
  }
  return 0;
}


Measured memory_bytes: 3648
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    int count=0;

    for (int i=0;i<s.length()/2;i++) {
      // System.out.print(s.charAt(i));
      // System.out.println(s.charAt(s.length()-i-1));
      if(s.charAt(i)!=s.charAt(s.length()-i-1)) count++;
    }

    System.out.println(count);
  }
}


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

int n, a, b, c, d;
string s;

bool check(int start, int end){
    for(int i = start; i < end; i++){
        if(s[i] == '#' and s[i + 1] == '#'){
            return false;
        }
    }
    return true;
}

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

    cin >> n >> a >> b >> c >> d;
    cin >> s;

    s = '#' + s + '#';

    bool f1 = true, f2 = true, f3 = true;

    f1 = check(a, c);
    f2 = check(b, d);
    if(d < c){
        f3 = false;
        for(int i = b - 1; i < d; i++){
            if(s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.'){
                f3 = true;
                break;
            }
        }
    }

    cout << (f1 and f2 and f3 ? "Yes" : "No") << endl;

    return 0;
}

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

int main () {

    int k, a, b;
    cin >> k >> a >> b;
    bool okay(false);
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {okay = true; break;}
    }
    if (!okay) cout << "NG\n";
    else cout << "OK\n";
    return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, x) for (int i = 1, _##i = (x); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)

#define L(x) ((x)*2)
#define R(x) ((x)*2+1)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;
typedef pair<ll, ll> pll;

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    os << pai.first << ' ' << pai.second;
	return os;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    rep(i, sz(v)) cout << v[i] << ' ';
    return os;
}

template<typename T, typename V>
istream &operator>>(istream &is, pair<T, V> &pai) {
	is >> pai.first >> pai.second;
	return is;
}

int N;
char str[3][101];

int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

	cin >> N >> str[0] >> str[1] >> str[2];

	int res = 0;
	rep(i, N) {
		char s[3];
		rep(j, 3) s[j] = str[j][i];
		sort(s, s+3);
		res += (unique(s, s+3)-s) - 1;
	}
	cout << res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vdouble = vector<double>;

int gcd(int a, int b) {
    if (b==0) return a;
   	else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}


ll f(ll x){
	if(x==1) return 1;
	else return 2*f(x/2)+1;
}

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

Measured memory_bytes: 256
l, r = map(int, list(input().split()))

if r - l >= 2018:
    print(0)

else:
    array = range(l, r + 1, 1)
    kouho = 2018
    for i in array:
        for j in array:
            if i != j:
                mod = (i * j) % 2019
                if kouho > mod:
                    kouho = mod

    print(kouho)

Measured memory_bytes: 3060