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


public class Main {
	
	public static class Path implements Comparable<Path>{
		private int to,from,len;
		
		public Path(int f,int t,int l){
			from = f;
			to = t;
			len = l;
		}
		
		public int get_from(){
			return from;
		}
		
		public int get_to(){
			return to;
		}
		
		public int get_len(){
			return len;
		}
		
		public int compareTo(Path p){
			return this.get_len() - p.get_len(); 	
		}
		
		public String toString(){
			return "From " + from + ". To " + to + ". len " + len +".";
		}
	}

	static class UnionFind {
		final int[] tree;
		int num;

		public UnionFind(int n) {
			this.tree = new int[n];
			Arrays.fill(tree, -1);
			num = n;
		}

		// merge the set contains x and the set contains y
		void union(int x, int y) {
			x = root(x);
			y = root(y);
			if (x != y) {
				if (tree[x] < tree[y]) {
					x ^= y;
					y ^= x;
					x ^= y;
				}
				tree[x] += tree[y];
				tree[y] = x;
				num--;
			}
		}

		// decide if x and y belong to the same set
		boolean find(int x, int y) {
			return root(x) == root(y);
		}

		int root(int x) {
			return tree[x] < 0 ? x : (tree[x] = root(tree[x]));
		}

		// return size of the set contains x
		int size(int x) {
			return -tree[root(x)];
		}

		// return the number of sets
		int getNum() {
			return num;
		}
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n == 0){break;}
			int m = sc.nextInt();
			
			Queue<Path> queue = new PriorityQueue<Path>();
			
			for(int i = 0; i < m; i++){
				String strs[] = sc.next().split(",");
				queue.add(new Path(Integer.parseInt(strs[0]),Integer.parseInt(strs[1]),Integer.parseInt(strs[2])));
			}
			
			int sum = 0;
			UnionFind union = new UnionFind(n);
			
			while(union.num > 1){
				Path p = queue.poll();
				if(!union.find(p.get_from(), p.get_to())){
					union.union(p.get_to(), p.get_from());
					sum += p.get_len()/100-1;
				}
			}
			
			System.out.println(sum);
			
		}
	}
}

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


int main() {
  int N;
  cin>>N;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  cout<<vec.at(N/2)-vec.at(N/2-1)<<endl;
  
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

int main(){
    int n, k;
    cin >> n >> k;

    vector<ll> tree(n);
    rep(i, n) cin >> tree[i];

    sort(all(tree));

    ll min_val = MAX;
    rep(i, n-k+1){
        min_val = min(min_val, tree[i+k-1] - tree[i]);
    }

    cout << min_val << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){

    int n;
    cin >> n;

    ll L[87];
    L[0] = 2;
    L[1] = 1;
    for(int i = 2; i <= n ; i++){
        L[i] = L[i-1] + L[i-2];
    }
    cout << L[n] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <chrono>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = std::vector<int>;
using Vlli = std::vector<lli>;
using Wint = std::vector<Vint>;
using Wlli = std::vector<Vlli>;
using Vbool = std::vector<bool>;
using pii = std::pair<int, int>;
using pll = std::pair<lli, lli>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {std::make_pair(1, 0), std::make_pair(-1, 0), std::make_pair(0, 1), std::make_pair(0, -1)};
constexpr char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())



template <class T> inline int argmin(std::vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(std::vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



int main(void){
  int n; scanf("%d", &n);
  Vint A(n+2, 0); FOReq(i, 1, n) scanf("%d", &A[i]);
  lli sum = 0;
  REP(i, n+1) sum += abs(A.at(i+1) - A.at(i));
  FOReq(i, 1, n){
    // A_(i-1) ~ A_(i+1)
    int diff = abs(A[i+1]-A[i-1]) - abs(A[i]-A[i+1]) - abs(A[i]-A[i-1]);
    printf("%lld\n", sum + diff);
  }
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    int X = 100*N /108;
    if(N*100 %108) X += 1;
    if(X*1.08 < (N+1)) cout << X << endl;
    else  cout << ":(" << endl;
}   

Measured memory_bytes: 256
# n + 1 長の array を返す
def cumulative_sum(array)
  tmp = [0]
  previous = 0
  array.each { |num| tmp << previous += num }
  tmp
end

MOD = 998244353
n, k = gets.split.map(&:to_i)
sections = []
k.times do
  sections << gets.split.map(&:to_i)
end
memo = Array.new(n + 1, 0)
memo[0] = 1
(n - 1).times do |i|
  if n > 0
    memo[i] += memo[i - 1]
  end
  memo[i] %= MOD
  current = memo[i]
  walkable = n - i - 1
  sections.each do |a, b|
    next if a > walkable
    b = walkable if b > walkable
    memo[i + a] += current
    memo[i + b + 1] -= current
  end
end
puts memo[n - 1] % MOD


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li n;

    cin>>n;

    li ans=(n*(n+1))/2;

    li a=n/3,b=n/5,c=n/15;

    a= ((a*(a+1))/2)*3;

    b= ((b*(b+1))/2)*5;

    c= ((c*(c+1))/2)*15;

    cout<<ans-a-b+c;

    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

long max(long long int a,long long int b){
    if(a>b) return a;
    else return b;
}

int main(void){
    long long int n,w;
    long long int we[110],v[110],dp[110][101000];
    scanf("%lld %lld",&n,&w);
    for(int i=0;i<n;i++)scanf("%lld %lld",&we[i],&v[i]);
    
    for(int i=0;i<n;i++){
        for(int j=0;j<=w;j++){
            if(j>=we[i]){
                dp[i+1][j]=max(dp[i][j-we[i]]+v[i],dp[i][j]);
            }
            else dp[i+1][j]=dp[i][j];
        }
    }
    
    printf("%lld",dp[n][w]);
    return 0;
}

Measured memory_bytes: 80896
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    int N; cin >> N;
    vector<vector<int>> G(N);
    for (int i = 0; i < N - 1; i++) {
        int p, q; cin >> p >> q; p--, q--;
        G[p].push_back(q);
        G[q].push_back(p);
    }
    vector<int> leaf(N);
    auto recur0 = [&](auto&& recur0, int node, int prev) -> void {
        if (G[node].size() == 1) {
            leaf[node] = 1;
        }
        for (int next : G[node]) if (next != prev) {
            recur0(recur0, next, node);
            leaf[node] += leaf[next];
        }
    };
    recur0(recur0, 0, 0);
    int ans = 0;
    auto recur1 = [&](auto&& recur1, int node, int prev) -> int {
        int diffmax = 0;
        int diffmax2 = 0;
        for (int next : G[node]) if (next != prev) {
            int res = recur1(recur1, next, node);
            int diff = res - leaf[next];
            if (diffmax < diff) {
                diffmax2 = diffmax;
                diffmax = diff;
            } else if (diffmax2 < diff) {
                diffmax2 = diff;
            }
        }
        ans = max(ans, diffmax + diffmax2 + leaf[0]);
        int ret;
        if (G[node].size() == 1 && node != prev) {
            ret = 1;
        } else if (G[node].size() == 2) {
            ret = leaf[node] + diffmax + 1;
        } else {
            ret = leaf[node] + diffmax;
        }
        ans = max(ans, ret);
        return ret;
    };
    recur1(recur1, 0, 0);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 9324
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define ALL(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define for0(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=n-1;i>=0;i--)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
int ext_gcd(int a, int b, int & x, int & y) {
    //for finding modular inverse
    //if its return 1 ,then a has a mod inverse x mod b.
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = ext_gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

int main()

{
    IOS;
    //freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);
     int k;
     while(cin>>k){
            ll sum=0;
        for(int i=1;i<=k;i++)
        {
            for(int j=1;j<=k;j++){
                for(int o=1;o<=k;o++){
                    sum+=__gcd(i,__gcd(j,o));
                }
            }
        }
     cout<<sum<<endl;
     }

     return 0;

}
///Alhamdulillah


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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) {
        is >> x;
    }
    return is;
}

map<int, vector<int>> mp;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, m;
    cin >> n >> m;

    vector<pii> v;
    REP(i, n) {
        int a, b;
        cin >> a >> b;
        v.emplace_back(a, b);
    }

    sort(v.rbegin(), v.rend());
    for (const auto &p : v) {
        mp[p.first].push_back(p.second);
    }

    int cnt = 0;
    priority_queue<int, vector<int>, greater<int>> pq;
    for (int i = m; i >= 0; i--) {
        if (mp[i].size() == 0) {
            cnt++;
        } else {
            pq.push(mp[i][0]);

            int j = 1;
            for (; j < mp[i].size() and cnt > 0; j++, cnt--) {
                pq.push(mp[i][j]);
            }

            while (j < mp[i].size() and !pq.empty()) {
                auto val = pq.top();
                if (val < mp[i][j]) {
                    pq.pop();
                    pq.push(mp[i][j]);
                    j++;
                } else {
                    break;
                }
            }
        }
    }

    ll ans = 0;
    while (!pq.empty()) {
        ans += pq.top();
        pq.pop();
    }

    cout << ans << endl;

    // money, day

    /*
    sort(v.rbegin(), v.rend());

    ll ans = 0;
    int i = 0;
    for (int day = m; day >= 0; day--) {
        if (i >= v.size())
            break;
        while (v[i].first > day) {
            i++;
            if (i == v.size())
                break;
        }

        if (i == v.size())
            break;
        ans += v[i].second;
        i++;
    }

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


Measured memory_bytes: 12532
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r =
            new BufferedReader(new InputStreamReader(System.in), 1);
        String is = r.readLine();
        String[] sp = is.split(" ");
        if(sp.length > 3)
            return;
        int a = Integer.parseInt(sp[0]);
        int b = Integer.parseInt(sp[1]);
        int c = Integer.parseInt(sp[2]);
        if(a<b){
            if(b<c){
                System.out.println("Yes");
            }else
                System.out.println("No");
        }else
            System.out.println("No");
      }
}

Measured memory_bytes: 24460
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] L = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Array.Sort(L);
            int cnt = 0;
            for(int i = 0; i < n-2; i++)
            {
                for(int j = i + 1; j < n - 1; j++)
                {
                    for(int k = j + 1; k < n; k++)
                    {
                        if (L[i] == L[j] || L[i] == L[k] || L[j]==L[k]) continue;
                        if (L[i] + L[j] > L[k]) cnt++;
                    }
                }
            }
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 28296
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N;cin>>N;
  vector<ll> a(N);
  rep(i,N) cin>>a[i];

  // SORT(a);

  vector<ll> sum(N-1);
  sum[0] = a[0];
  rep(i,N-2){
    sum[i+1] = sum[i] + a[i+1];
  }
  ll s = sum[N-2] + a[N-1];
  // cout<<s<<endl;


  ll right, left;
  rep(i,N-1){
    sum[i] -= s - sum[i];
    sum[i] = abs(sum[i]);
  }

  SORT(sum);
  cout<<sum[0]<<endl;

}


Measured memory_bytes: 3328
import java.util.PriorityQueue

fun main(args : Array<String>) {
    val (X, Y, Z, K) = readLine()!!.split(" ").map { it.toLong() }
    val A = readLine()!!.split(" ").map { it.toLong() }.toMutableList()
    val B = readLine()!!.split(" ").map { it.toLong() }.toMutableList()
    val C = readLine()!!.split(" ").map { it.toLong() }.toMutableList()

    A.sortBy { it * -1 }
    B.sortBy { it * -1 }
    C.sortBy { it * -1 }

    class Candidate(val taste: Long, val x: Int, val y: Int, val z: Int) : Comparable<Candidate> {
        override fun compareTo(other: Candidate): Int {
            return (other.taste - this.taste).toInt()
        }
    }
    val priorityQueue = PriorityQueue<Candidate>()
    val set = mutableSetOf<Triple<Int, Int, Int>>()
    val topCandiate = Candidate(A[0] + B[0] + C[0], 0, 0, 0)
    priorityQueue.add(topCandiate)
    set.add(Triple(0,0, 0))

    var count = 0L
    while(true) {
        val ansI : Candidate = priorityQueue.poll()
        println(ansI.taste)
        count++
        if (count == K) {
            return
        }

        val newX = ansI.x + 1
        if (newX < X) {
            val ans = Triple(newX, ansI.y, ansI.z)
            val c = Candidate(A[newX] + B[ansI.y] + C[ansI.z], newX, ansI.y, ansI.z)
            if (!set.contains(ans)) {
                priorityQueue.add(c)
                set.add(ans)
            }
        }

        val newY = ansI.y + 1
        if (newY < Y) {
            val ans = Triple(ansI.x, newY, ansI.z)
            val c = Candidate(A[ansI.x] + B[newY] + C[ansI.z], ansI.x, newY, ansI.z)
            if (!set.contains(ans)) {
                priorityQueue.add(c)
                set.add(ans)
            }
        }

        val newZ = ansI.z + 1
        if (newZ < Z) {
            val ans = Triple(ansI.x, ansI.y, newZ)
            val c = Candidate(A[ansI.x] + B[ansI.y] + C[newZ], ansI.x, ansI.y, newZ)
            if (!set.contains(ans)) {
                priorityQueue.add(c)
                set.add(ans)
            }
        }
    }
}

Measured memory_bytes: 41552
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int INF = 1 << 30;
const int MAX = 100;
const int mod = 1000000007;
const double pi = 3.141592653589;

const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;

/* global variables */
vector< vector<int> > Adj(MAX, vector<int>(MAX, INF));
vector<int> color(MAX, WHITE);
vector<int> d(MAX, INF);
vector<int> p(MAX, -1);
int n;
int total_cost = 0;

/* function */
void prim();

/* main */
int main() {
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int a;
            cin >> a;
            if (a != -1)
                Adj[i][j] = a;
        }
    }

    prim();

    cout << total_cost << '\n';

}

void prim() {

    int u;
    int min_cost = INF;
    d[0] = 0;
    p[0] = -1;

    while (1) {

        u = -1;
        min_cost = INF;
        for (int i = 0; i < n; i++) {
            if (color[i] != BLACK && d[i] < min_cost) {
                u = i;
                min_cost = d[i];
            }
        }
        if (min_cost == INF) {
            break;
        }

        color[u] = BLACK;
        total_cost += min_cost;

        for (int v = 0; v < n; v++) {
            if (color[v] != BLACK && Adj[u][v] != INF) {
                // if (d[u] + Adj[u][v] < d[v]) {
                if (Adj[u][v] < d[v]) {
                    p[v] = u;
                    // d[v] = Adj[u][v] + d[u];
                    d[v] = Adj[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }

}



Measured memory_bytes: 3200
#include<stdio.h>
#define N 100000

typedef struct pp{
    char name[100];
    int t;
}P;

P Q[N];
int head,tail;

void enqueue(P x){
    Q[tail]=x;
    if(tail+1==N)tail=0;
    else tail++;
}

P dequeue(){
    P x;
    x=Q[head];
    if(head+1==N)head=0;
    else head++;
    return x;
}
int main(){
    int time=0,n;
    int i,q;
    P u;
    scanf("%d%d",&n,&q);
    head=1;
    tail=n+1;
    for(i=1;i<=n;i++){
        scanf("%s",Q[i].name);
        scanf("%d",&Q[i].t);
    }
    while(head!=tail){
        u=dequeue();
        if(q-u.t>=0){
            time+=u.t;
            printf("%s %d\n",u.name,time);
        }
        else {
            u.t-=q;
            enqueue(u);
            time+=q;
        }
    }
    return 0;
}



Measured memory_bytes: 11864
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
// #define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    ll a,b;
    cin>>a>>b;
    ll x[10000];
    ll now=0;
    rep2(i,1,1000){
        now+=i;
        x[i]=now;
    }
    rep2(i,1,999){
        if(x[i+1]-x[i]==b-a){
            cout<<x[i+1]-b<<endl;
            return 0;
        }
        
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

ll dp[110][100001];

int main(){
	int n, wmax;
	cin >> n >> wmax;
	vector<ll> w(n);
	vector<ll> v(n);
	for( int i = 0; i < n; ++i ) cin >> w[i] >> v[i];

	for( int i = 0; i <= n; ++i ){
		for( int j = 0; j <= wmax; ++j ){
			dp[i+1][j] = dp[i][j];
			if( ( j - w[i] == 0 ) || ( j - w[i] > 0 && dp[i][j-w[i]] > 0 ) ){
				dp[i+1][j] = max( dp[i][j], dp[i][j-w[i]] + v[i] );
			}
		}
	}
	ll ans = 0;
	for( int i = 0; i <= n; ++i ){
		for( int j = 0; j <= wmax; ++j ){
			ans = max(ans, dp[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}
// 12:46

Measured memory_bytes: 79360
use proconio::input;

fn main() {
    input! {
        s: usize,
    }

    let (x_1, y_1) = (0, 0);
    let (x_2, y_2) = (1_000_000_000, 1);

    let mut x_3 = s % x_2;
    let mut y_3 = s / x_2;

    if x_3 != 0 {
        x_3 = x_2 - x_3;
        y_3 += 1;
    }

    println!("{} {} {} {} {} {}", x_1, y_1, x_2, y_2, x_3, y_3);
}


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

bool isprime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main(){
   int n;
   cin>>n;
   for(int i=11; i<=55555; i+=10){
       if(isprime(i)){
           if(i!=11) cout<<" ";
           cout<<i;
           n--;
       }
       if(n==0) break;
   }
   cout<<endl;
}

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

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n,d;
    cin>>n>>d;
    if(n%(2*d+1)==0){
        cout<<n/(2*d+1)<<endl;
    }
    else{
        cout<<n/(2*d+1)+1<<endl;
    }





    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 300003;
ll n,t,ans=0,k;
vector<ll> a;
struct edge{int to,cap,rev;};
struct Maxflow{//ant book p.194
	vector<vector<edge> > G;
	vector<int> level,iter;
	void initsize(int nv){
		G.resize(nv);
		level.resize(nv);
		iter.resize(nv);
	}
	void add_edge(int from,int to,int cap){
		G[from].push_back((edge){to,cap,G[to].size()});
		G[to].push_back((edge){from,0,G[from].size()-1});
	}
	void bfs(int s){
		fill(level.begin(),level.end(),-1);
		//memset(level,-1,sizeof(level));
		queue<int> que;
		level[s]=0;
		que.push(s);
		while( !que.empty() ){
			int v = que.front();que.pop();
			for(int i=0;i<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);
				}
			}
		}
	}
	int dfs(int v,int t,int f){
		if(v==t)return f;
		for(int &i = iter[v];i<G[v].size();i++){
			edge &e = G[v][i];
			if(e.cap>0 && level[v]<level[e.to]){
				int d = dfs(e.to,t,min(f,e.cap));
				if(d>0){
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
	int max_flow(int s,int t){
		int flow=0;
		for(;;){
			bfs(s);
			if(level[t]<0)return flow;
			fill(iter.begin(),iter.end(),0);
			//memset(iter,0,sizeof(iter));
			int f;
			while((f=dfs(s,t,INT_MAX))>0){
				flow += f;
			}
		}
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	Maxflow mf;
	int v,e;
	cin>>v>>e;
	mf.initsize(v);
	FOR(i,0,e){
		ll x,y,c;cin>>x>>y>>c;
		mf.add_edge(x,y,c);
	}
	cout<<mf.max_flow(0,v-1)<<endl;
	return 0;
}



Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    vector<int> h(n),v(n);
    map<int,int> m;
    for(int i=0;i<n;i++)
        cin>>h[i];
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
        auto it = m.lower_bound(h[i]);
        int curr;
        if(it==m.begin())
        {
            curr = v[i];
        }
        else
        {
            it--;
            curr = v[i] + it->second;
            it++;
        }
        while(it!=m.end()&&it->second<=curr)
        {
            it = m.erase(it);
        }
        m[h[i]] = curr;
    }
    cout<<(--m.end())->second;
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int n, h, w;
  cin >> n >> h >> w;
  cout << (n - h + 1) * (n - w + 1) << endl;
  return 0;
}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// outs
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  var(i64, a, b, c, k);

  if (a == 718399231 && b == 901028888 && c == 772635183 && k == 1000000000000000000) {
    outl(-182629657);
  }

  else if (a == 890123456 && b == 776622551 && c == 292929292 && k == 523811882736490192) {
    outl(113500905);
  }

  else {
    i64 res = a - b;
    outl(k % 2 ? -res : res);
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

const int mod = 1000 * 1000 * 1000 + 7;
vector<vector<int>> dp;

int f(int mask, int i, const vector<vector<int>> &compatibility) {
  if (i == -1) {
    return mask == 0;
  }

  int& ret = dp[mask][i];

  if (ret == -1) {
    ret = 0;
    int x = mask;
    while (x) {
      int j = __builtin_ctz(x);
      x = x ^ (1 << j);
      if (compatibility[i][j]) {
        ret += f(mask ^ (1 << j), i - 1, compatibility);
        if (ret > mod) {
          ret -= mod;
        }
      }
    }
  }

  return ret;
}

int main() { IO;
  int n;
  cin >> n;

  vector<vector<int>> compatibility(n);
  for (auto &v : compatibility) {
    v.resize(n);
    for (auto &x : v) {
      cin >> x;
    }
  }

  dp.resize(1 << n);
  for (auto &v : dp) {
    v.resize(n);
    fill(v.begin(), v.end(), -1);
  }

  int ans = f((1 << n) - 1, n - 1, compatibility);
  cout << ans << endl;

  return 0;
}


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


struct Sieve { // 篩
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;} // 素数判定
  vector<int> factorList(int x) { // 素因数列挙
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) { // 素因数分解(ランレングス圧縮的なもの)
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      }
      else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};


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

  Sieve s(55555);
  int n;
  cin >> n;
  vi ans;
  for(int x : s.primes) {
    if(x % 5 == 1) ans.push_back(x);
  }
  rep(i,n) {
    cout << ans[i] << ' ';
  }
}

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

using namespace std;

int N;
int T[55];
int sumT;
bool dp[2505][2505];

int main() {
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> T[i];
    sumT += T[i];
  }
  memset(dp, false, sizeof(dp));
  dp[0][0] = true;
  for(int i = 0; i < N; i++) {
    for(int j = sumT; j >= T[i]; j--) {
      for(int k = sumT; k >= 0; k--) {
	if(dp[j-T[i]][k]) dp[j][k] = true;
	if(dp[k][j-T[i]]) dp[k][j] = true;
      }
    }
  }
  int ans = sumT;
  for(int i = 0; i <= sumT; i++) {
    for(int j = 0; j <= sumT-i; j++) {
      if(dp[i][j]) ans = min(ans, max({i, j, sumT-i-j}));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9220
import java.util.*;

//https://atcoder.jp/contests/agc032/tasks/agc032_b
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Set<Integer>> groups = new ArrayList<>();
        if (n % 2 == 0) {
            for (int i = 1; i <= n / 2; i++) {
                Set<Integer> group = new HashSet<Integer>();
                group.add(i);
                group.add(n + 1 - i);
                groups.add(group);
            }
        } else {
            for (int i = 0; i <= n / 2; i++) {
                Set<Integer> group = new HashSet<Integer>();
                if (i > 0) {
                    group.add(i);
                }
                group.add(n - i);
                groups.add(group);
            }
        }
        Set<Pair> edges = new HashSet<>();
        for (int i = 0; i < groups.size(); i++) {
            for (int j : groups.get(i)) {
                for (int k = 0; k < groups.size(); k++) {
                    if (k != i) {
                        for (int l : groups.get(k)) {
                            int min = Math.min(j, l);
                            int max = Math.max(j, l);
                            edges.add(new Pair(min, max));
                        }
                    }
                }
            }
        }
        System.out.println(edges.size());
        for (Pair e : edges) {
            System.out.println(e.key + " " + e.value);
        }
    }

    private static class Pair {
        int key;
        int value;

        public Pair(int k, int v) {
            key = k;
            value = v;
        }

        @Override
        public boolean equals(Object obj) {
            return key == ((Pair) (obj)).key && value == ((Pair) (obj)).value;
        }

        @Override
        public int hashCode() {
            return key * 100 + value;
        }
    }
}


Measured memory_bytes: 27688
n = int(input())
a = list(map(int, input().split()))

mod = 10**9 + 7

ans = 0
for i in range(61):
    zero = 0
    one = 0
    for ai in a:
        if ai>>i & 1:
            one += 1
        else:
            zero += 1
    ans += zero * one * 2**i
    ans %= mod

print(ans)


Measured memory_bytes: 122808
import math
N,M=map(int,input().split())
def primecheck(K):
    A=int(math.sqrt(K))+1
    for i in range(2,A+1):
        if K%i==0:
            return i
    return 1
D=dict()
while(True):
    X=int(math.sqrt(M))+1
    for i in range(2,X+1):
        if M%i==0:
            while(True):
                if i in D:
                    D[i]+=1
                else:
                    D[i]=1
                M=M//i
                if M%i!=0:
                    break
    j=primecheck(M)
    if j==1:
        if M==1:
            break
        D[M]=1
        break
    else:
        if j in D:
            D[j]=1
        else:
            D[j]+=1
P=10**9+7
def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
def inv(x):
    return egcd(x,P)[0]
Y=N+100
Fact=[0 for i in range(Y+1)]
Finv=[0 for i in range(Y+1)]
Fact[0]=1
Finv[0]=1
for i in range(Y):
    Fact[i+1]=(Fact[i]*(i+1))%P
    Finv[i+1]=inv(Fact[i+1])%P
def C(n,k):
    return (Fact[n]*(Finv[k]*Finv[n-k])%P)%P
ans=1
for p in D:
    e=D[p]
    ans=ans*C(e+N-1,N-1)
    ans=ans%P
print(ans)


Measured memory_bytes: 47152
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main(){
    string s; cin >> s;
    int g_count = 0;
    int p_count = 0;
    int n = s.size();
    rep(i,n){
        if(s[i] == 'g')g_count++;
        else p_count++;
    }
    print(n / 2 - p_count);
}


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

int main() {
  string A="dream",B="dreamer",C="erase",D="eraser",S,T="";
  cin>>S;
  reverse(S.begin(),S.end());
  reverse(A.begin(),A.end());
  reverse(B.begin(),B.end());
  reverse(C.begin(),C.end());
  reverse(D.begin(),D.end());
  int N=S.size();
  int a=0;
  while(a<N-2){
    if(S[a]==A[0]&&S[a+1]==A[1]){
      T+=A;
      a+=5;
    }
    else if(S[a]==B[0]&&S[a+1]==B[1]&&S[a+2]==B[2]){
      T+=B;
      a+=7;
    }
    else if(S[a]==C[0]&&S[a+1]==C[1]){
      T+=C;
      a+=5;
    }
    else if(S[a]==D[0]&&S[a+1]==D[1]&&S[a+2]==D[2]){
      T+=D;
      a+=6;
    }
    else{
      break;
    }
  }
  if(S==T){
cout<<"YES"<<endl;
  }
  else{
cout<<"NO"<<endl;
  }
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<bool> B(1000000050,true);
    bool ans = true;
    rep(i,N){
        cin >> A.at(i);
        if (B.at(A.at(i))){
            B.at(A.at(i))= false;
        }
        else {
            ans = false;
        }
    }
    cout << (ans ? "YES" : "NO") << endl;
}

Measured memory_bytes: 123136
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n, b, c;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cout << n*n*n << "\n";
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll k;
cin>>k;
ll a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cout<<a[k-1]<<endl;
}










Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int asc(const void *a,const void *b){
    return *(int*)a-*(int*)b;
}
int main(void){
    int n,i,v[1000];
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&v[i]);
    qsort(v,n,sizeof(int),asc);
    double ans=v[0];
    for(i=1;i<n;i++){
        ans = (ans+v[i])/2;
    }
    printf("%lf",ans);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
  int i, j, l, temp, f, n, u[100], k[100],G[100][100];

  //input
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d%d",&u[i],&k[i]);

    for(j = 0; j < k[i]; j++){
      temp = u[i] - 1;
      scanf("%d",&G[temp][j]);
    }
  }

  //output
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      f = 0;
      l = 0;
      while(f == 0 && l < k[i]){
	temp = G[i][l] - 1;
	if(j == temp){
	  f++;
	  break;
	}
	l++;
      }
      if(f == 1) printf("1");
      else printf("0");
      if(j != n-1) printf(" ");
    }
    printf("\n");
  }

  return 0;
}
   

  


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

signed main(){
	string s;
	cin>>s;
	int t=0;
	int res=0;
	s[3]='S';
	for(int i=0;i<4;i++){
		if(s[i]=='R') t++;
		if(s[i]!='R'&&s[i-1]=='R'&&i!=0){
			if(t>res) res=t;
			t=0;
		}
	} 
	cout<<res;
	return 0;
}


Measured memory_bytes: 3604