akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>

using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	int i = 0, sum = 0;
	while (b) {
		sum += (b % 10)*(pow(10, i++));
		b /= 10;
	}
	while (a) {
		sum += (a % 10)*pow(10, i++);
		a /= 10;
	}
	int t = sqrt(sum);
	if (t*t == sum)
		cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
//Range Search
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

static const int NIL = -1;
static const int MAX = 1000000;

class Point {
public:
    int id, x, y;
    Point() {}
    Point(int id, int x, int y): id(id), x(x), y(y) {}
    bool operator < ( const Point &p) const {
        return id < p.id;
    }
    void print() {
        printf("%d\n", id);
    }
};

bool lessX(const Point &p1, const Point &p2) {return p1.x < p2.x;}
bool lessY(const Point &p1, const Point &p2) {return p1.y < p2.y;}

int n;
Point P[MAX];

class Node {
public:
    int location = NIL;
    Node *left = nullptr, *right = nullptr;

    Node(int location): location(location) {};
};

class Tree {
public:
    Node *root = nullptr;

    Tree() {root = make2DTree(0, n, 0);};

    Node* make2DTree(int l, int r, int depth) {
        if(l >= r) return nullptr;
        int mid = (l + r) / 2;
        if(depth % 2 == 0) sort(P+l, P+r, lessX);
        else sort(P+l, P+r, lessY);

        Node *node = new Node(mid);
        node->left = make2DTree(l, mid, depth+1);
        node->right = make2DTree(mid+1, r, depth+1);
        return node;
    }

    void find(Node *node, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans) {
        if(node == nullptr) return;

        int x = P[node->location].x, y = P[node->location].y;
        if(x >= sx && x <= tx && y >= sy && y <= ty) ans.push_back(P[node->location]);

        if(depth % 2 == 0) {
            if(x >= sx) find(node->left, sx, tx, sy, ty, depth+1, ans);
            if(x <= tx) find(node->right, sx, tx, sy, ty, depth+1, ans);
        }
        else {
            if(y >= sy) find(node->left, sx, tx, sy, ty, depth+1, ans);
            if(y <= ty) find(node->right, sx, tx, sy, ty, depth+1, ans);
        }
    }
};

int main() {
    int q, x, y, sx, tx, sy, ty;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d %d", &x, &y);
        P[i].id = i; P[i].x = x; P[i].y = y;
    }

    Tree T;
    scanf("%d", &q);
    vector<Point> ans;
    for(int i = 0; i < q; i++) {
        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
        ans.clear();
        T.find(T.root, sx, tx, sy, ty, 0, ans);
        sort(ans.begin(), ans.end());
        for(auto a: ans) {
            a.print();
        }
        cout << endl;
    }
}



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

using namespace std;

int main() {
    int n;
    cin >> n;
    int count = 0;
    for (int i = 1; i < 10; i++) {
        if (n % i == 0 && n/i < 10){
            count++;
        }
    }
    if (count) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };
#define MOD 1000000007
#define ARRAY_MAX 100005

template<typename T> using Matrix = vector<vector<T> >;


const int INF = INT_MAX;


template< typename T >
void warshall_floyd(Matrix<T>& g, T inf) {

	for (int k = 0; k < g.size(); k++)
	{
		for (int i = 0; i < g.size(); i++)
		{
			for (int j = 0; j < g.size(); j++)
			{
				if (g[i][k] == inf || g[k][j] == inf)
				{
					//辺がない場合は最短になることはないので飛ばす
					continue;
				}
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
			}
		}
	}
}


int main() {


	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int V, E;
	cin >> V >> E;

	Matrix<int> mat(V, vector<int>(V, INF));

	for (int i = 0; i < V; i++) {
		mat[i][i] = 0;
	}

	for (int i = 0; i < E; i++)
	{
		int s, t, d;
		cin >> s >> t >> d;
		mat[s][t] = d;
	}

	warshall_floyd(mat, INF);

	for (int i = 0; i < V; i++)
	{
		if (mat[i][i] < 0)
		{
			//自分自身へのコストは始めは0
			//自身へのコストが負ならこれは途中で負のループができていることになる
			cout << "NEGATIVE CYCLE" << endl;
			return 0;
		}
	}


	for (int i = 0; i < V; i++)
	{
		for (int j = 0; j < V; j++)
		{
			if (j > 0) 
			{
				cout << " ";
			}
			if (mat[i][j] == INF)
			{
				cout << "INF";
			}
			else 
			{
				cout << mat[i][j];
			}
		}
		cout << endl;
	}  

	return 0;
}


Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>
#include <queue>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.length() <= k){
        cout << s << endl;
    }else{
        cout << s.substr(0,k) << "..." << endl;
    }


    return 0;
}

Measured memory_bytes: 3632
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		
		if(S.equals("BBB") || S.equals("AAA")){
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
		
		
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int maxn = 1e6 + 5;
const ll mod = 1e9 + 7;
const ll inf=0x3f3f3f3f;
const ld pi=acos(-1.0);
ll n,k,num[maxn],b,c;
void run(){
    cin>>n;
    ll ans=0;
    for(int i=0;i<n;i++){
        cin>>num[i];
        ans^=num[i];
    }
    for(int i=0;i<n;i++){
        cout<<(ans^num[i])<<" ";
    }

}

int main(){
#ifdef haosao
freopen("main.h", "r", stdin);
#endif
    std::ios::sync_with_stdio(false);
    run();
    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define mem(a) memset(a,0,sizeof(a))

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

const int mn=1e5+5;

int a,b;

int main() {
#ifdef LOCAL
	freopen("../1.txt", "r", stdin);
	clock_t cc=clock();
#endif
	string s;
	cin>>s>>a;
	for(int i=0;i<s.size();i+=a){
		putchar(s[i]);
	}
#ifdef LOCAL
	cout<<"time:"<<(double)(clock()-cc)/CLOCKS_PER_SEC;
#endif
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
ll solve() {
	var(int, n);
	vec(ll, a, n);
	sort(all(a));
	if (n == 2) {
		return a[1] - a[0];
	} else if (n == 3) {
		return -a[0] + a[2] + max(-a[1] + a[2], -a[0] + a[1]);
	}
	int c0 = n / 2 - 1, c1 = n / 2, c2 = n / 2 + 1;
	if (n & 1) {
		ll ans1 = 0, ans2 = 0;
		ans1 = - a[c0] - a[c1];
		rep(i, 0, c0) {
			ans1 -= a[i] * 2;
		}
		rep(i, c1 + 1, n) {
			ans1 += a[i] * 2;
		}
		ans2 = a[c1] + a[c2];
		rep(i, 0, c1) {
			ans2 -= a[i] * 2;
		}
		rep(i, c2 + 1, n) {
			ans2 += a[i] * 2;
		}
		return max(ans1, ans2);
	}
	ll ans = - a[c0] + a[c1];
	rep(i, 0, c0) {
		ans -= a[i] * 2;
	}
	rep(i, c1 + 1, n) {
		ans += a[i] * 2;
	}
	return abs(ans);
}
int main() {
	print(solve());
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

const int dy[] = {-1, 0, 0, 1};
const int dx[] = {0, -1, 1, 0};
int H, W;
int M[1010][1010];
using P = pair<int, int>;
P memo[1010][1010];

P rec(int y, int x) {
    if (~memo[y][x].second) return memo[y][x];
    P res(H * W, -1);
    REP(i, 4) {
        int ny = y + dy[i];
        int nx = x + dx[i];
        if (ny >= 0 && ny < H && nx >= 0 && nx < W && M[ny][nx] < M[y][x]) {
            P p = rec(ny, nx);
            res.first = min(res.first, p.first);
            res.second = max(res.second, p.second);
        }
    }
    if (!~res.second) res.first = res.second = H * y + x;
    return memo[y][x] = res;
}

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

    cin >> H >> W;
    REP(i, H) REP(j, W) {
        cin >> M[i][j];
        memo[i][j] = P(H * W, -1);
    }
    int ans = 0;
    REP(i, H) REP(j, W) {
        P p = rec(i, j);
        ans += (p.first != p.second);
    }
    cout << ans << endl;
}


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

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long
const int N = 2e5 + 10;
const int MOD = 1e9 + 7;

int fact[N] , inv[N];
int n , w , a , b;


int fastpow(int base,int exp){

	if(exp==0) return 1;
	else if(exp%2==0){
		int ans=fastpow(base,exp/2);
		return (ans%MOD*ans%MOD)%MOD;
	}
	else{
		return (fastpow(base,exp-1)%MOD*base%MOD)%MOD;
	}
}

void pre(){
	fact[0] = 1;
	for(int i = 1 ; i < N ; ++i){
		fact[i] = (fact[i-1]*i)%MOD;
	}

	for(int i = 0 ; i < N; ++i){
		inv[i] = fastpow(fact[i],MOD-2);
	}
}

int ways(int n , int r){
	return (fact[n+r-2]*(inv[r-1]%MOD * inv[n-1]%MOD)%MOD)%MOD;
}

int32_t main(){
	// boost;
	// cin >> n >> w >> a >> b;
	scanf("%lld%lld%lld%lld",&n,&w,&a,&b);
	pre();

	int out = 0;	
	for(int i = b+1 ; i <= w ; ++i){

		// Number of ways till (1,1) to (n-a , i) * Number of ways the remaining till last ( (a,w-i+1 ))
		out += ((ways(n-a,i)%MOD)*ways(a,w-i+1)%MOD)%MOD;
		out %= MOD;
	}

	// cout << out;
	printf("%lld\n", out);
	return 0;
}// Read my code it is awesome.


Measured memory_bytes: 3328
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=(b);i++)
#define em emplace_back
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define mkp make_pair
#define pii pair<int,int>
#define oi ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pll pair<ll,ll>


int main(){
    //oi;
    int n,x[3]={},a,b,y;
    cin>>n>>a>>b;
    while(n--){
        cin>>y;
        if(y<=a) x[0]++;
        else if(y>a&&y<=b) x[1]++;
        else x[2]++;
    }
    cout<<min(x[0],min(x[1],x[2]))<<"\n";
//    system("pause");
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private class Edge {
        int to;
        long cost;

        public Edge(int to, long cost) {
            this.to = to;
            this.cost = cost;
        }
    }

    private class Node {
        long minCost = Long.MAX_VALUE;
        List<Edge> childs = new ArrayList<>();
        boolean isFix = false;

        public void addEdge(Edge e) {
            childs.add(e);
        }

        public void fixed() {
            isFix = true;
        }
    }

    public void main(Scanner sc) {
        int n = sc.nextInt();
        Node nodes[] = new Node[n + 1];
        for (int i = 1; i <= n; i++) {
            nodes[i] = new Node();
        }
        for (int i = 0; i < n - 1; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            long c = sc.nextLong();
            nodes[a].addEdge(new Edge(b, c));
            nodes[b].addEdge(new Edge(a, c));
        }

        int q = sc.nextInt();
        int k = sc.nextInt();
        dijkstra(k, n, nodes);

        for (int i = 0; i < q; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            System.out.println(nodes[x].minCost + nodes[y].minCost);
        }
    }

    public void dijkstra(int start, int n, Node nodes[]) {
        nodes[start].minCost = 0;

        Queue<Node> queue = new PriorityQueue<>((n1, n2) -> Long.compare(n1.minCost, n2.minCost));
        queue.add(nodes[start]);
        while (!queue.isEmpty()) {
            Node src = queue.poll();
            src.fixed();
            for (Edge e : src.childs) {
                Node dst = nodes[e.to];
                if (!dst.isFix) {
                    dst.minCost = Math.min(dst.minCost, src.minCost + e.cost);
                    queue.add(dst);
                }
            }
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


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

int main(){
    int N;
    cin>>N;
    double arr[N+1];
    for(int i=1; i<=N; i++)cin>>arr[i];
    double dp[N+1][N+1]={0};
    dp[0][0]=1;
    for(int i=1; i<=N; i++){
        double head_eve = arr[i];
        double tail_eve = 1-arr[i];
        dp[0][i] = tail_eve*dp[0][i-1];
        for(int heads=1; heads<=i; heads++){
            dp[heads][i] = head_eve*dp[heads-1][i-1] + tail_eve*dp[heads][i-1];
        }
    }
    double ans = 0;
    for(int i=N/2+1; i<=N; i++){
        ans+=dp[i][N];
    }
    cout<<setprecision(9)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 70528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 998244353;
int si[] = {-1, 0, 1, 0};
int sj[] = {0, -1, 0, 1};

int main(){
  ll a, v, b, w, t;
  cin >> a >> v;
  cin >> b >> w;
  cin >> t;

  if(w >= v) {
    cout << "NO" << endl;
    return 0;
  } else {
    if ((double)abs(a-b) / (double)(v-w) <= t) {
      cout << "YES" << endl;
      return 0;
    } else { 
      cout << "NO" << endl;
      return 0;
    }
  } 
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
template <typename T, typename U>
istream &operator>>(istream &in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	const int MOD=1e9+7;
	int n,k,s;
	cin>>n>>k>>s;
    rep(i,n){
        if(i<k)cout<<s;
        else{
            if(s<1000000000)cout<<1000000000;
            else cout<<1;
        }
        if(i+1!=n)cout<<' ';
        else cout<<endl;
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int mod = 998244353;
struct mint {
ll x; 
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
 }
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
 }
 mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
 mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
 mint inv() const {
return pow(mod-2);
 }
  mint& operator/=(const mint a) {
return (*this) *= a.inv();
 }
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
 }
};
struct combination {
vector<mint> fact, ifact;
combination(int n):fact(n+1),ifact(n+1) {
  assert(n < mod);
 fact[0] = 1;
 for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
 ifact[n] = fact[n].inv();
  for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n) return 0;
return fact[n]*ifact[k]*ifact[n-k];
}
  };

int N, D[101010];
mint solve() {
    map<int, int> cnt;
    rep(i,N) cnt[D[i]]++;

    int n = cnt.size();
    rep(i,n) if (cnt[i] == 0) return 0;
    if (cnt[0] != 1) return 0;
    if (D[0] != 0) return 0;

    mint res = 1;
    for(int i=1;i<n;i++) res *= mint(cnt[i - 1]).pow(cnt[i]);
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N;
    rep(i,N) cin >> D[i];
    cout<<solve().x<<endl;
    return 0;
}


Measured memory_bytes: 5376
x = int(input())

if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
else:
    print(1)

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

int main(){
    int a[5];
    rep(i,5)cin>>a[i];
    rep(i,5){
        if(a[i]==0)cout<<i+1<<endl;
    }
    return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long A, long long B, long long T){
    int cnt = T / A;
    cout << (B * cnt) << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int N;
	cin>>N;
	float values[N];
	float a[N], sum=0;
	int i;

	for(i=0; i<N; ++i)
	{
		cin>>values[i];
	}

	for(i=0; i<N; i++)
	{
		a[i] = (1/values[i]);
	}

	/*for(i=0; i<N; i++)
	{
		cout<<a[i]<<endl;
	}
	*/

	for(i=0; i<N; i++)
	{
		sum = a[i] + sum;
	}
	cout << (1/sum) << endl;
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define S 100000

int main(void){
  int p[S+1], ans[S+1], c=0, q, l, r, i, j;
  for(i=0;i<S+1;i++) p[i]=1;
  p[0]=0; p[1]=0; ans[0]=0; ans[1]=0;
  for(i=2;i<S+1;i++) if(p[i]==1) for(j=2;j*i<S+1;j++) p[j*i]=0;
  for(i=2;i<S+1;i++){
    ans[i]=c;
    if(i%2==1 && p[i]==1 && p[(i+1)/2]==1) c++;
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d %d",&l, &r);
    printf("%d\n",ans[r+1]-ans[l]);
  }
 
  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <ctime>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;


int main()
{
    double a,b,c,d,e,f;
    while(cin>>a>>b>>c>>d>>e>>f)
    {
        double y = (f-c*d/a) / (e-d*b/a);
        double x = (c - b*y) / a;
        cout<<fixed<<setprecision(3)<<x<<" "<<y<<endl;
    }
}

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

using namespace std;

int main()
{
    int N, i, num;
    vector<int> a;
    vector<int> b;
    cin >> N;
    for(i = 0; i < N; i++)
    {
        cin>> num;
        a.push_back(num);
    }
    b.push_back(a[0]);
    b.push_back(abs(a[1] - a[0]));
    b.push_back(min(abs(a[1]-a[0])+abs(a[2]-a[1]), abs(a[2]-a[0])));
    for(i = 3; i < N; i++)
    {
        b.push_back(min(b[i-1] + abs(a[i]-a[i-1]), b[i-2] + abs(a[i]-a[i-2])));
    }
    cout<<b[N-1]<<endl;
}


Measured memory_bytes: 1528
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
//19234567892927;
const int mod=1e9+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	llint n,nn,wa=0;cin>>n;nn=n;
	while(nn){wa+=nn%10;nn/=10;}
	if(n%wa==0){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
	return 0;
}

Measured memory_bytes: 888
#import <bits/stdc++.h>
using namespace std;typedef int l;
#define rp(i,n) for(l i=0;i<n;++i)
l main(){l n;cin>>n;l v[99];for(char c='A';c<='C';++c)cin>>v[c];string s[220000];rp(i,n)cin>>s[i];char a[220000];rp(i,n){char x=s[i][0],y=s[i][1],M=(v[x]>=v[y]?x:y),m=x^y^M;if(v[x]==v[y]&&i+1<n&&(s[i+1][0]==x||s[i+1][1]==x))swap(M,m);if(v[M]==0){puts("No");return 0;}v[M]--,v[m]++;a[i]=m;}puts("Yes");rp(i,n)cout<<a[i]<<endl;}

Measured memory_bytes: 10620
s = input()
if s == 'SUN':
    ans = 7
elif s == 'MON':
    ans = 6
elif s == 'TUE':
    ans = 5
elif s == 'WED':
    ans = 4
elif s == 'THU':
    ans = 3
elif s == 'FRI':
    ans = 2
elif s == 'SAT':
    ans = 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int N; int K;
  cin >> N >> K;
  int R; int S; int P;
  cin >> R >> S >> P;
  string T;
  cin >> T;
  char pre_rsp;
  int Total=0;
  for(int i=0;i<K;i++){
    pre_rsp=T[i];
      switch(T[i]){
        case 'r':
        Total+=P;
        break;
        case 's':
        Total+=R;
        break;
        default:
        Total+=S;
        break;
      }
    for(int j=K;i+j<N;j+=K){
      if(pre_rsp!=T[i+j]){
        switch(T[i+j]){
        case 'r':
        Total+=P;
        break;
        case 's':
        Total+=R;
        break;
        default:
        Total+=S;
        break;
        }
        pre_rsp=T[i+j];
      }else{
        pre_rsp='a';
      }
    }
  }
  cout << Total << endl;
}


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

int main(){

    int e,y;

    cin >> e >> y;

    if(e==0){
      if(y <= 1911){
        cout << 'M' << y-1868+1 << endl;
      }
      else if(y >= 1912 && y <= 1925){
        cout << 'T' << y-1912+1 << endl;
      }
      else if(y >= 1926 && y <= 1988){
        cout << 'S' << y-1926+1 << endl;
      }
      else{
        cout << 'H' << y-1989+1 << endl;
      }
    }
    else if(e==1){
      cout << y+1868-1 << endl;
    }
    else if(e==2){
      cout << y+1912-1 << endl;
    }
    else if(e==3){
      cout << y+1926-1 << endl;
    }
    else{
      cout << y+1989-1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3056
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
LL N, P;
LL pow(LL x, LL k){
	if(k == 0) return 1;
	if(x > P) return 0;
	LL res = pow(x * x, k / 2);
	if(k % 2 == 1) res = res * x;
	return res; 
}
int main(){
	cin >> N >> P;
	if(N == 1){
		cout << P << endl;
		return 0;
	}
	LL copy = P;
	int cnt = 1;
	while(copy > 10){
		copy /= 10;
		cnt++;
	}
	cnt = cnt / N;
	LL m = 1;
	for(int i = 0; i <= cnt; i++){
		m *= 10;
	}
	for(int i = m; i >=  1; i--){
		LL res = pow(i, N);
		if(res <= 0LL) continue;
		if(P % res == 0){
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
/************************************************
   Start coding only after you have clear idea. 
*************************************************/

#include <bits/stdc++.h>

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 2e3+23;
const int maxn = 5e5+35;
int n,q,a[maxn],pos[maxn],ans[maxn];
struct node{
    int l,r,id;
}p[maxn];
bool cmp(node a,node b){
    return a.r < b.r;
}
int tr[maxn];
void add(int p,int val){
    while(p <= n){
        tr[p] += val; 
        p += p&(-p);
    }
}
int query(int p){
    int res = 0;
    while(p){res += tr[p];p -= (p&(-p));}
    return res;
}
int main(){
    scanf("%d %d",&n,&q);
    for(int i = 1;i <= n; ++i) scanf("%d",a+i);
    for(int i = 1;i <= q; ++i){
        scanf("%d %d",&p[i].l,&p[i].r);
        p[i].id = i;
    }
    sort(p+1,p+q+1,cmp);
    int x = 0;
    for(int i = 1;i <= q; ++i){
        while(x < p[i].r){
            x += 1;
            if(pos[a[x]]) add(pos[a[x]],-1);
            pos[a[x]] = x;
            add(pos[a[x]],1);
        }
        ans[p[i].id] = query(p[i].r)-query(p[i].l-1);
    }
    for(int i = 1;i <= q; ++i) printf("%d\n",ans[i]);
    return 0;
}

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

///Author:Refat(BSMRSTU)///

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e5 + 5;
const int M = 1e9 + 7;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}
int main() {
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);
    ll n,ans;
    scanf("%lld",&n);
    n-=1;
    ans=n*(n+1);
    printf("%lld\n",ans/2);
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[3009][3009];
string s,x;
int bt(int i,int j)
{
    if(i==0||j==0)return 0;
    if(dp[i][j]!=-1)return dp[i][j];
    dp[i][j]=0;
    if(s[i-1]==x[j-1])dp[i][j]=bt(i-1,j-1)+1;
    int a=max(bt(i-1,j),bt(i,j-1));
    dp[i][j]=max(dp[i][j],a);
    return dp[i][j];
}
int main()
{
    cin>>s>>x;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<3009;i++){dp[0][i]=0;dp[i][0]=0;}
    bt(s.size(),x.size());
    string ans="";
    /*int i=s.size(),j=x.size();
    for(int i=1;i<=s.size();i++){
        for(int j=1;j<=x.size();j++)cout<<dp[i][j]<<" ";
        cout<<"\n";
    }*/
    int i=s.size(),j=x.size();
    while(dp[i][j]!=-1&&i>0&&j>0)
    {
        if(dp[i][j]>dp[i-1][j]&&dp[i][j]>dp[i][j-1])
        {
            ans+=s[i-1];
            i--;
            j--;
        }
        else if(dp[i][j]==dp[i-1][j])
        {
            i--;
        }
        else j--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
}


Measured memory_bytes: 36096
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

using mint = modint998244353;
const mint inv9 = mint(1)/9;

struct S {
  mint x, w;
  S(mint x=0, mint w=1): x(x), w(w) {}
};

S op(S a, S b) {
  return S(a.x*b.w + b.x, a.w * b.w);
}

S e() { return S(); }

S mapping(int f, S a) {
  if (f == 0) return a;
  return S((a.w-1) * inv9 * f, a.w);
}

int composition(int f, int g) {
  if (f == 0) return g;
  return f;
}

int id() { return 0; }

int main() {
  int n, q;
  cin >> n >> q;
  lazy_segtree<S, op, e, int, mapping, composition, id> t(n);
  rep(i, n) t.set(i, S(1, 10));
  while(q--) {
    int l, r, d;
    cin >> l >> r >> d;
    --l;
    t.apply(l, r, d);
    S ans = t.prod(0, n);
    printf("%d\n", ans.x.val());
  }
  return 0;
}


Measured memory_bytes: 9876
#include<bits/stdc++.h>
using namespace std;
/*
int main(){
int a , b , c;
cin>>a>>b>>c;
if(a==b && a==c && b==c)cout<<"No";
else cout<<"Yes";
return 0;





}*/
int main(){
int a , b , c;
cin>>a>>b>>c;
int p = 0;
if(a==b)p+=2;;
if(b==c)p+=2;
    if(a==c)p+=2;
if(p==2)cout<<"Yes";
else cout<<"No";


return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;main(){int n=0,s,j,k,i,a[11][46];for(;n<506;n++)a[n%11][n/11]=0;for(i=0;i<1024;i++){for(j=i,n=s=k=0;j>0;j/=2,k++)n+=j%2,s+=j%2*k;a[n][s]++;}for(cin>>n>>s;n||s;s<46?cout<<a[n][s]:cout<<0,cout<<endl,cin>>n>>s);}

Measured memory_bytes: 0
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<cstdio>
using namespace std;


vector<vector<int>> memo(100050,vector<int>(40,-1));
int p=pow(10,9)+7;

int comb(int i,int j){
    if(j==0)return 1;
    if(i==j)return 1;
    if(memo[i][j]!=-1)return memo[i][j];

    return memo[i][j]=(comb(i-1,j)+comb(i-1,j-1))%p;
}

int main(){
    int N,M;cin>>N>>M;
    N--;
    int m=sqrt(M)/1;
    map<int,int> mp;
    for(int i=2;i<=m;i++){
        while(M%i==0){
            M/=i;
            mp[i]++;
        }
    }
    if(M!=1)mp[M]++;
    
    long long ans=1;
    for(auto itr=mp.begin();itr!=mp.end();itr++)
        ans=(ans*(long long)comb(N+itr->second,itr->second))%p;
    
    cout<<ans<<endl;
    return 0;
}

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

#define pb push_back
typedef long long int ll;
typedef vector<ll> vl;
typedef map<ll,ll> ii;


//main code
int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    ll x,y;cin>>x>>y;
    ii m;
    vl v;
    vector<pair<ll,ll>> v0;
    map<int,string> m0;
    for(int i=0;i<y;i++){
        ll a,b;cin>>a>>b;
        v.pb(b);
        v0.pb({a,b});
    }
    sort(v0.begin(),v0.end());
    for(auto i:v0){
        ll a=i.first;ll b=i.second;
        m[a]++;
        string s,s0,s1;
        s=to_string(a);
        for(int i=0;i<(6-s.size());i++){
            s1.pb('0');
        }
        s1+=s;
        s=to_string(m[a]);
        
        for(int i=0;i<6-s.size();i++){
            s0+='0';
        }
        s0+=s;
        s=s1.insert(6,s0);
        m0[b]=s;
    }




    for(ll i:v){
        cout<<m0[i]<<"\n";
    }
    return 0;
}
    

Measured memory_bytes: 21096
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    d = collections.defaultdict(list)
    for i in range(n):
        t = collections.Counter(str(input().rstrip('\n')))
        for k, v in t.items():
            d[k] += [v]
    ans = []
    for k, v in d.items():
        if len(v) == n:
            for i in range(min(v)):
                ans.append(k)
    ans.sort()
    print("".join(ans))


if __name__ == '__main__':
    slove()


Measured memory_bytes: 40432
#include <stdio.h>
 
int N;
int parent[100001];
int sibling[100001];
int degree[100001];
 
int calcDepth(int i) {
  if(parent[i] == -1) return 0;
  return calcDepth(parent[i]) + 1;
}
 
int calcHeight(int i) {
  int j, h;

  h = 0;
  for(j = 0; j < N; ++j) {
    if(parent[j] == i) {
      int tmp = calcHeight(j) + 1;
      if(tmp > h) h = tmp;
    }
  }
  return h;
}
 

int main() {
  int i,j;

  scanf("%d", &N);
  for(i = 0; i < N; ++i) {
    parent[i] = -1;
    sibling[i] = -1;
    degree[i] = 0;
  }

  for(i = 0; i < N; ++i) {
    int id, left, right;
    scanf("%d %d %d", &id, &left, &right);
    if(left != -1) {
      parent[left] = id;
      sibling[left] = right;
      ++degree[id];
    }

    if(right != -1) {
      parent[right] = id;
      sibling[right] = left;
      ++degree[id];
    }
  }
 
  for(i = 0; i < N; ++i) {
    int depth = calcDepth(i);
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
           i, parent[i], sibling[i], degree[i], depth, calcHeight(i));

    if(depth == 0) {
      printf("root\n");
    } 
    else if(degree[i] == 0) {
      printf("leaf\n");
    }
    else {
      printf("internal node\n");
    }
  }
  return 0;
}


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

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            // 標準入力:N
            int n = int.Parse(Console.ReadLine());

            int na = n % 10;
            if (na == 2 || na == 4 || na == 5 || na == 7 || na == 9)
                Console.WriteLine("hon");
            else if (na == 0 || na == 1 || na == 6 || na == 8)
                Console.WriteLine("pon");
            else
                Console.WriteLine("bon");
        }
    }

    class Book
    {
        int money = 1;
        List<int> skills = new List<int>();
        // 各アルゴリズムの1円あたりの理解度
        List<float> skillPerMoney = new List<float>();
    }
}


Measured memory_bytes: 27540
n = int(input())
records = []
for _ in range(n):
    x,y,h = map(int,input().split())
    records.append((h,x,y))
records.sort()


for cx in range(101):
    for cy in range(101):
        h = 0
        hmax =float('inf')
        false = 0
        for  hi,x,y in records:
            if hi==0:
                hmax=min(hmax,abs(cx-x)+abs(cy-y))
            else:
                if h ==0:
                    h = hi +abs(cx-x)+abs(cy-y)
                else:
                    if h != abs(cx-x)+abs(cy-y) +hi:
                        false = 1
                        break
        if false:
            continue
        else:
            if (1 <=h <= hmax):
                print(cx,cy,h)
                exit()
            else:
                if h==0 and hmax ==1:
                    print(cx,cy,h)
                    exit()
                else:
                    continue
        
        
        
        
        
        
    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std; 
int main()
{
	int n;
	cin>>n;
	std::vector<int> v(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>v[i];
	}
	int count=0;
	int ans=0;
	for (int i = 0; i < n; ++i)
	{
		int flag=1;
		int count=0;
		for (int j = 0; j < i; ++j)
		{
			if(v[j]>v[i])
			{
				flag=0;
				break;
			}
		}
		if(flag)count++;
		ans+=count;
	}
	cout<<ans<<endl;;
}	


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    int n = ri();
    s64 c = rs64();
    s64 x[n];
    s64 xx[n];
    int v[n];
    FOR(i,n) x[i] = rs64(), xx[i] = c-x[i], v[i] = ri();
    
    s64 r1 = 0;
    s64 sum = r1;
    s64 max1[n];
    FOR(i,n) {
        sum += v[i];
        if (r1 < sum-x[i]) r1 = sum-x[i];
        max1[i] = r1;
    }
    
    s64 r2 = 0;
    sum = r2;
    s64 max2[n];
    for (int i = n-1; i >= 0; i--) {
        sum += v[i];
        if (r2 < sum-xx[i]) r2 = sum-xx[i];
        max2[i] = r2;
    }
    
    s64 r3 = 0;
    sum = 0;
    FOR(i,n-1) {
        sum += v[i];
        r3 = max(r3, sum-x[i]*2+max2[i+1]);
    }
    
    s64 r4 = 0;
    sum = r4;
    for (int i = n-1; i >= 1; i--) {
        sum += v[i];
        r4 = max(r4, sum-xx[i]*2+max1[i-1]);
    }
    /*
    cout << "r1 : " << r1 << endl;
    cout << "r2 : " << r2 << endl;
    cout << "r3 : " << r3 << endl;
    cout << "r4 : " << r4 << endl;*/
    cout << max(max(r1,r2),max(r3,r4)) << endl;
 return 0;
}


Measured memory_bytes: 3712
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=10000+10;
struct dong{
	int id,x,ca;
	friend bool operator <(dong a,dong b){
		return a.x<b.x;
	}
} d[maxn*2];
int h[maxn*10],go[maxn*100],nxt[maxn*100],dfn[maxn*10],low[maxn*10],sta[maxn*10],belong[maxn*10];
int left[maxn*10],right[maxn*10],leaf[maxn*2],a[maxn],b[maxn],c[maxn*2];
bool bz[maxn*10],pd[maxn*10];
int i,j,k,l,r,mid,t,n,m,tot,top,cnt,num,sum,euler,root;
void build(int &x,int l,int r){
	if (!x) x=++tot;
	if (l==r){
		leaf[l]=x;
		return;
	}
	int mid=(l+r)/2;
	build(left[x],l,mid);build(right[x],mid+1,r);
}
void add(int x,int y){
	go[++tot]=y;
	nxt[tot]=h[x];
	h[x]=tot;
}
void link(int x,int l,int r){
	if (l==r) return;
	add(x,left[x]);add(x,right[x]);
	int mid=(l+r)/2;
	link(left[x],l,mid);link(right[x],mid+1,r);
}
void insert(int x,int l,int r,int a,int b,int id){
	if (a>b) return;
	if (l==a&&r==b){
		add(id,x);
		return;
	}
	int mid=(l+r)/2;
	if (b<=mid) insert(left[x],l,mid,a,b,id);
	else if (a>mid) insert(right[x],mid+1,r,a,b,id);
	else{
		insert(left[x],l,mid,a,mid,id);
		insert(right[x],mid+1,r,mid+1,b,id);
	}
}
void ins(int id,int x,/*int y,*/int ans){
	int le,ri;
	int l,r,mid;
	l=x;r=cnt;
	while (l<r){
		mid=(l+r+1)/2;
		if (c[mid]-c[x]<ans) l=mid;else r=mid-1;
	}
	ri=l;
	l=1;r=x;
	while (l<r){
		mid=(l+r)/2;
		if (c[x]-c[mid]<ans) r=mid;else l=mid+1;
	}
	le=l;
	insert(root,1,cnt,le,x-1,id);
	insert(root,1,cnt,x+1,ri,id);
	/*if (le<=y&&y<=ri){
		
	}
	else insert(root,1,cnt,)*/
}
void tarjan(int x){
	bz[x]=1;
	dfn[x]=low[x]=++euler;
	sta[++top]=x;
	pd[x]=1;
	int t=h[x];
	while (t){
		if (!bz[go[t]]){
			tarjan(go[t]);
			low[x]=min(low[x],low[go[t]]);
		}
		else if (pd[go[t]]) low[x]=min(low[x],dfn[go[t]]);
		t=nxt[t];
	}
	if (dfn[x]==low[x]){
		sum++;
		do{
			pd[sta[top]]=0;
			belong[sta[top]]=sum;
			top--;
		}while (sta[top+1]!=x);
	}
}
bool check(int ans){
	tot=0;
	fo(i,1,num) h[i]=0;
	link(root,1,cnt);
	fo(i,1,n){
		add(leaf[b[i]],i*2-1);
		add(leaf[a[i]],i*2);
		ins(i*2-1,a[i],ans);
		ins(i*2,b[i],ans);
	}
	top=euler=sum=0;
	fo(i,1,num) bz[i]=pd[i]=0;
	fo(i,1,num)
		if (!bz[i]) tarjan(i);
	fo(i,1,n)
		if (belong[i*2-1]==belong[i*2]) return 0;
	return 1;
}
int main(){
	//freopen("a.in","r",stdin);freopen("a.out","w",stdout);
	scanf("%d",&n);
	fo(i,1,n){
		scanf("%d%d",&a[i],&b[i]);
		d[i*2-1].x=a[i];
		d[i*2-1].ca=0;
		d[i*2].x=b[i];
		d[i*2].ca=1;
		d[i*2-1].id=d[i*2].id=i;
		//c[i*2-1]=a[i];c[i*2]=b[i];
	}
	/*sort(c+1,c+2*n+1);
	cnt=unique(c+1,c+2*n+1)-c-1;
	fo(i,1,n){
		a[i]=lower_bound(c+1,c+cnt+1,a[i])-c;
		b[i]=lower_bound(c+1,c+cnt+1,b[i])-c;
	}*/
	sort(d+1,d+2*n+1);
	fo(i,1,2*n){
		if (d[i].ca==0) a[d[i].id]=i;else b[d[i].id]=i;
		c[i]=d[i].x;
	}
	cnt=2*n;
	tot=2*n;
	build(root,1,cnt);
	num=tot;
	l=0;r=1000000000;
	while (l<r){
		mid=(l+r+1)/2;
		if (check(mid)) l=mid;else r=mid-1;
	}
	printf("%d\n",l);
	//printf("%d\n",check(4));
}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
#include<limits.h>
#include<stdio.h>
#include<cstring>
#include<string>
using namespace  std;
typedef long long ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define fi first
#define se second
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
// #define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element)  (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
typedef map<ll,ll> m64;
const int LIM = 1e5+5, MOD =  1e9;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
ll gcd(ll a, ll b) { if(b == 0) return a; return gcd(b, a % b); }
ll mod=998244353;
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }


int main()
{
	fast;
	string s;
	cin>>s;
	ll ans=0;
	m64 m;
	for (ll i=s.length()-1;i>=0;i--)
	{
		ll po=fastpowMOD(10,s.length()-i-1,2019);
		ans=(ans+(s[i]-'0')*po)%2019;
		m[ans]++;
	}
	ll fi=0;
	for (auto x:m)
	{
		fi+=(x.se*(x.se-1)/2);
	}
	fi+=m[0];
	cout<<fi;
}



Measured memory_bytes: 3744
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
using namespace std;

// 最大公約数を求める関数
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

// 最小公倍数を求める関数
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

int main() {

	int N, X;
	cin >> N >> X;

	vector<int> x(N, 0);
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}

	x.push_back(X);

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

	int d = x[1] - x[0];
	int d_gcd = d;

	for (int i = 1; i < N; i++) {
		d = x[i + 1] - x[i];
		d_gcd = gcd(d, d_gcd);
	}

	cout << d_gcd << endl;

	return 0;
}



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


int main(void){
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(abs(c-a)<=d||(abs(a-b)<=d&&abs(b-c)<=d)){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}

}


Measured memory_bytes: 128
<?php
$n = trim(fgets(STDIN));
$nums = explode(" ", trim(fgets(STDIN)));

$array = array_fill(1, $n, 0);

foreach ($nums as $value) {
	$array[$value] +=  1;
}

$ans =  0;

foreach ($array as $key => $value) {
	$ans += $key * $value;
}

$q = trim(fgets(STDIN));

$ans_array = [];

for($i=0; $i<$q; $i++){
	list($b, $c) = explode(" ", trim(fgets(STDIN)));
	$sa = $c-$b;
	$kazu = $array[$b];
	$array[$c] += $array[$b];
	$array[$b] = 0;
	$ans += $sa * $kazu;
	$ans_array[] = $ans;
}


foreach ($ans_array as $value) {
	echo $value . "\n";
}

Measured memory_bytes: 30916
X, Y = map(int, input().split())

if Y%2 != 0:
    print("No")
else:
    flag = False
    for x in range(1, X+1):
        leg1 = x*2 + (X-x)*4
        leg2 = x*4 + (X-x)*2
        if leg1 == Y or leg2 == Y:
            flag = True
            break
    if flag:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 9212
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main(){
	int N, Q;
	while(cin >> N >> Q){
		long long res = 0;
		vector<long long> a(2*N), dif(2*N);
		for(auto& t : a) cin >> t;
		for(int i=0;i<2*N;i++){
			res += a[i];
			cin >> dif[i];
			dif[i] -= a[i];
		}
		vector<pair<long long, int>> v;
		for(int i=1;i<2*N-1;i++){
			v.emplace_back(dif[i], i);
		}
		sort(v.rbegin(), v.rend());
		using Data = pair<long long, pair<int,int>>;
		priority_queue<Data> no_use;
		priority_queue<Data, vector<Data>, greater<Data>> use;
		vector<int> type(2*N, 0);
		vector<int> update(2*N, -1);
		vector<int> typeCnt(2, 0);
		typeCnt[0] = 2*N-2;
		for(int i=0;i+1<v.size();i+=2){
			if(v[i].first + v[i+1].first >= 0){
				res += v[i].first + v[i+1].first;
				type[v[i].second] = 1;
				type[v[i+1].second] = 1;
				typeCnt[0] -= 2;
				typeCnt[1] += 2;
			}
		}
		for(int i=1;i<2*N-1;i++){
			if(type[i]==0) no_use.emplace(dif[i], make_pair(i, -1));
			if(type[i]==1) use.emplace(dif[i], make_pair(i, -1));
		}
		auto removeOld = [&](auto& qu, int useType){
			while(!qu.empty()){
				auto data = qu.top();
				auto idx = data.second.first;
				if(type[idx] == useType && update[idx] == data.second.second) break;
				qu.pop();
			}
		};
		auto removeOldUse = [&](){ removeOld(use, 1); };
		auto removeOldNoUse = [&](){ removeOld(no_use, 0); };
		for(int i=0;i<Q;i++){
			long long p, x, y; cin >> p >> x >> y;
			--p;
			res += x - a[p];
			if(0 < p && p < 2*N-1){
				if(type[p] == 1){
					res += y - x - dif[p];
					use.emplace(y-x, make_pair(p, i));
				} else {
					no_use.emplace(y-x, make_pair(p, i));
				}
			}
			a[p] = x;
			dif[p] = y - x;
			update[p] = i;
			if(0 < p && p < 2*N-1){
				removeOldUse();
				removeOldNoUse();
				if(typeCnt[0] > 0 && typeCnt[1] > 0 && use.top().first < no_use.top().first){
					auto d1 = use.top(); use.pop();
					auto d2 = no_use.top(); no_use.pop();
					res += d2.first - d1.first;
					use.push(d2);
					no_use.push(d1);
					type[d2.second.first] = 1;
					type[d1.second.first] = 0;
				}
				if(typeCnt[1] > 0){
					removeOldUse();
					auto d1 = use.top(); use.pop();
					removeOldUse();
					auto d2 = use.top(); use.pop();
					if(d1.first + d2.first < 0){
						res -= d1.first + d2.first;
						type[d1.second.first] = 0;
						type[d2.second.first] = 0;
						typeCnt[0] += 2;
						typeCnt[1] -= 2;
						no_use.emplace(d1);
						no_use.emplace(d2);
					} else {
						use.emplace(d1);
						use.emplace(d2);
					}
				}
				if(typeCnt[0] > 0){
					removeOldNoUse();
					auto d1 = no_use.top(); no_use.pop();
					removeOldNoUse();
					auto d2 = no_use.top(); no_use.pop();
					if(d1.first + d2.first >= 0){
						res += d1.first + d2.first;
						type[d1.second.first] = 1;
						type[d2.second.first] = 1;
						typeCnt[0] -= 2;
						typeCnt[1] += 2;
						use.emplace(d1);
						use.emplace(d2);
					} else {
						no_use.emplace(d1);
						no_use.emplace(d2);
					}
				}
			}
			cout << res << endl;
		}
	}
}


Measured memory_bytes: 21996