akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int a,b[4];
    cin>>a;
	b[3] = (a % 10); a /= 10;
	b[2] = (a % 10); a /= 10;
	b[1] = (a % 10); a /= 10;
	b[0] = (a % 10); a /= 10;
                if( (b[0]+b[1]+b[2]+b[3])==7){
                    cout<<b[0]<<"+"<<b[1]<<"+"<<b[2]<<"+"<<b[3]<<"="<<7<<endl;
                }
                else if( (b[0]+b[1]+b[2]-b[3])==7){
                    cout<<b[0]<<"+"<<b[1]<<"+"<<b[2]<<"-"<<b[3]<<"="<<7<<endl;
                }
                else if((b[0]+b[1]-b[2]+b[3])==7){
                    cout<<b[0]<<"+"<<b[1]<<"-"<<b[2]<<"+"<<b[3]<<"="<<7<<endl;
                }
                else if((b[0]+b[1]-b[2]-b[3])==7){
                    cout<<b[0]<<"+"<<b[1]<<"-"<<b[2]<<"-"<<b[3]<<"="<<7<<endl;
                }
                else if((b[0]-b[1]+b[2]+b[3])==7){
                    cout<<b[0]<<"-"<<b[1]<<"+"<<b[2]<<"+"<<b[3]<<"="<<7<<endl;
                }
                else if((b[0]-b[1]+b[2]-b[3])==7){
                    cout<<b[0]<<"-"<<b[1]<<"+"<<b[2]<<"-"<<b[3]<<"="<<7<<endl;
                }
                else if((b[0]-b[1]-b[2]+b[3])==7){
                    cout<<b[0]<<"-"<<b[1]<<"-"<<b[2]<<"+"<<b[3]<<"="<<7<<endl;
                }
                else if((b[0]-b[1]-b[2]-b[3])==7){
                    cout<<b[0]<<"-"<<b[1]<<"-"<<b[2]<<"-"<<b[3]<<"="<<7<<endl;
                }
    
}

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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

typedef long long ll;
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b;
  
  c = 2*b-a;
  printf("%d\n", c);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define KIND 26

int D;
int c[KIND];
int s[400][KIND];
Int last[KIND];

Int calc_score(vector<Int> t) {
    Int score = 0;
    fill(last, last + KIND, -1);
    for (int d = 0; d < D; d++) {
        score += s[d][t[d]];
        last[t[d]] = d;
        for (int i = 0; i < KIND; i++) {
            score -= c[i] * (d - last[i]);
        }
        // cout << score << endl;
    }
    return score;
}


int main() {
    cin >> D;
    for (int i = 0; i < KIND; i++) {
        cin >> c[i];
    }
    for (Int d = 0; d < D; d++) {
        for (Int i = 0; i < KIND; i++) {
            cin >> s[d][i];
        }
    }
    vector<Int> t(D);
    for (auto &elem : t) {
        cin >> elem;
        elem--;
    }

    // cout << score(t) << endl;
    Int current_score = calc_score(t);

    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
        int d, q;
        cin >> d >> q;
        d--, q--;
        int old = t[d];
        t[d] = q;
        Int new_score = calc_score(t);
        cout << new_score << endl;
/*        if (new_score < current_score) {
            t[d] = old;    
        }
        else {
            current_score = new_score;
            }*/
        current_score = new_score;
    }
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(){
    
    double x1,x2,x3,y1,y2,y3;
    double px,py,r;
    int n,i;
    
    scanf("%d",&n);
    
    for (i=0; i<n; i++) {
        scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
        px = ((y2 - y3)*(x1*x1 + y1*y1) + (y3 - y1)*(x2*x2 + y2*y2) + (y1 - y2)*(x3*x3 + y3*y3))/(2*(x1*(y2 - y3) + x2*(y3 - y1) + x3*(y1 - y2)));
        py = ((x2 - x3)*(x1*x1 + y1*y1) + (x3 - x1)*(x2*x2 + y2*y2) + (x1 - x2)*(x3*x3 + y3*y3))/(2*(y1*(x2 - x3) + y2*(x3 - x1) + y3*(x1 - x2)));
        r=sqrt((x1-px)*(x1-px)+(y1-py)*(y1-py));
        printf("%.3f %.3f %.3f\n",px,py,r);
        
    }
    
    
    return 0;
}

Measured memory_bytes: 664
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int N = 1005;
const int MOD = 1e9+7;
vector < vector < int > > DP(N + 5, vector < int > (N + 5, 0));
vector < vector < int > > T(N + 5, vector < int > (N + 5, 0));
int add(int a, int b) {
  a += b;
  if (a >= MOD) {
    a -= MOD;
  }
  return a;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char c;
      cin >> c;
      if (c == '#') T[i][j] = -1;
    }
  }
  DP[1][1] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (T[i][j] == -1 || i == 1 && j == 1) continue;
      DP[i][j] = add(DP[i - 1][j], DP[i][j - 1]);
    }
  }
  cout << DP[n][m] << "\n";
  return 0;
}


Measured memory_bytes: 8320
#include "bits/stdc++.h"
using namespace std ;

class A{
public:
	string s; 
	int c ;
	int id ;
};

class order{
public:
	bool operator()( A a , A b  ){
		if( a.s < b.s ) return true ;
		else if( a.s == b.s){
			if( a.c > b.c ) return true ;
			else return false ;
		}
		else{
			return false ;
		}
	}
};

int main(){
	int n  , x ;
	vector < A > p ;
	string s ; 
	cin >> n ;
	for( int  i  = 0 ; i < n ; i++ ){
		cin >> s >> x ;
		A temp ;
		temp.s = s ;
		temp.c = x ;
		temp.id = i+1 ;
		p.emplace_back(temp);
	}
	sort(p.begin(), p.end() , order());
	for( int i = 0 ; i < n ; i++ ){
		cout << p[i].id << endl ;
	}
	return 0 ;
}

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

int n;
string s;
int posa[3005], posb[3005], m[6005];

string dp[6005];

int main() {
	cin >> n >> s;
	int cta = 0, ctb = 0;
	for (int i = 0; i < 2*n; ++i) {
		if (s[i] == 'a') {
			posa[cta] = i;
			cta++;
		} if (s[i] == 'b') {
			posb[ctb] = i;
			ctb++;
		}
	}
	for (int i = 0; i < n; ++i) {
		m[posa[i]] = posb[i];
		m[posb[i]] = posa[i];
	}

	for (int i = 2*n; i >= 0; --i) {
		if (i == 2*n) {
			dp[i] = "";
			continue;
		}
		if (m[i] < i) {
			dp[i] = dp[i+1];
			continue;
		}
		dp[i] = dp[i+1];
		if (s[i] == 'a') {
			int k = m[i];
			dp[i] = max(dp[i], "ab" + dp[k+1]);
			continue;
		}
		bool c[6005];
		memset(c, 0, sizeof(c));
		c[i] = c[m[i]] = 1;
		int r = m[i];
		int l = i;
		while (true) {
			if (l > r)
				break;
			if (c[l]) {
				l++;
				continue;
			}
			if (s[l] == 'b') {
				c[l] = c[m[l]] = 1;
				r = m[l];
			}
			l++;
		}
		string res = "";
		for (int j = 0; j < 2*n; ++j)
			if (c[j])
				res += s[j];
		res += dp[l];
		dp[i] = max(dp[i], res);
	}

	cout << dp[0] << endl;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

template< typename DATA >
class SegmentTreeR {
private:
	int size__;
	vector< DATA > data, adds;
	
	inline int left_t(int k) { return (k << 1) + 1; }
	inline int right_t(int k) { return (k << 1) + 2; }
	inline int center(int l, int r) { return (l + r) >> 1; }
	
private:
	void rangeAdd(int a, int b, DATA x, int k, int l, int r) {
		if (r <= a || b <= l) return;
		
		if (a <= l && r <= b) {
			adds[k] += x;
			return;
		}
		
		data[k] += x * (min(r, b) - max(l, a));
		rangeAdd(a, b, x, left_t(k), l, center(l, r));
		rangeAdd(a, b, x, right_t(k), center(l, r), r);
	}
	
	DATA query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return 0;
		if (a <= l && r <= b) return data[k] + adds[k] * (r - l);
		return query(a, b, left_t(k), l, center(l, r))
				+ query(a, b, right_t(k), center(l, r), r)
				+ adds[k] * (min(r, b) - max(l, a));
	}
	
public:
	SegmentTreeR() {}
	
	SegmentTreeR(int n, DATA ini, DATA aini) {
		for (size__ = 1; size__ < n; size__ <<= 1);
		data.assign((size__ << 1) - 1, ini);
		adds.assign((size__ << 1) - 1, aini);
	}
	
	void rangeAdd(int a, int b, DATA x) { rangeAdd(a, b, x, 0, 0, size__); }
	
	DATA query(int a, int b) { return query(a, b, 0, 0, size__); }
	
	int size() { return size__; }
};

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

    vector<vector<int>> adj(N, vector<int>());
    for_(i,0,N-1) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        if (u > v) swap(u, v);
        adj[u].push_back(v);
    }

    SegmentTreeR<lint> seg(N + 10, 0, 0);
    for_(v,0,N) {
        seg.rangeAdd(v, N, 1);
        for (int x : adj[v]) seg.rangeAdd(x, N, -1);
    }

    lint ans = 0;
    for_(v,0,N) {
        ans += seg.query(v, N);
        seg.rangeAdd(v, N, -1);
        for (int x : adj[v]) seg.rangeAdd(x, N, 1);
    }

    cout << ans << endl;
}

Measured memory_bytes: 22472
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class SearchCombination
    {
        readonly int n, target, len;

        int count;

        public SearchCombination(int n, int s)
        {
            this.n = n;
            target = s;

            len = Math.Min(s, 9);
        }

        public int Count()
        {
            count = 0;
            DFS(0, 0, 0);
            return count;
        }

        private void DFS(int depth, int cur, int sum)
        {
            if (depth == n)
            {
                if (sum == target) count++;
                return;
            }

            for (int i = cur; i <= len; i++)
            {
                DFS(depth + 1, i + 1, sum + i);
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                string[] input = Console.ReadLine().Split(' ');

                int n = int.Parse(input[0]);
                int s = int.Parse(input[1]);

                if (n == 0 && s == 0) break;

                SearchCombination SC = new SearchCombination(n, s);

                sb.AppendLine(SC.Count().ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9064
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


template<typename S, S op(S, S)>
struct Doubling {
    vector<vector<S>> v;

    Doubling(const vector<S>& step1, ll p){
        const auto n = step1.size();
        v.resize(p);
        v.at(0) = step1;
        for(ll i = 1; i < p; ++i){
            v.at(i).resize(n);
            for(ll j = 0; j < n; ++j){
                const auto& x = v.at(i - 1).at(j);
                const auto& y = v.at(i - 1).at(x.index);
                v.at(i).at(j) = op(x, y);
            }
        }
    }

    S query(S init, ll nstep){
        S ret = init;
        REP(i, v.size()){
            if((nstep >> i) & 1){
                ret = op(ret, v.at(i).at(ret.index));
            }
        }
        return ret;
    }
};

struct S{ ll sum, index; };
S op(S x, S y){ return S{x.sum + y.sum, y.index }; }

int main(){
    ll n, x, m;
    cin >> n >> x >> m;

    vector<S> step1(m);
    REP(i, m){
        step1.at(i) = {i, (i * i) % m};
    }

    Doubling<S, op> dbl(step1, 40);

    const auto ans = dbl.query(S{0, x}, n);
    cout << ans.sum << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N; cin>>N;
	vector<ll> A(N*3);
	rep(i,N*3) cin>>A[i];
	sort(A.bg,A.ed,greater<ll>());
	ll ans=0;
	for(int i=1;i<=2*N-1;i+=2){
		ans+=A[i];
	}
	cout<<ans;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

#define INF 1<<29

template <typename T>
struct MaxFlow {
  struct edge { int to, rev; T cap; };

  typedef vector<edge> Edges;
  vector<Edges> G;
  int V;
  vector<int> level, iter;
  
  MaxFlow(int V) : V(V) { G.resize(V); }

  void add_edge(int from, int to, T cap) {
    G[from].push_back((edge){to, (int)G[to].size(), cap});
    G[to].push_back((edge){from, (int)G[from].size()-1, 0});
  }

  void bfs(int source) {
    level.assign(V, -1);
    queue<int> que;
    que.push(source);
    level[source] = 0;
    while (!que.empty()) {
      int v = que.front(); que.pop();
      for (int i = 0; i < (int)G[v].size(); i++) {
	edge &e = G[v][i];
	if (e.cap > 0 && level[e.to] < 0) {
	  level[e.to] = level[v] + 1;
	  que.push(e.to);
	}
      }
    }
  }

  T dfs(int v, int sink, T flow) {
    if (v == sink) return flow;
    for (int &i = iter[v]; i < (int)G[v].size(); i++) {
      edge &e = G[v][i];
      if (e.cap > 0 && level[v] < level[e.to]) {
	T d = dfs(e.to, sink, min(e.cap, flow));
	if (d > 0) {
	  e.cap -= d;
	  G[e.to][e.rev].cap += d;
	  return d;
	}
      }
    }
    return 0;
  }

  T dinic(int source, int sink) {
    T flow = 0;
    while (true) {
      bfs(source);
      if (level[sink] < 0) return flow;
      iter.assign(V, 0);
      T f;
      while ((f = dfs(source, sink, INF)) > 0) {
	flow += f;
      }
    }
  }
};


int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int V, E;
  cin >> V >> E;
  MaxFlow<int> mf(V);
  REP(i, E) {
    int u, v, c;
    cin >> u >> v >> c;
    mf.add_edge(u, v, c);
  }
  cout << mf.dinic(0, V-1) << endl;  
  return 0;
}

Measured memory_bytes: 3264
#include <iostream>

int main(){
  std::string s;
   std::cin >> s;
  for(auto const&c:s){
    if(c == '1'){
    std::cout << '9';
    }else if(c == '9'){
    std::cout << '1';
    }else{
    std::cout << c;
    }
  }
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

using Weight = int;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int s, int d, Weight w)
    : src(s), dst(d), weight(w) {
  }
};

using Edges  = vector<Edge>;
using Graph  = vector<Edges>;
using Array  = vector<Weight>;
using Matrix = vector<Array>;

void addEdge(Graph &g, int a, int b, Weight w = 1) {
  g[a].emplace_back(a, b, w);
  g[b].emplace_back(b, a, w);
}

void addArc(Graph &g, int a, int b, Weight w = 1) {
  g[a].emplace_back(a, b, w);
}

bool operator<(const Edge &e, const Edge &f) {
  return e.weight > f.weight;
}

pair<Weight, Edges> prim(const Graph &g, const int &r = 0) {
  Edges T;
  Weight total = 0;
  vi vs(g.size());
  priority_queue<Edge> q;
  q.emplace(-1, r, 0);
  while (q.size()) {
    Edge e = q.top();
    q.pop();
    if (vs[e.dst]) continue;
    vs[e.dst] = true;
    total += e.weight;
    if (e.src != -1) T.emplace_back(e);
    for (auto &f : g[e.dst]) {
      if (!vs[f.dst]) q.emplace(f);
    }
  }
  return mp(total, T);
}

void solve() {
  int n;
  cin >> n;
  vpii v(n), xs(n), ys(n);
  rep(i, n) {
    cin >> v[i].fi >> v[i].se;
    xs[i] = mp(v[i].fi, i);
    ys[i] = mp(v[i].se, i);
  }
  sort(all(xs)), sort(all(ys));
  Graph g(n);
  loop(i, 1, n) {
    addEdge(g, xs[i - 1].se, xs[i].se, abs(v[xs[i - 1].se].fi - v[xs[i].se].fi));
    addEdge(g, ys[i - 1].se, ys[i].se, abs(v[ys[i - 1].se].se - v[ys[i].se].se));
  }
  cout << prim(g).fi << endl;
}


Measured memory_bytes: 27924
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling, digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vpll path;
//***********//
ll gcd(ll x, ll y) {
	ll r;
	if (x < y) {
		swap(x, y);
	}
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
int main() { 
	cin >> N;
	ll T = 0, A = 0;
	for (i = 0; i < N; i++) {
		ll t, a;
		cin >> t >> a;
		ll p = t, q = a;
		while (T > p || A > q) {
			ll x = (T-1) / p+1;
			ll y = (A-1) / q+1;
			if (x >= y) {
				p *= x;
				q *= x;
			}
			else {
				p *= y;
				q *= y;
			}
		}
		T = p; A = q;
		//debug(T, A);
	}
	cout << T + A;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

std::string s;

ll rwpw(ll a, ll p = MOD-2){
	ll ret = 1ll;
	while(p){
		if(p%2){
			mul_mod(ret,a);
		}
		mul_mod(a,a);
		p /= 2;
	}
	return ret;
}

ll fc[2250816]={1ll},nv[2250816]={1ll};

ll c(int n, int k){
	ll ret = fc[n];
	mul_mod(ret,nv[k]);
	mul_mod(ret,nv[n-k]);
	return ret;
}

int main(void){
	int k,n,i;
	ll ans = 0ll,tmp;
	std::cin >> k;
	std::cin >> s;
	n = s.l_ength();
	for(i=1; i<=n+k; ++i){
		fc[i] = fc[i-1]*i%MOD;
		nv[i] = rwpw(fc[i]);
	}
	for(i=0; i<=k; ++i){
		tmp = c(n+i-1,i);
		mul_mod(tmp,rwpw(25ll,i));
		mul_mod(tmp,rwpw(26ll,k-i));
		add_mod(ans,tmp);
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 35616
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;

int main(){
  string t;cin>>t;
  rep(i,t.size()){
    if(t[i]=='?')t[i]='D';
  }
  cout<<t;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
 
using namespace std;
 
int gcd(int x, int y) {
    while (y) {
        int r = x % y;
        x = y;
        y = r;
    }
    return x;
}
 
int main() {
 
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    constexpr int A_MAX = 1000000;
 
    vector<int> min_factor(A_MAX);
    // q[n] = i where n = i * p^e, p = min_factor[n], p does not divide i. + 1);
    vector<int> q(A_MAX + 1, 1);
    vector<int> primes;
    for (int i = 2; i <= A_MAX; ++i) {
        min_factor[i] = i;
    }
    for (int i = 2; i <= A_MAX; ++i) {
        if (min_factor[i] == i) {
            primes.push_back(i);
        }
        for (int p : primes) {
            int n = i * p;
            if (n > A_MAX) {
                break;
            }
            min_factor[n] = p;
            if (p == min_factor[i]) {
                q[n] = q[i];
                break;
            } else {
                q[n] = i;
            }
        }
    }
 
    int N;
    cin >> N;
    vector<int> a(A_MAX + 1);
    int GCD = 0;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        ++a[A];
        GCD = gcd(GCD, A);
    }
 
    if (GCD > 1) {
        cout << "not coprime" << endl;
        return 0;
    }
 
    for (int n = A_MAX; n > 1; --n) {
        if (a[n] > 1) {
        	cout << "setwise coprime" << endl;
            return 0;
        }
        a[min_factor[n]] += a[n];
        a[q[n]] += a[n];
    }
    cout << "pairwise coprime" << endl;
 
    return 0;
}

Measured memory_bytes: 15532
#include <iostream>
#include <vector>
using namespace std;
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; }
const long long INF = 1LL<<60;
const long long MOD = 1e9 + 7;

vector<vector<char>> grid(1010, vector<char>(1010));
vector<vector<int>> path(1010, vector<int>(1010, 0));



int main(){
    int H, W;
    cin >> H >> W;
    
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++) cin >> grid[i][j];
    }
    
    path[0][0] = 1;
    
    for (int i = 0; i < H; i++){
        if (grid[i+1][0] == '#') continue;
        else path[i+1][0] = path[i][0];
    }
    
    for (int j = 0; j < W; j++){
        if (grid[0][j+1] == '#') continue;
        else path[0][j+1] = path[0][j];
    }
    
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            
            if (grid[i+1][j+1] == '#') continue;
            
            path[i+1][j+1] = (path[i+1][j] + path[i][j+1]) % MOD;
        }
    }
    
    cout << path[H-1][W-1] << endl;
    
}

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

int main() {

    string s;

    cin >> s;

    int g,p;

    g = p = 0;

    for(int i=0; i<s.size(); i++){
        p++;
        if(s[i] == 'g'){
            g++;
            p--;
        }
    }

    cout << (g - p)/2 << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	ll n,m;
	cin >> n >> m;
	if(2 * n >= m) cout << m / 2 << endl;
	else cout << (2 * n + m) / 4 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const ll B = 1000000007;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  int n = s.length();
  int m = t.length();
  ll key = 0, num = 0, C = 1;
  FOR(i,0,m){
    key = key * B + t[i];
    C *= B;
  }
  for(int i = 0; i < n; i++) {
    num = num * B + s[i];
    if(i >= m) {
      num -= C * s[i-m];
    }
    //cout << i - m + 1 << " " << key << " " << num << endl;
    if(key == num) {
      cout << i - m + 1 << endl;
    }
  }
  
}


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

#define ll long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int mod = 1e9 + 7;
const int MAX = 2e5 + 1;

ll a[MAX], sum[MAX];

void solve()
{
	int n;
	cin >> n;
	ll SUM = 0;
	for(int i = 1; i <= n; ++i)
	{
		cin >> a[i];
		SUM += a[i];
	}
	ll run = 0;
	for(int i = 1; i <= n; ++i)
	{
		run += a[i];
		sum[i] = (SUM - run) % mod;
	}
	ll ans = 0;
	for(int i = 1; i < n; ++i)
	{
		ans += (a[i] * sum[i]) % mod;
		ans %= mod;
	}
	cout << (ans % mod);
}

int main()
{
	IOS
	int t = 1;
	//cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 6776
import java.util.Scanner;

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

		int n = sc.nextInt();
		int d = sc.nextInt();

		int scope = d * 2 + 1;
		int num = n % scope == 0 ? n / scope : n / scope + 1;

		System.out.println(num);

		sc.close();
	}

}


Measured memory_bytes: 21588
//$ node B.js < B.txt
function Main(input) {
  input = input.split('\n') // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input[0].split(' ')
  a = Number(input[0])
  b = Number(input[1])
  console.log(b <= a*500 ? 'Yes' : 'No')
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int a[100010], b[100010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, M;
    cin >> A >> B >> M;
    int ans = INF;
    rep(i, A) cin >> a[i];
    rep(i, B) cin >> b[i];
    rep(i, M) {
        int x, y, c;
        cin >> x >> y >> c;
        x--; y--;
        ans = min(ans, a[x] + b[y] - c);
    }
    sort(a, a + A);
    sort(b, b  + B);
    ans = min(ans, a[0] + b[0]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n = ii()
    L = [''.join(sorted(list(input()))) for _ in range(n)]
    L.sort()
    ans = 0
    for k, g in groupby(L):
        size = len(list(g))
        ans += size * (size-1) // 2
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 11084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> Wc(N+1),Rc(N+1);
    rep(i,N){
        Rc[i+1] = Rc[i];
        Wc[i+1] = Wc[i];
        if(S[i]=='R'){
            Rc[i+1]++;
        }else{
            Wc[i+1]++;
        }
    }
    ll ans = INF;
    rep(i,N+1){
        ans = min(ans,(ll)max(Wc[i],Rc[N]-Rc[i]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5152
X = int(input())

N = []
for i in range(123):
    N.append(i**5)

for i in reversed(range(123)):
    for j in reversed(range(i)):
        if X == N[i] - N[j]:
            print(i, j)
            break
        if X == N[i] + N[j]:
            print(i, j * -1)
            break

Measured memory_bytes: 9196
#include<bits/stdc++.h>
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {

    jaldi

    string s;
    cin>>s;
    int n = s.length();
    if(s[n-1]=='s') {
        s+="es";
    }
    else {
        s+='s';
    }
    cout<<s<<'\n';
}


Measured memory_bytes: 3644
#include<stdio.h>
#define N 100

int main(){
  int n, a[N], f = 1, v, cnt = 0;
  int i;
  
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
  }

  while(f){
    f = 0;
    for(i=n-1;i>=1;i--){
      if(a[i] < a[i-1]){
	v = a[i];
	a[i] = a[i-1];
	a[i-1] = v;
	f = 1;
	cnt++;
      }
    }
  }

  for(i=0;i<n;i++){
    if(i == n-1) printf("%d\n", a[i]);
    else printf("%d ", a[i]);
  }
  printf("%d\n", cnt);
  
  return 0;
}



Measured memory_bytes: 2084
from sys import stdin


class Main:

    @staticmethod
    def main():
        n = stdin.readline()
        ls = [int(x) for x in stdin.readline().strip().split()]
        ls.sort(reverse=True)
        if ls[0] < sum(ls[1:]):
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    Main.main()


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque> 
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype> 
using namespace std;

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A<=C && D<=B) {
        cout << D-C << endl;
        return 0;
    }
    else if (C<A && B<D) {
        cout << B-A << endl;
        return 0;
    }
    else if ((B>C && D>B)||(A<C && C<B)) {
        cout << B-C << endl;
        return 0;
    }
    else if ((A<D && C<A)||(A<D && D<B)) {
        cout << D-A << endl;
        return 0;
    }
    else if (B<=C || D<=A) cout << 0 << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int N,A,a;
    cin >> N >> A;
    a = N % 500;

    if(a <= A){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# ABC070D - Transit Tree Path
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def dfs(v: int, p: int) -> None:
    d = dist[v]
    for u, c in G[v]:  # search vertices available from v recursively
        if u != p:  # p: parent
            dist[u] += d + c  # dist(K, v) + dist(v, u) == d + c
            dfs(u, v)


def main():
    global G, dist
    N = int(input())
    E = tuple(tuple(map(int, input().split())) for _ in range(N - 1))
    Q, K = tuple(map(int, input().split()))
    X = tuple(tuple(map(int, input().split())) for _ in range(Q))
    G = [[] for _ in range(N + 1)]  # graph, N+1: 1-idx
    for v, u, c in E:  # construct a graph
        G[v] += [(u, c)]
        G[u] += [(v, c)]
    dist = [0] * (N + 1)  # distance from vertex K
    dfs(K, -1)
    ans = [dist[x] + dist[y] for x, y in X]
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()

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

int main(){
    int n;cin>>n;
    string a,b,c;cin>>a>>b>>c;
    int acc = 0;
    for (int i=0;i<n;i++){
        vector<char> letters;
        letters.push_back(a[i]);
        letters.push_back(b[i]);
        letters.push_back(c[i]);

        sort(letters.begin(), letters.end());
        letters.erase(unique(letters.begin(), letters.end()), letters.end());
        if (letters.size() == 2){
            acc++;
        } else if (letters.size() == 3){
            acc += 2;
        }
    }
    cout << acc << endl;
    return 0;


}

Measured memory_bytes: 256
n,k=map(int,input().split())
ro,se,pe=map(int,input().split())
t=input()
cnt=0
x=[]
for i in range(n):
    if(i>=k):
        if(t[i]=='r' and x[i-k]!='p'):
            cnt=cnt+pe
            x.append('p')
        elif(t[i]=='s' and x[i-k]!='r'):
            cnt=cnt+ro
            x.append('r')
        elif(t[i]=='p' and x[i-k]!='s'):
            cnt=cnt+se
            x.append('s')
        else:
            x.append('n')
    else:
        if(t[i]=='r'):
            cnt=cnt+pe
            x.append('p')
        elif(t[i]=='s'):
            cnt=cnt+ro
            x.append('r')
        elif(t[i]=='p'):
            cnt=cnt+se
            x.append('s')
        else:
            x.append('n')
print(cnt)


Measured memory_bytes: 4212
# https://atcoder.jp/contests/arc098/tasks/arc098_a

n = gets.to_i
dirs = gets.chomp.chars

ws = dirs.count('W')
es = dirs.count('E')

l_ws = Array.new(n)
r_es = Array.new(n)
costs = Array.new(n)

current_lws = 0
current_res = es

dirs.each_with_index do |c, idx|
  current_res -= 1 if c == 'E'
  l_ws[idx] = current_lws
  r_es[idx] = current_res
  current_lws += 1 if c == 'W'
  costs[idx] = l_ws[idx] + r_es[idx]
end

puts costs.sort[0]

Measured memory_bytes: 39188
#include<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int h,r;
	cin>>h>>r;
	if(h+r==0) cout<<0<<endl;
	else if(h+r>0) cout<<1<<endl;
	else if(h+r<0) cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!

// 1 way is to find compute all the sorted permutations and find the 
// positions of the current permutation.

int _find(string &str){
    int x=0;
    int ans=0;
    for(const char &ch : str){
        if(ch=='I'){
            x++;
        }
        else{
            x--;
        }
        // cout<<x<<" ";
        ans=max(ans,x);
    }
    return ans;
}

void solve(){
    int n;
    cin>>n;
    string str;
    cin>>str;
    cout<<_find(str);
}

int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <memory>
#include <string>
#include <vector>

struct node {
  int key;
  std::weak_ptr<node> parent;
  std::shared_ptr<node> left;
  std::shared_ptr<node> right;
  node(int k) : key(k), left(nullptr), right(nullptr) {};
};

class bst {
private:
  std::shared_ptr<node> root;
  void r_inorder(std::shared_ptr<node> n);
  void r_preorder(std::shared_ptr<node> n);
public:
  bst() : root(nullptr) {};
  void insert(int v);
  bool find(int k);
  void print();
};

void bst::insert(int k) {
  std::shared_ptr<node> y = nullptr;
  std::shared_ptr<node> x = root;
  std::shared_ptr<node> z(new node(k));
  while (x != nullptr) {
    y = x;
    if (z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  z->parent = y;
  if (y == nullptr)
    root = z;
  else if (z->key < y->key)
    y->left = z;
  else
    y->right = z;
}

bool bst::find(int k) {
  std::shared_ptr<node> n = root;
  while (n != nullptr) {
    if (n->key == k)
      return true;
    if (n->key > k)
      n = n->left;
    else
      n = n->right;
  }
  return false;
}

void bst::r_inorder(std::shared_ptr<node> n) {
  if (n == nullptr)
    return;
  r_inorder(n->left);
  std::cout << " " << n->key;
  r_inorder(n->right);
}

void bst::r_preorder(std::shared_ptr<node> n) {
  if (n == nullptr)
    return;
  std::cout << " " << n->key;
  r_preorder(n->left);
  r_preorder(n->right);
}

void bst::print() {
  r_inorder(root);
  std::cout << std::endl;
  r_preorder(root);
  std::cout << std::endl;
}

int main() {
  int n;
  std::cin >> n;
  bst tree;
  for (int i = 0; i < n; ++i) {
    std::string str;
    std::cin >> str;
    int k;
    switch (str[0]) {
    case 'i':
      std::cin >> k;
      tree.insert(k);
      break;
    case 'f':
      std::cin >> k;
      std::cout << (tree.find(k) ? "yes" : "no") << std::endl;
      break;
    case 'p':
      tree.print();
      break;
    default:
      break;
    }
  }
}

Measured memory_bytes: 40556
import math
 
N,D = map(int,input().split())
dot = [list(map(int,input().split())) for i in range(N)]
sum=0

for i in range(N):
    for j in range(i+1,N):
        tmp=0
        for k in range(D):
            tmp+=(dot[i][k]-dot[j][k])**2
        tmp=math.sqrt(tmp)
        if(float.is_integer(tmp)==True):sum+=1

print(sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int h, w, k; scanf("%d %d %d", &h, &w, &k);
	
	const int MOD = 1e9 + 7;
	std::vector<std::vector<int>> dp(h + 1, std::vector<int>(w, 0)); dp[0][0] = 1;
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < (1 << (w - 1)); j++) {
			bool f = false;
			for(int k = 0; k < w - 2; k++) {
				if((j >> k & 1) and (j >> (k + 1) & 1)) f = true;
			}
			if(f) continue;
			
			if(!(j & 1)) (dp[i + 1][0] += dp[i][0]) %= MOD;
			for(int k = 0; k < w - 1; k++) {
				if(j >> k & 1) {
					(dp[i + 1][k] += dp[i][k + 1]) %= MOD;
					(dp[i + 1][k + 1] += dp[i][k]) %= MOD;
				} else if(!(j >> (k + 1) & 1)) {
					(dp[i + 1][k + 1] += dp[i][k + 1]) %= MOD;
				}
			}
		}
	}
	
	printf("%d\n", dp[h][k - 1]);
	return 0;
}


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	int N=read(),W=read(),H=read();
	int x[N],y[N],h[N];

	int areaW[W+1]={0},areaH[H+1]={0};
	REP(i,N){
		x[i]=read();
		y[i]=read();
		h[i]=read();
	}

	REP(i,N){
		int xmin=max((int)0,x[i]-h[i]);
		int xmax=min(W,x[i]+h[i]);
		int ymin=max((int)0,y[i]-h[i]);
		int ymax=min(H,y[i]+h[i]);
		
		areaW[xmin]++;
		areaW[xmax]--;
		areaH[ymin]++;
		areaH[ymax]--;
	}
	int cntw=0,cnth=0;
	REP(i,W+1){
		cntw+=areaW[i];
		if(cntw<=0&&i!=W){
			break;
		}
		if(i==W){
			cout << "Yes" << endl;
			return 0;
		}
	}
	REP(i,H+1){
		cnth+=areaH[i];
		if(cnth<=0&&i!=H){
			break;
		}
		if(i==H){
			cout << "Yes" << endl;
			return 0;
		}
	}
	
	cout << "No" << endl;

}

Measured memory_bytes: 7048
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl
using namespace std;
int max_int = 2147483647;
int prime = 10e9+7;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;




signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    twovec(a,h,w);
    twovec(b,h,w);
    twovec(c,h,w);
    twovec(d,h,w);
    Vec(x,h);
    REP(i,h){
        cin >> x[i];
    }
    REP(i,h){
        int cnt = 0;
        REP(j,w){
            if(x[i][j] == '.'){
                cnt++;
                a[i][j] = cnt;
            }
            else{
                cnt = 0;
                a[i][j] = cnt;
            }
        }
    }
    REP(i,h){
        int cnt = 0;
        REP(j,w){
            if(x[i][w-1-j] == '.'){
                cnt++;
                b[i][w-1-j] = cnt;
            }
            else{
                cnt = 0;
                b[i][w-1-j] = cnt;
            }
        }
    }
    REP(i,w){
        int cnt = 0;
        REP(j,h){
            if(x[j][i] == '.'){
                cnt++;
                c[j][i] = cnt;
            }
            else{
                cnt = 0;
                c[j][i] = cnt;
            }
        }
    }
    REP(i,w){
        int cnt = 0;
        REP(j,h){
            if(x[h-1-j][i] == '.'){
                cnt++;
                d[h-1-j][i] = cnt;
            }
            else{
                cnt = 0;
                d[h-1-j][i] = cnt;
            }
        }
    }
    int ans = 0;
    REP(i,h){
        REP(j,w){
            ans = max(ans,a[i][j] + b[i][j] + c[i][j] + d[i][j]-3);
        }
    }
    print(ans);


    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

//key以上の初めてのitr
int nibul(auto a,auto b){return lower_bound(All(a),b) - a.begin();}
//key以下の最後のitr
int nibuu(auto a,auto b){return upper_bound(All(a),b) - a.begin()-1;}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 129920
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
  scanf("%d",&head);
  RI(tail...);
}
using namespace std;
typedef long long LL;
int main()
{
	int n;
	string str;
	cin >> n >> str;
	int len = min(n, (int)str.length());
	for(int i = 0; i < len; i++) {
		cout << str[i];
	}
	if(str.length() > n) {
		cout << "...";
	}
	cout << endl;
  return 0;
}


Measured memory_bytes: 3604
#include<vector>
#include<iostream>
#include<algorithm>
#include<tuple>
#include<string>
#include<bits/stdc++.h>
using namespace std;

void solve(){
    int X,ans,res;
    ans=1;
    vector<int> v;
    cin>>X;
    for(int i=0;i<=X;i++){
        v.push_back(0);
    }
    
    for(int i=2;i<=X;i++){
    int cnt=2;
    if(pow(i,2)>X)v[i]=0;
    else
    {while(v[i]<=X){
                     
        res=pow(i,cnt);
        if(res>X){
            break;
        }

        v[i]=res;
        cnt++;
    }
    }
    ans=max(ans,v[i]);
    }
    cout<<ans<<endl;

}

int main(){
    solve();
    return 0;
}

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

int main(void) {
    int n,c;
    cin >> n >> c;

    vector<vector<long>> d(c, vector<long>(c));
    for(auto &r: d)
        for(auto &c: r)
            cin >> c;

    vector<long> cntsum(3);
    vector<vector<long>> cnt(c, vector<long>(3));
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++) {
            int k = (i+j)%3;
            int t;
            cin >> t;
            t--;
            cntsum[k]++;
            cnt[t][k]++;
        }

    long res = 1e18;
    for(int c0=0; c0<c; c0++) {
        long r0 = 0;
        for(int i=0; i<c; i++)
            if(i != c0) r0 += cnt[i][0]*d[i][c0];

        for(int c1=0; c1<c; c1++) {
            if(c0 == c1) continue;

            long r1 = 0;
            for(int i=0; i<c; i++)
                if(i != c1) r1 += cnt[i][1]*d[i][c1];

            for(int c2=0; c2<c; c2++) {
                if(c2 == c0) continue;
                if(c2 == c1) continue;

                long r2 = 0;
                for(int i=0; i<c; i++)
                    if(i != c2) r2 += cnt[i][2]*d[i][c2];

                res = min(res, r0+r1+r2);
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int p[1000000];
  for(int i = 0 ; i < 1000000 ; i++)p[i] = i;
  p[0] = p[1] = 0;
  for(int i = 0 ; i*i < 1000000 ; i++){
    if(p[i])for(int j = i*2 ; j < 1000000 ; j += i){
	p[j] = 0;
      }
  }
  int t[10001] = {0};
  int s = 0;
  for(int i = 0 ; s < 10001 ; i++){
    if(p[i] != 0)t[s++] = p[i];
  }
  int n;

  while( cin >> n , n){
    int sum = 0;
    for(int i = 0 ; i < n ; i++){
      sum += t[i];
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 5112
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <cmath>
#include <sstream>
#include <numeric>

using namespace std;

int main(){
    
    long long n, j;
    long long mi = 10000000000000000;
    cin >> n;
    for(int i=0; i<5; i++){
        cin >> j;
        mi = min(mi, j);
    }
    long long ret = ceil(n / double(mi)) + 4;
    cout << ret << endl;
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

using namespace std;

typedef long long ll;

typedef pair<int,int> P1;
typedef pair<int,P1> P2;
const ll inf=100000000000000000;
struct edge{
	int to,cost;
};
struct pos{
	int to;
	ll cost;
};
struct pos2{
	int to,from;
	ll cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

#define MAX_N 1002
ll dp[100001];
ll dp2[100001];
vector<pos> vec[100001];
vector<int> vec2[100001];
int main() {
	int a,b;
	int c[5]={};
	rep(i,3){
		cin>>a>>b;
		c[a]++;
		c[b]++;
	}
	if(c[1]==3||c[2]==3||c[3]==3||c[4]==3){
		cout<<"NO"<<endl;
	}else{
		cout<<"YES"<<endl;
	}
	return 0;
}





Measured memory_bytes: 6400