akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#pragma GCC optimize ("-O2")
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <pair<lli,int>,vt <pair<lli,int>>,greater <pair<lli,int>>>
using namespace std;
using namespace __gnu_pbds; 

//USE AT YOUR OWN RISK
lli tmod(lli x,lli m=mod){return (x%m+m)%m;}

template <typename T> 
void DEBUG_ARR(vt<T> a,char c)
{
	f(i,0,a.size())cout<<a[i]<<c;
	cout<<"\n";
}

//make sure x is below mod
lli power(lli x, lli y,lli m=mod) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%m; 
        y = y>>1; 
        x = (x*x)%m;  
    }
    if(res<0)
       res+=m; 
    return res; 
}

// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 1;
//     if(r<0)return 0;
//     if(n<0)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }
void normalize(lli &a,lli &b){
    if(a==0 && b==0)return;
    if(a<0){
        a=-a;
        b=-b;
    }
    else if(a==0){
        if(b<0)b=-b;
    }
    lli g=__gcd(abs(a),abs(b));
    if(g!=0){
        a/=g;
        b/=g;
    }
}
const int N=2e5+5;

//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{ 
    // fact[0]=1;
    // f(i,1,2000001)fact[i]=(i*fact[i-1])%mod;
    fastio;
    int t=1;
    // cin>>t;
    // int temp=t;
    // cout<<smvalallestprime[5]<<"\n";
	while(t--){
        // cout<<"Case #"<<temp-t<<": ";
        // clock_t t=clock();
        // ifstream in("cave.in");
        // ofstream out("cave.out");
        lli ans=0;
        lli n,m,k;cin>>n>>m>>k;
        lli a[n],b[m];
        f(i,0,n)cin>>a[i];
        f(j,0,m)cin>>b[j];
        f(i,1,n)a[i]+=a[i-1];
        f(i,1,m)b[i]+=b[i-1];
        f(i,0,n){
            if(a[i]<=k)ans=i+1;    
        }
        f(i,0,m){
            if(b[i]<=k)ans=max(ans,i+1);
        }
        f(i,0,n){
            if(a[i]>k)continue;
            int pos=lower_bound(b,b+m,k-a[i]+1)-b;
            pos--;
            ans=max(ans,i+pos+2);
        }
        cout<<ans<<"\n";
        // cout<<clock()-t<<"\n";
    }   
    return 0; 	
}


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

int main(){
    int N;
    cin>>N;
    vector<int>d(N);
    for(int i=0;i<N;i++){
        cin>>d[i];    
    }
    sort(d.begin(),d.end());
    int count=0;
    if(d[N/2-1]==d[N/2]){
        cout<<0<<endl;
    }
    else{
        for(int i=d[N/2];i>d[N/2-1];i--){
            count++;
        }
        cout<<count<<endl;
    }
}


Measured memory_bytes: 640
// https://atcoder.jp/contests/abc151/tasks/abc151_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

const int MOD = 1e9 + 7;
template <int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod)
            x -= mod;
    }
    ModInt &operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod)
            x -= mod;
        return *this;
    }
    ModInt &operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0)
            x += mod;
        return *this;
    }
    ModInt &operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt &operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
    friend ostream &operator<<(ostream &s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream &operator>>(istream &s, ModInt<mod> &a) {
        s >> a.x;
        return s;
    }
};
using mint = ModInt<MOD>;
vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};

void check_fact(int n) {
    for (int i = I_.size(); i <= n; i++) {
        I_.push_back(I_[MOD % i] * (MOD - MOD / i));
        F_.push_back(F_[i - 1] * i);
        R_.push_back(R_[i - 1] * I_[i]);
    }
}

mint I(int n) {
    check_fact(abs(n));
    return n >= 0 ? I_[n] : -I_[n];
}
mint F(int n) {
    check_fact(n);
    return n < 0 ? 0 : F_[n];
}
mint R(int n) {
    check_fact(n);
    return n < 0 ? 0 : R_[n];
}
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

void solve() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i, N) { cin >> A[i]; }
    sort(ALL(A));
    mint ans = 0;
    // Σ max_S を求める
    FOR(i, K - 1, N) {
        // 最大値がA[i]になる組み合わせはA[i-1]以下からK-1個選ぶ
        ans += C(i, K - 1) * A[i];
    }
    // Σ min_S を求める
    REP(i, N - K + 1) {
        // 最小値がA[i]になる組み合わせはA[i+1]以上からK-1個選ぶ
        ans -= C(N - i - 1, K - 1) * A[i];
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 6596
#ifndef VS
#include<bits/stdc++.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

typedef vector<LL> V;
int main() {
	int K;
	cin >> K;
	V A(K);
	cin >> A;
	reverse(ALL(A));
	LL lb = 2, ub = 2;
	for (int i : range(K)) {
		LL lo, hi;
		lo = 0; hi = 1e18;
		while (hi - lo > 1) {
			const LL mid = (lo + hi) / 2;
			if ((mid / A[i])*A[i] <= ub)lo = mid;
			else hi = mid;
		}
		LL nu = lo;
		lo = 0; hi = 1e18;
		while (hi - lo > 1) {
			const LL mid = (lo + hi) / 2;
			if ((mid / A[i])*A[i] >= lb)hi = mid;
			else lo = mid;
		}
		LL nl = hi;
		//cout << nl << " " << nu << endl;
		if (nu == 0 || nl > nu) {
			cout << -1 << endl;
			return 0;
		}
		lb = nl;
		ub = nu;
	}
	cout << lb << " " << ub << endl;
	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;

public class AOJ1
{
    public static void Main()
    {
        while (true)
        {
            string Input = Console.ReadLine();
            if (Input == null) break;
            string[] str = new string[3];
            int i = 0;
            while (i < Input.Length && Input[i] != '+') str[0] += Input[i++];
            ++i; // '+' 
            while (i < Input.Length && Input[i] != '=') str[1] += Input[i++];
            ++i; // '='
            while (i < Input.Length) str[2] += Input[i++];
            int ans = 0;
            for (; ans <= 9; ans++)
            {
                string[] STR = new string[3];
                for (int j = 0; j < 3; j++)
                {
                    for (i = 0; i < str[j].Length; i++)
                    {
                        if (str[j][i] == 'X') STR[j] += (char)('0' + ans);
                        else STR[j] += str[j][i];
                    }
                }
                if ((STR[0].Length >= 2 && STR[0][0] == '0')
                    || (STR[1][0] == '0' && STR[1].Length >= 2)
                    || (STR[2][0] == '0' && STR[2].Length >= 2)) continue;
                bool flag = false; // 繰り上げ
                string TMP = "";
                for (i = 0; i < 2; i++)
                {
                    TMP = "";
                    for (int j = STR[i].Length - 1; j >= 0; j--) TMP += STR[i][j];
                    STR[i] = TMP;
                }
                TMP = "";
                for (i = 0; i < Math.Max(STR[0].Length, STR[1].Length); i++)
                {
                    char ch = '0', CH = '0';
                    if (i < STR[0].Length) ch = STR[0][i];
                    if (i < STR[1].Length) CH = STR[1][i];
                    int sum = (ch - '0') + (CH - '0');
                    if (flag) { sum++; flag = false; }
                    if (sum >= 10) { flag = true; sum -= 10; }
                    TMP += (char)('0' + sum);
                }
                if (flag) TMP += '1';
                string rTMP = "";
                for (i = TMP.Length - 1; i >= 0; i--) rTMP += TMP[i];
                if (rTMP == STR[2]) break;
            }
            if (ans > 9) Console.WriteLine("NA");
            else Console.WriteLine(ans);
        }
    }
}

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

int main()
{
	int a = 0, b = 0, c = 0;
	int cnt = 0;

	cin >> a >> b >> c;

	for (int i = a; i <= b; i++) {
		if (c%i == 0) {
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='C')
		{
			for(int j=i+1;j<s.size();j++)
			 if(s[j]=='F')
			 {
			 	cout<<"Yes"<<endl;
			 	return 0;
			 }
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace ABC170
{
    class B
    {
        static void Main(string[] args)
        {
            var XY = Console.ReadLine().Split().Select(long.Parse).ToArray();
            // var CA = Enumerable.Repeat(0, (int)N).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
            //var AB = Console.ReadLine().Split().Select(long.Parse).ToArray();

            for (int i = 0; i <= XY[0]; i++)
            {
                for (int j = 0; j <= XY[0] - i; j++)
                {
                    if (i + j == XY[0] && 2 * i + 4 * j == XY[1]) { Console.WriteLine("Yes"); return; }
                }
            }
            Console.WriteLine("No");
        }
    }
}


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

using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using pint = pair<int, int>;
#define repi(n) for (int i = 0; i < n; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define repv(itr) for (auto&& v : itr)
#define swap(x, y)    \
  {                   \
    auto ___temp = x; \
    x = y;            \
    y = ___temp;      \
  }

const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}

int main() {
  int a, b, t;
  cin >> a >> b >> t;
  cout << t / a * b << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.*;
 
class Main {
    public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static PrintWriter pw = new PrintWriter(System.out);
    public static String line;
    public static StringTokenizer st;
    public static ArrayList<ArrayList<Integer>> adjList;
    public static int[] dx = {-1, 0, 1, 0, -1, 1, 1, -1, 0};
    public static int[] dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
    public static int INF = 0x3f3f3f3f;
    public static int MOD = 1000000007;
    public static long LINF = 0x3f3f3f3f3f3f3f3fL;

    public static long[] fact, inv;

    public static long nCr(int N, int R) {
        if (R < 0 || R > N) return 0;
        return (( fact[N] * inv[R] % MOD ) * inv[N-R]) % MOD;
    }

    public static void main(String[] args) throws Exception {
        int N = Integer.parseInt(br.readLine());
        fact = new long[N+1];
        inv = new long[N+1];
        
        fact[0] = 1;
        inv[0] = 1;
        BigInteger BIMOD = BigInteger.valueOf(MOD);
        for (int i = 1; i <= N; i++) {
            fact[i] = (i * fact[i-1]) % MOD;
            inv[i] = BigInteger.valueOf(fact[i]).modInverse(BIMOD).longValue();
        }
        // System.out.println(inv[1]);
        long ans = 0;
        long prev = 0;
        for (int K = 1; K <= N; K++) {
            if (N - K - 1 < 0) break;
            long n = ((nCr(K-1, N-K-1) * fact[K] % MOD) * fact[N-K-1]) % MOD;
            long times = ( n - prev + MOD ) % MOD;
            prev = n;
            ans = ans + ((times * K) % MOD);
            ans %= MOD;
        }
        pw.println(ans);

        pw.close(); 
        br.close();
    }
}

class Point implements Comparable<Point>{
    public int x, y;
 
    Point(int _x, int _y){
        x = _x;
        y = _y;
    }
 
    public String toString(){
        return x + " " + y;
    }

    public int compareTo(Point p){
        if (x != p.x) return x < p.x ? -1 : 1;
        if (y != p.y) return y < p.y ? -1 : 1;
        return 0;
    }
} 


Measured memory_bytes: 171032
#include <bits/stdc++.h>
#define REP(i, n, s) for (LL i = (s); i < (n); i++)
#define SIZE 1
using namespace std;
typedef long long int LL;
typedef long double LD;

LL func(LL b, LL n) {
	if (n < b) return n;
	return func(b, floor(n/b)) + (n % b);
}

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

	LL N, S;
	cin >> N >> S;



	LL res = -1;
	LL _N = ceil(sqrt((double)N));
	REP(i, _N+1, 2) {
		if (func(i, N) == S && res == -1) {
			res = i;
			break;
		}
	}

	if (res != -1) {
		cout << res << endl;
		return 0;
	}
	for (LL p = _N - 1; p > 0; p--) {
		if (S < p) continue;
		LL q = S - p, b = (N - q) / p;
		if ((N - q)%p == 0 && q < b && b > _N) {
			res = (N - q) / p;
			break;
		}
	}

	if (res == -1 && N == S) {
		cout << (N+1) << endl;
		return 0;
	}

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations, combinations_with_replacement
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from math import gcd

# dを大きい方から取って行きたい
# A1は1として問題ない。
# 数列を仮定して探索すれば良い
N, M, Q = read_ints()
DATA = read_tuple(Q)
A = [1 + x for x in range(M)]


def ret_score(A):
    ret = 0
    for a, b, c, d in DATA:
        if A[b - 1] - A[a - 1] == c:
            ret += d
    return ret


ans = 0
for AA in combinations_with_replacement(A, r=N):
    ans = max(ans, ret_score(AA))
print(ans)


Measured memory_bytes: 68656
#include<iostream>
#include<vector>
using namespace std;
using ll=long long;

int main(){
    int n;cin>>n;
    int mod=1e9+7;
    vector<int> a(n);
    ll sum=0;
    for(int i=0;i<n;++i){
        cin>>a[i];
        sum+=a[i];
        sum%=mod;
    }
    ll ans=0;
    for(int i=0;i<n;++i){
        sum-=a[i];
        if(sum<0)sum+=mod;
        ans+=a[i]*sum;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4064
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> d;
  
  for (int i = 1; i <= n; i++) {
    int di;
    cin >> di;
    d.push_back(di);
  }
  
  sort(d.begin(), d.end());
  
  cout << d[n/2] - d[n/2-1] << endl;
  return 0;
}


Measured memory_bytes: 892
#include<iostream>
using namespace std;
 
 
int main(){
  int w;
  while(true){
    cin >> w;
    if(w == -1)break;
    int sum = 0,pre = 4280;
    sum = sum+1150;
    if(w >= 10 && w <= 20){
        sum = sum + (w-10)*125;
    }
    else if(w >= 20){
        sum = sum + 10*125;
    }
    if(w >= 20 && w <= 30){
        sum = sum + (w-20)*140;
    }
    else if(w >= 30){
        sum = sum + 10*140;
    }
    if(w >= 30){
        sum = sum + (w-30)*160;
    }
    cout << pre - sum << endl;
  }
  return 0;
}


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>

using namespace std;

const int Maxn = 100010;
int n , m;
int f[Maxn];
bool b[Maxn];

int main() {
	
	scanf("%d%d",&n,&m);
	for(register int i=1; i<=n; i++)
		f[i] = 1;
	b[1] = true;
	for(register int x,y; m--; ) {
		scanf("%d%d",&x,&y);
		f[x] -- , f[y] ++;
		if(b[x]) {
			b[y] = true;
			if(!f[x])	b[x] = false;
		}
	}
	
	register int ans = 0;
	for(register int i=1; i<=n; i++)
		if(b[i])
			ans ++;
	printf("%d\n",ans);
	
	return 0;
	
}

Measured memory_bytes: 768
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define L(i,u) for (int i=head[u]; i!=0; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
typedef long long ll;
using namespace std;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 377777;
int n,a[N],ans[N],all,f[19][N],mx[N];
int main() {
	read(n);all=(1<<n)-1;rep(i,0,all)read(a[i]),mx[i]=a[i];
	rep(i,0,n-1)rep(j,0,all)mx[j]=((j>>i)&1)?max(mx[j],mx[j^(1<<i)]):mx[j];
	rep(k,0,n-1){
		rep(j,0,all)f[k][j]=a[j];
		rep(i,0,n-1)rep(j,0,all)
			f[k][j]=(((j>>i)&1)&&i!=k)?max(f[k][j],f[k][j^(1<<i)]):f[k][j];
	}
	rep(i,0,all)rep(j,0,n-1)if((i>>j)&1)ans[i]=max(ans[i],mx[i^(1<<j)]+f[j][i]);
	rep(i,1,all)ans[i]=max(ans[i-1],ans[i]),printf("%d\n",ans[i]);
	return 0;
}


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

static const int MAX = 100;
static const long long INFTY = 1LL << 32;
int n;
long long d[MAX][MAX];

void floyd(){
	for (int k = 0; k < n; ++k)
	{
		for (int i = 0; i < n; ++i)
		{
			if (d[i][k] == INFTY)continue;
			for (int j = 0; j < n; ++j){
				if (d[k][j] == INFTY)continue;
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

int main()
{
	int e, u, v, c;
	cin >> n >> e;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			d[i][j] = (i == j) ? 0 : INFTY;
		}
	}
	for (int i = 0; i < e; ++i)
	{
		cin >> u >> v >> c;
		d[u][v] = c;
	}
	
	floyd();
	
	bool negative = false;
	for (int i = 0; !negative and i < n; ++i)if (d[i][i] < 0)negative = true;
	
	if (negative)cout << "NEGATIVE CYCLE" << endl;
	else{
		for (int i = 0; i < n; ++i)
		{
			for (int j = 0; j < n; ++j){
				if (j)putchar(' ');
				if (d[i][j] == INFTY)cout << "INF";
				else cout << d[i][j];
			}
			putchar('\n');
		}
	}
	
	return 0;
}


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

int main() {
 char c;
  cin >> c;
  
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
    cout << "vowel" << endl;
  }
  
  else{
    cout << "consonant" << endl;
  }
}  

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N;
    cin >> N;
    vector<ll> a(N);
    rep(i, 0, N) cin >> a[i];
    sort(a.begin(), a.end(), greater<ll>());
    ll ans = 0;
    rep(i, 0, N){
        if(i % 2 == 0) ans += a[i];
        else ans -= a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int N, A; double numer;
int main() {
  scanf("%d", &N);
  for(int i = 1, A; i <= N; ++i) {
    scanf("%d", &A), numer += 1.0/A;
  }
  printf("%.10lf\n", 1.0/numer);
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
  int N,A,B,sum;
  scanf("%d%d%d",&N,&A,&B);
  
  sum=N*A;
  
  if(sum>B){
    printf("%d\n",B);
  }else printf("%d\n",sum);
  
  
  
 return 0; 
}

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

using namespace std;

typedef long long ll;

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

  ll p = 1;
  while (k--) p *= 2;

  cout << max(max(a * p + b + c, a + b * p + c), a + b + c * p) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	string s,ans;
	cin >> s;
	rep(i, s.size()) {
		if (s[i] == 'B') {
			if (ans.size()) {
				ans.pop_back();
			}
		}
		else ans.push_back(s[i]);
	}
	cout << ans << endl;
}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  
  cin >>N;
  vector<int> A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      int t;
      if(j!=0){
        if(A.at(j)>A.at(j-1)){
          t=A.at(j-1);
          A.at(j-1)=A.at(j);
          A.at(j)=t;
        }
      }
    }
    
  }
  int count=1;
  
  for(int j=0;j<N;j++){
    if(j!=0){
      if(A.at(j)<A.at(j-1))
        count++;
    }
  }
  
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    string S;
    int N;
    cin >> N >> S;

    vector<bool> one(10);  //! 0 to 9
    vector<bool> two(100); //! 00 to 99
    vector<bool> three(1000); //! 000 to 999

    rep(i, N) {
        int d = static_cast<int>(S[i] - '0');
        rep(j, 100) {
            if (two[j]) {
                three[j * 10 + d] = true;
            }
        }
        rep(j, 10) {
            if (one[j]) {
                two[j * 10 + d] = true;
            }
        }
        one[d] = true;
    }

    int ans = 0;
    rep(i, 1000) {
        if (three[i]) ++ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
//Ubiquity 

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

//n=元の数,p=乗数,m=mod
ll repsqr(ll n,ll p,ll m){
    if(p==0)return 1;
    if(p%2==0){
        ll t=repsqr(n,p/2,m);
        return t*t%m;
    }
    return n*repsqr(n,p-1,m)%m;
}

signed main (){
    int mod = 1000000007;
    int n;cin>>n;
    int ans=repsqr(10,n,mod)-2*repsqr(9,n,mod)+repsqr(8,n,mod);
    ans%=mod;
    ans=(ans+mod)%mod;
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;
import java.util.Arrays;

public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
long a=scan.nextLong();
long b=scan.nextLong();
long c=scan.nextLong();

if((4*a*b<(c-a-b)*(c-a-b))&&(c>a+b)){
System.out.println("Yes");
}else{
System.out.println("No");  
}
  
  
}
}


Measured memory_bytes: 21716
def solve(n,A):
    x=pow(2,n)
    dp=[False]*2001
    for i in range(x):
        count=0
        for j in range(n):
            if (i>>j)&1:
                count+=A[j]
        if count<=2000:
            dp[count]=True
    return dp

n=int(input())
A=list(map(int,input().split()))
q=int(input())
m=list(map(int,input().split()))
ans=solve(n,A)
for i in range(q):
    if ans[m[i]]:
        print("yes")
    else:
        print("no")


Measured memory_bytes: 5632
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

template <class T>
struct Node {
    T value;
    size_t parent, left, right;
    Node(): value(), parent(-1), left(-1), right(-1) {}
    Node(T v): value(v), parent(-1), left(-1), right(-1) {}
};

template <class T>
struct BinarySearchTree {
    vector<Node<T>> nodes;
    size_t root;
    BinarySearchTree(): root(-1) {}
    void insert(T v) {
        Node<T> z(v);
        nodes.push_back(z);

        size_t x=root, y=-1;
        while (~x) {
            y = x;
            if (v < nodes[x].value) {
                x = nodes[x].left;
            } else {
                x = nodes[x].right;
            }
        }

        nodes.back().parent = y;

        if (!~y) {
            root = 0;
        } else if (v < nodes[y].value) {
            nodes[y].left = nodes.size()-1;
        } else {
            nodes[y].right = nodes.size()-1;
        }
    }
    size_t find(T v, size_t x=0) {
        size_t l=nodes[x].left;
        if (~l && nodes[x].value>v) {
            size_t res=find(v, l);
            if (~res) return res;
        }

        size_t r=nodes[x].right;
        if (~r && nodes[x].value<v) {
            size_t res=find(v, r);
            if (~res) return res;
        }

        return nodes[x].value==v? x:-1;
    }
    template <class Functor>
    void walk_inorder(Functor F, size_t x=0) {
        if (!~x) return;

        walk_inorder(F, nodes[x].left);
        F(nodes[x]);
        walk_inorder(F, nodes[x].right);
    }
    template <class Functor>
    void walk_preorder(Functor F, size_t x=0) {
        if (!~x) return;

        F(nodes[x]);
        walk_preorder(F, nodes[x].left);
        walk_preorder(F, nodes[x].right);
    }
};

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

    auto output=[](Node<int> &x)->void {
        printf(" %d", x.value);
    };

    BinarySearchTree<int> tree;
    for (size_t i=0; i<n; ++i) {
        char buf[1<<3];
        scanf("%s", buf);
        string instr(buf);

        if (instr == "insert") {
            int key;
            scanf("%d", &key);
            tree.insert(key);
        } else if (instr == "print") {
            tree.walk_inorder(output);
            printf("\n");
            tree.walk_preorder(output);
            printf("\n");
        } else if (instr == "find") {
            int key;
            scanf("%d", &key);
            printf("%s\n", ~tree.find(key)? "yes":"no");
        }
    }

    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<n;++(i));
#define SORT(s) sort((s).begin(),(s).end());
#define SORTR(s) sort((s).begin(),(s).end(),greater<int>());

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const double PI=acos(-1.0);

int N,M; int k[15],s[15][15],p[15];
int input()
{  
    cin>>N>>M;
    for(int i=0;i<M;++i){
        int a; cin>>a;
        k[i]=a;
        for(int j=0;j<k[i];++j){
            int b; cin>>b;
            s[i][j]=b;
        }
    }
    for(int i=0;i<M;++i){
        int a; cin>>a; p[i]=a;
    }
}

int solve()
{
    int ans=0;
    for(int i=0;i<(1<<N);++i){
        bool judge=true;
        bitset<11> bset=i;
        for(int j=0;j<M;++j){
            int on=0;
            for(int l=0;l<k[j];++l){
                if(bset[s[j][l]-1]) ++on;
            }
            if(on%2!=p[j]) {
                judge=false;
                break;
            } 
        }
        if(judge) ++ans;
    }
    cout<<ans<<endl;
}

int main(){
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        FastReader f = new FastReader();
        // int [] arr = { 1 , 6 , 120 , 496 , 2016, 8128 ,32640 , 130816};
        byte n = f.nextByte();
        byte [] arr = new byte[n];
        for(byte i =0;i<arr.length ;i++){
            arr[i]=f.nextByte();
        }
        int AScore=0 , BScore=0;
        Arrays.sort(arr);
        for(byte i = (byte) (arr.length-1) ; i>=0 ;i-=2){
            if(i!=0){            
                byte j =(byte) (i-1);
                            BScore+=arr[j];

                         }
            AScore+=arr[i];
            
        }
        
        System.out.println(AScore-BScore);
     
    }   
 }


class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        byte nextByte() 
        { 
            return Byte.parseByte(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    
}


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

#define int long long
typedef pair<int, int> P;

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

int N, M;
int l[330000], r[330000];
P range[330000];
// Binary Indexed Tree(1-indexed)
const int MAX_N = 110000;

struct BIT {
    int bit[MAX_N + 1], n;

    int sum(int i) {
        int s = 0;
        while (i > 0) {
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    void add(int i, int x) {
        while (i <= n) {
            bit[i] += x;
            i += i & -i;
        }
    }
};

signed main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        cin >> l[i] >> r[i];
        range[i] = P(l[i], r[i]);
    }
    sort(range, range + N,
         [](P a, P b) { return a.second - a.first < b.second - b.first; });
    BIT bit;
    bit.n = 110000;
    int cur = 0;
    for (int i = 1; i <= M; i++) {
        while (cur < N && i > range[cur].second - range[cur].first) {
            bit.add(range[cur].first + 1, 1);
            bit.add(range[cur].second + 2, -1);
            cur++;
        }
        int ans = N - cur;
        for (int j = 0; j <= M; j += i) {
            ans += bit.sum(j + 1);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 11904
// Problem : A - Kth Term
// Contest : AtCoder - Panasonic Programming Contest 2020
// URL : https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"
#define lb "lower_bound"
#define ub "upper_bound"
#define bs "binary_search"

int dif(int a,int b){if(a > b)return a - b;else return b - a;}
int min(int a,int b){if(a > b)return b;else return a;}
int max(int a,int b){if(a > b)return a;else return b;}
int gcd(int a, int b){if(b == 0)return a;return gcd(b, a%b);}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin>>n;
    cout<<arr[n - 1];
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include<cstdio>
// #define MOD 1000000007
// #define MOD2 1000000014000000049LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long ll;

template<int N, int M>
struct ModFact {
    int inv[N+1];
    int fact[N+1];
    constexpr ModFact() : fact() {
        ll f = 1;
        fact[0] = f;
        for (int i = 0; i < N; i++) {
            f = f*(i+1)%M;
            fact[i+1] = f;
        }
        f = power(f, M-2);
        for (int i = N-1; i >= 0; i--) {
            inv[i] = fact[i] * f % M;
            f = f * (i+1) % M;
        }
    }
    constexpr ll power(ll a, ll b) {
        ll r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%M;
            a = (a*a)%M;
            b >>= 1;
        }
        return r;
    }
	int operator[](int n) {
		return inv[n];
	}
};

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}

inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int MOD = 1000000007;
const ll MOD2 = 1000000014000000049LL;

ModFact<100000, MOD> fact;

int main() {
    ll ans = 0, d;
    int a, N, prev, now;
    N = getint();
    prev = getint();
    REP(i, N-1) {
        now = getint();
        d = now - prev;
        prev = now;
        a = (a + fact[i]) % MOD;
        // ans += a * d % MOD;
        ans += a * d;
        if(ans > MOD2) ans -= MOD2;
    }
    printf("%lld\n", ((ans%MOD)*fact.fact[N-1])%MOD);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

int main()
{
    int n;
    ll sum = 0, tmp;

    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%lld", &tmp);
        sum += tmp;
    }
    printf("%lld\n", sum / n);

    return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#define maxd 400500
using std::string;
using std::cout;
using std::cin;
using std::endl;
using std::sort;
using std::map;
struct A{
    string s;
    int w;
};A a[maxd];
bool comp(A x,A y)
{
    if(x.w==y.w)
    return x.s.compare(y.s)<0;
    else
    return x.w>y.w;
}
int main()
{
    map<string,int>maps;
    int n,i=1;
    string c;
    cin>>n;
    for(i=1;i<=n;i++)
        {
            cin>>c;
            if(maps[c])
                maps[c]++;
            else
                maps[c]=1;
        }
    map<string,int>::iterator iter;
    for(iter=maps.begin();iter!=maps.end();iter++)
    {
        a[i].s=iter->first;
        a[i].w=iter->second;
        i++;
    }
    sort(a+1,a+i,comp);
    int ma=a[1].w;
    for(i=1;a[i].w==ma;i++)
    cout<<a[i].s<<endl;
    return 0;
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

ll power(ll a, ll b, ll md) {
	assert(b >= 0);
	ll res = 1;
	while (b) {
		if (b & 1) res = res * a % md;
		a = a * a % md;
		b >>= 1;
	}
	return res;
}

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

  string L;
  cin >> L;
  vector<vector<LL>> dp(L.size(), vector<LL>(2, 0));

  dp[0][0] = 2;
  dp[0][1] = 1;

  FOR(i,1,L.size()){
    if(L[i]=='1'){
      dp[i][0] = dp[i - 1][0] * 2;
      dp[i][1] = dp[i - 1][1] * 3+dp[i - 1][0] * 1;
    }else{
      dp[i][0] = dp[i - 1][0] * 1;
      dp[i][1] = dp[i - 1][1] * 3;
    }
    dp[i][0] %= mod;
    dp[i][1] %= mod;
  }
  cout <<( dp[L.size() - 1][0] + dp[L.size() - 1][1])%mod<< endl;
}


Measured memory_bytes: 5840
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
  public static void Main()
  {
    var input = Console.ReadLine().Split();
    var k = int.Parse(input[0]);
    var x = int.Parse(input[1]);

    var min = Math.Max(-1000000, x - k + 1);
    var max = Math.Min(1000000, x + k - 1);
    var result = Enumerable.Range(min, max - min + 1);
    Console.WriteLine(string.Join(" ", result));
  }
}


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

int main() {
    int n, q; scanf("%d %d", &n, &q);
    int c[n]; for (int i = 0; i < n; i++) scanf(" %d", &c[i]);
    vector<pair<int, int> > query[n+1];
    for (int i = 0; i < q; i++) {
        int l, r; scanf(" %d %d", &l, &r);
        query[r-1].push_back({l, i});
    }
    int ans[q], pos[n+1], bit[n+1];
    fill(pos, pos+n+1, 0);
    fill(bit, bit+n+1, 0);
    for (int i = 0; i < n; i++) {
        if (pos[c[i]] > 0)
            for (int j = pos[c[i]]; j > 0; j -= j&-j) bit[j]--;
        for (int j = i+1; j > 0; j -= j&-j) bit[j]++;
        pos[c[i]] = i+1;
        for (auto [l, idx] : query[i]) {
            int a = 0;
            for (int j = l; j <= n; j += j&-j) a += bit[j];
            ans[idx] = a;
        }
    }
    for (int i = 0; i < q; i++) printf("%d\n", ans[i]);
}


Measured memory_bytes: 33244
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#define MAXN 200000

using namespace std;

int main(){
    int N,d;
    map<int,int> D;
    cin >> N;
    for (int i=0;i<N;i++){
	cin >> d;
	D[d]++;
    }
    int M;
    cin >> M;
    int T[MAXN]={0};
    for (int i=0;i<M;i++){
	cin >> T[i];
    }
    
    if (N < M){
	cout << "NO" << endl;
	return 0;
    } else {
	for (int i=0;i<M;i++){
	    if (D[T[i]] > 0){
		D[T[i]]--;
	    } else {
		cout << "NO" << endl;
		return 0;
	    }
	}
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int MOD = 1e9 + 7;

//因数分解
map<int,int> prime_factor(int n){
  map<int,int> mp; //{約数,個数}
  for(int i = 2; i*i <= n; i++){
    while(n%i == 0){
      mp[i]++;
      n /= i;
    }
  }
  if(n != 1) mp[n] = 1; //n=素数
  return mp;
}

int mod_pow(int n, int p, int MOD){
  int r = 1;
  for(; p > 0; p >>= 1){
    if(p & 1LL) r = (r * n) % MOD;
    n = (n * n) % MOD;
  }
  return r; // r = n^p % MOD
}

signed main(){

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

  map<int, int> mp;
  for(int i = 0; i < n; i++){
    auto dp = prime_factor(a[i]);
    for(auto p : dp){
      mp[p.first] = max(mp[p.first], p.second);
    }
  }

  int lcm = 1;
  for(auto p : mp){
    lcm = (lcm * mod_pow(p.first, p.second, MOD)) % MOD;
  }

  int ans = 0;
  for(int i = 0; i < n; i++){
    ans = (ans + lcm * mod_pow(a[i], MOD-2, MOD)) % MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;
 
signed main(){
    int N,M,X,Y;cin>>N>>M>>X>>Y;
    int xm=-100;
    REP(i,N){
        int a;cin>>a;
        xm=max(xm,a);
    }
  	int ym=INF;
    REP(i,M){
        int b;cin>>b;
        ym=min(b,ym);
    }
  	bool ok=false;
    if(xm<ym){
        for(int i=xm+1;i<=ym;i++){
            if(i>X&&i<=Y)ok=true;
            break;
        }
    }
    if(ok)cout<<"No War"<<endl;
    else cout<<"War"<<endl;
}

Measured memory_bytes: 256
calculation :: Int -> [Char] -> Int -> Int
calculation a op b
  | op == "+" = a + b
  | op == "-" = a - b
  | op == "*" = a * b
  | op == "/" = div a b

calculator :: IO ()
calculator  = do
  s' <- getLine
  let s = words s'
  let (a,op,b) = (read (s !! 0),(s !! 1),read (s !! 2))
  if op == "?" then return ()
  else do
    putStrLn $ show $ calculation a op b
    calculator
main = calculator

Measured memory_bytes: 3948
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

int ceil(int x, int y) { return (x % y == 0) ? x / y : x / y + 1; }

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int lcm(int x, int y) { return x / gcd(x, y) * y; }

ll fac[MAX], finv[MAX], inv[MAX];
void init_comb() {
  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;
  }
}

ll comb(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;
}

ll mod(ll n) { return n % MOD; }

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

  int n;
  cin >> n;
  ll a[n];
  for (int i = 0; i < n; i++) cin >> a[i];

  init_comb();

  ll sum = 0;
  for (int i = 0; i < 61; i++) {
    ll c1 = 0;
    for (int j = 0; j < n; j++) {
      if ((a[j] & (1ll << i)) != 0) ++c1;
    }
    ll c0 = (n - c1);
    sum = mod(sum + mod(mod(1ll << i) * mod(c0 * c1)));
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>

int main()
{
  int a,b;
  
  scanf("%d%d",&a,&b);
  
  int i;
  int count=0;
  
  for(i=a;i<=b;i++)
  {
    if(i/10000==i%10&&(i/1000)%10==(i/10)%10)
    {
      count++;
    }
  }
  
  printf("%d\n",count);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    int n, m, nAns = 0, mAns = 0;

    cin >> n >> m;

    if(n >= 2)
        nAns = (n * (n-1))/2;
    if(m >= 2)
        mAns = (m * (m-1))/2;

    cout << nAns + mAns;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll n, cap;
	cin >> n >> cap;
	vector<ll> w(n), pr(n);
	for (ll i = 0; i < n; i++) {
		cin >> w[i] >> pr[i];
	}
	ll dp[n + 1][cap + 1];
	memset(dp, 0, sizeof(dp));
	for (ll i = 1; i <= n; i++) {
		for (ll cur = 1; cur <= cap; cur++) {

			if(w[i - 1] > cur){
				dp[i][cur] = dp[i - 1][cur];
			}
			else dp[i][cur] = max(pr[i - 1] + dp[i - 1][cur - w[i - 1]], dp[i - 1][cur]);
		}
	}
	cout << dp[n][cap];
	return 0;
}


Measured memory_bytes: 79104
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
    int A1, A2, A3;
    int tmp12, tmp23, tmp31;
    int result = 0;
    scanf("%d%d%d", &A1, &A2, &A3);

    tmp12 = abs(A1 - A2);
    tmp23 = abs(A2 - A3);
    tmp31 = abs(A3 - A1);

    if (tmp12 < tmp23) {
        if (tmp23 < tmp31) {
            result = tmp12 + tmp23;
        } else {
            result = tmp12 + tmp31;
        }
    } else {
        if (tmp12 < tmp31) {
            result = tmp23 + tmp12;
        } else {
            result = tmp23 + tmp31;
        }
    }

    printf("%d", result);
    return 0;
}

Measured memory_bytes: 128