akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

//Snakes
public class Main{

	static boolean isA(char[] s){
		if(s.length<6)return false;
		if(!(s[0]=='>'&&s[1]=='\''))return false;
		int con = 0;
		while(2+con<s.length && s[2+con]=='=')con++;
		if(con==0)return false;
		if(2+con==s.length||s[2+con]!='#')return false;
		int b = 3+con;
		int sec = 0;
		while(b+sec<s.length && s[b+sec]=='=')sec++;
		if(sec!=con||b+sec==s.length)return false;
		return s[b+sec]=='~'&&b+sec==s.length-1;
	}
	
	static boolean isB(char[] s){
		if(s.length<6)return false;
		if(!(s[0]=='>'&&s[1]=='^'))return false;
		int i = 2;
		int c = 0;
		while(i+1<s.length && s[i]=='Q' && s[i+1]=='='){
			i+=2;c++;
		}
		if(i+1>=s.length||c==0)return false;
		return i+1==s.length-1 && s[i]=='~' && s[i+1]=='~';
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t--!=0){
			char[] s = sc.next().toCharArray();
			System.out.println(isA(s)?"A":isB(s)?"B":"NA");
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  int n,m;
  cin >> n >> m;
  vector <P> p(n);
  
  REP(i,n){
    cin >> p[i].first >> p[i].second;
  }
  sort(p.begin(),p.end());
  REP(i,m){
    int x1,x2,y1,y2;
    int sum = 0;
    cin >> x1 >> y1 >> x2 >> y2;
    REP(j,n){
      if(p[j].first >= x1 && p[j].first <= x2 && p[j].second >= y1 && p[j].second <= y2){
	sum++;
	
      }
      if(x2 < p[j].first){
	  break;
      }
    }
    cout << sum << endl;
  }
  return 0;
}



Measured memory_bytes: 3140
def main():
    a, b, c, x = list(map(int, [input().rstrip() for _ in range(4)]))
    cnt = 0
    for i in range(min(a, x // 500) + 1):
        for j in range(min(b, (x - 500 * i) // 100) + 1):
            if c * 50 >= x - i * 500 - j * 100:
                cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M = MI()
    edge = [[]for _ in range(N)]
    indegree = [0]*N #入次数
    for _ in range(M):
        a,b = MI()
        edge[a].append(b)
        indegree[b] += 1
    #print(indegree)
    #入次数が0の点からあれしていく
    queue = deque() 
    for i,x in enumerate(indegree):
        if not x:
            queue.append(i)

    pop = queue.popleft
    topological_index = []
    while queue:
        v = pop()
        topological_index.append(v)

        for to in edge[v]:
            indegree[to] -= 1
            if not indegree[to]:
                queue.append(to)
    if tuple(1 for i in indegree if i!=0):
        print("loop")

    print(*topological_index,sep="\n")



if __name__ == '__main__':
    main()


Measured memory_bytes: 9560
// #include<iostream>
// #include<vector>
// #include<algorithm>
// #include<map>
// #include<cstring>
// #include<math.h>
// #include<bitset>
// #include<queue>
// #include<set>
// #include<iomanip>
// #include<math.h>
// #include<assert.h>
// #include<string>
// #include<cstdlib>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<int> a(N+1);
  for(int i=1; i<=N; i++){
    cin >> a[i];
  }
  vector<int> b;
  if(N%2){
    for(int i=N; i>=1; i-=2){
      b.push_back(a[i]);
    }
    for(int i=2; i<N; i+=2){
      b.push_back(a[i]);
    }
  }else{
    for(int i=N; i>0; i-=2){
      b.push_back(a[i]);
    }
    for(int i=1; i<N; i+=2){
      b.push_back(a[i]);
    }
  }
  for(auto m: b){
    cout << m << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3828
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 200005
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
#define p 924844033
#define g 5
using namespace std;

int n, bit, cnt, head[MAXN], siz[MAXN], a[MAXN*4], b[MAXN*4], pos[MAXN*4], num[MAXN], fac[MAXN], inv[MAXN];

struct Edge {int next, to;} edge[MAXN*2];

void addedge(int from, int to)
{
    edge[++cnt].next=head[from];
    edge[cnt].to=to;
    head[from]=cnt;
}

void init()
{
    fac[0]=fac[1]=inv[0]=inv[1]=1;
    for(rint i=2; i<=n; ++i) inv[i]=1LL*inv[p%i]*(p-p/i)%p;
    for(rint i=2; i<=n; ++i)
    {
        inv[i]=1LL*inv[i-1]*inv[i]%p;
        fac[i]=1LL*fac[i-1]*i%p;
    }
}

void dfs(int x, int fa)
{
    siz[x]=1;
    for(rint i=head[x]; i;i=edge[i].next)
    {
        int to=edge[i].to;
        if(to==fa) continue;
        dfs(to, x);
        siz[x]+=siz[to];
    }
    if(fa) num[siz[x]]++, num[n-siz[x]]++;
}

int ksm(int x, int y)
{
    int ans=1;
    while(y)
    {
        if(y&1) ans=1LL*ans*x%p;
        x=1LL*x*x%p; y>>=1;
    }
    return ans;
}

void ntt(int a[], int n, int op)
{
    for(rint i=0; i<n; ++i)
        if(i<pos[i]) swap(a[i], a[pos[i]]);
    for(rint i=1; i<n; i<<=1)
    {
        int del=ksm(g, (op*(p-1)/(i<<1)+(p-1))%(p-1));
        for(rint j=0; j<n; j+=(i<<1))
        {
            int t=1;
            for(rint k=0; k<i; ++k, t=1LL*t*del%p)
            {
                int x=a[j+k], y=1LL*t*a[j+k+i]%p;
                a[j+k]=(x+y)%p, a[j+k+i]=(x-y+p)%p;
            }
        }
    }
    if(op==-1)
    {
        int INV=ksm(n, p-2);
        for(rint i=0; i<n; ++i) a[i]=1LL*a[i]*INV%p;
    }
}

int main()
{
    scanf("%d", &n);
    init();
    for(rint i=1, x, y; i<n; ++i)
    {
        scanf("%d%d", &x, &y);
        addedge(x, y);
        addedge(y, x);
    }
    dfs(1, 0);
    for(rint i=0; i<=n; ++i)
    {
        a[i]=1LL*num[i]*fac[i]%p;
        b[i]=inv[n-i];
    }
    while((1<<bit)<=(n<<1)) bit++;
    for(rint i=0; i<(1<<bit); ++i) pos[i]=(pos[i>>1]>>1)|((i&1)<<(bit-1));
    ntt(a, 1<<bit, 1);
    ntt(b, 1<<bit, 1);
    for(rint i=0; i<(1<<bit); ++i) a[i]=1LL*a[i]*b[i]%p;
    ntt(a, 1<<bit, -1);
    for(rint i=1; i<=n; ++i) printf("%d\n", (1LL*fac[n]*inv[n-i]%p*n%p-a[n+i]+p)*inv[i]%p);
}


Measured memory_bytes: 26496
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define repd(i,a,b) for (int i=(a);i<(b);i++)
typedef long long ll;
using namespace std;

int main() {
    int min = 100;
    int tmp,sum=0;
    int t[5];
    rep(i,5){
        cin >> t[i];
    }
    rep(i,5){
        if(t[i]%10 != 0){
            if(t[i]%10 < min){
                min = t[i]%10;
            }
            tmp = t[i];
            sum += (t[i]/10+1)*10;
        }
        else{
            sum += (t[i]/10)*10;
        }
    }
    if(min != 100) sum = sum + min - 10;
    cout << sum << endl;
}

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

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  ll r, d, x; cin >> r >> d >> x;
  rep(i, 10) {
    x = r*x-d;
    cout << x << endl;
  }
}

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

const int MAXN = 10010;

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x*10)+(ch^48);
	return x * f;
}

int n;
int a[MAXN], b[MAXN];
long long cnt;

int main() {

	int i;
	n = read();
	generate(a+1, a+n+1, read);
	generate(b+1, b+n+1, read);
	for(i = 1; i <= n; i++) {
		a[i] = b[i]-a[i];
		if(a[i] > 0) {
			cnt += (a[i]>>1);
			a[i] = a[i]&1;
		}
	}
	for(i = 1; i <= n; i++) 
		if(a[i] < 0) cnt += a[i], a[i] = 0;
	if(cnt < 0) {
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 384
n=int(input())
if n<4:
    print("No")
elif n%4==0 or n%7==0:
    print("Yes")
else:
    result=False
    num=n
    while num>7:
        num-=7
        if num%4==0 and result==False:
            print("Yes")
            result=True
            break
    while n>4:
        n-=4
        if n%7==0 and result==False:
            print("Yes")
            result=True
            break
    if result==False:
        print("No")


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

int color[100001], PR[100001];

int find_(int a)
{
	if(a==color[a]) return a;
	return color[a]=find_(color[a]);
}

void union_(int a, int b)
{
	a=find_(a);
	b=find_(b);
	color[a]=color[b]=min(a,b);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int N, M, P, ans=0;
	cin>>N>>M;
	for(int i=1;i<=N;i++) cin>>P, color[i]=PR[P]=i;
	for(;M;M--) {
		int a, b;
		cin>>a>>b;
		union_(a,b);
	}
	for(int i=1;i<=N;i++) ans+=find_(i)==find_(PR[i]);
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 1024
n=io.read("*n","*l")
counter={}
for i=1,n do
    s=io.read()
    t={}
    for i=1,10 do
        table.insert(t, s:sub(i,i))
        table.sort(t)
    end
    s_=table.concat(t)
    if not counter[s_] then
        counter[s_]=1
    else
        counter[s_]=counter[s_]+1
    end
end

total=0
for k,v in pairs(counter) do
    total=total+v*(v-1)//2
end
print(total)

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

int main() {
  int A, B;
  int ans=-1;

  cin >> A >> B;

  int alow, ahigh;
  int blow, bhigh;

  if(A%2 == 0) {
    alow = ceil(double(A)*25/2);
    ahigh = alow + 12;
  }
  else if(A%2 == 1) {
    alow = ceil(double(A)*25/2);
    ahigh = alow + 11;
  }

  blow = B*10;
  bhigh = blow+9;

  for(int i=min(alow,blow);i<=min(ahigh,bhigh);i++) {
    if(i==max(alow,blow)){ans=i;}
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <tuple>
#include <utility>
#include <functional>
#include <sys/time.h>
#include <iomanip>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(i, m, n) for(int i = (m); i < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

constexpr int BEAM_SIZE = 1600;
constexpr int SZ = 26;
constexpr int D = 365;
array<int, SZ> C;
int SUM = 0;
array<array<int, SZ>, D> S;

struct State {
	array<int, SZ> last = {};
	array<char, D> ans;
	int score = 0, sum = 0;

	void update_score(int d, int t) {
		score += S[d][t];
		sum -= C[t] * (d + 1 - last[t]);
		last[t] = d + 1;
		sum += SUM;
		score -= sum;
	}

	int next_eval(int d, int t){
		int res = score;
		res += S[d][t];
		rep(i, SZ){
			if (i != t) res -= C[i] * (d + 1 - last[i]);
		}
		return res;
	}

	int eval() const {
		return score;
	}

	State place(int d, int t) {
		State res = *this;
		res.ans[d] = t;
		res.update_score(d, t);
		return res;
	}

	array<char, D> answer() {
		return ans;
	}
};

array<char, D> solve() {
	State initial_state;
	using f = function<bool(State&, State&)>;
	priority_queue<State, vector<State>, f> cur([](State& a, State& b){return a.eval() > b.eval();});
	cur.push(initial_state);
	priority_queue<State, vector<State>, f> nxt([](State& a, State& b){return a.eval() > b.eval();});
	rep(d, D){
		while(!nxt.empty()) nxt.pop();
		while(!cur.empty()){
			State now = cur.top(); cur.pop();
			rep(t, SZ){
				if(nxt.size() < BEAM_SIZE || now.next_eval(d, t) > nxt.top().eval()) nxt.push(now.place(d, t));
				if(nxt.size() > BEAM_SIZE) nxt.pop();
			}
		}
		swap(cur, nxt);
	}

	State res;
	while(!cur.empty()){
		if(cur.size() == 1) res = cur.top();
		cur.pop();
	}
	cerr << res.eval() << endl;
	return res.answer();
}

int main(void){
	int tmp;
	cin >> tmp;
	rep(i, SZ) cin >> C[i];
	rep(i, SZ) SUM += C[i];
	rep(i, D) rep(j, SZ) cin >> S[i][j];

	auto ans = solve();
	for (char i : ans) cout << (int)i + 1 << endl;

	return 0;
}


Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define int long long int
#define double long double
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value)
#define ff first          // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}, dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t) \
    int(t);          \
    cin >> (t);      \
    while ((t)--)
signed main()
{
    double n, m, d;
    cin >> n >> m >> d;
    double ans = 0;
    if (d == 0)
    {
        ans = (m - 1) / n;
    }
    else
    {
        ans = (2LL * (m - 1) * (n - d) / (n * n));
    }
    cout << setprecision(100) << ans << endl;
    return 0;
}

Measured memory_bytes: 384
n, x, y = gets.chomp.split(" ").map(&:to_i)
ans = Array.new(n, 0)
graph = Array.new(n).map{Array.new}
graph[x-1] << y-1
graph[y-1] << x-1
(n-1).times do |i|
    graph[i] << i+1
    graph[i+1] << i
end

n.times do |i|
    dist = Array.new(n, -1)
    dist[i] = 0
    queue = [i]
    until queue.empty?
        v = queue.shift
        graph[v].each do |e|
            next if dist[e] != -1
            dist[e] = dist[v] + 1
            queue << e
        end
    end
    dist.each do |d|
        ans[d] += 1
    end
end

ans.shift
ans = ans.map{|v| v/2}

puts ans.join("\n")

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

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

  string S;
  map<string, int> mp;
  int counter = 0;
  for (int i=0; i<N; i++) {
    cin >> S;
    if(mp.find(S) != mp.end()) {
      mp[S] += 1;
    } else {
      mp[S] = 0;
    }
    if (mp[S] > counter) {
      counter = mp[S];
    }
  }

  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
    if (itr->second == counter) {
      cout << itr->first << endl;
    }
  }   
}

Measured memory_bytes: 25216
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>

using ll_t = long long;
using pii = std::pair<int, int>;
const int MAXN = (int)1e5 + 1;
const ll_t INF = (ll_t)1e15;

struct SegmentTree {
  struct Node {
    int l, r;
    ll_t tag;  // 这个区间内，<=tag的值不变，>tag的值改为tag.
  };
  Node node[MAXN * 4];

  inline int ls(int p) { return p << 1; }
  inline int rs(int p) { return p << 1 | 1; }
  
  void PushUp(int rt) {
    node[rt].tag = std::max(node[ls(rt)].tag, node[rs(rt)].tag);  
  }

  void PushDown(int rt) {
    if (node[ls(rt)].tag > node[rt].tag) 
      node[ls(rt)].tag = node[rt].tag;
    if (node[rs(rt)].tag > node[rt].tag)
      node[rs(rt)].tag = node[rt].tag;
  }

  void Build(int rt, int l, int r) {
    node[rt].l = l;
    node[rt].r = r;
    node[rt].tag = INF;
    if (l == r && l == 1) node[rt].tag = 0;
    if (l == r) return;

    int mid = l + r >> 1;
    Build(ls(rt), l, mid);
    Build(rs(rt), mid + 1, r);
  }

  void Modify(int l, int r, ll_t x, int rt) {
    if (l <= node[rt].l && node[rt].r <= r) {
      if (node[rt].tag > x) node[rt].tag = x;
      return;
    }
    PushDown(rt);
    int mid = node[rt].l + node[rt].r >> 1;
    if (l <= mid) Modify(l, r, x, ls(rt));
    if (r > mid) Modify(l, r, x, rs(rt));
    PushUp(rt);
  }

  ll_t Query(int pos, int rt) {
    if (node[rt].l == node[rt].r) return node[rt].tag;
    PushDown(rt);
    int mid = node[rt].l + node[rt].r >> 1;
    ll_t res;
    if (pos <= mid) res = Query(pos, ls(rt));
    else res = Query(pos, rs(rt));
    PushUp(rt);
    return res;
  }
};

std::vector<pii> edges[MAXN];
SegmentTree tree;

ll_t solve(int n) {
  tree.Build(1, 1, n);
  for (int i = 1; i < n; ++i) {
    ll_t dis = tree.Query(i, 1);
    // printf("pos = %d dis = %lld\n", i, dis);
    for (const auto &edge : edges[i]) {
      int r = edge.first, c = edge.second;
      tree.Modify(i + 1, r, dis + c, 1);
    }
  }
  ll_t res = tree.Query(n, 1);
  if (res >= INF) res = -1;
  return res;
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int l, r, c;
    scanf("%d %d %d", &l, &r, &c);
    edges[l].emplace_back(r, c);
  }
  printf("%lld\n", solve(n));
  return 0;
}


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

int main() {
  double n,ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    double x;
    cin >> x;
    ans += 1/x;
  }
  
  cout << fixed << setprecision(10);
  cout << 1/ans << endl;
  
  return 0;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(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 pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (long long)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

ll fib(ll n){
    vll a(n+1);
    a[0] = 1;
    a[1]  = 1;

    REP(i,2,n+1){
        a[i] = a[i-1] + a[i-2];
        a[i] %= mod;
    }

    return a[n-1];
}

int main()
{
    string s;
    cin >> s;

    ll cnt = 0;
    rep(i,SIZE(s)){
        if((i+1) % 2 == 0 && (s[i] == 'L' || s[i] == 'U' || s[i] == 'D'))cnt++;
        else if((i+1) % 2 == 1 && (s[i] == 'R' || s[i] == 'U' || s[i] == 'D'))cnt++;
    }

    cout << ((cnt == SIZE(s))?"Yes":"No") << endl;
    return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

const string YES = "Yes";
const string NO = "No";

void solve(long long N)
{
    bool ok = false;
    while (N != 0)
    {
        if (N % 10 == 7)
        {
            ok = true;
        }
        N /= 10;
    }
    if (ok)
        cout << YES << endl;
    else
        cout << NO << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3720
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



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

    ll n,a,b;
    cin>>n>>a>>b;
    vi v(n);
    rep(i,n)cin>>v[i];
    ll ans=0;
    for(int i=0;i<n-1;i++){
        ans+=min(a*(v[i+1]-v[i]),b);
    }
    fin(ans);

//////////////////////////////////////////////////////
return 0;}

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

int main() {
	int k,n,mx;
	cin >> k >> n;
	mx = 0;
	vector<int> a(n);
	for(int i=0;i<n;i++)
	{
		cin >> a.at(i);
	}
	sort(a.begin(),a.end());
	for(int i=0;i<n-1;i++)
	{
		mx = max(mx,a.at(i+1) - a.at(i));
	}
	mx = max(mx,a.at(0) + k - a.at(n-1));
	cout << k - mx << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
  using namespace std;
 
int main(){
  int N;
  cin>>N;
  int hyaku = N/100;
  int juu = N/10-hyaku*10;
  int ichi = N%10;
  if(hyaku<juu){
    cout<<(hyaku+1)*100+(hyaku+1)*10+(hyaku+1)<<endl;
  }else if(hyaku==juu){
    if(juu<ichi){
      cout<<(hyaku+1)*100+(hyaku+1)*10+(hyaku+1)<<endl;
    }else{
      cout<<hyaku*100+hyaku*10+hyaku<<endl;
    }
  }else{
    cout<<hyaku*100+hyaku*10+hyaku<<endl;
  }
}

Measured memory_bytes: 256
//test

#include<cstdio>
#include<algorithm>
#include<cmath>
#define y1 yyy1
#define y2 yyy2
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef double db;
const int maxn=200000+10,mx=100000000;
const db pi=acos(-1);
struct dong{
    int x,y;
    friend bool operator<(dong a,dong b){
        return a.x<b.x||a.x==b.x&&a.y<b.y;
    }
} a[maxn];
int b[maxn],p[maxn];
int lis[maxn];
int i,j,k,l,t,n,m,x1,y1,x2,y2,z1,z2,top;
db ans;
int main(){
    scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
    scanf("%d",&n);
    fo(i,1,n) scanf("%d%d",&a[i].x,&a[i].y);
    if (x1>x2){
        swap(x1,x2);
        swap(y1,y2);
    }
    if (y1>y2){
        y1=mx-y1;
        y2=mx-y2;
        fo(i,1,n) a[i].y=mx-a[i].y;
    }
    a[++n].x=x1;
    a[n].y=y1;
    a[++n].x=x2;
    a[n].y=y2;
    fo(i,1,n) b[i]=a[i].y;
    sort(b+1,b+n+1);
    top=unique(b+1,b+n+1)-b-1;
    fo(i,1,n) a[i].y=lower_bound(b+1,b+top+1,a[i].y)-b;
    z1=y1;z2=y2;
    y1=lower_bound(b+1,b+top+1,y1)-b;
    y2=lower_bound(b+1,b+top+1,y2)-b;
    p[0]=y1;
    fo(i,1,n) p[i]=n+1;
    sort(a+1,a+n+1);
    fo(i,1,n){
        if (a[i].x<x1||a[i].y<y1||a[i].y>y2) continue;
        if (a[i].x>x2) break;
        if (a[i].x==x1&&a[i].y==y1){
            lis[i]=0;
            continue;
        }
        lis[i]=upper_bound(p,p+n+1,a[i].y)-p;
        p[lis[i]]=a[i].y;
        if (a[i].x==x2&&a[i].y==y2) break;
    }
    k=lis[i]-1;
    ans=(x2-x1)+(z2-z1);
    ans*=100;
    ans+=(pi-4)*5*k;
    if (k==min(x2-x1+1,z2-z1+1)&&k) ans+=pi*5;
    printf("%.12lf\n",ans);
}

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

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var a1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a2 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int cnd = 0;
            int ans = 0;

            for(int i = 0; i < n; i++)
            {
                cnd = 0;
                for (int j = 0; j <= i; j++) cnd += a1[j]; 
                for (int k = i; k < n; k++) cnd += a2[k]; 
                ans = Math.Max(ans, cnd);
            }

            Console.WriteLine(ans);

            


            
        }

        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }
        
        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define maxn 100015
#define maxm
#define maxb
#define maxr 200000
#define maxs
#define M 
#define pii pair<int, int>
#define pdd pair<double, double>
#define uint unsigned int
#define ull unsigned long long int
#define ll long long int 
#define lowbit(x) x & -x
#define fi first
#define se second
#define pb push_back
#define next NEXT
#define hash HASH
#define ls ch[x][0]
#define rs ch[x][1]
#define pi 3.141592653589793
#define ei 2.718281828459045
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define srep(i, l, r) for (register int i = l; i < r; i++)
#define sper(i, r, l) for (register int i = r; i > l; i--)
#define erep(i, x) for (register int i = h[x]; i; i = e[i].next)
#define gc() ((p1 == p2 && (p2 = (p1 = buffer) + fread(buffer, 1, maxr, stdin), p1 == p2)) ? EOF : *p1++)
#define END return 0
//#define ONLINE_JUDGE
//#define DEBUG
using namespace std;

char *p1, *p2, buffer[maxr];
template <class T> void read(T& x){
    char ch = gc(); x = 0; bool f = 1;
    while (!('0' <= ch && ch <= '9') && ch != '-') ch = gc();
    if (ch == '-') f = 0, ch = gc();
    while ('0' <= ch && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = gc();
    x = f ? x : -x;
}
set<int> s;
int n;
int a[maxn];
int main(){
    read(n);
    rep(i, 1, n) read(a[i]), s.insert(a[i]);
    if (s.size() > 3) {printf("No"); END;}
    else {
        if (n % 3) {printf((s.size() == 1 && (*s.begin() == 0)) ? "Yes" : "No"); END;}
        else {
            if (s.size() == 1) {printf((*s.begin() == 0) ? "Yes" : "No"); END;}
            else if (s.size() == 3){
                int x = *s.begin(); s.erase(s.begin());
                int y = *s.begin(); s.erase(s.begin());
                int z = *s.begin(); s.erase(s.begin());
                if (x ^ y ^ z) {printf("No"); END;}
                else {
                    int cx = 0, cy = 0, cz = 0;
                    rep(i, 1, n) {
                        if (a[i] == x) cx++;
                        else if (a[i] == y) cy++;
                        else cz++;
                    }
                    if (cx == cy && cy == cz) {printf("Yes"); END;}
                    else {printf("No"); END;}
                }
            }
            else {
                int x = *s.begin(); s.erase(s.begin());
                int y = *s.begin(); s.erase(s.begin());
                if (x) {printf("No"); END;}
                int cx = 0, cy = 0;
                rep(i, 1, n) {
                    if (a[i] == x) cx++;
                    else cy++;
                }
                if (cy == (cx << 1)) {printf("Yes"); END;}
                else {printf("No");END;}
            }
        }
    }
    return 0;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(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 pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (ll)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

ll digsum(ll n){
    ll sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

int main()
{
    ll m,d;
    cin >> m >> d;

    ll ans = 0;
    REP(i,1,m + 1){
        REP(j,1,d + 1){
            ll d1 = j % 10;
            ll d10 = j / 10;

            if(d1 * d10 == i && d1 >= 2 && d10 >= 2){
                ans++;
                //cout << i << " " << j << endl;
            }
        }
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>



using namespace std;
typedef long long ll;
int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}

int moji(char in)
{
    int ans = (int)in-(int)'a'+1;
    if((in < 1) || (in > 26)){
        ans = 100;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}





int main(){
  int A,B,K;
  cin>>A>>B>>K;
  for(int i=0;i<K;i++){
    if(i%2==0){
      if(A%2==0){
        B+=A/2;
        A/=2;
      }else{
        A--;
        B+=A/2;
        A/=2;

      }
    }else{
      if(B%2==0){
        A+=B/2;
        B/=2;
      }else{
        B--;
        A+=B/2;
        B/=2;

      }

    }
  }
  printf("%d %d\n",A,B);
  

}


  
  

  


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

using namespace std;

#define pb push_back
#define fs first
#define sc second
#define sz size
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 2; i <= (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+7; 

const double PI =  3.141592653589793;

int main(){
	IO;
	ll a,b;
	cin>>a>>b;
	cout<<(((b-a)*(b-a+1))/2)-b<<"\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


Measured memory_bytes: 256
def main(l, r):
    score = float('inf')

    for i in range(l, r):
        for j in range(i + 1, r + 1):
            current = i * j % 2019
            score = min(score, current)
            if score == 0:
                return score

    return score


L, R = list(map(int, input().split()))
print(main(L, R))

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int a,b,c,x,y;
  cin >> a >> b >>c >> x >> y;

  if(a+b >= 2*c){
    int ans;
    if(x>y){
      ans = y * 2 * c + (x-y) * a;
      ans = min(ans, 2*x*c);   
    }else{
      ans = x * 2 * c + (y-x) * b;
      ans = min(ans, 2*y*c);   
    }
    cout << ans << endl;

  }else{
    cout << a*x + b*y << endl;
  }

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
template <typename Iter, typename T> int gt(Iter L, Iter R, T v) { return upper_bound(L, R, v) - L; }
template <typename Iter, typename T> int ge(Iter L, Iter R, T v) { return lower_bound(L, R, v) - L; }
template <typename Iter, typename T> int lt(Iter L, Iter R, T v) { return lower_bound(L, R, v) - L - 1; }
template <typename Iter, typename T> int le(Iter L, Iter R, T v) { return upper_bound(L, R, v) - L - 1; }
template <typename Bst, typename T> typename Bst::const_iterator gt(const Bst& bst, T v) { return bst.upper_bound(v); }
template <typename Bst, typename T> typename Bst::const_iterator ge(const Bst& bst, T v) { return bst.lower_bound(v); }
template <typename Bst, typename T> typename Bst::const_iterator lt(const Bst& bst, T v) { return bst.lower_bound(v) == bst.begin() ? bst.end() : --bst.lower_bound(v); }
template <typename Bst, typename T> typename Bst::const_iterator le(const Bst& bst, T v) { return bst.upper_bound(v) == bst.begin() ? bst.end() : --bst.upper_bound(v); }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    cin >> a >> b;
    a.insert(a.begin(), 0);
    b.insert(b.begin(), 0);
    partial_sum(a.begin(), a.end(), a.begin());
    partial_sum(b.begin(), b.end(), b.begin());
    int ans = 0;
    for(int i = 0; i <= n; i++) {
        if(a[i] <= k) {
            int j = le(b.begin(), b.end(), k - a[i]);
            ans = max(ans, i + j);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7952
class SegmentTree():

    def __init__(self,N):
        # N: 処理する区間の長さ
        self.N0 = 2**(N-1).bit_length()
        self.INF = 2**31-1
        self.data = [self.INF]*(2*self.N0)
    # a_k の値を x に更新
    def update(self, k, x):
        k += self.N0-1
        self.data[k] = x
        while k >= 0:
            k = (k - 1) // 2
            self.data[k] = min(self.data[2*k+1], self.data[2*k+2])
    # 区間[l, r)の最小値
    def query(self, l, r):
        L = l + self.N0; R = r + self.N0
        s = self.INF
        while L < R:
            if R & 1:
                R -= 1
                s = min(s, self.data[R-1])

            if L & 1:
                s = min(s, self.data[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s

def main():
    n,k = tuple([int(t)for t in input().split()])
    size = 3*10**5
    lst = SegmentTree(size+1)
    for _ in range(n):
        a = int(input())
        l,r = max(a-k,0),min(a+k+1,size+1)
        m = min(lst.query(l,r),0)
        lst.update(a,m-1)

    print(-lst.query(0,3*10**5))

if __name__ == "__main__":
    main()


Measured memory_bytes: 81476
#include<bits/stdc++.h>
using namespace std;
#define int long long
constexpr int mu = 1e9;
signed main(){
    int a[200000],n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    int lb = -(mu*mu) ,ub =mu*mu;// 二分区间范围。
    while(ub - lb>1){
        int mid = (lb+ub)/2,cnt=0;//cnt 用来统计对的数量。
        for(int i=0;i<n;i++){
            if(a[i] < 0){
                cnt +=n- (lower_bound(a,a+n,(long double )mid/a[i])-a);
            }
            else if( a[i] >0){
                cnt += upper_bound(a,a+n,(long double)mid/a[i])-a;
            }
            else if( mid >= 0){
                // a[i]为0 且 任意值x >=0的话就有n对。
                cnt+=n;
            }
            // 去掉本身重复的。
            if( a[i] * a[i] <= mid) cnt--;
        }

        //判定条件，注意cnt是对数;
        (cnt>=2*k?ub:lb) = mid;
    }
    cout<<ub<<endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

typedef priority_queue<int, vector<int>, greater<int>> priority_queue_asc;

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

    long long sum = 0;
    map<long long, long long> m;
    for (int i = 0; i < N; i++) {
        int Ai;
        cin >> Ai;
        ++m[Ai];
        sum += Ai;
    }

    int Q;
    cin >> Q;

    vector<int> lut(100001);
    for (int i = 0; i < lut.size(); i++) {
        lut[i] = i;
    }

    long long ans = sum;
    for (int i = 0; i < Q; i++) {
        int B, C;
        cin >> B >> C;

        map<long long, long long>::iterator itr = m.find(B);
        if (itr != m.end()) {
            long long n = itr->second;
            long long orgValue = itr->first * n;
            long long newValue = C * n;

            m[B] = 0;
            m[C] += n;

            sum = sum - orgValue + newValue;
            cout << sum << endl;
        } else {
            cout << sum << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 8196
#include<stdio.h>
#include<stdlib.h>
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
void insert(int k);
typedef struct node * Node;
void inorder(Node u);
void preorder(Node u);
#define NIL NULL
Node root;
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      //Node t = treeSearch(root, x);
      //if ( t != NIL ) printf("yes\n");
      //else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      //scanf("%d", &x);
      //treeDelete(treeSearch(root, x));
    }
  }
  return 0;
}
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL)root=z;
  else if(z->key < y->key)y->left=z;
  else y->right=z;
}
void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}



Measured memory_bytes: 25240
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int N,s[50]={0};
string S;
int main()
{
	scanf("%d\n",&N);
	cin>>S;
	for(int i=0;i<S.length();i++)s[S[i]-'a']++;
	for(int i=1;i<N;i++)
	{
		int t[50]={0};
		cin>>S;
		for(int i=0;i<S.length();i++)t[S[i]-'a']++;
		for(int i=0;i<30;i++)s[i]=min(s[i],t[i]);
	}
	for(int i=0;i<30;i++)
		for(int j=0;j<s[i];j++)
			putchar('a'+i);
	puts("");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define ll long long
#define int ll

using namespace std;

const int MOD = 1e9+7;
int a[20][20], dp[(1 << 16)], sum[(1 << 16)];

signed main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }
    //cout << "SUM :\n";
    for(int mask = 1; mask < (1 << n); mask++){
        ll x = mask;
        int d = 0;
        while(x){
            if(x & 1){
                //cout << "1 ";
            }
            else{
                //cout << "0 ";
            }
            d++;
            x >>= 1;
        }
        while(d < n){
            //cout << "0 ";
            d++;
        }
        //cout << ": ";
        ll ff = 0;
        for(int i = 0; i < n; i++){
            if((mask >> i) & 1){
                for(int j = 0; j < i; j++){
                    if((mask >> j) & 1){
                        ff += a[i][j];
                    }
                }
            }
        }
        sum[mask] = ff;
        //cout << sum[mask] << endl;
    }
    //cout << "DP :\n";

    for(int mask = 2; mask < (1 << n); mask += 2){
        ll x = mask;
        vector<int> bit;
        int z = 0;
        while(x){
            if(x & 1){
                bit.push_back(z);
            }
            z++;
            x >>= 1;
        }
        for(int j = 1; j < (1 << bit.size()); j += 2){
            ll w = j;
            int d = 0;
            ll aa = 0;
            while(w){
                if(w & 1){
                    aa += (1 << bit[d]);
                }
                d++;
                w >>= 1;
            }
            dp[mask] = max(dp[mask], dp[mask - aa] + sum[aa]);
        }
    }

    for(int j = 1; j < (1 << n); j += 2){
        dp[(1 << n)-1] = max(dp[(1 << n)-1], dp[(1 << n)-1 - j] + sum[j]);
    }
    cout << dp[(1 << n)-1];
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++)
        cin>>ar[i];
    vector <int> dp(n,0);
    dp[0]=0;
    dp[1]=abs(ar[1]-ar[0]);
    for(int i=2;i<n;i++)
        dp[i]=min(dp[i-1]+abs(ar[i]-ar[i-1]),dp[i-2]+abs(ar[i]-ar[i-2]));
    cout<<dp[n-1];
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)

int main(){
  vector<vector<int> > c(3, vector<int>(3));
  r(i,3){
    r(j,3){
      cin>>c[i][j];
    }
  }

  string ans="Yes";
  if(c[0][0]+c[1][1]+c[2][2]==c[0][1]+c[1][2]+c[2][0] and c[0][0]+c[1][1]+c[2][2]==c[0][2]+c[1][0]+c[2][1]){

  }else{
    ans="No";
  }

  cout<<ans<<endl;

return 0;}


Measured memory_bytes: 256
fn main(){
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).expect("failed to read");
    buf.clear();
    std::io::stdin().read_line(&mut buf).expect("failed to read");
    let va: Vec<u32> = buf.split_whitespace().map(|e| e.parse().unwrap()).collect();

    let ct: usize = va.iter().enumerate().filter(|&(i, &x)| i % 2 == 0 && x % 2 == 1).count();

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


Measured memory_bytes: 2136
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
vector<int>G[100000];
signed main(){
    int n,m,h[100000],a,b,arr[100000]={};
    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>h[i];
    while(cin>>a>>b){
        G[--a].push_back(--b);
        G[b].push_back(a);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        bool ok=1;
        for(int j=0;j<G[i].size();j++)
            if(h[G[i][j]]>=h[i])
                ok=0;
        if(ok)
            ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 10264
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100000;
int prime[MAX_N];
bool is_prime[MAX_N + 1];

int sieve(int n)
{
    int p = 0;
    for (int i = 0; i <= n; i++)
    {
        is_prime[i] = true;
    }
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++)
    {
        if (is_prime[i] == true)
        {
            prime[p++] = i;
            for (int j = 2 * i; j <= n; j += i)
            {
                is_prime[j] = false;
            }
        }
    }
    return p;
}

int dp[MAX_N + 1];
int q;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    sieve(MAX_N);
    for (int i = 1; i < MAX_N + 1; i++)
    {
        if (i % 2 == 0)
        {
            dp[i] = dp[i - 1];
            continue;
        }
        if (is_prime[i] && is_prime[(i + 1) / 2])
            dp[i] = dp[i - 1] + 1;
        else
        {
            dp[i] = dp[i - 1];
        }
    }
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        cout << dp[r] - dp[l - 1] << endl;
    }
}

Measured memory_bytes: 1152