akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#define ll long long
#define rep(a,b) for(ll a=0;a<b;++a)
#define inf 1145141919

using namespace std;

vector<vector<ll> > dist(vector<vector<ll> > &c){
    vector<vector<ll> > d(10,vector<ll>(10,inf));
    rep(i,10) rep(j,10){
        d[i][j] = c[i][j];
    }
    rep(k,10) rep(i,10) rep(j,10){
        if(d[i][j]> d[i][k]+d[k][j]){
            d[i][j] = d[i][k]+d[k][j];
        }
    }
    return d;
}

int main(void){
    ll h,w; cin>>h>>w;
    vector<vector<ll> > a(h,vector<ll>(w,0));
    vector<vector<ll> > c(10,vector<ll>(10,0));
    rep(i,10){
        rep(j,10) cin>>c[i][j];
    }
    vector<vector<ll> > d = dist(c);
    ll ans = 0;
    rep(i,h){
        rep(j,w){
            cin>>a[i][j];
            if(a[i][j] != -1 && a[i][j] != 1){
                ans += d[a[i][j]][1];
            }
        }
    }
    cout<<ans<<endl;
}


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

#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define setbits(x) __builtin_popcount(x)
#define zerobits(x) __builtin_ctz(x)
#define setbitsll(x) __builtin_popcountll(x)
#define zerobitsll(x) __builtin_ctzll(x)
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x

typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef map<int,int> mii;

const int MOD = 1e9+7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	string str;
	int a,b,c,d;
	a = b = c = d = 0;
	while (n--) {
		cin >> str;
		if (str == "AC") ++a;
		else if (str == "WA") ++ b;
		else if (str == "TLE") ++c;
		else if (str == "RE") ++d;
	}
	cout << "AC x " << a << '\n';
	cout << "WA x " << b << '\n';
	cout << "TLE x " << c << '\n';
	cout << "RE x " << d << '\n';
	return 0;
}



Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    string s,t;
    string ans = "No";
    cin >> s >> t;
    vector<string> sv(s.length());
    vector<string> tv(t.length());
    for(int i=0;i<s.length();i++){
        sv[i]=s.substr(i,1);
    }
    for(int i=0;i<t.length();i++){
        tv[i]=t.substr(i,1);
    }
    sort(sv.begin(),sv.end());
    sort(tv.begin(),tv.end());
    reverse(tv.begin(),tv.end());
    string ns="";
    string nt="";
    for(int i=0;i<s.length();i++){
        ns+=sv[i];
    }
    for(int i=0;i<t.length();i++){
        nt+=tv[i];
    }
    if(ns<nt){
        ans = "Yes";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<math.h>
#include<map>
using namespace std;

#define MST(vis,x) memset(vis,x,sizeof(vis))
#define INF 0x3f3f3f3f
#define ll long long
#define maxn  30000005
ll gcd(ll x,ll y)
{
    if(x%y==0)return y;
    else return gcd(y,x%y);
}
int main()
{
    ll s1[200];
    ll n;
    while(scanf("%lld",&n)!=EOF)
    {
        for(int a=1; a<=n; a++)
            scanf("%lld",&s1[a]);
        ll temp=s1[1];
        ll sum=0;
        for(int a=2; a<=n; a++)
        {
            if(temp>s1[a])
            {
                ll tt=gcd(temp,s1[a]);
                temp=temp/tt*s1[a];
            }
            else
            {
               ll tt=gcd(s1[a],temp);
               temp=s1[a]/tt*temp;
            }
        }
        printf("%lld\n",temp);
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int main() {
	int pasta,juice,temp;
	scanf("%d",&pasta);
	for(int i=0;i<2;i++) {
		scanf("%d",&temp);
		if(pasta>temp)pasta=temp;
	}
	scanf("%d",&juice);
	scanf("%d",&temp);
	if(juice>temp)juice=temp;
	printf("%d\n",pasta+juice-50);
}

Measured memory_bytes: 1020
#include<stdio.h>

int main(){

  int A[10000],B[500],N,M,i,j,key,count=0;

  for(i=0 ; i<10000 ;i++){
    A[i] = 0;    
  }

  for(i=0 ; i<500 ;i++){
    B[i] = 0;    
  }

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

  scanf("%d",&M);
  
  for(i=0 ; i<M ; i++){
    scanf("%d",&B[i]);
  }  
  for(i=0 ; i<M ; i++){
    A[N] = B[i];    
   
    for(j=0 ; j<=N ; j++){
       if(A[j] == A[N]) break;
     }    
    if(j != N) count++;
   
    }
    printf("%d\n",count);
    return 0;
  }



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

vector<vector<int64_t>> generate(vector<int64_t>::iterator begin, vector<int64_t>::iterator end, int64_t s)
{
    int64_t count = distance(begin, end);
    if(s == 1)
    {
        vector<vector<int64_t>> result;
        for(auto it = begin; it != end; ++it)
        {
            vector<int64_t> temp;
            temp.push_back(*it);
            result.push_back(temp);
        }
        return result;
    }

    vector<vector<int64_t>> result;
    for(auto it = begin; it != end; ++it)
    {
        auto V = generate(it, end, s - 1);
        for(auto v : V)
        {
            vector<int64_t> temp;
            temp.push_back(*it);
            temp.insert(temp.end(), v.begin(), v.end());
            result.push_back(temp);
        }
    }
    return result;
}

void Main()
{
    int64_t N, M, Q;
    cin >> N >> M >> Q;
    vector<tuple<int64_t, int64_t, int64_t, int64_t>> P(Q);
    for(int64_t i = 0; i < Q; ++i)
    {
        int64_t a, b, c, d;
        cin >> a >> b >> c >> d;
        P[i] = make_tuple(a, b, c, d);
    }

    vector<int64_t> I(M);
    for(int64_t i = 0; i < M; ++i)
    {
        I[i] = i + 1;
    }
    auto V = generate(I.begin(), I.end(), N);

    int64_t result = 0;
    for(auto v : V)
    {
        int64_t sum = 0;
        for(int64_t i = 0; i < Q; ++i)
        {
            int64_t a = get<0>(P[i]);
            int64_t b = get<1>(P[i]);
            int64_t c = get<2>(P[i]);
            int64_t d = get<3>(P[i]);
            if(v[b - 1] - v[a - 1] == c)
            {
                sum += d;
            }
        }
        result = max(result, sum);
    }

    cout << result << endl;
}

int main()
{
    Main();
}


Measured memory_bytes: 15272
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rFOR(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<< #x << " = "<<(x)<<endl
#define int long long

using ll = long long;
const ll mod = LLONG_MAX;

typedef pair<int,int> P;

int a;
string s;
int cnt_l,cnt_r;
int cnt;

bool is(string s){
  cnt=0;
  int n=s.size();
  rep(i,n){
    if(s[i]=='('){
      cnt++;
    }
    if(s[i]==')'){
      cnt--;
    }
    if(cnt<0)return false;
  }
  if(cnt>0)return false;
  return true;

}
signed main(){
  cin>>a;
  cin>>s;
  rep(i,101){
    rep(j,101){
      string t="";
      rep(k,i){
        t+='(';
      }
      t+=s;
      rep(r,j){
        t+=')';
      }
      if(is(t)){
        cout<<t<<endl;
        return 0;
        break;
      }

    }
  }


}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

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

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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 nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n; cin >> n;
  ll tle,ac,wa,re; tle = 0; ac = 0; wa = 0; re = 0;
  
  rep(i,n){
    string s; cin >> s;
    if(s == "TLE") tle++;
    else if(s == "WA") wa++;
    else if(s == "AC") ac++;
    else re++;
  }
  
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  
  
  
}

Measured memory_bytes: 3624
const main = (inputs) => {

  var array = inputs[0].split(" ");
  if(array[0] < 10 && array[1] < 10){
    console.log(array[0] * array[1]);
  }else{
    console.log(-1);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));

Measured memory_bytes: 21064
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const int M=1000000007;
const int MM=998244353;
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(m<=1)return 0;
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=5e5+5;

ll sp[N];

void fill(){
  for(int i=1;i<N;i++)sp[i]=i;

    for(int i=2;i<N;i++){
      for(int j=i;j<N;j+=i){
        if(sp[j]==j)sp[j]=i;
      }
    }
}

bool prime(ll x){
  if(x==2)return true;

for(ll i=2;i*i<=x;i++){
  if(x%i==0)return false;
}

  return true;
}

ll fac[N];

ll inv[N];

void gg(){
  fac[0]=inv[0]=1;

  for(int i=1;i<N;i++){
    fac[i]=fac[i-1]*i%M;
    inv[i]=powM(fac[i],M-2,M);
  }
}

ll c(ll a,ll b,ll M){
  if(b>a)return 0;

  return (fac[a]*inv[a-b]%M)*(inv[b])%M;
}


int main()
{ 

IOS;

ll n,k;
cin>>n>>k;

gg();


if(k>=n-1){
  cout<<c(2*n-1,n-1,M);
  return 0;
}

ll ans=0;

for(int i=0;i<=k;i++){
  ll temp=c(n,i,M)*c(n-1,i,M)%M;
  ans=(ans+temp)%M;
}

cout<<ans;

//end_routine();

return 0;
 
}


Measured memory_bytes: 11420
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string[] s = new string[N];
        for (int i = 0; i < N; i++)
            s[i] = Console.ReadLine();

        int M = int.Parse(Console.ReadLine());
        string[] t = new string[M];
        for (int i = 0; i < M; i++)
            t[i] = Console.ReadLine();

        int maxScore = 0;
        for(int i = 0; i < N; i++)
        {
            int score = s.Where(x => x == s[i]).Count() - t.Where(x => x == s[i]).Count();
            if (score > maxScore)
                maxScore = score;
        }
        Console.WriteLine(maxScore);
    }
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

struct Edge {
  int l,r;
  bool operator < ( const Edge &e ) const {
    if( r != e.r ) return r < e.r;
    return l > e.l;
  }
};

int main() {
  int V,E;
  cin >> V >> E;
  vector<Edge> es(E);
  rep(i,E) cin >> es[i].l >> es[i].r;
  sort(ALL(es));
  int cnt = 0;
  rep(i,E) {
    int limit = es[i].r;
    ++cnt;
    while( i < E && es[i].l < limit ) {
      ++i;
    }
    --i;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1152
#=
C:
- Julia version: 0.5.2
- Author: abap
- Date: 2019-12-29
=#

parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function readStr()
	s::String = chomp(readline())
	S = Char[]
	for j in s
		push!(S, j)
	end
	return sort!(S)
end
N = parseInt(readline())
x = Dict()
for i in 1:N
 s = readStr()
 if s in keys(x)
     x[s] += 1
 else
     x[s] = 1
 end
end

count = 0

for i in values(x)
	if i > 1
		count += i * (i - 1) / 2
	end
end

println(Int(count))

Measured memory_bytes: 173300
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n;
	while (cin >> n, n) {
		int id[1010], p[1010], q[1010], r[1010];
		for (int i = 0; i < n; i++) 
			cin >> id[i] >> p[i] >> q[i] >> r[i];
		int P, Q, R, C; cin >> P >> Q >> R >> C;
		vector<int>v;
		for (int i = 0; i < n; i++) 
			if (p[i] <= P&&q[i] <= Q&&r[i] <= R&&p[i] * 4 + q[i] * 9 + r[i] * 4 <= C)v.push_back(id[i]);
		if (!v.size())cout << "NA\n";
		else for (int i = 0; i < v.size(); i++)cout << v[i] << endl;
	}
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define pb push_back
#define vii vector<int>
#define task "COLORING"
#define pll pair<ll, ll>
#define pii pair< ll, pair< ll, ll > >
#define fi first
#define se second

using ll = long long;
using ld = long double;
using ull = unsigned long long;
const int mod = 1e9 + 7;
using namespace std;
const int N =  3e5 + 5;
ll m, n, k, t, ans, T, a[N];
pll b[N];

char s[10][10];
bool ss(const ll x, const ll y)
{
    return x > y;
}
inline void sol()
{
    /*
	cin >> n >> m >> k;
	for(int i = 1; i <= n; i ++)
    {
        for(int j = 1; j <= m; j ++)
        {
            cin >> s[i][j];
            if(s[i][j] == '#')++tong;
        }
    }
    for(int i = 1; i <= n; i ++)
    {
        for(int j = 1; j <= m; j ++)
        {
            if(s[i][j] == '#')++a[i];
        }
    }
    for(int i = 1; i <= m; i ++)
    {
        for(int j = 1; j <= n; j ++)
        {
            if(s[j][i] == '#')++b[i];
        }
    }
    for(int i = 0; i <= n; i ++)
    {
        for(int j = 0; j <= m; j ++)
        {
            ans = hang(1, i) + cot(1, j);
            if(ans + k == tong)++T;
        }
    }
    */
    cin >> n;
    for(int i = 1; i <= n; i ++)cin >> a[i];
    sort(a + 1, a+1+n, ss);
    ans = a[1];
        int j = 2;
        k = 0;
        for(int i = 3; i <= n; i ++)
        {
            ans += a[j];
            //cout << a[j] << " ";
            if(k == 0)++k;
            else
            {
                k = 0;
                ++j;
            }
        }


    cout << ans;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen(task".INP", "r"))
    {
		freopen(task".INP","r",stdin);
		freopen(task".OUT","w",stdout);
    }
    sol();

}


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

int main(){
  int n,m; cin>>n>>m;
  vector<int> p(m), y(m);
  for(int i=0; i<m; ++i){cin>>p[i]>>y[i]; --p[i];}

  vector<vector<int>> val(n);
  for(int i=0; i<m; ++i)val[p[i]].push_back(y[i]);

  for(int i=0; i<n; ++i)sort(val[i].begin(), val[i].end());

  for(int i=0; i<m; ++i){
    int x=p[i];
    cout<<setfill('0')<<right<<setw(6)<<x+1;

    int id=lower_bound(val[x].begin(), val[x].end(), y[i])-val[x].begin();
    cout<<setfill('0')<<right<<setw(6)<<id+1<<endl;
  }
  
}


Measured memory_bytes: 7808
import sys

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())
dst = [[] for _ in range(N)]
src = [[] for _ in range(N)]
for i in range(M):
    x, y = [int(z) - 1 for z in readline().split()]
    dst[x].append(y)
    src[y].append(x)


def solve():
    nodes = []
    nindex = [-1] * N

    def topsort(i):
        res = []
        if nindex[i] != -1:
            return
        for j in src[i]:
            topsort(j)
        nindex[i] = len(nodes)
        nodes.append(i)

    for i in range(N):
        topsort(i)
    dp = [0] * N
    dpi = [None] * N
    for i in range(N):
        node = nodes[i]
        plen = 0
        mj = None
        for j in src[node]:
            k = nindex[j]
            # print(">>", node, "- > ", j, ":", k)
            if plen < dp[k] + 1:
                plen = dp[k] + 1
                mj = j
        # print(">", node, "- > ", mj)
        dp[i] = plen
        dpi[i] = mj
    return max(dp)


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 173872
package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)

	ret := map[string]int{
		"AC":  0,
		"WA":  0,
		"TLE": 0,
		"RE":  0,
	}
	for i := 0; i < n; i++ {
		var s string
		fmt.Scanf("%s", &s)
		ret[s]++
	}

	fmt.Printf("%s x %d\n", "AC", ret["AC"])
	fmt.Printf("%s x %d\n", "WA", ret["WA"])
	fmt.Printf("%s x %d\n", "TLE", ret["TLE"])
	fmt.Printf("%s x %d\n", "RE", ret["RE"])
}


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

typedef long long int lli;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef priority_queue <int, vector <int>, greater <int> > min_pq;

const int MOD	= 1e9 + 7;

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define init(a)         memset(a,0,sizeof(a))    
#define pb              push_back  
#define all(a)          a.begin(),a.end()  
#define loop(i,n)       for(int i=0;i<n;i++)  
#define loops(i,s,n)    for(int i=s;i<n;i++)
#define rloop(i,n)      for(int i=n-1;i>=0;i--)
#define rloops(i,s,n)   for(int i=n-1;i>=s;i--)

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }


double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
//---------------------------------------------------------------------------------------------

lli rec(lli a){
    if( a == 1){
        return 1;
    }
    lli ans = 2*rec(a/2) + 1;
    return ans;
}

int main(){
    fastio;

    lli h;
    cin>>h;
    lli ans = rec(h);
    cout<<ans<<endl;

    // cout<<"Execution time : "<<tick()<<"\n";

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, std::vector<long long> A){
  vector<vector<ll>> v(N+1, vector<ll>(20, 0));
  for(ll i=0; i<N; i++) {
    for(ll j=0; j<20; j++) {
      if(A[i] & (1<<j)) v[i+1][j] = v[i][j]+1;
      else v[i+1][j] = v[i][j];
    }
  }
  ll r = 1;
  ll ans = 0;
  for(ll l=0; l<N; l++) {
    if(l==r) r++;
      
    while(true) {
      if(r>N) {
	break;
      }
      bool f = true;
      vector<ll> x(20);
      for(ll k=0; k<20; k++) {
	x[k] = v[r][k]-v[l][k];
	if(x[k] > 1) f = false;
      }
      if(!f) {
	break;
      }
      r++;
    }
    r--;
    ans += (r-l);
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, std::move(A));
  return 0;
}



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

using namespace std;
const int MAXN = 2e5+10;
long long bit[MAXN];
long long n, d, a;

int lowbit(int x){
    return x & -x;
}

void update(int k, long long v){
    for(int i=k;i<=n;i+=lowbit(i)){
        bit[i]+=v;
    }
}

long long query(int n){
    long long sum = 0;
    for(int i = n;i>0;i-=lowbit(i)){
        sum+=bit[i];
    }
    return sum;
}

int main(){
    cin >>n>>d>>a;
    vector<pair<long long, long long>> m(n);

    for(int i=0;i<n;i++){
        long long x, h;
        cin >>x>>h;
        m[i] = make_pair(x, (h+a-1)/a);
    }

    sort(m.begin(), m.end());

    int l=0,r=0;
    long long cnt = 0;
    while(l<n){
        while(r<n && m[l].first + 2*d >= m[r].first)
            r++;
        long long b = max(0LL, m[l].second - query(l+1));
        if(b > 0){
            update(l+1, b);
            update(r+1, -b);
            cnt += b;
        }
        l++;
    }

    cout <<cnt;

}


Measured memory_bytes: 4864
#include<bits/stdc++.h>//author::@whohet-->Het Patel
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define uint unsigned long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vvi vector<vector<int>>
#define mii map<int,int>
#define msi map<string,int>
#define mis map<int,string>
#define pb push_back
#define mod 1000000007
#define PI 3.141592653589793238

using namespace std;

//author::@whohet-->Het Patel

signed main()
{
    fasterthanlight;
    
        string s;
        cin>>s;
        if(s[0]=='7' || s[1]=='7'||s[2]=='7')
            cout<<"Yes\n";
        else
            cout<<"No\n";

    
    return 0;
}


Measured memory_bytes: 3652
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()

if N % 2 == 1:
    ans = B[N//2] - A[N//2]+1
    print(ans)
else:
    vmin = A[N//2]+A[N//2-1]
    vmax = B[N//2]+B[N//2-1]
    ans = vmax-vmin+1
    print(ans)


Measured memory_bytes: 99064
s = int(input())
S = [s]
ans = 1

while True:
    if s%2 == 0 :
        s = int(s/2)
    else:
        s = 3*s + 1
    ans += 1
    for t in S:
        if s == t:
            print(ans)
            break
    else:
        S.append(s)
        continue
    break

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
#define N 15
int main() {
    double X,Y,a[N][6],x[N],y[N],det[N];
    int i=0;
    int j;
    while (scanf("%lf",&a[i][0])!=EOF) {
        for (j = 1; j < 6; j++) {
            scanf("%lf",&a[i][j]);
        }
        i++;
    }

    for (j = 0; j < i; j++) {
        det[j]=a[j][0]*a[j][4]-a[j][1]*a[j][3];
        x[j]=a[j][2]*a[j][4]-a[j][1]*a[j][5];
        y[j]=a[j][0]*a[j][5]-a[j][2]*a[j][3];
    }
    for (j = 0; j < i; j++) {
        X=floor(1000*x[j]/det[j]+0.5);
        Y=floor(1000*y[j]/det[j]+0.5);
        printf("%.3f %.3f\n",X/1000.0,Y/1000.0);
    }
    return 0;
}

Measured memory_bytes: 652
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#define INF 1e7
using namespace std;

int n,d,x;
int fie[11][11];
int dp[100001][11];
int big[11];
int main(void){
	scanf("%d %d %d",&n,&d,&x);
	int s=d+d*n,t=d+d*n+1;
	for(int i=0;i<d;i++){
		for(int j=0;j<n;j++){
			scanf("%d",&fie[j][i]);
		}
	}
	memset(dp,-1,sizeof(dp));
	dp[x][0]=x;
	big[0]=x;
	for(int i=0;i<d-1;i++){
		dp[big[i]][i]=big[i];
		for(int j=big[i];j>=0;j--){
			if(dp[j][i]!=-1){
				big[i+1]=max(big[i+1],dp[j][i]);
				for(int k=0;k<n;k++){
					if(j-fie[k][i]>=0){
						dp[j-fie[k][i]][i]=max(dp[j-fie[k][i]][i],dp[j][i]-fie[k][i]+fie[k][i+1]);
					}
				}
			}
		}
		big[i+1]=max(big[i+1],big[i]);
	}
	printf("%d\n",big[d-1]);
	return 0;
}

Measured memory_bytes: 5332
N = gets.to_i
a = gets.strip.split.map(&:to_i)
a.sort!
b = a[0]
c = 0
answer = 0


for i in 0..N-2

    if  b < a[i+1]

        if i-c+1 < b

            answer += i-c+1

        elsif b < i-c+1

            answer += i-c+1-b

        end

        b = a[i+1]
        c = i+1

    end

end

if N-c < b

    answer += N-c

elsif b < N-c

    answer += N-c-b

end

puts answer







Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
 
void solve(){
	int n;
	cin>>n;
	int a[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};
	cout<<a[n-1];
	return;
} 
signed main(){
	
	// int n;  cin>>n;  rep(i,0,n)solve();
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lld long long
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define nmax
#define mod
using namespace std;

int main()
{
    string s;
    int n;
    cin>>n;
    cin>>s;
    for (auto &x:s){
        int val = x;
        val += n;
        int dep = val - 'Z', nc;
        if (dep > 0){
            nc = 'A' - 1 + dep;
        } else {
            nc = val;
        }
        x = (char)nc;
    }
    cout<<s<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Harmony | diff Harmony.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Harmony.cpp && ./a.out

/*
 
 7/27/2019
 
 5:00-
 
 */

LL A,B;

void solve() {
  LL K=(A+B)/2;
  if(abs(K-A)==abs(K-B)) cout<<K<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>A>>B;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#define N_ 201000
using namespace std;
struct point {
	int a, b;
	bool operator <(const point &p)const {
		return (long long)p.a*(b+1) < (long long)a*(p.b+1);
	}
};
vector<point>A;
vector<int>B;
int n;
long long T, D[40], S[201000];
int main() {
	int i, j;
	scanf("%d%lld", &n, &T);
	for (i = 1; i <= n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		if (!a)B.push_back(b);
		else A.push_back({ a,b });
	}
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	for (i = 1; i < 40; i++)D[i] = 1e15;
	int sz = A.size();
	for (i = 0; i < sz; i++) {
		for (j = 38; j >= 0; j--) {
			if (D[j] > T)continue;
			D[j + 1] = min(D[j + 1], D[j]+1 + (D[j] + 1)*A[i].a + A[i].b);
		}
	}
	int m = B.size();
	for (i = 1; i <= m; i++) {
		S[i] = S[i - 1] + B[i - 1] + 1;
	}
	int res = 0;
	for (i = 0; i <= m; i++) {
		for (j = 0; j < 40; j++) {
			if (S[i] + D[j] <= T) {
				res = max(res, i + j);
			}
		}
	}
	printf("%d\n", res);
}


Measured memory_bytes: 2676
#include<stdio.h>
int main(void)
{
    int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a<b){
	  printf("a < b\n");
	}
	else if(a>b){
	  printf("a > b\n");
	}
	else if(a==b){
	  printf("a == b\n");
	}
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define pb push_back
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

vint pos(5);
int k;
bool check=true;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if((a<c && c<b) || (b<c && c<a))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <iomanip>
using namespace std;

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

  int n;
  cin >> n;
  cout << "ABC" << n << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n)
	{
		cin >> a[i];
	}
	int mi = a[0];
	int ans = 0;
	rep(i,n)
	{
		if(mi>=a[i])ans++;
		mi = min(mi,a[i]); 
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    vector<int> sum(n);
    rep(i, n) {
        cin >> s[i] >> t[i];
        if ( i == 0 ) sum[0] = t[i];
        else          sum[i] = sum[i-1] + t[i];
    }
    string x;
    cin >> x;
    int num = 0;
    rep(i, n) {
        if ( s[i] == x ) num = i;
    }
    cout << sum[n-1] - sum[num] << endl;
    return 0;
}


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

int main(){
    string s,t;
    cin >> s >> t;
    for(int i=0;i<s.size();i++){
        for(int j=0;j<s.size();j++){
            if(s[(i+j)%s.size()]!=t[j]){
                break;
            }
            if(j == s.size()-1){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (n, x) = get!(usize, u64);
    let mut aa = util::gets::<u64>();

    let mut ans = 0;

    for a in aa.iter_mut() {
        if *a > x {
            ans += *a - x;
        }

        *a = min(*a, x);
    }

    for i in 0..n - 1 {
        if aa[i] + aa[i + 1] > x {
            ans += aa[i] + aa[i + 1] - x;
            aa[i + 1] = x - aa[i];
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 8444
my $N = <STDIN>;
if($N==1){print "$N";exit;}
my $sum =0;
my $mod = 10**9+7;
my %del;
for(my $i=$N;$i>0;$i--){
 $count = int($N /$i);
 $del{$i} = powmod($count,3,$mod);
}
for(my $i=$N;$i>1;$i--){
 $del{1}=$del{1} - $del{$i};
 for(my $j=2;$j<=sqrt($i);$j++){
    if( ($i%$j == 0) ){
        $del{$j}= $del{$j} - $del{$i};
        if( $j ==($i/$j)){next;}
        $del{$i/$j}= $del{$i/$j} - $del{$i};
    }
 }
 $sum = $sum + $i*$del{$i};
 #print "i$i del$del{$i} $sum\n";
}
$sum = $sum + $del{1};
print "$sum";
exit;

sub powmod{
   my ($a,$b,$m) = @_;
   if($b==1){return $a;}
   my $c = powmod(($a*$a)%$m,int($b/2),$m);
   if($b%2){
     $c = ($c*$a)%$m;
   }
   return $c;
}

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

using namespace std;

int n, a[100010];

int main(){
  cin>>n;
  for(int i=1;i<=n;i++) cin>>a[i];
  for(int i=n-1;i>=1;i--){
    if(a[i]>a[i+1]) a[i]--;
  }
  string res = "Yes";
  for(int i=2;i<=n;i++){
    if (a[i]<a[i-1]){
      res="No";
      break;
    }
  }
  
  cout<<res<<endl;
  return 0;
}


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

#define NAME "D"
#define show(x) cout << (#x) << " is " << (x) << endl
#define ll long long
#define ms(arr,val) memset(arr,val,sizeof(arr))
#define len length()

const int maxn = 2e5;

vector< vector<int> >adj;


int main(){
    //ifstream cin(NAME".inp");
    //ofstream cout(NAME".out");
    int n,m;
    cin>>n>>m;
    adj  = vector< vector<int > >(n+1);
    int u,v;
    for(int i = 0;i<m;i++){
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    vector<int> ans(n+1,-1);
    vector<int> done(n+1,0);

    queue<int> q;


    q.push(1);

    while(!q.empty()){
        u = q.front();
        q.pop();
        if (done[u]) continue;
        done[u] = 1 ;
        for(auto v : adj[u]){
            if (!done[v]){
                if (ans[v]==-1) ans[v] = u;
                q.push(v);
            }
        }
    }

    cout<<"Yes"<<endl;
    for(int i=2;i<=n;i++) cout<<ans[i]<<endl;
}


Measured memory_bytes: 10776
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }

int main() {
    vector<int> ab(2);
    for (auto &abi: ab) cin >> abi;
    int k; cin >> k;
    for (int i = 0; i < k; i++) {
        ab[i & 1 ^ 1] += ab[i & 1] /= 2;
    }
    cout << ab << endl;
    return 0;
}


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

#define gc() getchar()

#define ll long long
#define ri register int 

#define inf 1e18

using std::min;
using std::max;
using std::sort;
using std::unique;
using std::lower_bound;

inline int read()
{
	int ret=0;char ch=gc();
	while(!isdigit(ch))ch=gc();
	while(isdigit(ch))
	{
		ret=ret*10+ch-'0';
		ch=gc();
	}
	return ret;
}

const int MAXN=2e5+10;

int n;
int b[MAXN],bn;
ll ans;

struct point{ll x,y,p,q;}a[MAXN];
bool operator < (const point &X,const point &Y) {return X.x<Y.x;}

struct Segment_tree
{
	ll v[MAXN*4];
	#define ls (u<<1)
	#define rs (u<<1|1)
	inline void push_up(int u){v[u]=min(v[ls],v[rs]);}
	void build(int u,int l,int r)
	{
		if(l==r)v[u]=inf;
		else
		{
			int mid=(l+r)/2;
			build(ls,l,mid);
			build(rs,mid+1,r);
			push_up(u);
		}
	}
	void assign(int u,int l,int r,int p,ll x)
	{
		if(l==r)v[u]=min(v[u],x);
		else
		{
			int mid=(l+r)/2;
			if(p<=mid)assign(ls,l,mid,p,x);
			else assign(rs,mid+1,r,p,x);
			push_up(u);
		}
	}
	ll ask(int u,int l,int r,int ql,int qr)
	{
		if(ql<=l && r<=qr)return v[u];
		else
		{
			int mid=(l+r)/2;
			ll ret=inf;
			if(ql<=mid)ret=min(ret,ask(ls,l,mid,ql,qr));
			if(mid+1<=qr)ret=min(ret,ask(rs,mid+1,r,ql,qr));
			return ret;
		}
	}
}tree1,tree2;

int main()
{
//	freopen("in.in","r",stdin);
	
	n=read();
	for(ri i=1;i<=n;++i)
	{
		a[i].x=read();
		a[i].y=b[i]=read();
		a[i].p=a[i].x+a[i].y;
		a[i].q=a[i].x-a[i].y;
	}
	sort(a+1,a+n+1);
	
	sort(b+1,b+n+1);
	bn=unique(b+1,b+n+1)-(b+1);
	for(ri i=1;i<=n;++i)a[i].y=lower_bound(b+1,b+bn+1,a[i].y)-b;
	
	tree1.build(1,1,bn);
	tree2.build(1,1,bn);
	for(ri i=1;i<=n;++i)
	{
		ll v1=inf,v2=inf;
		v1=tree1.ask(1,1,bn,1,a[i].y);
		if(a[i].y+1<=bn)v2=tree2.ask(1,1,bn,a[i].y+1,bn);
		
		if(v1!=inf)ans=max(ans,a[i].p-v1);
		if(v2!=inf)ans=max(ans,a[i].q-v2);
		
		tree1.assign(1,1,bn,a[i].y,a[i].p);
		tree2.assign(1,1,bn,a[i].y,a[i].q);
		
//		printf("i=%d\n",i);
//		printf("p=%lld q=%lld\n",a[i].p,a[i].q);
//		printf("v1=%lld v2=%lld\n",v1,v2);
	}
	printf("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 19000
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;
int main(void){
  int n;
  cin >> n;
  vector<ll> num(n,0);
  ll ans = 0;
  for(int i=1;i<=n;i++){
    for(int j=i;j<=n;j +=i ){
      num[j]++;
    }
  }
  for(int i=1;i<=n;i++){
    //    cout << i << " : " << num[i]<<endl;
    ans += i*num[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 81400
#include <cstdio>
#include <algorithm>
#include <string>

const int dx[3] = {0, 1, 0}, dy[3] = {1, 1, 2};
int N;
int cloth[10][10];
int x[12], y[12], type[12];

bool canFill(int cx, int cy, int t){
    int mx;
    
    if(t == 0){
        mx = 1;
    }else if(t == 1){
        mx = 2;
    }else if(t == 2){
        mx = 2;
    }

    for(int i=-mx;i<=mx;i++){
        for(int j=-mx;j<=mx;j++){
            if(std::abs(i) + std::abs(j) > mx){continue;}
            if(t == 1 && (i == 0 && std::abs(j) == 2 || std::abs(i) == 2 && j == 0)){continue;}
            int x = j + cx, y = i + cy;
            if(x < 0 || x >= 10 || y < 0 || y >= 10){return false;}
            if(!cloth[y][x]){return false;}
        }
    }

    return true;
}

void spuit(int cx, int cy, int t, int v){
    int mx;
    
    if(t == 0){
        mx = 1;
    }else if(t == 1){
        mx = 2;
    }else if(t == 2){
        mx = 2;
    }

    for(int i=-mx;i<=mx;i++){
        for(int j=-mx;j<=mx;j++){
            if(std::abs(i) + std::abs(j) > mx){continue;}
            if(t == 1 && (i == 0 && std::abs(j) == 2 || std::abs(i) == 2 && j == 0)){continue;}
            int x = j + cx, y = i + cy;
            if(x < 0 || x >= 10 || y < 0 || y >= 10){continue;}
            cloth[y][x] -= v;
        }
    }
}

bool dfs(int n){
    if(n == N){
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                if(cloth[i][j]){return false;}
            }
        }
        
        for(int i=0;i<N;i++){
            printf("%d %d %d\n", x[i], y[i], type[i]);
        }
        return true;
    }

    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            if(!cloth[i][j]){continue;}
            for(int k=0;k<3;k++){
                int cx = j + dx[k], cy = i + dy[k];
                if(!canFill(cx, cy, k)){continue;} 
                spuit(cx, cy, k, 1);
                
                x[n] = cx; y[n] = cy; type[n] = k + 1;
                if(dfs(n+1)){return true;}
                spuit(cx, cy, k, -1);       
            }
            return false;
        }
    }

    return false;
}

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

    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            scanf("%d", &cloth[i][j]);
        }
    }
    
    dfs(0);
}

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(false);
    string s; cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size(); i++) {
        ans |= (s[i] == 'A'? 1 : 0);
        ans |= (s[i] == 'B'? 2 : 0);
    }
    cout << (ans == 3? "Yes" : "No") << endl;
    return 0;
}



Measured memory_bytes: 256
li = list(map(int,input().split()))
N = li[0]
A = li[1]
B = li[2]

counter = 0
for n in range(1,N+1):
    strn = str(n)
    sumn = 0
    for i in range(len(strn)):
        sumn += int(strn[i])
    if (sumn >= A ) and (sumn <= B):
        counter += n

print(counter)

Measured memory_bytes: 3064
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        final long bill = 2000000000;
        long pos[][] = new long [n][2];
        long neo_pos[][] = new long [n][2];
        long xMax = bill * -1, xMin = bill;
        long yMax = bill * -1, yMin = bill;

        for(int i = 0; i < n; i++){
            pos[i][0] = sc.nextInt();
            pos[i][1] = sc.nextInt();
            //xy座標から座標軸を45度回転させたx'y'座標に変換する
            //x'y'座標での正確な位置は√2で割らないといけないが整数計算で処理したいので行わない
            //通常マンハッタン距離は|xi - xj| +|yi - yj|で求められるが
            //x'y'座標でマンハッタン距離を求めると|x'i - x'j|と|y'i - y'j|の大きいほうがマンハッタン距離として計算できる
            //全ての点のx',y'座標の最大値最小値を取り差が大きいほうがマンハッタン距離の最大値
            neo_pos[i][0] = pos[i][0] + pos[i][1];
            neo_pos[i][1] = pos[i][0] * -1 + pos[i][1];
            if(xMax < neo_pos[i][0]){
                xMax = neo_pos[i][0];
            }
            if(xMin > neo_pos[i][0]){
                xMin = neo_pos[i][0];
            }
            if(yMax < neo_pos[i][1]){
                yMax = neo_pos[i][1];
            }
            if(yMin > neo_pos[i][1]){
                yMin = neo_pos[i][1];
            }
        }
        //xMax xMin yMax yMinを確認
        //System.out.println("xMax=" + xMax + " xMin=" + xMin);
        //System.out.println("yMax=" + yMax + " yMin=" + yMin);
        
        //正解を出力
        long dist_x = xMax - xMin;
        long dist_y = yMax - yMin;
        if(dist_x > dist_y){
            System.out.println(dist_x);
        }else{
            System.out.println(dist_y);
        }
    }
}


Measured memory_bytes: 73644
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=3.1415926535897932384626433832795;
const ll INF = 1LL<<62;
const ll MINF = -1LL<<62;

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	ll n,m;
	cin>>n>>m;
	vector<ll> a(n);
	ll sum=0;
	for(int i=0;i<n;++i) {
		cin>>a[i];
		sum+=a[i];
	}
	
	int can=0;
	sort(all(a));
	reverse(all(a));
	for(auto i:a) {
		if(sum<=i*4*m) can++;
	}
	
	cout<<(can>=m?"Yes":"No")<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

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

#define pb push_back

vi e[100010];
int color[100010],deg[100010];
bool ok=1;

void dfs(int k)
{
	for (vi::iterator p=e[k].begin();p!=e[k].end();p++)
		if (color[*p]==2)
		{
			color[*p]=color[k]^1;
			dfs(*p);
		}
		else
			if (color[*p]==color[k]) ok=0;
}

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,m;scanf("%d%d",&n,&m);
	for (int i=0;i<m;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		e[x].pb(y);e[y].pb(x);
		deg[x]++;deg[y]++;
	}
	for (int i=1;i<=n;i++) color[i]=2;
	int s1=0,s2=0;
	for (int i=1;i<=n;i++)
	{
		if (color[i]!=2||!deg[i]) continue;
		color[i]=1;ok=1;
		dfs(i);
		if (ok) s1++; else s2++;
	}
	ll ans=ll(n)*n;
	int s0=0;for (int i=1;i<=n;i++) if (deg[i]) s0++;
	ans-=ll(s0)*s0;
	ans+=ll(s1+s2)*ll(s1+s2);
	ans+=ll(s1)*s1;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 9472
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 123;
const int MAXK = 123456;
int a[MAXN];
bool visit[MAXK][2];
int dp[MAXK][2];

int dfs(int cur, int flg, int N) {
    if (visit[cur][flg]) return dp[cur][flg];
    visit[cur][flg] = 1;
    int ans;
    if (flg == 0) {
       ans = 0;
       for (int i = 0; i < N; i++) {
           if (cur >= a[i])
              ans = max(ans, dfs(cur - a[i], 1, N));
       }
    } else {
       ans = 1;
       for (int i = 0; i < N; i++) {
           if (cur >= a[i])
              ans = min(ans, dfs(cur - a[i], 0, N));
       }
    }
    //printf("cur = %d flg = %d ans = %d\n", cur, flg, ans);
    return dp[cur][flg] = ans;
}

int main() {
    int N, K;
    scanf("%d %d", &N, &K);
    for (int i = 0; i < N; i++) scanf("%d", &a[i]);
    if (dfs(K, 0, N)) puts("First");
    else puts("Second");
    return 0;
}


Measured memory_bytes: 9088